Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def configure_version_specific(toolset_arg, version, conditions):
# Starting with versions 7.0, the msvc compiler have the /Zc:forScope and
# /Zc:wchar_t options that improve C++ standard conformance, but those
# options are off by default. If we are sure that the msvc version is at
# 7.*, add those options explicitly. We can be sure either if user specified
# version 7.* explicitly or if we auto-detected the version ourselves.
if not re.search('^6\\.', version):
toolset.flags('{}.compile'.format(toolset_arg), 'CFLAGS',conditions, ['/Zc:forScope','/Zc:wchar_t'])
toolset.flags('{}.compile.c++'.format(toolset_arg), 'C++FLAGS',conditions, ['/wd4675'])
# Explicitly disable the 'function is deprecated' warning. Some msvc
# versions have a bug, causing them to emit the deprecation warning even
# with /W0.
toolset.flags('{}.compile'.format(toolset_arg), 'CFLAGS',extend_conditions(conditions,['off']), ['/wd4996'])
if re.search('^[78]\.', version):
# 64-bit compatibility warning deprecated since 9.0, see
# http://msdn.microsoft.com/en-us/library/yt4xw8fh.aspx
toolset.flags('{}.compile'.format(toolset_arg), 'CFLAGS',extend_conditions(conditions,['all']), ['/Wp64'])
#
# Processor-specific optimization.
#
if re.search('^[67]', version ):
# 8.0 deprecates some of the options.
# the latter have their HPP type derived from H. The type of compilation
# is determined entirely by the destination type.
generators.register(MsvcPchGenerator('msvc.compile.c.pch', False, ['H'], ['C_PCH','OBJ'], ['on', 'msvc']))
generators.register(MsvcPchGenerator('msvc.compile.c++.pch', False, ['H'], ['CPP_PCH','OBJ'], ['on', 'msvc']))
generators.override('msvc.compile.c.pch', 'pch.default-c-pch-generator')
generators.override('msvc.compile.c++.pch', 'pch.default-cpp-pch-generator')
toolset.flags('msvc.compile', 'PCH_FILE' , ['on'], ['' ])
toolset.flags('msvc.compile', 'PCH_SOURCE', ['on'], [''])
toolset.flags('msvc.compile', 'PCH_HEADER', ['on'], [''])
#
# Declare flags for compilation.
#
toolset.flags('msvc.compile', 'CFLAGS', ['speed'], ['/O2'])
toolset.flags('msvc.compile', 'CFLAGS', ['space'], ['/O1'])
toolset.flags('msvc.compile', 'CFLAGS', [ a + '/' + t for a in __cpu_arch_ia64 for t in __cpu_type_itanium ], ['/G1'])
toolset.flags('msvc.compile', 'CFLAGS', [ a + '/' + t for a in __cpu_arch_ia64 for t in __cpu_type_itanium2 ], ['/G2'])
toolset.flags('msvc.compile', 'CFLAGS', ['on/object'], ['/Z7'])
toolset.flags('msvc.compile', 'CFLAGS', ['on/database'], ['/Zi'])
toolset.flags('msvc.compile', 'CFLAGS', ['off'], ['/Od'])
toolset.flags('msvc.compile', 'CFLAGS', ['off'], ['/Ob0'])
toolset.flags('msvc.compile', 'CFLAGS', ['on'], ['/Ob1'])
toolset.flags('msvc.compile', 'CFLAGS', ['full'], ['/Ob2'])
toolset.flags('msvc.compile', 'CFLAGS', ['on'], ['/W3'])
toolset.flags('msvc.compile', 'CFLAGS', ['off'], ['/W0'])
toolset.flags('msvc.compile', 'CFLAGS', ['all'], ['/W4'])
toolset.flags('msvc.compile', 'CFLAGS', ['on'], ['/WX'])
['LIB', 'OBJ'],
['EXE'],
['gcc']))
generators.register(
GccLinkingGenerator('gcc.link.dll', True,
['LIB', 'OBJ'],
['SHARED_LIB'],
['gcc']))
# Declare flags for linking.
# First, the common flags.
flags('gcc.link', 'OPTIONS', ['on'], ['-g'])
flags('gcc.link', 'OPTIONS', ['on'], ['-pg'])
flags('gcc.link', 'USER_OPTIONS', [], [''])
flags('gcc.link', 'LINKPATH', [], [''])
flags('gcc.link', 'FINDLIBS-ST', [], [''])
flags('gcc.link', 'FINDLIBS-SA', [], [''])
flags('gcc.link', 'LIBRARIES', [], [''])
# For static we made sure there are no dynamic libraries in the
# link. On HP-UX not all system libraries exist as archived libraries (for
# example, there is no libunwind.a), so, on this platform, the -static option
# cannot be specified.
if os_name() != 'HPUX':
flags('gcc.link', 'OPTIONS', ['static'], ['-static'])
# Now, the vendor specific flags.
# The parameter linker can be either gnu, darwin, osf, hpux or sun.
def init_link_flags(toolset, linker, condition):
"""
Now, the vendor specific flags.
The parameter linker can be either gnu, darwin, osf, hpux or sun.
# The linker disables the default optimizations when using /DEBUG so we
# have to enable them manually for release builds with debug symbols.
toolset.flags('msvc', 'LINKFLAGS', ['on/off'], ['/OPT:REF,ICF'])
toolset.flags('msvc', 'LINKFLAGS', ['console'], ['/subsystem:console'])
toolset.flags('msvc', 'LINKFLAGS', ['gui'], ['/subsystem:windows'])
toolset.flags('msvc', 'LINKFLAGS', ['wince'], ['/subsystem:windowsce'])
toolset.flags('msvc', 'LINKFLAGS', ['native'], ['/subsystem:native'])
toolset.flags('msvc', 'LINKFLAGS', ['auto'], ['/subsystem:posix'])
toolset.flags('msvc.link', 'OPTIONS', [], [''])
toolset.flags('msvc.link', 'LINKPATH', [], [''])
toolset.flags('msvc.link', 'FINDLIBS_ST', [], [''])
toolset.flags('msvc.link', 'FINDLIBS_SA', [], [''])
toolset.flags('msvc.link', 'LIBRARY_OPTION', ['msvc'], [''])
toolset.flags('msvc.link', 'LIBRARIES_MENTIONED_BY_FILE', [], [''])
toolset.flags('msvc.archive', 'AROPTIONS', [], [''])
class NotfileGenerator(generators.Generator):
def run(self, project, name, ps, sources):
pass
action_name = ps.get('action')[0]
if action_name[0] == '@':
action = virtual_target.Action(get_manager(), sources, action_name[1:], ps)
else:
action = virtual_target.Action(get_manager(), sources, "notfile.run", ps)
return [get_manager().virtual_targets().register(
virtual_target.NotFileTarget(name, project, action))]
generators.register(NotfileGenerator("notfile.main", False, [], ["NOTFILE_MAIN"]))
toolset.flags("notfile.run", "ACTION", [], [""])
get_manager().engine().register_action("notfile.run", "$(ACTION)")
@bjam_signature((["target_name"], ["action"], ["sources", "*"], ["requirements", "*"],
["default_build", "*"]))
def notfile(target_name, action, sources, requirements, default_build):
requirements.append("" + action)
return targets.create_typed_metatarget(target_name, "NOTFILE_MAIN", sources, requirements,
default_build, [])
get_manager().projects().add_rule("notfile", notfile)
flags(toolset_link, 'RPATH', condition, ['']) # : unchecked ;
flags(toolset_link, 'RPATH_LINK', condition, ['']) # : unchecked ;
elif linker == 'osf':
# No --strip-all, just -s.
flags(toolset_link, 'OPTIONS', map(lambda x: x + '/off', condition), ['-Wl,-s'])
# : unchecked ;
flags(toolset_link, 'RPATH', condition, ['']) # : unchecked ;
# This does not supports -R.
flags(toolset_link, 'RPATH_OPTION', condition, ['-rpath']) # : unchecked ;
# -rpath-link is not supported at all.
elif linker == 'sun':
flags(toolset_link, 'OPTIONS', map(lambda x: x + '/off', condition), ['-Wl,-s'])
# : unchecked ;
flags(toolset_link, 'RPATH', condition, ['']) # : unchecked ;
# Solaris linker does not have a separate -rpath-link, but allows to use
# -L for the same purpose.
flags(toolset_link, 'LINKPATH', condition, ['']) # : unchecked ;
# This permits shared libraries with non-PIC code on Solaris.
# VP, 2004/09/07: Now that we have -fPIC hardcode in link.dll, the
# following is not needed. Whether -fPIC should be hardcoded, is a
# separate question.
# AH, 2004/10/16: it is still necessary because some tests link against
# static libraries that were compiled without PIC.
flags(toolset_link, 'OPTIONS', map(lambda x: x + '/shared', condition), ['-mimpure-text'])
# : unchecked ;
elif linker == 'hpux':
flags(toolset_link, 'OPTIONS', map(lambda x: x + '/off', condition),
['-Wl,-s']) # : unchecked ;
if debug():
for cpu_condition in cpu_conditions:
print "notice: [msvc-cfg] condition: '{}', setup: '{}'".format(cpu_condition,setup_script)
cpu_assembler = assembler
if not cpu_assembler:
cpu_assembler = locals()['default_assembler_{}'.format(c)]
toolset.flags('msvc.compile', '.CC' , cpu_conditions, ['{}{} /Zm800 -nologo' .format(setup_script, compiler)])
toolset.flags('msvc.compile', '.RC' , cpu_conditions, ['{}{}' .format(setup_script, resource_compiler)])
toolset.flags('msvc.compile', '.ASM', cpu_conditions, ['{}{} -nologo' .format(setup_script, cpu_assembler)])
toolset.flags('msvc.link' , '.LD' , cpu_conditions, ['{}{} /NOLOGO /INCREMENTAL:NO'.format(setup_script, linker)])
toolset.flags('msvc.archive', '.LD' , cpu_conditions, ['{}{} /lib /NOLOGO' .format(setup_script, linker)])
toolset.flags('msvc.compile', '.IDL', cpu_conditions, ['{}{}' .format(setup_script, idl_compiler)])
toolset.flags('msvc.compile', '.MC' , cpu_conditions, ['{}{}' .format(setup_script, mc_compiler)])
toolset.flags('msvc.link' , '.MT' , cpu_conditions, ['{}{} -nologo' .format(setup_script, manifest_tool)])
if cc_filter:
toolset.flags('msvc', '.CC.FILTER', cpu_conditions, ['"|" {}'.format(cc_filter)])
# Set version-specific flags.
configure_version_specific('msvc', version, conditions)
# By default 8.0 enables rtti support while prior versions disabled it. We
# simply enable or disable it explicitly so we do not have to depend on this
# default behaviour.
toolset.flags('msvc.compile', 'CFLAGS', ['on'], ['/GR'])
toolset.flags('msvc.compile', 'CFLAGS', ['off'], ['/GR-'])
toolset.flags('msvc.compile', 'CFLAGS', ['off/shared'], ['/MD'])
toolset.flags('msvc.compile', 'CFLAGS', ['on/shared'], ['/MDd'])
toolset.flags('msvc.compile', 'CFLAGS', ['off/static/multi'], ['/MT'])
toolset.flags('msvc.compile', 'CFLAGS', ['on/static/multi'], ['/MTd'])
toolset.flags('msvc.compile', 'OPTIONS', [], [''])
toolset.flags('msvc.compile.c++', 'OPTIONS', [], [''])
toolset.flags('msvc.compile', 'PDB_CFLAG', ['on/database'],['/Fd'])
toolset.flags('msvc.compile', 'DEFINES', [], [''])
toolset.flags('msvc.compile', 'UNDEFS', [], [''])
toolset.flags('msvc.compile', 'INCLUDES', [], [''])
# Declare flags for the assembler.
toolset.flags('msvc.compile.asm', 'USER_ASMFLAGS', [], [''])
toolset.flags('msvc.compile.asm', 'ASMFLAGS', ['on'], ['/Zi', '/Zd'])
toolset.flags('msvc.compile.asm', 'ASMFLAGS', ['on'], ['/W3'])
toolset.flags('msvc.compile.asm', 'ASMFLAGS', ['off'], ['/W0'])
toolset.flags('msvc.compile.asm', 'ASMFLAGS', ['all'], ['/W4'])
toolset.flags('msvc.compile.asm', 'ASMFLAGS', ['on'], ['/WX'])
toolset.flags('msvc.compile.asm', 'DEFINES', [], [''])
['gcc']))
generators.register(
GccLinkingGenerator('gcc.link.dll', True,
['LIB', 'OBJ'],
['SHARED_LIB'],
['gcc']))
# Declare flags for linking.
# First, the common flags.
flags('gcc.link', 'OPTIONS', ['on'], ['-g'])
flags('gcc.link', 'OPTIONS', ['on'], ['-pg'])
flags('gcc.link', 'USER_OPTIONS', [], [''])
flags('gcc.link', 'LINKPATH', [], [''])
flags('gcc.link', 'FINDLIBS-ST', [], [''])
flags('gcc.link', 'FINDLIBS-SA', [], [''])
flags('gcc.link', 'LIBRARIES', [], [''])
# For static we made sure there are no dynamic libraries in the
# link. On HP-UX not all system libraries exist as archived libraries (for
# example, there is no libunwind.a), so, on this platform, the -static option
# cannot be specified.
if os_name() != 'HPUX':
flags('gcc.link', 'OPTIONS', ['static'], ['-static'])
# Now, the vendor specific flags.
# The parameter linker can be either gnu, darwin, osf, hpux or sun.
def init_link_flags(toolset, linker, condition):
"""
Now, the vendor specific flags.
The parameter linker can be either gnu, darwin, osf, hpux or sun.
"""
toolset_link = toolset + '.link'
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
# - 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: