aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-09-10 09:38:40 -0400
committerJack Lloyd <[email protected]>2019-09-10 09:38:40 -0400
commit71a92630ac1e3d995a017610e82a62ad6c54d246 (patch)
tree4bc287ed545c61df8983d50495ba31f5016564f0
parent0ee18280a798c3f311259036ae70e503ae9ff3a3 (diff)
parent00bfb00326b1277151316da692b3284cd74b2e3e (diff)
Merge GH #2098 Add --build-targets= option
-rwxr-xr-xconfigure.py52
-rw-r--r--src/scripts/ci/lgtm.yml2
-rwxr-xr-xsrc/scripts/ci_build.py17
3 files changed, 55 insertions, 16 deletions
diff --git a/configure.py b/configure.py
index 94b7b9460..d23201783 100755
--- a/configure.py
+++ b/configure.py
@@ -276,6 +276,8 @@ class BuildPaths(object): # pylint: disable=too-many-instance-attributes
else:
raise InternalError("Unknown src info type '%s'" % (typ))
+ACCEPTABLE_BUILD_TARGETS = ["static", "shared", "cli", "tests", "bogo_shim"]
+
def process_command_line(args): # pylint: disable=too-many-locals,too-many-statements
"""
Handle command line options
@@ -487,8 +489,8 @@ def process_command_line(args): # pylint: disable=too-many-locals,too-many-state
build_group.add_option('--with-debug-asserts', action='store_true', default=False,
help=optparse.SUPPRESS_HELP)
- build_group.add_option('--build-bogo-shim', action='store_true', default=False,
- help=optparse.SUPPRESS_HELP)
+ build_group.add_option('--build-targets', default=None, dest="build_targets", action='append',
+ help="build specific targets and tools (%s)" % ', '.join(ACCEPTABLE_BUILD_TARGETS))
build_group.add_option('--with-pkg-config', action='store_true', default=None,
help=optparse.SUPPRESS_HELP)
@@ -1950,15 +1952,17 @@ def create_template_vars(source_paths, build_paths, options, modules, cc, arch,
return path
return os.path.join(build_dir, path)
- def all_targets():
+ def all_targets(options):
yield 'libs'
- yield 'cli'
- yield 'tests'
- yield 'docs'
+ if 'cli' in options.build_targets:
+ yield 'cli'
+ if 'tests' in options.build_targets:
+ yield 'tests'
if options.build_fuzzers:
yield 'fuzzers'
- if options.build_bogo_shim:
+ if 'bogo_shim' in options.build_targets:
yield 'bogo_shim'
+ yield 'docs'
variables = {
'version_major': Version.major(),
@@ -1976,7 +1980,7 @@ def create_template_vars(source_paths, build_paths, options, modules, cc, arch,
'macos_so_compat_ver': '%s.%s.0' % (Version.packed(), Version.so_rev()),
'macos_so_current_ver': '%s.%s.%s' % (Version.packed(), Version.so_rev(), Version.patch()),
- 'all_targets': ' '.join(all_targets()),
+ 'all_targets': ' '.join(all_targets(options)),
'base_dir': source_paths.base_dir,
'src_dir': source_paths.src_dir,
@@ -2108,7 +2112,7 @@ def create_template_vars(source_paths, build_paths, options, modules, cc, arch,
'include_paths': build_paths.format_include_paths(cc, options.with_external_includedir),
'module_defines': sorted(flatten([m.defines() for m in modules])),
- 'build_bogo_shim': options.build_bogo_shim,
+ 'build_bogo_shim': bool('bogo_shim' in options.build_targets),
'bogo_shim_src': os.path.join(source_paths.src_dir, 'bogo_shim', 'bogo_shim.cpp'),
'os_features': osinfo.enabled_features(options),
@@ -2975,6 +2979,36 @@ def canonicalize_options(options, info_os, info_arch):
if options.cpu != options.arch:
logging.info('Canonicalized CPU target %s to %s', options.cpu, options.arch)
+ # select and sanity check build targets
+ def canonicalize_build_targets(options):
+ # --build-targets was not provided: build default targets
+ if options.build_targets is None:
+ return ["cli", "tests"]
+
+ # flatten the list of multiple --build-targets="" and comma separation
+ build_targets = [t.strip().lower() for ts in options.build_targets for t in ts.split(",")]
+
+ # validate that all requested build targets are available
+ for build_target in build_targets:
+ if build_target not in ACCEPTABLE_BUILD_TARGETS:
+ raise UserError("unknown build target: %s" % build_target)
+
+ # building the shared lib desired and without contradiction?
+ if options.build_shared_lib is None:
+ options.build_shared_lib = "shared" in build_targets
+ elif bool(options.build_shared_lib) != bool("shared" in build_targets):
+ raise UserError("inconsistent usage of --enable/disable-shared-library and --build-targets")
+
+ # building the static lib desired and without contradiction?
+ if options.build_static_lib is None:
+ options.build_static_lib = "static" in build_targets
+ elif bool(options.build_static_lib) != bool("static" in build_targets):
+ raise UserError("inconsistent usage of --enable/disable-static-library and --build-targets")
+
+ return build_targets
+
+ options.build_targets = canonicalize_build_targets(options)
+
shared_libs_supported = options.os in info_os and info_os[options.os].building_shared_supported()
if not shared_libs_supported:
diff --git a/src/scripts/ci/lgtm.yml b/src/scripts/ci/lgtm.yml
index 6967f3299..fa2423858 100644
--- a/src/scripts/ci/lgtm.yml
+++ b/src/scripts/ci/lgtm.yml
@@ -28,4 +28,4 @@ extraction:
cpp:
configure:
command:
- - ./configure.py --build-bogo-shim --build-fuzzers=test --with-zlib --with-bzip2 --with-lzma --with-openssl --with-sqlite3 --no-store-vc-rev
+ - ./configure.py --build-targets="static,shared,cli,tests,bogo_shim" --build-fuzzers=test --with-zlib --with-bzip2 --with-lzma --with-openssl --with-sqlite3 --no-store-vc-rev
diff --git a/src/scripts/ci_build.py b/src/scripts/ci_build.py
index 756bc880b..bdab39317 100755
--- a/src/scripts/ci_build.py
+++ b/src/scripts/ci_build.py
@@ -65,15 +65,16 @@ def determine_flags(target, target_os, target_cpu, target_cc, cc_bin, ccache, ro
flags = ['--prefix=%s' % (install_prefix),
'--cc=%s' % (target_cc),
'--os=%s' % (target_os)]
+ build_targets = ['cli', 'tests']
if target_cpu is not None:
flags += ['--cpu=%s' % (target_cpu)]
if target in ['shared', 'mini-shared']:
- flags += ['--disable-static']
+ build_targets += ['shared']
if target in ['static', 'mini-static', 'fuzzers'] or target_os in ['ios', 'mingw']:
- flags += ['--disable-shared']
+ build_targets += ['static']
if target in ['mini-static', 'mini-shared']:
flags += ['--minimized-build', '--enable-modules=system_rng,sha2_32,sha2_64,aes']
@@ -89,15 +90,16 @@ def determine_flags(target, target_os, target_cpu, target_cc, cc_bin, ccache, ro
# Arbitrarily test disable static on module policy builds
# tls is optional for bsi/nist but add it so verify tests work with these minimized configs
flags += ['--module-policy=%s' % (target),
- '--enable-modules=tls',
- '--disable-static']
+ '--enable-modules=tls']
+ build_targets += ['shared']
if target == 'docs':
flags += ['--with-doxygen', '--with-sphinx', '--with-rst2man']
test_cmd = None
if target == 'coverage':
- flags += ['--with-coverage-info', '--with-debug-info', '--test-mode', '--build-bogo-shim']
+ flags += ['--with-coverage-info', '--with-debug-info', '--test-mode']
+ build_targets += ['bogo_shim']
if target == 'valgrind':
# valgrind in 16.04 has a bug with rdrand handling
flags += ['--with-valgrind', '--disable-rdrand']
@@ -128,8 +130,8 @@ def determine_flags(target, target_os, target_cpu, target_cc, cc_bin, ccache, ro
# these profiling flags) but we can't use --no-optimizations as that
# will make running the tests too slow.
flags += ['--cc-abi-flags=-fprofile-instr-generate -fcoverage-mapping',
- '--disable-shared',
'--optimize-for-size']
+ build_targets += ['static']
make_prefix = [os.path.join(root_dir, 'build-wrapper-linux-x86/build-wrapper-linux-x86-64'),
'--out-dir', 'bw-outputs']
@@ -273,6 +275,9 @@ def determine_flags(target, target_os, target_cpu, target_cc, cc_bin, ccache, ro
else:
run_test_command = test_prefix + test_cmd
+ if 'static' not in build_targets and 'shared' not in build_targets:
+ build_targets += ['static', 'shared'] if target_os != 'windows' else ['shared']
+ flags += ['--build-targets=%s' % ','.join(build_targets)]
return flags, run_test_command, make_prefix