From 5f8f6bfe0f9dd6aa70261691b994e32212de58b5 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Fri, 3 May 2019 15:52:39 -0700 Subject: [PATCH] fbcode_builder: getdeps: add Boost builder Summary: the boost builder knows how to perform the non-standard configure and build for boost. Ideally we'd just build this statically and be happy but there are some nuances I've observed while building on different platforms: * One of our projects (thrift or wangle) explicitly requests static boost linkage for reasons unspecified * on darwin the install_name is broken when building dynamic libs For the sake of expediency in getting getdeps up and running, the solution for the moment is to build static on posix systems and build both static and shared on windows systems. Reviewed By: simpkins Differential Revision: D14691009 fbshipit-source-id: 634770a6f53c3ada42d1877cc6c3dacc6eed7d18 --- build/fbcode_builder/getdeps/builder.py | 50 ++++++++++++++++++++++++ build/fbcode_builder/getdeps/manifest.py | 4 ++ 2 files changed, 54 insertions(+) diff --git a/build/fbcode_builder/getdeps/builder.py b/build/fbcode_builder/getdeps/builder.py index 691bd0716d..17c34a4f87 100644 --- a/build/fbcode_builder/getdeps/builder.py +++ b/build/fbcode_builder/getdeps/builder.py @@ -285,3 +285,53 @@ class OpenSSLBuilder(BuilderBase): ] ) self._run_cmd([make, "install_sw", "install_ssldirs"]) + + +class Boost(BuilderBase): + def __init__(self, build_opts, ctx, manifest, src_dir, build_dir, inst_dir): + children = os.listdir(src_dir) + assert len(children) == 1, "expected a single directory entry: %r" % (children,) + boost_src = children[0] + assert boost_src.startswith("boost") + src_dir = os.path.join(src_dir, children[0]) + super(Boost, self).__init__( + build_opts, ctx, manifest, src_dir, build_dir, inst_dir + ) + + def _build(self, install_dirs, reconfigure): + linkage = ["static"] + if self.build_opts.is_windows(): + linkage.append("shared") + for link in linkage: + args = [] + if self.build_opts.is_windows(): + bootstrap = os.path.join(self.src_dir, "bootstrap.bat") + self._run_cmd([bootstrap], cwd=self.src_dir) + args += ["address-model=64"] + else: + bootstrap = os.path.join(self.src_dir, "bootstrap.sh") + self._run_cmd( + [bootstrap, "--prefix=%s" % self.inst_dir], cwd=self.src_dir + ) + + b2 = os.path.join(self.src_dir, "b2") + self._run_cmd( + [ + b2, + "-j%s" % self.build_opts.num_jobs, + "--prefix=%s" % self.inst_dir, + "--builddir=%s" % self.build_dir, + ] + + args + + [ + "link=%s" % link, + "runtime-link=shared", + "variant=release", + "threading=multi", + "debug-symbols=on", + "visibility=global", + "-d2", + "install", + ], + cwd=self.src_dir, + ) diff --git a/build/fbcode_builder/getdeps/manifest.py b/build/fbcode_builder/getdeps/manifest.py index 89898eda78..68b08a8c26 100644 --- a/build/fbcode_builder/getdeps/manifest.py +++ b/build/fbcode_builder/getdeps/manifest.py @@ -12,6 +12,7 @@ import io from .builder import ( AutoconfBuilder, + Boost, CMakeBuilder, MakeBuilder, NinjaBootstrap, @@ -318,6 +319,9 @@ class ManifestParser(object): build_options, ctx, self, src_dir, build_dir, inst_dir, args ) + if builder == "boost": + return Boost(build_options, ctx, self, src_dir, build_dir, inst_dir) + if builder == "cmake": defines = self.get_section_as_dict("cmake.defines", ctx) return CMakeBuilder(