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

[boost] fix library name for custom namespace and custom buildid cases #6510

Merged
merged 2 commits into from
Jul 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion recipes/boost/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ class BoostConan(ConanFile):
"visibility": ["global", "protected", "hidden"],
"addr2line_location": "ANY",
"with_stacktrace_backtrace": [True, False],
"buildid": "ANY",
"python_buildid": "ANY",
}
options.update({"without_{}".format(_name): [True, False] for _name in CONFIGURE_OPTIONS})

Expand Down Expand Up @@ -132,6 +134,8 @@ class BoostConan(ConanFile):
"visibility": "hidden",
"addr2line_location": "/usr/bin/addr2line",
"with_stacktrace_backtrace": True,
"buildid": None,
"python_buildid": None,
}
default_options.update({"without_{}".format(_name): False for _name in CONFIGURE_OPTIONS})
default_options.update({"without_{}".format(_name): True for _name in ("graph_parallel", "mpi", "python")})
Expand Down Expand Up @@ -351,6 +355,8 @@ def configure(self):
if not self.options.python_version:
self.options.python_version = self._detect_python_version()
self.options.python_executable = self._python_executable
else:
del self.options.python_buildid

if self._stacktrace_addr2line_available:
if os.path.abspath(str(self.options.addr2line_location)) != str(self.options.addr2line_location):
Expand Down Expand Up @@ -1038,6 +1044,11 @@ def add_defines(library):
cxx_flags = 'cxxflags="%s"' % " ".join(cxx_flags) if cxx_flags else ""
flags.append(cxx_flags)

if self.options.buildid:
flags.append("--buildid=%s" % self.options.buildid)
if not self.options.without_python and self.options.python_buildid:
flags.append("--python-buildid=%s" % self.options.python_buildid)

if self.options.extra_b2_flags:
flags.extend(shlex.split(str(self.options.extra_b2_flags)))

Expand Down Expand Up @@ -1329,6 +1340,13 @@ def package_info(self):
if self.options.segmented_stacks:
self.cpp_info.components["headers"].defines.extend(["BOOST_USE_SEGMENTED_STACKS", "BOOST_USE_UCONTEXT"])

if self.options.buildid:
# If you built Boost using the --buildid option then set this macro to the same value
# as you passed to bjam.
# For example if you built using bjam address-model=64 --buildid=amd64 then compile your code with
# -DBOOST_LIB_BUILDID=amd64 to ensure the correct libraries are selected at link time.
self.cpp_info.components["headers"].defines.append("BOOST_LIB_BUILDID=%s" % self.options.buildid)

if not self.options.header_only:
if self.options.error_code_header_only:
self.cpp_info.components["headers"].defines.append("BOOST_ERROR_CODE_HEADER_ONLY")
Expand Down Expand Up @@ -1446,7 +1464,15 @@ def filter_transform_module_libraries(names):
continue
if not self.options.get_safe("numa") and "_numa" in name:
continue
libs.append(add_libprefix(name.format(**libformatdata)) + libsuffix)
new_name = add_libprefix(name.format(**libformatdata)) + libsuffix
if self.options.namespace != 'boost':
new_name = new_name.replace('boost_', str(self.options.namespace) + '_')
if name.startswith('boost_python') or name.startswith('boost_numpy'):
if self.options.python_buildid:
new_name += '-%s' % self.options.python_buildid
if self.options.buildid:
new_name += '-%s' % self.options.buildid
libs.append(new_name)
return libs

for module in self._dependencies["dependencies"].keys():
Expand Down
4 changes: 4 additions & 0 deletions recipes/boost/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ project(test_package)
include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
conan_basic_setup(TARGETS)

if(BOOST_NAMESPACE)
add_definitions("-DBOOST_NAMESPACE=${BOOST_NAMESPACE}")
endif()

if(NOT HEADER_ONLY)
if(WITH_RANDOM)
find_package(Boost COMPONENTS random REQUIRED)
Expand Down
4 changes: 4 additions & 0 deletions recipes/boost/all/test_package/chrono.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#include <iostream>
#include <cmath>

#if defined(BOOST_NAMESPACE)
namespace boost = BOOST_NAMESPACE;
#endif

