diff options
Diffstat (limited to 'configure.py')
-rwxr-xr-x | configure.py | 52 |
1 files changed, 43 insertions, 9 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: |