Skip to content

Commit

Permalink
Add argument to pass extra arguments to boost b2 build tool (#28)
Browse files Browse the repository at this point in the history
Summary:
X-link: facebook/fb303#28

X-link: facebook/fboss#115

X-link: facebook/folly#1736

X-link: facebook/proxygen#403

X-link: facebook/fbthrift#488

This adds a way to pass arguments to the `b2` build tool, used by Boost. This is needed in order to link a getdeps built boost into an relocatable `.so`. The motivating use case is that we need to statically link Boost into a native library used by a python wheel, which must be relocatable. This functionality already exists for CMake-based projects.

Reviewed By: mackorone

Differential Revision: D34796774

fbshipit-source-id: 0d6a9f4703865dc02048b87e77394c44ef646af6
  • Loading branch information
dgrnbrg-meta authored and facebook-github-bot committed Mar 14, 2022
1 parent 7728de6 commit 9a2a5a4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions build/fbcode_builder/getdeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,8 @@ def run_project_cmd(self, args, loader, manifest):
else {}
)

extra_b2_args = args.extra_b2_args or []

if sources_changed or reconfigure or not os.path.exists(built_marker):
if os.path.exists(built_marker):
os.unlink(built_marker)
Expand All @@ -620,6 +622,7 @@ def run_project_cmd(self, args, loader, manifest):
loader,
final_install_prefix=loader.get_project_install_prefix(m),
extra_cmake_defines=extra_cmake_defines,
extra_b2_args=extra_b2_args,
)
builder.build(install_dirs, reconfigure=reconfigure)

Expand Down Expand Up @@ -760,6 +763,15 @@ def setup_project_cmd_parser(self, parser):
'e.g: \'{"CMAKE_CXX_FLAGS": "--bla"}\''
),
)
parser.add_argument(
"--extra-b2-args",
help=(
"Repeatable argument that contains extra arguments to pass "
"to b2, which compiles boost. "
"e.g.: 'cxxflags=-fPIC' 'cflags=-fPIC'"
),
action="append",
)
parser.add_argument(
"--shared-libs",
help="Build shared libraries if possible",
Expand Down
3 changes: 3 additions & 0 deletions build/fbcode_builder/getdeps/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ def create_builder( # noqa:C901
loader,
final_install_prefix=None,
extra_cmake_defines=None,
extra_b2_args=None,
):
builder = self.get_builder_name(ctx)
build_in_src_dir = self.get("build", "build_in_src_dir", "false", ctx=ctx)
Expand Down Expand Up @@ -527,6 +528,8 @@ def create_builder( # noqa:C901

if builder == "boost":
args = self.get_section_as_args("b2.args", ctx)
if extra_b2_args is not None:
args += extra_b2_args
return Boost(build_options, ctx, self, src_dir, build_dir, inst_dir, args)

if builder == "bistro":
Expand Down

0 comments on commit 9a2a5a4

Please sign in to comment.