Add support for modular build structure. (#2905)

* 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.
This commit is contained in:
René Ferdinand Rivera Morell
2024-09-01 02:56:02 -05:00
committed by GitHub
parent aefc564fa7
commit 2bda7870fe
11 changed files with 203 additions and 152 deletions

136
Jamfile
View File

@ -1,136 +0,0 @@
#
# Copyright (c) 2019 Vinnie Falco (vinnie dot falco at gmail dot com)
#
# 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)
#
# Official repository: https://github.com/boostorg/beast
#
import ac ;
import os ;
import path ;
import feature ;
import boost ;
import modules ;
import testing ;
import ../config/checks/config : requires ;
using openssl ;
boost.use-project ;
lib socket ; # SOLARIS, QNXNTO
lib nsl ; # SOLARIS
lib ws2_32 ; # NT
lib mswsock ; # NT
lib ipv6 ; # HPUX
lib network ; # HAIKU
feature.feature boost.beast.allow-deprecated : on off : propagated ;
feature.feature boost.beast.separate-compilation : on off : propagated ;
variant beast_coverage
: debug
: <cxxflags>"-msse4.2 --coverage"
<linkflags>"--coverage"
;
feature.feature boost.beast.valgrind : on : optional propagated composite ;
feature.compose <boost.beast.valgrind>on : <define>BOOST_USE_VALGRIND ;
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
;
project /boost/beast ;
local defines =
[ requires
cxx11_constexpr
cxx11_decltype
cxx11_hdr_tuple
cxx11_template_aliases
cxx11_variadic_templates
]
<implicit-dependency>/boost//headers
<include>.
<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.allow-deprecated>on:<define>BOOST_BEAST_ALLOW_DEPRECATED
<boost.beast.separate-compilation>on:<define>BOOST_BEAST_SEPARATE_COMPILATION
;
lib lib-asio
: test/lib_asio.cpp
: requirements
<link>static
$(defines)
: usage-requirements
$(defines)
;
if [ os.name ] = LINUX
{
lib dl ;
}
lib lib-asio-ssl
: test/lib_asio_ssl.cpp
: requirements
<link>static
$(defines)
[ 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
$(defines)
<library>/openssl//ssl/<link>shared
<library>/openssl//crypto/<link>shared
<target-os>linux:<library>dl
;
lib lib-beast
: test/lib_beast.cpp
: requirements
<link>static
$(defines)
: usage-requirements
$(defines)
;

74
build.jam Normal file
View File

@ -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
build/Jamfile Normal file
View File

@ -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
;

View File

@ -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 ]

View File

@ -8,7 +8,8 @@
#
import testing ;
import ../../config/checks/config : requires ;
import-search /boost/config/checks ;
import config : requires ;
project /boost/beast/example
: requirements
@ -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 ;

View File

@ -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 :

View File

@ -11,4 +11,5 @@ exe json_client : json_client.cpp
:
<variant>coverage:<build>no
<variant>ubasan:<build>no
<use>/boost/json//boost_json
;

View File

@ -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
@ -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

View File

@ -7,10 +7,11 @@
# Official repository: https://github.com/boostorg/beast
#
project : requirements <library>/boost/beast/test//lib-test ;
run
nodejs_parser.cpp
bench_parser.cpp
/boost/beast/test//lib-test
: : : :
bench-parser ;

View File

@ -7,6 +7,10 @@
# Official repository: https://github.com/boostorg/beast
#
project
: requirements
<include>../.. ;
local libs =
/boost/beast//lib-asio-ssl
/boost/beast/test//lib-test

View File

@ -7,6 +7,10 @@
# Official repository: https://github.com/boostorg/beast
#
project
: requirements
<include>../../.. ;
local SOURCES =
root_certificates.cpp
server_certificate.cpp