def __init__ (self, engine, global_build_dir): """ Constructor. engine: the build engine that will actually construct the targets. """ from build.virtual_target import VirtualTargetRegistry from build.targets import TargetRegistry from build.project import ProjectRegistry from build.scanner import ScannerRegistry from build.errors import Errors from b2.util.logger import NullLogger from build import build_request, property_set, feature self.engine_ = engine self.virtual_targets_ = VirtualTargetRegistry (self) self.projects_ = ProjectRegistry (self, global_build_dir) self.targets_ = TargetRegistry () self.logger_ = NullLogger () self.scanners_ = ScannerRegistry (self) self.argv_ = bjam.variable("ARGV") self.boost_build_path_ = bjam.variable("BOOST_BUILD_PATH") self.errors_ = Errors() self.command_line_free_features_ = property_set.empty() # Object Map. # TODO: This is a kludge: maps object names to the actual instances. # Sometimes, objects are stored in properties, along with some grist. # This map is used to store the value and return an id, which can be later on used to retriev it back. self.object_map_ = {} global the_manager the_manager = self
def reset (): """ Clear the module state. This is mainly for testing purposes. Note that this must be called _after_ resetting the module 'feature'. """ global __had_unspecified_value, __had_value, __declared_subfeature global __init_loc global __all_signatures, __debug_configuration, __show_configuration # Stores toolsets without specified initialization values. __had_unspecified_value = {} # Stores toolsets with specified initialization values. __had_value = {} # Stores toolsets with declared subfeatures. __declared_subfeature = {} # Stores all signatures of the toolsets. __all_signatures = {} # Stores the initialization locations of each toolset __init_loc = {} __debug_configuration = '--debug-configuration' in bjam.variable('ARGV') __show_configuration = '--show-configuration' in bjam.variable('ARGV')
def __init__ (self, engine, global_build_dir): """ Constructor. engine: the build engine that will actually construct the targets. """ from build.virtual_target import VirtualTargetRegistry from build.targets import TargetRegistry from build.project import ProjectRegistry from build.scanner import ScannerRegistry from build.errors import Errors from b2.util.logger import NullLogger from build import build_request, property_set, feature self.engine_ = engine self.virtual_targets_ = VirtualTargetRegistry (self) self.projects_ = ProjectRegistry (self, global_build_dir) self.targets_ = TargetRegistry () self.logger_ = NullLogger () self.scanners_ = ScannerRegistry (self) self.argv_ = bjam.variable("ARGV") self.boost_build_path_ = bjam.variable("BOOST_BUILD_PATH") self.errors_ = Errors() self.command_line_free_features_ = property_set.empty() global the_manager the_manager = self
def on_windows (): """ Returns true if running on windows, whether in cygwin or not. """ if bjam.variable("NT"): return True elif bjam.variable("UNIX"): uname = bjam.variable("JAMUNAME") if uname and uname[0].startswith("CYGWIN"): return True return False
def run(self, project, name, ps, sources): # TODO: Replace this with the use of a target-os property. no_static_link = False if bjam.variable('UNIX'): no_static_link = True; ##FIXME: what does this mean? ## { ## switch [ modules.peek : JAMUNAME ] ## { ## case * : no-static-link = true ; ## } ## } reason = None if no_static_link and ps.get('runtime-link') == 'static': if ps.get('link') == 'shared': reason = "On gcc, DLL can't be build with '<runtime-link>static'." elif type.is_derived(self.target_types[0], 'EXE'): for s in sources: source_type = s.type() if source_type and type.is_derived(source_type, 'SHARED_LIB'): reason = "On gcc, using DLLS together with the " +\ "<runtime-link>static options is not possible " if reason: print 'warning:', reason print 'warning:',\ "It is suggested to use '<runtime-link>static' together",\ "with '<link>static'." ; return else: generated_targets = unix.UnixLinkingGenerator.run(self, project, name, ps, sources) return generated_targets
def reset (): """ Clear the module state. This is mainly for testing purposes. Note that this must be called _after_ resetting the module 'feature'. """ global __had_unspecified_value, __had_value, __declared_subfeature global __init_loc global __all_signatures, __debug_configuration, __show_configuration # Stores toolsets without specified initialization values. __had_unspecified_value = {} # Stores toolsets with specified initialization values. __had_value = {} # Stores toolsets with declared subfeatures. __declared_subfeature = {} # Stores all signatures of the toolsets. __all_signatures = {} # Stores the initialization locations of each toolset __init_loc = {} __debug_configuration = '--debug-configuration' in bjam.variable('ARGV') __show_configuration = '--show-configuration' in bjam.variable('ARGV') global __executable_path_variable OS = bjam.call("peek", [], "OS")[0] if OS == "NT": # On Windows the case and capitalization of PATH is not always predictable, so # let's find out what variable name was really set. for n in os.environ: if n.lower() == "path": __executable_path_variable = n break else: __executable_path_variable = "PATH" m = {"NT": __executable_path_variable, "CYGWIN": "PATH", "MACOSX": "DYLD_LIBRARY_PATH", "AIX": "LIBPATH", "HAIKU": "LIBRARY_PATH"} global __shared_library_path_variable __shared_library_path_variable = m.get(OS, "LD_LIBRARY_PATH")
def get_program_files_dir(): """ returns the location of the "program files" directory on a windows platform """ ProgramFiles = bjam.variable("ProgramFiles") if ProgramFiles: ProgramFiles = ' '.join(ProgramFiles) else: ProgramFiles = "c:\\Program Files" return ProgramFiles
def verify_engine_version(): major, minor, _ = v = bjam.variable('JAM_VERSION') if major != _major or minor != _minor: from textwrap import dedent engine = sys.argv[0] core = os.path.dirname(os.path.dirname(__file__)) print dedent("""\ warning: mismatched version of Boost.Build engine core warning: Boost.Build engine "{}" is "{}" warning: Boost.Build core at {} is {} """.format(engine, '.'.join(v), core, boost_build())) return False return True
def use_project(version = None): projects.push_current( projects.current() ) if not version: version = __boost_default if not version: version = "auto_config" global __initialized if __initialized: if __initialized != version: get_manager().errors()('Attempt to use {} with different parameters'.format('boost')) else: if version in __boost_configured: opts = __boost_configured[ version ] root = opts.get('<root>' ) inc = opts.get('<include>') lib = opts.get('<library>') if debug(): print "notice: using boost library {} {}".format( version, opt.raw() ) global __layout global __version_tag __layout = opts.get('<layout>') if not __layout: __layout = 'versioned' __build_id = opts.get('<build-id>') __version_tag = re.sub("[*\\/:.\"\' ]", "_", version) __initialized = version if ( root and inc ) or \ ( root and lib ) or \ ( lib and not inc ) or \ ( not lib and inc ): get_manager().errors()("Ambiguous parameters, use either <root> or <inlude> with <library>.") elif not root and not inc: root = bjam.variable("BOOST_ROOT") module = projects.current().project_module() if root: bjam.call('call-in-module', module, 'use-project', ['boost', root]) else: projects.initialize(__name__) if version == '0.0.1': boost_0_0_1( inc, lib ) else: boost_std( inc, lib ) else: get_manager().errors()("Reference to unconfigured boost version.") projects.pop_current()
def main(): global argv argv = bjam.variable("ARGV") # FIXME: document this option. if "--profiling" in argv: import cProfile import pstats cProfile.runctx('main_real()', globals(), locals(), "stones.prof") stats = pstats.Stats("stones.prof") stats.strip_dirs() stats.sort_stats('time', 'calls') stats.print_callers(20) else: main_real()
def report(self): print "error:", self.args[0] if self.original_exception_: print format(str(self.original_exception_), " ") print print " error context (most recent first):" for c in self.context_[::-1]: c.report() print if "--stacktrace" in bjam.variable("ARGV"): if self.original_tb_: traceback.print_tb(self.original_tb_) elif self.stack_: for l in traceback.format_list(self.stack_): print l, else: print " use the '--stacktrace' option to get Python stacktrace" print
def main(): sys.argv = bjam.variable("ARGV") # FIXME: document this option. if "--profiling" in sys.argv: import cProfile r = cProfile.runctx('main_real()', globals(), locals(), "stones.prof") import pstats stats = pstats.Stats("stones.prof") stats.strip_dirs() stats.sort_stats('time', 'calls') stats.print_callers(20) return r else: try: return main_real() except ExceptionWithUserContext, e: e.report()
'"$(CONFIG_COMMAND)" -L"$(LINKPATH)" ' + '-Wl,$(RPATH_OPTION:E=-R)$(SPACE)-Wl,"$(RPATH)" ' + '"$(.IMPLIB-COMMAND)$(<[1])" -o "$(<[-1])" ' + '$(HAVE_SONAME)-Wl,$(SONAME_OPTION)$(SPACE)-Wl,$(<[-1]:D=) ' + '-shared $(START-GROUP) "$(>)" "$(LIBRARIES)" $(FINDLIBS-ST-PFX) ' + '-l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) ' + '$(OPTIONS) $(USER_OPTIONS)', function = gcc_link_dll, bound_list=['LIBRARIES']) # Set up threading support. It's somewhat contrived, so perform it at the end, # to avoid cluttering other code. if on_windows(): flags('gcc', 'OPTIONS', ['<threading>multi'], ['-mthreads']) elif bjam.variable('UNIX'): jamuname = bjam.variable('JAMUNAME') host_os_name = jamuname[0] if host_os_name.startswith('SunOS'): flags('gcc', 'OPTIONS', ['<threading>multi'], ['-pthreads']) flags('gcc', 'FINDLIBS-SA', [], ['rt']) elif host_os_name == 'BeOS': # BeOS has no threading options, don't set anything here. pass elif host_os_name.endswith('BSD'): flags('gcc', 'OPTIONS', ['<threading>multi'], ['-pthread']) # there is no -lrt on BSD elif host_os_name == 'DragonFly': flags('gcc', 'OPTIONS', ['<threading>multi'], ['-pthread']) # there is no -lrt on BSD - DragonFly is a FreeBSD variant, # which anoyingly doesn't say it's a *BSD.
for v in self.all_: if not self.feature_map_.has_key(v.feature()): self.feature_map_[v.feature()] = [] self.feature_map_[v.feature()].append(v.value()) return self.feature_map_.get(feature, []) @cached def get_properties(self, feature): """Returns all contained properties associated with 'feature'""" if not isinstance(feature, b2.build.feature.Feature): feature = b2.build.feature.get(feature) assert isinstance(feature, b2.build.feature.Feature) result = [] for p in self.all_: if p.feature() == feature: result.append(p) return result def __contains__(self, item): return item in self.all_set_ def hash(p): m = hashlib.md5() m.update(p) return m.hexdigest() hash_maybe = hash if "--hash" in bjam.variable("ARGV") else None
def load_configuration_files(): # Flag indicating that site configuration should not be loaded. ignore_site_config = "--ignore-site-config" in sys.argv if legacy_ignore_config and debug_config: print "notice: Regular site and user configuration files will be ignored" print "notice: due to the --ignore-config command-line option." initialize_config_module("test-config") test_config = None for a in sys.argv: m = re.match("--test-config=(.*)$", a) if m: test_config = b2.util.unquote(m.group(1)) break if test_config: where = load_config("test-config", os.path.basename(test_config), [os.path.dirname(test_config)]) if where: if debug_config and not legacy_ignore_config: print "notice: Regular site and user configuration files will" print "notice: be ignored due to the test configuration being loaded." user_path = [os.path.expanduser("~")] + bjam.variable("BOOST_BUILD_PATH") site_path = ["/etc"] + user_path if os.name in ["nt"]: site_path = [os.getenv("SystemRoot")] + user_path if ignore_site_config and not legacy_ignore_config: print "notice: Site configuration files will be ignored due to the" print "notice: --ignore-site-config command-line option." initialize_config_module("site-config") if not test_config and not ignore_site_config and not legacy_ignore_config: load_config('site-config', 'site-config.jam', site_path) initialize_config_module('user-config') if not test_config and not legacy_ignore_config: user_config = None for a in sys.argv: m = re.match("--user-config=(.*)$", a) if m: user_config = m.group(1) break if not user_config: user_config = os.getenv("BOOST_BUILD_USER_CONFIG") # Special handling for the case when the OS does not strip the quotes # around the file name, as is the case when using Cygwin bash. user_config = b2.util.unquote(user_config) explicitly_requested = user_config if not user_config: user_config = "user-config.jam" if explicitly_requested: user_config = os.path.abspath(user_config) if debug_config: print "notice: Loading explicitly specified user configuration file:" print " " + user_config load_config('user-config', os.path.basename(user_config), [os.path.dirname(user_config)], True) else: load_config('user-config', os.path.basename(user_config), user_path) elif debug_config: print "notice: User configuration file loading explicitly disabled." # We look for project-config.jam from "." upward. # I am not sure this is 100% right decision, we might as well check for # it only alonside the Jamroot file. However: # # - We need to load project-root.jam before Jamroot # - We probably would need to load project-root.jam even if there's no # Jamroot - e.g. to implement automake-style out-of-tree builds. if os.path.exists("project-config.jam"): file = ["project-config.jam"] else: file = b2.util.path.glob_in_parents(".", ["project-config.jam"]) if file: initialize_config_module('project-config', os.path.dirname(file[0])) load_config('project-config', "project-config.jam", [os.path.dirname(file[0])], True)
def getenv(self, name): return bjam.variable(name)
def os_name (): result = bjam.variable("OS") assert(len(result) == 1) return result[0]
def os_version(): return bjam.variable("OSVER")
def debug(): global __debug if __debug is None: __debug = "--debug-configuration" in bjam.variable("ARGV") return __debug
'"$(CONFIG_COMMAND)" -L"$(LINKPATH)" ' + '-Wl,$(RPATH_OPTION:E=-R)$(SPACE)-Wl,"$(RPATH)" ' + '"$(.IMPLIB-COMMAND)$(<[1])" -o "$(<[-1])" ' + '$(HAVE_SONAME)-Wl,$(SONAME_OPTION)$(SPACE)-Wl,$(<[-1]:D=) ' + '-shared $(START-GROUP) "$(>)" "$(LIBRARIES)" $(FINDLIBS-ST-PFX) ' + '-l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) ' + '$(OPTIONS) $(USER_OPTIONS)', function = gcc_link_dll, bound_list=['LIBRARIES']) # Set up threading support. It's somewhat contrived, so perform it at the end, # to avoid cluttering other code. if on_windows(): flags('gcc', 'OPTIONS', ['<threading>multi'], ['-mthreads']) elif bjam.variable('UNIX'): jamuname = bjam.variable('JAMUNAME') host_os_name = jamuname[0] if host_os_name.startswith('SunOS'): flags('gcc', 'OPTIONS', ['<threading>multi'], ['-pthreads']) flags('gcc', 'FINDLIBS-SA', [], ['rt']) elif host_os_name == 'BeOS': # BeOS has no threading options, don't set anything here. pass elif host_os_name == 'Haiku': flags('gcc', 'OPTIONS', ['<threading>multi'], ['-lroot']) # there is no -lrt on Haiku, and -pthread is implicit elif host_os_name.endswith('BSD'): flags('gcc', 'OPTIONS', ['<threading>multi'], ['-pthread']) # there is no -lrt on BSD elif host_os_name == 'DragonFly':
def platform(): return bjam.variable("OSPLAT")
def main_real(): global ignore_config global debug_config boost_build_path = bjam.variable("BOOST_BUILD_PATH") engine = Engine() global_build_dir = get_string_option("build-dir") debug_config = get_boolean_option("debug-configuration") manager = Manager(engine, global_build_dir) # This module defines types and generator and what not, # and depends on manager's existence import b2.tools.builtin # Check if we can load 'test-config.jam'. If we can, load it and # ignore user configs. test_config = glob(boost_build_path, ["test-config.jam"]) if test_config: test_config = test_config[0] if test_config: if debug_config: print "notice: loading testing-config.jam from '%s'" % test_config print "notice: user-config.jam and site-config.jam will be ignored" manager.projects().load_standalone("test-config", test_config) ignore_config = test_config or get_boolean_option("ignore-config") user_path = home_directories() + boost_build_path site_path = ["/etc"] + user_path if bjam.variable("OS") in ["NT", "CYGWIN"]: site_path = [os.environ("SystemRoot")] + user_path load_config(manager, "site-config", site_path) user_config_path = get_string_option("user-config") if not user_config_path: user_config_path = os.environ.get("BOOST_BUILD_USER_CONFIG") if user_config_path: if debug_config: print "Loading explicitly specifier user configuration file:" print " %s" % user_config_path manager.projects().load_standalone("user-config", user_config_path) else: load_config(manager, "user-config", user_path) # FIXME: ## # ## # Autoconfigure toolsets based on any instances of --toolset=xx,yy,...zz or ## # toolset=xx,yy,...zz in the command line ## # ## local option-toolsets = [ regex.split-list [ MATCH ^--toolset=(.*) : $(argv) ] : "," ] ; ## local feature-toolsets = [ regex.split-list [ MATCH ^toolset=(.*) : $(argv) ] : "," ] ; ## # if the user specified --toolset=..., we need to add toolset=... to ## # the build request ## local extra-build-request ; extra_build_request = [] ## if ! $(ignore-config) ## { ## for local t in $(option-toolsets) $(feature-toolsets) ## { ## # Parse toolset-version/properties ## local (t-v,t,v) = [ MATCH (([^-/]+)-?([^/]+)?)/?.* : $(t) ] ; ## local toolset-version = $((t-v,t,v)[1]) ; ## local toolset = $((t-v,t,v)[2]) ; ## local version = $((t-v,t,v)[3]) ; ## if $(debug-config) ## { ## ECHO notice: [cmdline-cfg] Detected command-line request for ## $(toolset-version): toolset= \"$(toolset)\" "version= \""$(version)\" ; ## } ## local known ; ## # if the toolset isn't known, configure it now. ## if $(toolset) in [ feature.values <toolset> ] ## { ## known = true ; ## } ## if $(known) && $(version) ## && ! [ feature.is-subvalue toolset : $(toolset) : version : $(version) ] ## { ## known = ; ## } ## if ! $(known) ## { ## if $(debug-config) ## { ## ECHO notice: [cmdline-cfg] toolset $(toolset-version) ## not previously configured; configuring now ; ## } ## toolset.using $(toolset) : $(version) ; ## } ## else ## { ## if $(debug-config) ## { ## ECHO notice: [cmdline-cfg] toolset $(toolset-version) already configured ; ## } ## } ## # make sure we get an appropriate property into the build request in ## # case the user used the "--toolset=..." form ## if ! $(t) in $(argv) ## && ! $(t) in $(feature-toolsets) ## { ## if $(debug-config) ## { ## ECHO notice: [cmdline-cfg] adding toolset=$(t) "to build request." ; ## } ## extra-build-request += toolset=$(t) ; ## } ## } ## } # FIXME: ## if USER_MODULE in [ RULENAMES ] ## { ## USER_MODULE site-config user-config ; ## } if get_boolean_option("version"): # FIXME: Move to a separate module. Include bjam # verision. print "Boost.Build M15 (Python port in development)" sys.exit(0) b2.tools.common.init(manager) # We always load project in "." so that 'use-project' directives has # any chance of been seen. Otherwise, we won't be able to refer to # subprojects using target ids. current_project = None projects = manager.projects() if projects.find(".", "."): current_project = projects.target(projects.load(".")) # FIXME: revive this logic, when loading of gcc works if not feature.values("<toolset>") and not ignore_config and 0: default_toolset = "gcc" ; if bjam.variable("OS") == "NT": default_toolset = "msvc" print "warning: No toolsets are configured." ; print "warning: Configuring default toolset '%s'" % default_toolset print "warning: If the default is wrong, you may not be able to build C++ programs." print "warning: Use the \"--toolset=xxxxx\" option to override our guess." print "warning: For more configuration options, please consult" print "warning: http://boost.org/boost-build2/doc/html/bbv2/advanced/configuration.html" projects.project_rules().using([default_toolset]) (target_ids, properties) = b2.build.build_request.from_command_line( argv[1:] + extra_build_request) if properties: expanded = b2.build.build_request.expand_no_defaults(properties) xexpanded = [] for e in expanded: xexpanded.append(property_set.create(feature.split(e))) expanded = xexpanded else: expanded = [property_set.empty()] targets = [] clean = get_boolean_option("clean") clean_all = get_boolean_option("clean-all") bjam_targets = [] # Given a target id, try to find and return corresponding target. # This is only invoked when there's no Jamfile in "." # This code somewhat duplicates code in project-target.find but we can't reuse # that code without project-targets instance. def find_target (target_id): split = target_id.split("//") pm = None if len(split) > 1: pm = projects.find(split[0], ".") else: pm = projects.find(target_id, ".") result = None if pm: result = projects.target(pm) if len(split) > 1: result = result.find(split[1]) if not current_project and not target_ids: print "error: no Jamfile in current directory found, and no target references specified." sys.exit(1) for id in target_ids: if id == "clean": clean = 1 else: t = None if current_project: t = current_project.find(id, no_error=1) else: t = find_target(id) if not t: print "notice: could not find main target '%s'" % id print "notice: assuming it's a name of file to create " ; bjam_targets.append(id) else: targets.append(t) if not targets: targets = [projects.target(projects.module_name("."))] virtual_targets = [] # Virtual targets obtained when building main targets references on # the command line. When running # # bjam --clean main_target # # we want to clean the files that belong only to that main target, # so we need to record which targets are produced. results_of_main_targets = [] for p in expanded: manager.set_command_line_free_features(property_set.create(p.free())) for t in targets: try: g = t.generate(p) if not isinstance(t, ProjectTarget): results_of_main_targets.extend(g.targets()) virtual_targets.extend(g.targets()) except ExceptionWithUserContext, e: e.report() except Exception: raise
if v.feature not in self.feature_map_: self.feature_map_[v.feature] = [] self.feature_map_[v.feature].append(v.value) return self.feature_map_.get(feature, []) @cached def get_properties(self, feature): """Returns all contained properties associated with 'feature'""" if not isinstance(feature, b2.build.feature.Feature): feature = b2.build.feature.get(feature) assert isinstance(feature, b2.build.feature.Feature) result = [] for p in self.all_: if p.feature == feature: result.append(p) return result def __contains__(self, item): return item.id in self._all_set def hash(p): m = hashlib.md5() m.update(p) return m.hexdigest() hash_maybe = hash if "--hash" in bjam.variable("ARGV") else None
def os_name(): result = bjam.variable("OS") assert (len(result) == 1) return result[0]
# Copyright 2003, 2005 Dave Abrahams # Copyright 2006 Rene Rivera # Copyright 2003, 2004, 2005, 2006, 2007 Vladimir Prus # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import os import sys import re import bjam # set this early on since some of the following modules # require looking at the sys.argv sys.argv = bjam.variable("ARGV") from b2.build.engine import Engine from b2.manager import Manager from b2.util.path import glob from b2.build import feature, property_set import b2.build.virtual_target from b2.build.targets import ProjectTarget import b2.build.build_request from b2.build.errors import ExceptionWithUserContext import b2.tools.common from b2.build.toolset import using import b2.build.virtual_target as virtual_target import b2.build.build_request as build_request
def platform (): return bjam.variable("OSPLAT")
def main_real(): global ignore_config global debug_config boost_build_path = bjam.variable("BOOST_BUILD_PATH") engine = Engine() global_build_dir = get_string_option("build-dir") debug_config = get_boolean_option("debug-configuration") manager = Manager(engine, global_build_dir) # This module defines types and generator and what not, # and depends on manager's existence import b2.tools.builtin # Check if we can load 'test-config.jam'. If we can, load it and # ignore user configs. test_config = glob(boost_build_path, ["test-config.jam"]) if test_config: test_config = test_config[0] if test_config: if debug_config: print "notice: loading testing-config.jam from '%s'" % test_config print "notice: user-config.jam and site-config.jam will be ignored" manager.projects().load_standalone("test-config", test_config) ignore_config = test_config or get_boolean_option("ignore-config") user_path = home_directories() + boost_build_path site_path = ["/etc"] + user_path if bjam.variable("OS") in ["NT", "CYGWIN"]: site_path = [os.environ("SystemRoot")] + user_path load_config(manager, "site-config", site_path) user_config_path = get_string_option("user-config") if not user_config_path: user_config_path = os.environ.get("BOOST_BUILD_USER_CONFIG") if user_config_path: if debug_config: print "Loading explicitly specifier user configuration file:" print " %s" % user_config_path manager.projects().load_standalone("user-config", user_config_path) else: load_config(manager, "user-config", user_path) # FIXME: ## # ## # Autoconfigure toolsets based on any instances of --toolset=xx,yy,...zz or ## # toolset=xx,yy,...zz in the command line ## # ## local option-toolsets = [ regex.split-list [ MATCH ^--toolset=(.*) : $(argv) ] : "," ] ; ## local feature-toolsets = [ regex.split-list [ MATCH ^toolset=(.*) : $(argv) ] : "," ] ; ## # if the user specified --toolset=..., we need to add toolset=... to ## # the build request ## local extra-build-request ; extra_build_request = [] ## if ! $(ignore-config) ## { ## for local t in $(option-toolsets) $(feature-toolsets) ## { ## # Parse toolset-version/properties ## local (t-v,t,v) = [ MATCH (([^-/]+)-?([^/]+)?)/?.* : $(t) ] ; ## local toolset-version = $((t-v,t,v)[1]) ; ## local toolset = $((t-v,t,v)[2]) ; ## local version = $((t-v,t,v)[3]) ; ## if $(debug-config) ## { ## ECHO notice: [cmdline-cfg] Detected command-line request for ## $(toolset-version): toolset= \"$(toolset)\" "version= \""$(version)\" ; ## } ## local known ; ## # if the toolset isn't known, configure it now. ## if $(toolset) in [ feature.values <toolset> ] ## { ## known = true ; ## } ## if $(known) && $(version) ## && ! [ feature.is-subvalue toolset : $(toolset) : version : $(version) ] ## { ## known = ; ## } ## if ! $(known) ## { ## if $(debug-config) ## { ## ECHO notice: [cmdline-cfg] toolset $(toolset-version) ## not previously configured; configuring now ; ## } ## toolset.using $(toolset) : $(version) ; ## } ## else ## { ## if $(debug-config) ## { ## ECHO notice: [cmdline-cfg] toolset $(toolset-version) already configured ; ## } ## } ## # make sure we get an appropriate property into the build request in ## # case the user used the "--toolset=..." form ## if ! $(t) in $(argv) ## && ! $(t) in $(feature-toolsets) ## { ## if $(debug-config) ## { ## ECHO notice: [cmdline-cfg] adding toolset=$(t) "to build request." ; ## } ## extra-build-request += toolset=$(t) ; ## } ## } ## } # FIXME: ## if USER_MODULE in [ RULENAMES ] ## { ## USER_MODULE site-config user-config ; ## } if get_boolean_option("version"): # FIXME: Move to a separate module. Include bjam # verision. print "Boost.Build M15 (Python port in development)" sys.exit(0) b2.tools.common.init(manager) # We always load project in "." so that 'use-project' directives has # any chance of been seen. Otherwise, we won't be able to refer to # subprojects using target ids. current_project = None projects = manager.projects() if projects.find(".", "."): current_project = projects.target(projects.load(".")) # FIXME: revive this logic, when loading of gcc works if not feature.values("<toolset>") and not ignore_config and 0: default_toolset = "gcc" if bjam.variable("OS") == "NT": default_toolset = "msvc" print "warning: No toolsets are configured." print "warning: Configuring default toolset '%s'" % default_toolset print "warning: If the default is wrong, you may not be able to build C++ programs." print "warning: Use the \"--toolset=xxxxx\" option to override our guess." print "warning: For more configuration options, please consult" print "warning: http://boost.org/boost-build2/doc/html/bbv2/advanced/configuration.html" projects.project_rules().using([default_toolset]) (target_ids, properties ) = b2.build.build_request.from_command_line(argv[1:] + extra_build_request) if properties: expanded = b2.build.build_request.expand_no_defaults(properties) xexpanded = [] for e in expanded: xexpanded.append(property_set.create(feature.split(e))) expanded = xexpanded else: expanded = [property_set.empty()] targets = [] clean = get_boolean_option("clean") clean_all = get_boolean_option("clean-all") bjam_targets = [] # Given a target id, try to find and return corresponding target. # This is only invoked when there's no Jamfile in "." # This code somewhat duplicates code in project-target.find but we can't reuse # that code without project-targets instance. def find_target(target_id): split = target_id.split("//") pm = None if len(split) > 1: pm = projects.find(split[0], ".") else: pm = projects.find(target_id, ".") result = None if pm: result = projects.target(pm) if len(split) > 1: result = result.find(split[1]) if not current_project and not target_ids: print "error: no Jamfile in current directory found, and no target references specified." sys.exit(1) for id in target_ids: if id == "clean": clean = 1 else: t = None if current_project: t = current_project.find(id, no_error=1) else: t = find_target(id) if not t: print "notice: could not find main target '%s'" % id print "notice: assuming it's a name of file to create " bjam_targets.append(id) else: targets.append(t) if not targets: targets = [projects.target(projects.module_name("."))] virtual_targets = [] # Virtual targets obtained when building main targets references on # the command line. When running # # bjam --clean main_target # # we want to clean the files that belong only to that main target, # so we need to record which targets are produced. results_of_main_targets = [] for p in expanded: manager.set_command_line_free_features(property_set.create(p.free())) for t in targets: try: g = t.generate(p) if not isinstance(t, ProjectTarget): results_of_main_targets.extend(g.targets()) virtual_targets.extend(g.targets()) except ExceptionWithUserContext, e: e.report() except Exception: raise
def load_configuration_files(): # Flag indicating that site configuration should not be loaded. ignore_site_config = "--ignore-site-config" in sys.argv initialize_config_module("test-config") test_config = None for a in sys.argv: m = re.match("--test-config=(.*)$", a) if m: test_config = b2.util.unquote(m.group(1)) break if test_config: where = load_config("test-config", os.path.basename(test_config), [os.path.dirname(test_config)]) if where: if debug_config: print "notice: Regular site and user configuration files will" print "notice: be ignored due to the test configuration being loaded." user_path = [os.path.expanduser("~")] + bjam.variable("BOOST_BUILD_PATH") site_path = ["/etc"] + user_path if os.name in ["nt"]: site_path = [os.getenv("SystemRoot")] + user_path if debug_config and not test_config and ignore_site_config: print "notice: Site configuration files will be ignored due to the" print "notice: --ignore-site-config command-line option." initialize_config_module("site-config") if not test_config and not ignore_site_config: load_config('site-config', 'site-config.jam', site_path) initialize_config_module('user-config') if not test_config: # Here, user_config has value of None if nothing is explicitly # specified, and value of '' if user explicitly does not want # to load any user config. user_config = None for a in sys.argv: m = re.match("--user-config=(.*)$", a) if m: user_config = m.group(1) break if user_config is None: user_config = os.getenv("BOOST_BUILD_USER_CONFIG") # Special handling for the case when the OS does not strip the quotes # around the file name, as is the case when using Cygwin bash. user_config = b2.util.unquote(user_config) explicitly_requested = user_config if user_config is None: user_config = "user-config.jam" if user_config: if explicitly_requested: user_config = os.path.abspath(user_config) if debug_config: print "notice: Loading explicitly specified user configuration file:" print " " + user_config load_config('user-config', os.path.basename(user_config), [os.path.dirname(user_config)], True) else: load_config('user-config', os.path.basename(user_config), user_path) else: if debug_config: print "notice: User configuration file loading explicitly disabled." # We look for project-config.jam from "." upward. I am not sure this is # 100% right decision, we might as well check for it only alongside the # Jamroot file. However: # - We need to load project-config.jam before Jamroot # - We probably need to load project-config.jam even if there is no Jamroot # - e.g. to implement automake-style out-of-tree builds. if os.path.exists("project-config.jam"): file = ["project-config.jam"] else: file = b2.util.path.glob_in_parents(".", ["project-config.jam"]) if file: initialize_config_module('project-config', os.path.dirname(file[0])) load_config('project-config', "project-config.jam", [os.path.dirname(file[0])], True)
def os_version (): return bjam.variable("OSVER")