Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for modular build structure. #444

Merged
merged 12 commits into from
Aug 18, 2024
41 changes: 41 additions & 0 deletions build.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright René Ferdinand Rivera Morell 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 ;

constant boost_dependencies :
/boost/align//boost_align
/boost/bind//boost_bind
/boost/config//boost_config
/boost/conversion//boost_conversion
/boost/core//boost_core
/boost/detail//boost_detail
/boost/foreach//boost_foreach
/boost/function//boost_function
/boost/iterator//boost_iterator
/boost/lexical_cast//boost_lexical_cast
/boost/mpl//boost_mpl
/boost/numeric_conversion//boost_numeric_conversion
/boost/preprocessor//boost_preprocessor
/boost/static_assert//boost_static_assert
/boost/tuple//boost_tuple
/boost/type_traits//boost_type_traits
/boost/utility//boost_utility ;

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

explicit
[ alias boost_python : build//boost_python ]
[ alias boost_numpy : build//boost_numpy ]
[ alias all : boost_python boost_numpy test ]
;

call-if : boost-library python
: install boost_python boost_numpy
;

70 changes: 39 additions & 31 deletions build/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,34 @@ else
;
}

project boost/python
constant boost_dependencies_private :
/boost/graph//boost_graph
/boost/integer//boost_integer
/boost/property_map//boost_property_map
/boost/smart_ptr//boost_smart_ptr
;

project
: source-location ../src
: common-requirements <library>$(boost_dependencies)
: requirements <library>$(boost_dependencies_private)
;

rule cond ( test ? : yes * : no * ) { if $(test) { return $(yes) ; } else { return $(no) ; } }
rule unless ( test ? : yes * : no * ) { if ! $(test) { return $(yes) ; } else { return $(no) ; } }
local rule eq ( a : b ) { if $(a) = $(b) { return 1 ; } }

rule tag ( name : type ? : property-set )
{
if python-tag in [ RULENAMES $(__name__) ]
{
return [ $(__name__).python-tag $(name) : $(type) : $(property-set) ] ;
}
}

if [ python.configured ]
{

lib boost_python
: # sources
list.cpp
Expand Down Expand Up @@ -92,17 +112,30 @@ lib boost_python
[ unless [ python.configured ] : <build>no ]
<dependency>config-warning
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
-<tag>@%boostcpp.tag
-<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
<tag>@python-tag
<tag>@tag
<conditional>@python.require-py

: # default build
<link>shared
: # usage requirements
<link>static:<define>BOOST_PYTHON_STATIC_LIB
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
<define>BOOST_PYTHON_NO_LIB
;

}
else
{

alias boost_python : config-warning ;

}

if [ python.configured ] && [ python.numpy ]
{

numpy-include = [ python.numpy-include ] ;
lib boost_numpy
: # sources
Expand All @@ -120,48 +153,23 @@ lib boost_numpy
<library>/python//numpy
<library>boost_python
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
-<tag>@%boostcpp.tag
-<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
<tag>@python-tag
<tag>@tag
<conditional>@python.require-py

: # default build
<link>shared
: # usage requirements
<link>static:<define>BOOST_NUMPY_STATIC_LIB
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
<define>BOOST_NUMPY_NO_LIB
;

# boost-install creates `stage` and `install` targets
#
# `stage` stages (builds and copies into `stage/lib`) the given libraries
# `boost_python` and `boost_numpy` and their dependencies and is similar
# to issuing `b2 --with-python stage` from top level
#
# `install` installs the two libraries and their dependencies and is similar
# to issuing `b2 --with-python install` from top level

if [ python.configured ]
{
if [ python.numpy ]
{
boost-install boost_python boost_numpy ;
}
else
{
boost-install boost_python ;
}
}
else
{

# When Python isn't configured, the above `boost-install` is not executed,
# so we create empty `stage` and `install` targets that do nothing but issue
# a warning message unless `--without-python` is given

alias stage : config-warning ;
explicit stage ;

alias install : config-warning ;
explicit install ;
alias boost_numpy : config-warning ;

}
2 changes: 1 addition & 1 deletion example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Examples

This directory contains various examples using Boost.Python.
You may compile these using the `bjam` command either in this directory
You may compile these using the `b2` command either in this directory
or in any of the subdirectories.
You may need to adjust the paths in the Jamroot file if Boost.Python
is not installed in a default location.
Expand Down
53 changes: 34 additions & 19 deletions test/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
# 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.0.1 ;
import-search /boost/config/checks ;

import python ;
import os ;
import ../../config/checks/config : requires ;
import config : requires ;

lib socket ;

use-project /boost/python : ../build ;
project /boost/python/test
project
: requirements
<toolset>gcc:<cxxflags>-Wextra
<target-os>qnxnto:<library>socket
Expand All @@ -28,7 +30,7 @@ rule py-run ( sources * : input-file ? )
: $(input-file)
: #requirements
<define>BOOST_PYTHON_SUPPRESS_REGISTRY_INITIALIZATION

] ;
}