int main()
{
boost::chrono::system_clock::time_point start = boost::chrono::system_clock::now();
Expand Down
2 changes: 2 additions & 0 deletions recipes/boost/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def build(self):
cmake.definitions["WITH_STACKTRACE"] = not self.options["boost"].without_stacktrace
cmake.definitions["WITH_STACKTRACE_ADDR2LINE"] = self.deps_user_info["boost"].stacktrace_addr2line_available
cmake.definitions["WITH_STACKTRACE_BACKTRACE"] = self._boost_option("with_stacktrace_backtrace", False)
if self.options["boost"].namespace != 'boost' and not self.options["boost"].namespace_alias:
cmake.definitions['BOOST_NAMESPACE'] = self.options["boost"].namespace
cmake.configure()
# Disable parallel builds because c3i (=conan-center's test/build infrastructure) seems to choke here
cmake.parallel = False
Expand Down
4 changes: 4 additions & 0 deletions recipes/boost/all/test_package/coroutine.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include <boost/coroutine/all.hpp>
#include <iostream>

#if defined(BOOST_NAMESPACE)
namespace boost = BOOST_NAMESPACE;
#endif

using namespace boost::coroutines;

void cooperative(coroutine<void>::push_type &sink)
Expand Down
4 changes: 4 additions & 0 deletions recipes/boost/all/test_package/fiber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

#include <boost/fiber/detail/thread_barrier.hpp>

#if defined(BOOST_NAMESPACE)
namespace boost = BOOST_NAMESPACE;
#endif

static std::size_t fiber_count{ 0 };
static std::mutex mtx_count{};
static boost::fibers::condition_variable_any cnd_count{};
Expand Down
5 changes: 5 additions & 0 deletions recipes/boost/all/test_package/json.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#include <boost/json.hpp>

#if defined(BOOST_NAMESPACE)
namespace boost = BOOST_NAMESPACE;
#endif

using namespace boost::json;

#include <string>
Expand Down
4 changes: 4 additions & 0 deletions recipes/boost/all/test_package/lambda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
#include <vector>
#include <algorithm>

#if defined(BOOST_NAMESPACE)
namespace boost = BOOST_NAMESPACE;
#endif

int main(int argc, const char * const argv[])
{
using namespace boost::lambda;
Expand Down
5 changes: 5 additions & 0 deletions recipes/boost/all/test_package/locale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
#include <iostream>
#include <iomanip>
#include <ctime>

#if defined(BOOST_NAMESPACE)
namespace boost = BOOST_NAMESPACE;
#endif

int main()
{
using namespace boost::locale;
Expand Down
5 changes: 5 additions & 0 deletions recipes/boost/all/test_package/nowide.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
#include <boost/nowide/args.hpp>
#include <boost/nowide/fstream.hpp>
#include <boost/nowide/iostream.hpp>

#if defined(BOOST_NAMESPACE)
namespace boost = BOOST_NAMESPACE;
#endif

int main(int argc,char **argv)
{
boost::nowide::args a(argc,argv); // Fix arguments - make them UTF-8
Expand Down
4 changes: 4 additions & 0 deletions recipes/boost/all/test_package/numpy.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include <boost/python/numpy.hpp>
#include <iostream>

#if defined(BOOST_NAMESPACE)
namespace boost = BOOST_NAMESPACE;
#endif

namespace p = boost::python;
namespace np = boost::python::numpy;

Expand Down
4 changes: 4 additions & 0 deletions recipes/boost/all/test_package/python.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include <boost/python.hpp>

#if defined(BOOST_NAMESPACE)
namespace boost = BOOST_NAMESPACE;
#endif

char const* greet()
{
return "hello, world!!!!!";
Expand Down
4 changes: 4 additions & 0 deletions recipes/boost/all/test_package/random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#include <boost/random/uniform_int_distribution.hpp>
#include <iostream>

#if defined(BOOST_NAMESPACE)
namespace boost = BOOST_NAMESPACE;
#endif

int main() {
std::string chars(
"abcdefghijklmnopqrstuvwxyz"
Expand Down
4 changes: 4 additions & 0 deletions recipes/boost/all/test_package/regex.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include <boost/regex.hpp>
#include <iostream>

#if defined(BOOST_NAMESPACE)
namespace boost = BOOST_NAMESPACE;
#endif

int main(int argc, const char * const argv[])
{
std::string line;
Expand Down
4 changes: 4 additions & 0 deletions recipes/boost/all/test_package/stacktrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

#include <iostream>

#if defined(BOOST_NAMESPACE)
namespace boost = BOOST_NAMESPACE;
#endif

void f3() {
std::cout << "==start stacktrace==\n" << boost::stacktrace::stacktrace() << "==end stacktrace==\n";
}
Expand Down