mirror of
https://github.com/facebook/proxygen.git
synced 2025-08-08 18:02:05 +03:00
Add --shared-libs arg to getdeps.py
Summary: This diffs adds * `--shared-libs` command line argument to the `build` command which enables building shared libraries for supported projects (cmake-based projects, boost, libevent) * this flag overrides `BUILD_SHARED_LIBS` cmake flags in manifest files and from `--extra-cmake-defines` * adds `shared_libs=on` expression support in manifest files * for boost, the flag enables building shared libraries **in addition to** statically linked ones Reviewed By: simonmar Differential Revision: D27462289 fbshipit-source-id: d22ab434f7228c30472611bc323830d88efba0a5
This commit is contained in:
committed by
Facebook GitHub Bot
parent
fa4dbed8a7
commit
10216910e9
@@ -100,6 +100,9 @@ class ProjectCmdBase(SubCmd):
|
||||
else:
|
||||
ctx_gen.set_value_for_project(args.project, "test", "off")
|
||||
|
||||
if opts.shared_libs:
|
||||
ctx_gen.set_value_for_all_projects("shared_libs", "on")
|
||||
|
||||
loader = ManifestLoader(opts, ctx_gen)
|
||||
self.process_project_dir_arguments(args, loader)
|
||||
|
||||
@@ -709,6 +712,12 @@ class BuildCmd(ProjectCmdBase):
|
||||
'e.g: \'{"CMAKE_CXX_FLAGS": "--bla"}\''
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--shared-libs",
|
||||
help="Build shared libraries if possible",
|
||||
action="store_true",
|
||||
default=False,
|
||||
)
|
||||
|
||||
|
||||
@cmd("fixup-dyn-deps", "Adjusts dynamic dependencies for packaging purposes")
|
||||
|
@@ -486,6 +486,8 @@ if __name__ == "__main__":
|
||||
if extra_cmake_defines:
|
||||
self.defines.update(extra_cmake_defines)
|
||||
self.loader = loader
|
||||
if build_opts.shared_libs:
|
||||
self.defines["BUILD_SHARED_LIBS"] = "ON"
|
||||
|
||||
def _invalidate_cache(self):
|
||||
for name in [
|
||||
@@ -968,7 +970,7 @@ class Boost(BuilderBase):
|
||||
def _build(self, install_dirs, reconfigure):
|
||||
env = self._compute_env(install_dirs)
|
||||
linkage = ["static"]
|
||||
if self.build_opts.is_windows():
|
||||
if self.build_opts.is_windows() or self.build_opts.shared_libs:
|
||||
linkage.append("shared")
|
||||
|
||||
args = []
|
||||
@@ -1118,7 +1120,7 @@ install(FILES sqlite3.h sqlite3ext.h DESTINATION include)
|
||||
|
||||
defines = {
|
||||
"CMAKE_INSTALL_PREFIX": self.inst_dir,
|
||||
"BUILD_SHARED_LIBS": "OFF",
|
||||
"BUILD_SHARED_LIBS": "ON" if self.build_opts.shared_libs else "OFF",
|
||||
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
|
||||
}
|
||||
define_args = ["-D%s=%s" % (k, v) for (k, v) in defines.items()]
|
||||
|
@@ -56,6 +56,7 @@ class BuildOptions(object):
|
||||
vcvars_path=None,
|
||||
allow_system_packages=False,
|
||||
lfs_path=None,
|
||||
shared_libs=False,
|
||||
):
|
||||
"""fbcode_builder_dir - the path to either the in-fbsource fbcode_builder dir,
|
||||
or for shipit-transformed repos, the build dir that
|
||||
@@ -69,6 +70,7 @@ class BuildOptions(object):
|
||||
num_jobs - the level of concurrency to use while building
|
||||
use_shipit - use real shipit instead of the simple shipit transformer
|
||||
vcvars_path - Path to external VS toolchain's vsvarsall.bat
|
||||
shared_libs - whether to build shared libraries
|
||||
"""
|
||||
if not num_jobs:
|
||||
import multiprocessing
|
||||
@@ -103,6 +105,7 @@ class BuildOptions(object):
|
||||
self.use_shipit = use_shipit
|
||||
self.allow_system_packages = allow_system_packages
|
||||
self.lfs_path = lfs_path
|
||||
self.shared_libs = shared_libs
|
||||
if vcvars_path is None and is_windows():
|
||||
|
||||
try:
|
||||
@@ -183,6 +186,7 @@ class BuildOptions(object):
|
||||
"distro_vers": host_type.distrovers,
|
||||
"fb": "on" if facebook_internal else "off",
|
||||
"test": "off",
|
||||
"shared_libs": "on" if self.shared_libs else "off",
|
||||
}
|
||||
)
|
||||
|
||||
@@ -455,20 +459,30 @@ def setup_build_options(args, host_type=None):
|
||||
if not is_windows():
|
||||
scratch_dir = os.path.realpath(scratch_dir)
|
||||
|
||||
# Save any extra cmake defines passed by the user in an env variable, so it
|
||||
# Save these args passed by the user in an env variable, so it
|
||||
# can be used while hashing this build.
|
||||
os.environ["GETDEPS_CMAKE_DEFINES"] = getattr(args, "extra_cmake_defines", "") or ""
|
||||
|
||||
host_type = _check_host_type(args, host_type)
|
||||
|
||||
build_args = {
|
||||
k: v
|
||||
for (k, v) in vars(args).items()
|
||||
if k
|
||||
in {
|
||||
"num_jobs",
|
||||
"use_shipit",
|
||||
"vcvars_path",
|
||||
"allow_system_packages",
|
||||
"lfs_path",
|
||||
"shared_libs",
|
||||
}
|
||||
}
|
||||
|
||||
return BuildOptions(
|
||||
fbcode_builder_dir,
|
||||
scratch_dir,
|
||||
host_type,
|
||||
install_dir=args.install_prefix,
|
||||
num_jobs=args.num_jobs,
|
||||
use_shipit=args.use_shipit,
|
||||
vcvars_path=args.vcvars_path,
|
||||
allow_system_packages=args.allow_system_packages,
|
||||
lfs_path=args.lfs_path,
|
||||
**build_args
|
||||
)
|
||||
|
@@ -263,6 +263,7 @@ class ManifestLoader(object):
|
||||
env["os"] = self.build_opts.host_type.ostype
|
||||
env["distro"] = self.build_opts.host_type.distro
|
||||
env["distro_vers"] = self.build_opts.host_type.distrovers
|
||||
env["shared_libs"] = str(self.build_opts.shared_libs)
|
||||
for name in [
|
||||
"CXXFLAGS",
|
||||
"CPPFLAGS",
|
||||
|
@@ -588,7 +588,7 @@ class ManifestContext(object):
|
||||
This object should be passed as the `ctx` parameter in ManifestParser.get() calls.
|
||||
"""
|
||||
|
||||
ALLOWED_VARIABLES = {"os", "distro", "distro_vers", "fb", "test"}
|
||||
ALLOWED_VARIABLES = {"os", "distro", "distro_vers", "fb", "test", "shared_libs"}
|
||||
|
||||
def __init__(self, ctx_dict):
|
||||
assert set(ctx_dict.keys()) == self.ALLOWED_VARIABLES
|
||||
|
@@ -25,5 +25,8 @@ EVENT__DISABLE_BENCHMARK = ON
|
||||
EVENT__DISABLE_SAMPLES = ON
|
||||
EVENT__DISABLE_REGRESS = ON
|
||||
|
||||
[cmake.defines.shared_libs=on]
|
||||
EVENT__BUILD_SHARED_LIBRARIES = ON
|
||||
|
||||
[dependencies.not(os=linux)]
|
||||
openssl
|
||||
|
Reference in New Issue
Block a user