Expand All @@ -52,6 +54,18 @@ rule require-windows ( properties * )

if [ python.configured ]
{
alias base_deps : usage-requirements
<library>/boost/align//boost_align
<library>/boost/assert//boost_assert
<library>/boost/config//boost_config
<library>/boost/core//boost_core
<library>/boost/detail//boost_detail
<library>/boost/function//boost_function
<library>/boost/mpl//boost_mpl
<library>/boost/preprocessor//boost_preprocessor
<library>/boost/static_assert//boost_static_assert
<library>/boost/type_traits//boost_type_traits
;
test-suite python
:

Expand Down Expand Up @@ -97,8 +111,8 @@ bpl-test crossmod_exception
[ bpl-test andreas_beyer ]
[ bpl-test wrapper_held_type ]

[ bpl-test polymorphism2_auto_ptr
: polymorphism2_auto_ptr.py polymorphism2.py polymorphism2_auto_ptr.cpp
[ bpl-test polymorphism2_auto_ptr
: polymorphism2_auto_ptr.py polymorphism2.py polymorphism2_auto_ptr.cpp
: [ requires auto_ptr ]
]

Expand All @@ -119,7 +133,7 @@ bpl-test crossmod_exception
[ bpl-test try : newtest.py m1.cpp m2.cpp ]
[ bpl-test const_argument ]
[ bpl-test keywords : keywords.cpp keywords_test.py ]


[ python-extension builtin_converters_ext : builtin_converters.cpp /boost/python//boost_python ]
[ bpl-test builtin_converters : test_builtin_converters.py builtin_converters_ext ]
Expand Down Expand Up @@ -192,13 +206,13 @@ bpl-test crossmod_opaque
# Whenever the cause for the failure of the polymorphism test is found
# and fixed, this should be retested.
<toolset>hp_cxx:<build>no ]

[ python-extension map_indexing_suite_ext
: map_indexing_suite.cpp int_map_indexing_suite.cpp a_map_indexing_suite.cpp
/boost/python//boost_python ]
[ bpl-test
[ bpl-test
map_indexing_suite : map_indexing_suite.py map_indexing_suite_ext ]

[ run import_.cpp /boost/python//boost_python $(PY) : : import_.py ]

# if $(TEST_BIENSTMAN_NON_BUGS)
Expand All @@ -212,28 +226,29 @@ bpl-test crossmod_opaque

# --- unit tests of library components ---

[ compile indirect_traits_test.cpp ]
[ run destroy_test.cpp ]
[ compile indirect_traits_test.cpp : <use>base_deps ]
[ run destroy_test.cpp : : : <use>base_deps ]
[ py-run pointer_type_id_test.cpp ]
[ py-run bases.cpp ]
[ run if_else.cpp ]
[ run if_else.cpp : : : <use>base_deps ]
[ py-run pointee.cpp ]
[ run result.cpp ]
[ run result.cpp : : : <use>base_deps ]

[ compile string_literal.cpp ]
[ compile string_literal.cpp : <use>base_deps ]
[ py-compile borrowed.cpp ]
[ py-compile object_manager.cpp ]
[ py-compile copy_ctor_mutates_rhs.cpp ]

[ py-run upcast.cpp ]

[ py-compile select_holder.cpp ]
[ run select_from_python_test.cpp ../src/converter/type_id.cpp
:

[ run select_from_python_test.cpp ../src/converter/type_id.cpp
:
:
: <define>BOOST_PYTHON_STATIC_LIB
<use>$(PY)
<use>base_deps

]

Expand Down
Loading