def install_data(target_name, package_name, data, requirements): if not package_name: package_name = target_name if option.get("prefix"): # If --prefix is explicitly specified on the command line, # then we need wipe away any settings of datarootdir option.set("datarootdir", None) prefix = get_prefix(package_name, requirements) datadir = option.get("datarootdir", os.path.join(prefix, "share")) stage.install(target_name, data, requirements + ["<location>" + os.path.join(datadir, package_name)]) get_manager().projects().current().mark_targets_as_explicit([target_name])
def install_data(target_name, package_name, data, requirements): if not package_name: package_name = target_name if option.get("prefix"): # If --prefix is explicitly specified on the command line, # then we need wipe away any settings of datarootdir option.set("datarootdir", None) prefix = get_prefix(package_name, requirements) datadir = option.get("datarootdir", os.path.join(prefix, "share")) stage.install( target_name, data, requirements + ["<location>" + os.path.join(datadir, package_name)]) get_manager().projects().current().mark_targets_as_explicit([target_name])
def get_prefix(package_name, requirements): specified = property.select("install-default-prefix", requirements) if specified: specified = ungrist(specified[0]) prefix = option.get("prefix", specified) requirements = property.change(requirements, "install-default-prefix", None) # Or some likely defaults if neither is given. if not prefix: if os.name == "nt": prefix = "C:\\" + package_name elif os.name == "posix": prefix = "/usr/local" return prefix
def declare_targets(all_libraries, headers): configure.register_components(all_libraries) # Select the libraries to install. libraries = libraries_to_install(all_libraries) configure.components_building(libraries) if option.get("show-libraries", None, True): print "The following libraries require building:" for l in libraries: print " - " + l sys.exit(0) declare_top_level_targets(libraries, headers)
def get_library_name(path): path = path.replace("\\", "/") match1 = __ln1.match(path) match2 = __ln2.match(path) match3 = __ln3.match(path) if match1: return match1.group(2) elif match2: return match2.group(2) elif match3: return "" elif option.get("dump-tests", False, True): # The 'run' rule and others might be used outside boost. In that case, # just return the path, since the 'library name' makes no sense. return path
def main_real(): global debug_config, out_xml debug_config = "--debug-configuration" in sys.argv out_xml = any(re.match("^--out-xml=(.*)$", a) for a in sys.argv) engine = Engine() global_build_dir = option.get("build-dir") manager = Manager(engine, global_build_dir) import b2.build.configure as configure if "--version" in sys.argv: version.report() return # This module defines types and generator and what not, # and depends on manager's existence import b2.tools.builtin b2.tools.common.init(manager) load_configuration_files() # Load explicitly specified toolset modules. extra_properties = process_explicit_toolset_requests() # Load the actual project build script modules. We always load the project # in the current folder so 'use-project' directives have any chance of # being seen. Otherwise, we would not be able to refer to subprojects using # target ids. current_project = None projects = get_manager().projects() if projects.find(".", "."): current_project = projects.target(projects.load(".")) # Load the default toolset module if no other has already been specified. if not feature.values("toolset"): dt = default_toolset dtv = None if default_toolset: dtv = default_toolset_version else: dt = "gcc" if os.name == 'nt': dt = "msvc" # FIXME: # else if [ os.name ] = MACOSX # { # default-toolset = darwin ; # } print "warning: No toolsets are configured." print "warning: Configuring default toolset '%s'." % dt print "warning: If the default is wrong, your build may not work correctly." 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" using(dt, dtv) # Parse command line for targets and properties. Note that this requires # that all project files already be loaded. (target_ids, properties) = build_request.from_command_line(sys.argv[1:] + extra_properties) # Expand properties specified on the command line into multiple property # sets consisting of all legal property combinations. Each expanded property # set will be used for a single build run. E.g. if multiple toolsets are # specified then requested targets will be built with each of them. if properties: expanded = build_request.expand_no_defaults(properties) else: expanded = [property_set.empty()] # Check that we actually found something to build. if not current_project and not target_ids: get_manager().errors( )("no Jamfile in current directory found, and no target references specified." ) # FIXME: # EXIT # Flags indicating that this build system run has been started in order to # clean existing instead of create new targets. Note that these are not the # final flag values as they may get changed later on due to some special # targets being specified on the command line. clean = "--clean" in sys.argv cleanall = "--clean-all" in sys.argv # List of explicitly requested files to build. Any target references read # from the command line parameter not recognized as one of the targets # defined in the loaded Jamfiles will be interpreted as an explicitly # requested file to build. If any such files are explicitly requested then # only those files and the targets they depend on will be built and they # will be searched for among targets that would have been built had there # been no explicitly requested files. explicitly_requested_files = [] # List of Boost Build meta-targets, virtual-targets and actual Jam targets # constructed in this build system run. targets = [] virtual_targets = [] actual_targets = [] explicitly_requested_files = [] # Process each target specified on the command-line and convert it into # internal Boost Build target objects. Detect special clean target. If no # main Boost Build targets were explictly requested use the current project # as the target. 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 " explicitly_requested_files.append(id) else: targets.append(t) if not targets: targets = [projects.target(projects.module_name("."))] # FIXME: put this BACK. ## if [ option.get dump-generators : : true ] ## { ## generators.dump ; ## } # We wish to put config.log in the build directory corresponding # to Jamroot, so that the location does not differ depending on # directory where we do build. The amount of indirection necessary # here is scary. first_project = targets[0].project() first_project_root_location = first_project.get('project-root') first_project_root_module = manager.projects().load( first_project_root_location) first_project_root = manager.projects().target(first_project_root_module) first_build_build_dir = first_project_root.build_dir() configure.set_log_file(os.path.join(first_build_build_dir, "config.log")) virtual_targets = [] global results_of_main_targets # Now that we have a set of targets to build and a set of property sets to # build the targets with, we can start the main build process by using each # property set to generate virtual targets from all of our listed targets # and any of their dependants. 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 debug_config, out_xml debug_config = "--debug-configuration" in sys.argv out_xml = any(re.match("^--out-xml=(.*)$", a) for a in sys.argv) engine = Engine() global_build_dir = option.get("build-dir") manager = Manager(engine, global_build_dir) import b2.build.configure as configure if "--version" in sys.argv: from b2.build import version version.report() return # This module defines types and generator and what not, # and depends on manager's existence import b2.tools.builtin b2.tools.common.init(manager) load_configuration_files() # Load explicitly specified toolset modules. extra_properties = process_explicit_toolset_requests() # Load the actual project build script modules. We always load the project # in the current folder so 'use-project' directives have any chance of # being seen. Otherwise, we would not be able to refer to subprojects using # target ids. current_project = None projects = get_manager().projects() if projects.find(".", "."): current_project = projects.target(projects.load(".")) # Load the default toolset module if no other has already been specified. if not feature.values("toolset"): dt = default_toolset dtv = None if default_toolset: dtv = default_toolset_version else: dt = "gcc" if os.name == 'nt': dt = "msvc" # FIXME: #else if [ os.name ] = MACOSX #{ # default-toolset = darwin ; #} print "warning: No toolsets are configured." print "warning: Configuring default toolset '%s'." % dt print "warning: If the default is wrong, your build may not work correctly." 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" using(dt, dtv) # Parse command line for targets and properties. Note that this requires # that all project files already be loaded. (target_ids, properties) = build_request.from_command_line(sys.argv[1:] + extra_properties) # Expand properties specified on the command line into multiple property # sets consisting of all legal property combinations. Each expanded property # set will be used for a single build run. E.g. if multiple toolsets are # specified then requested targets will be built with each of them. if properties: expanded = build_request.expand_no_defaults(properties) else: expanded = [property_set.empty()] # Check that we actually found something to build. if not current_project and not target_ids: get_manager().errors()("no Jamfile in current directory found, and no target references specified.") # FIXME: # EXIT # Flags indicating that this build system run has been started in order to # clean existing instead of create new targets. Note that these are not the # final flag values as they may get changed later on due to some special # targets being specified on the command line. clean = "--clean" in sys.argv cleanall = "--clean-all" in sys.argv # List of explicitly requested files to build. Any target references read # from the command line parameter not recognized as one of the targets # defined in the loaded Jamfiles will be interpreted as an explicitly # requested file to build. If any such files are explicitly requested then # only those files and the targets they depend on will be built and they # will be searched for among targets that would have been built had there # been no explicitly requested files. explicitly_requested_files = [] # List of Boost Build meta-targets, virtual-targets and actual Jam targets # constructed in this build system run. targets = [] virtual_targets = [] actual_targets = [] explicitly_requested_files = [] # Process each target specified on the command-line and convert it into # internal Boost Build target objects. Detect special clean target. If no # main Boost Build targets were explictly requested use the current project # as the target. 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 " ; explicitly_requested_files.append(id) else: targets.append(t) if not targets: targets = [projects.target(projects.module_name("."))] # FIXME: put this BACK. ## if [ option.get dump-generators : : true ] ## { ## generators.dump ; ## } # We wish to put config.log in the build directory corresponding # to Jamroot, so that the location does not differ depending on # directory where we do build. The amount of indirection necessary # here is scary. first_project = targets[0].project() first_project_root_location = first_project.get('project-root') first_project_root_module = manager.projects().load(first_project_root_location) first_project_root = manager.projects().target(first_project_root_module) first_build_build_dir = first_project_root.build_dir() configure.set_log_file(os.path.join(first_build_build_dir, "config.log")) virtual_targets = [] global results_of_main_targets # Now that we have a set of targets to build and a set of property sets to # build the targets with, we can start the main build process by using each # property set to generate virtual targets from all of our listed targets # and any of their dependants. 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
## { ## __ACTION_RULE__ = build-system.out-xml.collect ## [ modules.peek build-system : .out-xml ] ; ## } ## IMPORT ## build-system : ## out-xml.collect ## out-xml.generate-action ## : : ## build-system.out-xml.collect ## build-system.out-xml.generate-action ## ; ## } j = option.get("jobs") if j: bjam.call("set-variable", PARALLELISM, j) k = option.get("keep-going", "true", "true") if k in ["on", "yes", "true"]: bjam.call("set-variable", "KEEP_GOING", "1") elif k in ["off", "no", "false"]: bjam.call("set-variable", "KEEP_GOING", "0") else: print "error: Invalid value for the --keep-going option" sys.exit() # The 'all' pseudo target is not strictly needed expect in the case when we # use it below but people often assume they always have this target # available and do not declare it themselves before use which may cause
match3 = __ln3.match(path) if match1: return match1.group(2) elif match2: return match2.group(2) elif match3: return "" elif option.get("dump-tests", False, True): # The 'run' rule and others might be used outside boost. In that case, # just return the path, since the 'library name' makes no sense. return path # Was an XML dump requested? __out_xml = option.get("out-xml", False, True) # Takes a target (instance of 'basic-target') and prints # - its type # - its name # - comments specified via the <test-info> property # - relative location of all source from the project root. # def dump_test(target): type = target.type() name = target.name() project = target.project() project_root = project.get('project-root') library = get_library_name(os.path.abspath(project.get('location')))
## { ## __ACTION_RULE__ = build-system.out-xml.collect ## [ modules.peek build-system : .out-xml ] ; ## } ## IMPORT ## build-system : ## out-xml.collect ## out-xml.generate-action ## : : ## build-system.out-xml.collect ## build-system.out-xml.generate-action ## ; ## } j = option.get("jobs") if j: bjam.call("set-variable", 'PARALLELISM', j) k = option.get("keep-going", "true", "true") if k in ["on", "yes", "true"]: bjam.call("set-variable", "KEEP_GOING", "1") elif k in ["off", "no", "false"]: bjam.call("set-variable", "KEEP_GOING", "0") else: print "error: Invalid value for the --keep-going option" sys.exit() # The 'all' pseudo target is not strictly needed expect in the case when we # use it below but people often assume they always have this target # available and do not declare it themselves before use which may cause
def install(name, package_name=None, requirements=[], binaries=[], libraries=[], headers=[]): requirements = requirements[:] binaries = binaries[:] libraries if not package_name: package_name = name if option.get("prefix"): # If --prefix is explicitly specified on the command line, # then we need wipe away any settings of libdir/includir that # is specified via options in config files. option.set("bindir", None) option.set("libdir", None) option.set("includedir", None) # If <install-source-root> is not specified, all headers are installed to # prefix/include, no matter what their relative path is. Sometimes that is # what is needed. install_source_root = property.select('install-source-root', requirements) if install_source_root: requirements = property.change(requirements, 'install-source-root', None) install_header_subdir = property.select('install-header-subdir', requirements) if install_header_subdir: install_header_subdir = ungrist(install_header_subdir[0]) requirements = property.change(requirements, 'install-header-subdir', None) # First, figure out all locations. Use the default if no prefix option # given. prefix = get_prefix(name, requirements) # Architecture dependent files. exec_locate = option.get("exec-prefix", prefix) # Binaries. bin_locate = option.get("bindir", os.path.join(prefix, "bin")) # Object code libraries. lib_locate = option.get("libdir", os.path.join(prefix, "lib")) # Source header files. include_locate = option.get("includedir", os.path.join(prefix, "include")) stage.install(name + "-bin", binaries, requirements + ["<location>" + bin_locate]) alias(name + "-lib", [name + "-lib-shared", name + "-lib-static"]) # Since the install location of shared libraries differs on universe # and cygwin, use target alternatives to make different targets. # We should have used indirection conditioanl requirements, but it's # awkward to pass bin-locate and lib-locate from there to another rule. alias(name + "-lib-shared", [name + "-lib-shared-universe"]) alias(name + "-lib-shared", [name + "-lib-shared-cygwin"], ["<target-os>cygwin"]) # For shared libraries, we install both explicitly specified one and the # shared libraries that the installed executables depend on. stage.install(name + "-lib-shared-universe", binaries + libraries, requirements + ["<location>" + lib_locate, "<install-dependencies>on", "<install-type>SHARED_LIB"]) stage.install(name + "-lib-shared-cygwin", binaries + libraries, requirements + ["<location>" + bin_locate, "<install-dependencies>on", "<install-type>SHARED_LIB"]) # For static libraries, we do not care about executable dependencies, since # static libraries are already incorporated into them. stage.install(name + "-lib-static", libraries, requirements + ["<location>" + lib_locate, "<install-dependencies>on", "<install-type>STATIC_LIB"]) stage.install(name + "-headers", headers, requirements \ + ["<location>" + os.path.join(include_locate, s) for s in install_header_subdir] + install_source_root) alias(name, [name + "-bin", name + "-lib", name + "-headers"]) pt = get_manager().projects().current() for subname in ["bin", "lib", "headers", "lib-shared", "lib-static", "lib-shared-universe", "lib-shared-cygwin"]: pt.mark_targets_as_explicit([name + "-" + subname])
@bjam_signature((["version"], )) def set_version(version): global BOOST_VERSION, BOOST_VERSION_TAG BOOST_VERSION = version pieces = version.split(".") if pieces[2] == "0": pieces = pieces[0:2] BOOST_VERSION_TAG = "_".join(pieces) # Option to choose how many variants to build. The default is "minimal". build_type = option.get("build-type", "minimal") if not build_type in ["minimal", "complete"]: get_manager().errors( )("The value of the --build-type option should be either 'complete' or 'minimal'" ) # What kind of layout are we doing? layout = option.get("layout") # On Windows, we used versioned layout by default in order to # be compatible with autolink. On other systems, we use system # layout which is what every other program uses. Note that windows # check is static, and won't if not layout: if os.name == "nt": layout = "versioned" else:
print "HERE I AM" @bjam_signature((["version"],)) def set_version(version): global BOOST_VERSION, BOOST_VERSION_TAG BOOST_VERSION = version pieces = version.split(".") if pieces[2] == "0": pieces = pieces[0:2] BOOST_VERSION_TAG = "_".join(pieces) # Option to choose how many variants to build. The default is "minimal". build_type = option.get("build-type", "minimal") if not build_type in ["minimal", "complete"]: get_manager().errors()("The value of the --build-type option should be either 'complete' or 'minimal'") # What kind of layout are we doing? layout = option.get("layout") # On Windows, we used versioned layout by default in order to # be compatible with autolink. On other systems, we use system # layout which is what every other program uses. Note that windows # check is static, and won't if not layout: if os.name == "nt": layout = "versioned" else: layout = "system"
def install(name, package_name=None, requirements=[], binaries=[], libraries=[], headers=[]): requirements = requirements[:] binaries = binaries[:] libraries if not package_name: package_name = name if option.get("prefix"): # If --prefix is explicitly specified on the command line, # then we need wipe away any settings of libdir/includir that # is specified via options in config files. option.set("bindir", None) option.set("libdir", None) option.set("includedir", None) # If <install-source-root> is not specified, all headers are installed to # prefix/include, no matter what their relative path is. Sometimes that is # what is needed. install_source_root = property.select('install-source-root', requirements) if install_source_root: requirements = property.change(requirements, 'install-source-root', None) install_header_subdir = property.select('install-header-subdir', requirements) if install_header_subdir: install_header_subdir = ungrist(install_header_subdir[0]) requirements = property.change(requirements, 'install-header-subdir', None) # First, figure out all locations. Use the default if no prefix option # given. prefix = get_prefix(name, requirements) # Architecture dependent files. exec_locate = option.get("exec-prefix", prefix) # Binaries. bin_locate = option.get("bindir", os.path.join(prefix, "bin")) # Object code libraries. lib_locate = option.get("libdir", os.path.join(prefix, "lib")) # Source header files. include_locate = option.get("includedir", os.path.join(prefix, "include")) stage.install(name + "-bin", binaries, requirements + ["<location>" + bin_locate]) alias(name + "-lib", [name + "-lib-shared", name + "-lib-static"]) # Since the install location of shared libraries differs on universe # and cygwin, use target alternatives to make different targets. # We should have used indirection conditioanl requirements, but it's # awkward to pass bin-locate and lib-locate from there to another rule. alias(name + "-lib-shared", [name + "-lib-shared-universe"]) alias(name + "-lib-shared", [name + "-lib-shared-cygwin"], ["<target-os>cygwin"]) # For shared libraries, we install both explicitly specified one and the # shared libraries that the installed executables depend on. stage.install( name + "-lib-shared-universe", binaries + libraries, requirements + [ "<location>" + lib_locate, "<install-dependencies>on", "<install-type>SHARED_LIB" ]) stage.install( name + "-lib-shared-cygwin", binaries + libraries, requirements + [ "<location>" + bin_locate, "<install-dependencies>on", "<install-type>SHARED_LIB" ]) # For static libraries, we do not care about executable dependencies, since # static libraries are already incorporated into them. stage.install( name + "-lib-static", libraries, requirements + [ "<location>" + lib_locate, "<install-dependencies>on", "<install-type>STATIC_LIB" ]) stage.install(name + "-headers", headers, requirements \ + ["<location>" + os.path.join(include_locate, s) for s in install_header_subdir] + install_source_root) alias(name, [name + "-bin", name + "-lib", name + "-headers"]) pt = get_manager().projects().current() for subname in [ "bin", "lib", "headers", "lib-shared", "lib-static", "lib-shared-universe", "lib-shared-cygwin" ]: pt.mark_targets_as_explicit([name + "-" + subname])
match2 = __ln2.match(path) match3 = __ln3.match(path) if match1: return match1.group(2) elif match2: return match2.group(2) elif match3: return "" elif option.get("dump-tests", False, True): # The 'run' rule and others might be used outside boost. In that case, # just return the path, since the 'library name' makes no sense. return path # Was an XML dump requested? __out_xml = option.get("out-xml", False, True) # Takes a target (instance of 'basic-target') and prints # - its type # - its name # - comments specified via the <test-info> property # - relative location of all source from the project root. # def dump_test(target): type = target.type() name = target.name() project = target.project() project_root = project.get('project-root') library = get_library_name(os.path.abspath(project.get('location'))) if library: