Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
toolset.inherit_flags('msvc','mc')
# Dynamic runtime comes only in MT flavour.
toolset.add_requirements(['msvc,shared:multi'])
# Declare msvc toolset specific features.
feature.feature('debug-store', ['object', 'database'], ['propagated'])
feature.feature('pch-source', [], ['dependency', 'free'])
# Declare generators.
# TODO: Is it possible to combine these? Make the generators
# non-composing so that they do not convert each source into a separate
# .rsp file.
generators.register(MsvcLinkingGenerator('msvc.link', True, ['OBJ', 'SEARCHED_LIB', 'STATIC_LIB', 'IMPORT_LIB'], ['EXE'], ['msvc']))
generators.register(MsvcLinkingGenerator('msvc.link.dll', True, ['OBJ', 'SEARCHED_LIB', 'STATIC_LIB', 'IMPORT_LIB'], ['SHARED_LIB','IMPORT_LIB'], ['msvc']))
builtin.register_archiver('msvc.archive', ['OBJ'], ['STATIC_LIB'], ['msvc'])
builtin.register_c_compiler('msvc.compile.c++', ['CPP'], ['OBJ'], ['msvc'])
builtin.register_c_compiler('msvc.compile.c', ['C'], ['OBJ'], ['msvc'])
builtin.register_c_compiler('msvc.compile.c++.preprocess', ['CPP'], ['PREPROCESSED_CPP'], ['msvc'])
builtin.register_c_compiler('msvc.compile.c.preprocess', ['C'], ['PREPROCESSED_C'], ['msvc'])
# Using 'register-c-compiler' adds the build directory to INCLUDES.
builtin.register_c_compiler('msvc.compile.rc', ['RC'], ['OBJ(%_res)'], ['msvc'])
generators.override('msvc.compile.rc', 'rc.compile.resource')
generators.register_standard('msvc.compile.asm', ['ASM'], ['OBJ'], ['msvc'])
builtin.register_c_compiler('msvc.compile.idl', ['IDL'], ['MSTYPELIB', 'H', 'C(%_i)', 'C(%_proxy)', 'C(%_dlldata)'], ['msvc'])
generators.override('msvc.compile.idl', 'midl.compile.idl')
generators.register_standard('msvc.compile.mc', ['MC'], ['H','RC'], ['msvc'])
# The generator for
actual_type = 'LIB'
elif 'shared' in properties:
actual_type = 'SHARED_LIB'
else:
actual_type = 'STATIC_LIB'
prop_set = prop_set.add_raw(['LIB'])
# Construct the target.
return generators.construct(project, name, actual_type, prop_set, sources)
def viable_source_types(self):
return ['*']
generators.register(LibGenerator("builtin.lib-generator"))
generators.override("builtin.prebuilt", "builtin.lib-generator")
def lib(names, sources=[], requirements=[], default_build=[], usage_requirements=[]):
"""The implementation of the 'lib' rule. Beyond standard syntax that rule allows
simplified: 'lib a b c ;'."""
assert is_iterable_typed(names, basestring)
assert is_iterable_typed(sources, basestring)
assert is_iterable_typed(requirements, basestring)
assert is_iterable_typed(default_build, basestring)
assert is_iterable_typed(usage_requirements, basestring)
if len(names) > 1:
if any(r.startswith('') for r in requirements):
get_manager().errors()("When several names are given to the 'lib' rule\n" +
"it is not allowed to specify the feature.")
# Using 'register-c-compiler' adds the build directory to INCLUDES.
builtin.register_c_compiler('msvc.compile.rc', ['RC'], ['OBJ(%_res)'], ['msvc'])
generators.override('msvc.compile.rc', 'rc.compile.resource')
generators.register_standard('msvc.compile.asm', ['ASM'], ['OBJ'], ['msvc'])
builtin.register_c_compiler('msvc.compile.idl', ['IDL'], ['MSTYPELIB', 'H', 'C(%_i)', 'C(%_proxy)', 'C(%_dlldata)'], ['msvc'])
generators.override('msvc.compile.idl', 'midl.compile.idl')
generators.register_standard('msvc.compile.mc', ['MC'], ['H','RC'], ['msvc'])
generators.override('msvc.compile.mc', 'mc.compile')
# Note: the 'H' source type will catch both '.h' and '.hpp' headers as
# 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'])
need_relink = False;
if ps.get('os') in ['NT', 'CYGWIN'] or ps.get('target-os') in ['windows', 'cygwin']:
# Never relink
pass
else:
# See if the dll-path properties are not changed during
# install. If so, copy, don't relink.
need_relink = ps.get('dll-path') != source[0].action().properties().get('dll-path')
if need_relink:
return [relink_file(project, source, ps)]
else:
return [copy_file(project, None, source[0], ps)]
generators.register(InstalledExeGenerator())
# Installing a shared link on Unix might cause a creation of versioned symbolic
# links.
b2.build.type.register('INSTALLED_SHARED_LIB', [], 'SHARED_LIB')
class InstalledSharedLibGenerator(generators.Generator):
def __init__(self):
generators.Generator.__init__(self, 'install-shared-lib', False, ['SHARED_LIB'], ['INSTALLED_SHARED_LIB'])
def run(self, project, name, ps, source):
source = source[0]
if ps.get('os') in ['NT', 'CYGWIN'] or ps.get('target-os') in ['windows', 'cygwin']:
copied = copy_file(project, None, source, ps)
### # The derived toolset must specify their own rules and actions.
# FIXME: restore?
# action.register ('unix.prebuilt', None, None)
generators.register (UnixPrebuiltLibGenerator ('unix.prebuilt', False, [], ['LIB'], ['', 'unix']))
### # Declare generators
### generators.register [ new UnixLinkingGenerator unix.link : LIB OBJ : EXE
### : unix ] ;
generators.register (UnixArchiveGenerator ('unix.archive', True, ['OBJ'], ['STATIC_LIB'], ['unix']))
### generators.register [ new UnixLinkingGenerator unix.link.dll : LIB OBJ : SHARED_LIB
### : unix ] ;
###
### generators.register [ new UnixSearchedLibGenerator
### unix.SearchedLibGenerator : : SEARCHED_LIB : unix ] ;
###
###
### # The derived toolset must specify their own actions.
### actions link {
### }
###
### actions link.dll {
### }
def unix_archive (manager, targets, sources, properties):
class UnixPrebuiltLibGenerator (generators.Generator):
def __init__ (self, id, composing, source_types, target_types_and_names, requirements):
generators.Generator.__init__ (self, id, composing, source_types, target_types_and_names, requirements)
def run (self, project, name, prop_set, sources):
f = prop_set.get ('')
set_library_order_aux (f, sources)
return f + sources
### # The derived toolset must specify their own rules and actions.
# FIXME: restore?
# action.register ('unix.prebuilt', None, None)
generators.register (UnixPrebuiltLibGenerator ('unix.prebuilt', False, [], ['LIB'], ['', 'unix']))
### # Declare generators
### generators.register [ new UnixLinkingGenerator unix.link : LIB OBJ : EXE
### : unix ] ;
generators.register (UnixArchiveGenerator ('unix.archive', True, ['OBJ'], ['STATIC_LIB'], ['unix']))
### generators.register [ new UnixLinkingGenerator unix.link.dll : LIB OBJ : SHARED_LIB
### : unix ] ;
###
### generators.register [ new UnixSearchedLibGenerator
### unix.SearchedLibGenerator : : SEARCHED_LIB : unix ] ;
###
# The generator for
actual_type = 'LIB'
elif 'shared' in properties:
actual_type = 'SHARED_LIB'
else:
actual_type = 'STATIC_LIB'
prop_set = prop_set.add_raw(['LIB'])
# Construct the target.
return generators.construct(project, name, actual_type, prop_set, sources)
def viable_source_types(self):
return ['*']
generators.register(LibGenerator("builtin.lib-generator"))
generators.override("builtin.prebuilt", "builtin.lib-generator")
def lib(names, sources=[], requirements=[], default_build=[], usage_requirements=[]):
"""The implementation of the 'lib' rule. Beyond standard syntax that rule allows
simplified: 'lib a b c ;'."""
if len(names) > 1:
if any(r.startswith('') for r in requirements):
get_manager().errors()("When several names are given to the 'lib' rule\n" +
"it is not allowed to specify the feature.")
if sources:
get_manager().errors()("When several names are given to the 'lib' rule\n" +
"it is not allowed to specify sources.")
def register_linker(id, source_types, target_types, requirements):
g = LinkingGenerator(id, True, source_types, target_types, requirements)
generators.register(g)
def register_linker(id, source_types, target_types, requirements):
g = LinkingGenerator(id, True, source_types, target_types, requirements)
generators.register(g)
else:
r = self.run_pch(project, name,
prop_set.add_raw(['BOOST_BUILD_PCH_ENABLED']),
sources)
return generators.add_usage_requirements(
r, ['BOOST_BUILD_PCH_ENABLED'])
# This rule must be overridden by the derived classes.
def run_pch(self, project, name, prop_set, sources):
pass
# NOTE: requirements are empty, default pch generator can be applied when
# pch=off.
generators.register(builtin.DummyGenerator(
"pch.default-c-pch-generator", False, [], ['C_PCH'], []))
generators.register(builtin.DummyGenerator(
"pch.default-cpp-pch-generator", False, [], ['CPP_PCH'], []))