Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Example:
using gcc : 3.4 : : foo bar sun ;
"""
options = to_seq(options)
command = to_seq(command)
# Information about the gcc command...
# The command.
command = to_seq(common.get_invocation_command('gcc', 'g++', command))
# The root directory of the tool install.
root = feature.get_values('', options) ;
# The bin directory where to find the command to execute.
bin = None
# The flavor of compiler.
flavor = feature.get_values('', options)
# Autodetect the root and bin dir if not given.
if command:
if not bin:
bin = common.get_absolute_tool_path(command[-1])
if not root:
root = os.path.dirname(bin)
# Autodetect the version and flavor if not given.
if command:
machine_info = subprocess.Popen(command + ['-dumpmachine'], stdout=subprocess.PIPE).communicate()[0]
machine = __machine_match.search(machine_info).group(1)
version_info = subprocess.Popen(command + ['-dumpversion'], stdout=subprocess.PIPE).communicate()[0]
version = __version_match.search(version_info).group(1)
if not flavor and machine.find('mingw') != -1:
flavor = 'mingw'
assert isinstance(prop_set, property_set.PropertySet)
assert is_iterable_typed(sources, virtual_target.VirtualTarget)
if not name:
return None
# If name is empty, it means we're called not from top-level.
# In this case, we just fail immediately, because SearchedLibGenerator
# cannot be used to produce intermediate targets.
properties = prop_set.raw ()
shared = 'shared' in properties
a = virtual_target.NullAction (project.manager(), prop_set)
real_name = feature.get_values ('', properties)
if real_name:
real_name = real_name[0]
else:
real_name = name
search = feature.get_values('', properties)
usage_requirements = property_set.create(['' + p for p in search])
t = SearchedLibTarget(real_name, project, shared, search, a)
# We return sources for a simple reason. If there's
# lib png : z : png ;
# the 'z' target should be returned, so that apps linking to
# 'png' will link to 'z', too.
return(usage_requirements, [b2.manager.get_manager().virtual_targets().register(t)] + sources)
- OPTIOns for compile to the value of in options
- OPTIONS for compile.c to the value of in options
- OPTIONS for compile.c++ to the value of in options
- OPTIONS for compile.fortran to the value of in options
- OPTIONs for link to the value of in options
"""
from b2.build import toolset
assert(isinstance(tool, str))
assert(isinstance(condition, list))
assert(isinstance(command, str))
assert(isinstance(options, list))
assert(command)
toolset.flags(tool, 'CONFIG_COMMAND', condition, [command])
toolset.flags(tool + '.compile', 'OPTIONS', condition, feature.get_values('', options))
toolset.flags(tool + '.compile.c', 'OPTIONS', condition, feature.get_values('', options))
toolset.flags(tool + '.compile.c++', 'OPTIONS', condition, feature.get_values('', options))
toolset.flags(tool + '.compile.fortran', 'OPTIONS', condition, feature.get_values('', options))
toolset.flags(tool + '.link', 'OPTIONS', condition, feature.get_values('', options))
def default_path(version):
# Use auto-detected path if possible.
options = __versions.get(version, 'options')
tmp_path = None
if options:
tmp_path = feature.get_values('', options)
if tmp_path:
tmp_path="".join(tmp_path)
tmp_path=os.path.dirname(tmp_path)
else:
env_var_var_name = '__version_{}_env'.format(version.replace('.','_'))
vc_path = None
if env_var_var_name in globals():
env_var_name = globals()[env_var_var_name]
if env_var_name in os.environ:
vc_path = environ[env_var_name]
if vc_path:
vc_path = os.path.join(vc_path,globals()['__version_{}_envpath'.format(version.replace('.','_'))])
tmp_path = os.path.normpath(vc_path)
var_name = '__version_{}_path'.format(version.replace('.','_'))
# binary with 64-bit compiler, but user can always pass -m32 manually.
lib_path = [os.path.join(root, 'bin'),
os.path.join(root, 'lib'),
os.path.join(root, 'lib32'),
os.path.join(root, 'lib64')]
if debug():
print 'notice: using gcc libraries ::', condition, '::', lib_path
toolset.flags('gcc.link', 'RUN_PATH', condition, lib_path)
# If it's not a system gcc install we should adjust the various programs as
# needed to prefer using the install specific versions. This is essential
# for correct use of MinGW and for cross-compiling.
# - The archive builder.
archiver = common.get_invocation_command('gcc',
'ar', feature.get_values('', options), [bin], path_last=True)
toolset.flags('gcc.archive', '.AR', condition, [archiver])
if debug():
print 'notice: using gcc archiver ::', condition, '::', archiver
# - The resource compiler.
rc_command = common.get_invocation_command_nodefault('gcc',
'windres', feature.get_values('', options), [bin], path_last=True)
rc_type = feature.get_values('', options)
if not rc_type:
rc_type = 'windres'
if not rc_command:
# If we can't find an RC compiler we fallback to a null RC compiler that
# creates empty object files. This allows the same Jamfiles to work
# across the board. The null RC uses the assembler to create the empty
#
# VC 7.1 had only the vcvars32.bat script specific to 32 bit i386
# builds. It was located in the bin folder for the regular version
# and in the root folder for the free VC 7.1 tools.
#
# Later 8.0 & 9.0 versions introduce separate platform specific
# vcvars*.bat scripts (e.g. 32 bit, 64 bit AMD or 64 bit Itanium)
# located in or under the bin folder. Most also include a global
# vcvarsall.bat helper script located in the root folder which runs
# one of the aforementioned vcvars*.bat scripts based on the options
# passed to it. So far only the version coming with some PlatformSDK
# distributions does not include this top level script but to
# support those we need to fall back to using the worker scripts
# directly in case the top level script can not be found.
global_setup = feature.get_values('',options)
if global_setup:
global_setup = global_setup[0]
else:
global_setup = None
if not below_8_0 and not global_setup:
global_setup = locate_default_setup(command,parent,'vcvarsall.bat')
default_setup = {
'amd64' : 'vcvarsx86_amd64.bat',
'i386' : 'vcvars32.bat',
'ia64' : 'vcvarsx86_ia64.bat' }
# http://msdn2.microsoft.com/en-us/library/x4d2c09s(VS.80).aspx and
# http://msdn2.microsoft.com/en-us/library/x4d2c09s(vs.90).aspx
- OPTIONS for compile.c++ to the value of in options
- OPTIONS for compile.asm to the value of in options
- OPTIONS for compile.fortran to the value of in options
- OPTIONs for link to the value of in options
"""
from b2.build import toolset
assert isinstance(tool, basestring)
assert is_iterable_typed(condition, basestring)
assert command and isinstance(command, basestring)
assert is_iterable_typed(options, basestring)
toolset.flags(tool, 'CONFIG_COMMAND', condition, [command])
toolset.flags(tool + '.compile', 'OPTIONS', condition, feature.get_values('', options))
toolset.flags(tool + '.compile.c', 'OPTIONS', condition, feature.get_values('', options))
toolset.flags(tool + '.compile.c++', 'OPTIONS', condition, feature.get_values('', options))
toolset.flags(tool + '.compile.asm', 'OPTIONS', condition, feature.get_values('', options))
toolset.flags(tool + '.compile.fortran', 'OPTIONS', condition, feature.get_values('', options))
toolset.flags(tool + '.link', 'OPTIONS', condition, feature.get_values('', options))
'ar', feature.get_values('', options), [bin], path_last=True)
toolset.flags('gcc.archive', '.AR', condition, [archiver])
if debug():
print 'notice: using gcc archiver ::', condition, '::', archiver
# - Ranlib
ranlib = common.get_invocation_command('gcc',
'ranlib', feature.get_values('', options), [bin], path_last=True)
toolset.flags('gcc.archive', '.RANLIB', condition, [ranlib])
if debug():
print 'notice: using gcc archiver ::', condition, '::', ranlib
# - The resource compiler.
rc_command = common.get_invocation_command_nodefault('gcc',
'windres', feature.get_values('', options), [bin], path_last=True)
rc_type = feature.get_values('', options)
if not rc_type:
rc_type = 'windres'
if not rc_command:
# If we can't find an RC compiler we fallback to a null RC compiler that
# creates empty object files. This allows the same Jamfiles to work
# across the board. The null RC uses the assembler to create the empty
# objects, so configure that.
rc_command = common.get_invocation_command('gcc', 'as', [], [bin], path_last=True)
rc_type = 'null'
rc.configure(rc_command, condition, '' + rc_type)
if not linker:
linker = "link"
resource_compiler = feature.get_values("", options)
if not resource_compiler:
resource_compiler = "rc"
# Turn on some options for i386 assembler
# -coff generate COFF format object file (compatible with cl.exe output)
default_assembler_amd64 = 'ml64'
default_assembler_i386 = 'ml -coff'
default_assembler_ia64 = 'ias'
assembler = feature.get_values('',options)
idl_compiler = feature.get_values('',options)
if not idl_compiler:
idl_compiler = 'midl'
mc_compiler = feature.get_values('',options)
if not mc_compiler:
mc_compiler = 'mc'
manifest_tool = feature.get_values('',options)
if not manifest_tool:
manifest_tool = 'mt'
cc_filter = feature.get_values('',options)
for c in cpu:
cpu_conditions = [ condition + '/' + arch for arch in globals()['__cpu_arch_{}'.format(c)] for condition in conditions ]
def run(self, project, name, prop_set, sources):
if not name:
return None
# If name is empty, it means we're called not from top-level.
# In this case, we just fail immediately, because SearchedLibGenerator
# cannot be used to produce intermediate targets.
properties = prop_set.raw ()
shared = 'shared' in properties
a = virtual_target.NullAction (project.manager(), prop_set)
real_name = feature.get_values ('', properties)
if real_name:
real_name = real_name[0]
else:
real_nake = name
search = feature.get_values('', properties)
usage_requirements = property_set.create(['' + p for p in search])
t = SearchedLibTarget(name, project, shared, real_name, search, a)
# We return sources for a simple reason. If there's
# lib png : z : png ;
# the 'z' target should be returned, so that apps linking to
# 'png' will link to 'z', too.
return(usage_requirements, [b2.manager.get_manager().virtual_targets().register(t)] + sources)