Skip to content

Commit

Permalink
Add support for modular build structure. (#2905)
Browse files Browse the repository at this point in the history
* Use beast exclusive valgrind feature.

* Make the library modular usable.

* Switch to library requirements instead of source. As source puts extra source in install targets.

* Add Beast root dir for includes. As some tests refer to files relative to that.

* Replace relative docca refs with project based.

* Avoid mtuliple openssl configurations.

* Always declare openssl. If it's empty and duplicate it will be ignored.

* Add missing import-search for cconfig/predef checks.

* Add requires-b2 check to top-level build file.

* Bump B2 require to 5.2

* Update copyright dates.

* Move inter-lib dependencies to a project variable and into the build targets.

* Update build deps.

* Update build deps.

* The http/client/body example uses the source header from json instead of the linked library.
  • Loading branch information
grafikrobot authored Sep 1, 2024
1 parent aefc564 commit 2bda787
Show file tree
Hide file tree
Showing 11 changed files with 203 additions and 152 deletions.
136 changes: 0 additions & 136 deletions Jamfile

This file was deleted.

74 changes: 74 additions & 0 deletions build.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Copyright René Ferdinand Rivera Morell 2023-2024
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

require-b2 5.2 ;

import feature ;

constant boost_dependencies :
/boost/asio//boost_asio
/boost/assert//boost_assert
/boost/bind//boost_bind
/boost/config//boost_config
/boost/container//boost_container
/boost/container_hash//boost_container_hash
/boost/core//boost_core
/boost/endian//boost_endian
/boost/intrusive//boost_intrusive
/boost/logic//boost_logic
/boost/mp11//boost_mp11
/boost/optional//boost_optional
/boost/preprocessor//boost_preprocessor
/boost/smart_ptr//boost_smart_ptr
/boost/static_assert//boost_static_assert
/boost/static_string//boost_static_string
/boost/system//boost_system
/boost/throw_exception//boost_throw_exception
/boost/type_index//boost_type_index
/boost/type_traits//boost_type_traits
/boost/winapi//boost_winapi ;

project /boost/beast
: common-requirements
<include>include
;

explicit
[ alias boost_beast : build//boost_beast ]
[ alias boost_beast_asio : build//boost_beast_asio ]
[ alias boost_beast_asio_ssl : build//boost_beast_asio_ssl ]
[ alias all : boost_beast boost_beast_asio boost_beast_asio_ssl example test ]
# Old-style targets. Remove once the rest of Beast changes.
[ alias lib-beast : boost_beast ]
[ alias lib-asio : boost_beast_asio ]
[ alias lib-asio-ssl : boost_beast_asio_ssl ]
;

call-if : boost-library beast
: install boost_beast boost_beast_asio boost_beast_asio_ssl
;

feature.feature boost.beast.allow-deprecated : on off : propagated ;
feature.feature boost.beast.separate-compilation : on off : propagated ;
feature.feature boost.beast.valgrind : on off : optional propagated ;

variant beast_coverage
: debug
: <cxxflags>"-msse4.2 --coverage"
<linkflags>"--coverage"
;

variant beast_valgrind
: release
: <boost.beast.valgrind>on
;

variant beast_ubasan
: release
: <cxxflags>"-msse4.2 -funsigned-char -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=address,undefined -fsanitize-blacklist=libs/beast/tools/blacklist.supp"
<linkflags>"-fsanitize=address,undefined"
<define>BOOST_USE_ASAN=1
;

99 changes: 99 additions & 0 deletions build/Jamfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Copyright René Ferdinand Rivera Morell 2023-2024
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

import ac ;
import-search /boost/config/checks ;
import config : requires ;
import os ;
import path ;

local openssl-root ;
if [ os.on-windows ]
{
openssl-root ?= [ os.environ OPENSSL_ROOT ] ;
if ! $(openssl-root) && [ path.glob "C:/OpenSSL" : lib include ]
{
openssl-root = "C:/OpenSSL" ;
}
}
using openssl : : <search>$(openssl-root)/lib <include>$(openssl-root)/include ;

project
: source-location ../test
: common-requirements
<library>$(boost_dependencies)
[ requires
cxx11_constexpr
cxx11_decltype
cxx11_hdr_tuple
cxx11_template_aliases
cxx11_variadic_templates
]
<define>BOOST_ALL_NO_LIB=1
<define>BOOST_ASIO_SEPARATE_COMPILATION
<define>BOOST_ASIO_NO_DEPRECATED=1
<define>BOOST_ASIO_DISABLE_BOOST_ARRAY=1
<define>BOOST_ASIO_DISABLE_BOOST_BIND=1
<define>BOOST_ASIO_DISABLE_BOOST_DATE_TIME=1
<define>BOOST_ASIO_DISABLE_BOOST_REGEX=1
<define>BOOST_COROUTINES_NO_DEPRECATION_WARNING=1
<toolset>msvc:<cxxflags>"/bigobj"
<toolset>msvc-14.1:<cxxflags>"/permissive-"
<toolset>msvc-14.2:<cxxflags>"/permissive-"
<toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS=1
<toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS=1
<toolset>msvc:<define>_SILENCE_CXX17_ALLOCATOR_VOID_DEPRECATION_WARNING
<toolset>msvc:<define>_SILENCE_CXX17_ADAPTOR_TYPEDEFS_DEPRECATION_WARNING
<toolset>msvc,<variant>release:<cxxflags>"/Ob2 /Oi /Ot"
<target-os>linux:<define>_XOPEN_SOURCE=600
<target-os>linux:<define>_GNU_SOURCE=1
<target-os>solaris:<define>_XOPEN_SOURCE=500
<target-os>solaris:<define>__EXTENSIONS__
<target-os>solaris:<library>socket
<target-os>solaris:<library>nsl
<target-os>windows:<define>_WIN32_WINNT=0x0601
<target-os>windows,<toolset>gcc:<library>ws2_32
<target-os>windows,<toolset>gcc:<library>mswsock
<target-os>windows,<toolset>gcc-cygwin:<define>__USE_W32_SOCKETS
<target-os>hpux,<toolset>gcc:<define>_XOPEN_SOURCE_EXTENDED
<target-os>hpux:<library>ipv6
<target-os>qnxnto:<library>socket
<target-os>haiku:<library>network
<boost.beast.valgrind>on:<define>BOOST_USE_VALGRIND
<boost.beast.allow-deprecated>on:<define>BOOST_BEAST_ALLOW_DEPRECATED
<boost.beast.separate-compilation>on:<define>BOOST_BEAST_SEPARATE_COMPILATION
;

explicit
[ searched-lib socket ] # SOLARIS, QNXNTO
[ searched-lib nsl ] # SOLARIS
[ searched-lib ws2_32 : : <target-os>windows ] # NT
[ searched-lib mswsock : : <target-os>windows ] # NT
[ searched-lib ipv6 ] # HPUX
[ searched-lib network ] # HAIKU
;

lib boost_beast_asio
: lib_asio.cpp
: requirements
<link>static
;

lib boost_beast_asio_ssl
: lib_asio_ssl.cpp
: requirements
<link>static
[ ac.check-library /openssl//ssl : <library>/openssl//ssl/<link>shared : <build>no ]
[ ac.check-library /openssl//crypto : <library>/openssl//crypto/<link>shared : <build>no ]
: usage-requirements
[ ac.check-library /openssl//ssl : <library>/openssl//ssl/<link>shared : <build>no ]
[ ac.check-library /openssl//crypto : <library>/openssl//crypto/<link>shared : <build>no ]
;

lib boost_beast
: lib_beast.cpp
: requirements
<link>static
;
3 changes: 2 additions & 1 deletion doc/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ project beast/doc ;

import boostbook ;
import type ;
import ../../../tools/docca/docca.jam ;
import-search /boost/docca ;
import docca ;


if ! [ type.registered IPP ]
Expand Down
4 changes: 3 additions & 1 deletion example/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
#

import testing ;
import ../../config/checks/config : requires ;
import-search /boost/config/checks ;
import config : requires ;

project /boost/beast/example
: requirements
Expand All @@ -22,6 +23,7 @@ project /boost/beast/example
]
<library>/boost/beast//lib-asio/<link>static
<boost.beast.separate-compilation>on:<library>/boost/beast//lib-beast/<link>static
<include>..
;

build-project advanced ;
Expand Down
1 change: 1 addition & 0 deletions example/advanced/server-flex-awaitable/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import ac ;
project
: requirements
[ ac.check-library /boost/beast//lib-asio-ssl : <library>/boost/beast//lib-asio-ssl/<link>static : <build>no ]
<library>/boost/scope//boost_scope
;

exe advanced-server-flex-awaitable :
Expand Down
1 change: 1 addition & 0 deletions example/http/client/body/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ exe json_client : json_client.cpp
:
<variant>coverage:<build>no
<variant>ubasan:<build>no
<use>/boost/json//boost_json
;
26 changes: 13 additions & 13 deletions test/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,8 @@
#

import testing ;
import ../../config/checks/config : requires ;

lib lib-test
: lib_test.cpp
: requirements
<link>static
$(defines)
: usage-requirements
<include>./extras/include
$(defines)
;
import-search /boost/config/checks ;
import config : requires ;

project /boost/beast/test
: requirements
Expand All @@ -34,12 +25,21 @@ project /boost/beast/test
<target-os>darwin:<define>Z_HAVE_UNISTD_H=1
<library>/boost/beast//lib-asio/<link>static
<boost.beast.separate-compilation>on:<library>/boost/beast//lib-beast/<link>static
<library>/boost/filesystem//boost_filesystem
<library>/boost/context//boost_context
<library>/boost/filesystem//boost_filesystem/<link>static
<library>/boost/context//boost_context/<link>static
<address-sanitizer>norecover:<context-impl>ucontext
<address-sanitizer>norecover:<define>BOOST_USE_ASAN=1
<include>..
;

lib lib-test
: lib_test.cpp
: requirements
<link>static
: usage-requirements
<include>extras/include
;

lib lib-zlib :
extern/zlib-1.2.12/adler32.c
extern/zlib-1.2.12/compress.c
Expand Down
Loading

0 comments on commit 2bda787

Please sign in to comment.