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 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 validate_property_sets (sets): for s in sets: validate(feature.split(s))