Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import sys
def init():
pass
# Feature controlling the command used to lanch test programs.
feature.feature("testing.launcher", [], ["free", "optional"])
feature.feature("test-info", [], ["free", "incidental"])
feature.feature("testing.arg", [], ["free", "incidental"])
feature.feature("testing.input-file", [], ["free", "dependency"])
feature.feature("preserve-test-targets", ["on", "off"], ["incidental", "propagated"])
# Register target types.
type.register("TEST", ["test"])
type.register("COMPILE", [], "TEST")
type.register("COMPILE_FAIL", [], "TEST")
type.register("RUN_OUTPUT", ["run"])
type.register("RUN", [], "TEST")
type.register("RUN_FAIL", [], "TEST")
type.register("LINK", [], "TEST")
type.register("LINK_FAIL", [], "TEST")
type.register("UNIT_TEST", ["passed"], "TEST")
__all_tests = []
# Declare the rules which create main targets. While the 'type' module already
# creates rules with the same names for us, we need extra convenience: default
# name of main target, so write our own versions.
feature.feature("testing.arg", [], ["free", "incidental"])
feature.feature("testing.input-file", [], ["free", "dependency"])
feature.feature("preserve-test-targets", ["on", "off"], ["incidental", "propagated"])
# Register target types.
type.register("TEST", ["test"])
type.register("COMPILE", [], "TEST")
type.register("COMPILE_FAIL", [], "TEST")
type.register("RUN_OUTPUT", ["run"])
type.register("RUN", [], "TEST")
type.register("RUN_FAIL", [], "TEST")
type.register("LINK", [], "TEST")
type.register("LINK_FAIL", [], "TEST")
type.register("UNIT_TEST", ["passed"], "TEST")
__all_tests = []
# Declare the rules which create main targets. While the 'type' module already
# creates rules with the same names for us, we need extra convenience: default
# name of main target, so write our own versions.
# Helper rule. Create a test target, using basename of first source if no target
# name is explicitly passed. Remembers the created target in a global variable.
def make_test(target_type, sources, requirements, target_name=None):
assert isinstance(target_type, basestring)
assert is_iterable_typed(sources, basestring)
assert is_iterable_typed(requirements, basestring)
assert isinstance(target_type, basestring) or target_type is None
if not target_name:
feature.feature("test-info", [], ["free", "incidental"])
feature.feature("testing.arg", [], ["free", "incidental"])
feature.feature("testing.input-file", [], ["free", "dependency"])
feature.feature("preserve-test-targets", ["on", "off"], ["incidental", "propagated"])
# Register target types.
type.register("TEST", ["test"])
type.register("COMPILE", [], "TEST")
type.register("COMPILE_FAIL", [], "TEST")
type.register("RUN_OUTPUT", ["run"])
type.register("RUN", [], "TEST")
type.register("RUN_FAIL", [], "TEST")
type.register("LINK", [], "TEST")
type.register("LINK_FAIL", [], "TEST")
type.register("UNIT_TEST", ["passed"], "TEST")
__all_tests = []
# Declare the rules which create main targets. While the 'type' module already
# creates rules with the same names for us, we need extra convenience: default
# name of main target, so write our own versions.
# Helper rule. Create a test target, using basename of first source if no target
# name is explicitly passed. Remembers the created target in a global variable.
def make_test(target_type, sources, requirements, target_name=None):
assert isinstance(target_type, basestring)
assert is_iterable_typed(sources, basestring)
assert is_iterable_typed(requirements, basestring)
assert isinstance(target_type, basestring) or target_type is None
from b2.exceptions import AlreadyDefined
from b2.tools import builtin
from b2.util import regex
from b2.build.toolset import flags
from b2.manager import get_manager
from b2.util import utility
__debug = None
def debug():
global __debug
if __debug is None:
__debug = "--debug-configuration" in bjam.variable("ARGV")
return __debug
type.register('RC', ['rc'])
def init():
pass
def configure (command = None, condition = None, options = None):
"""
Configures a new resource compilation command specific to a condition,
usually a toolset selection condition. The possible options are:
* (rc|windres) - Indicates the type of options the command
accepts.
Even though the arguments are all optional, only when a command, condition,
and at minimum the rc-type option are given will the command be configured.
This is so that callers don't have to check auto-configuration values
before calling this. And still get the functionality of build failures when
# libxxx.lib static library
# xxx.dll DLL
# xxx.lib import library
#
# On windows (mingw):
# libxxx.a static library
# libxxx.dll DLL
# libxxx.dll.a import library
#
# On cygwin i.e. cygwin
# libxxx.a static library
# cygxxx.dll DLL
# libxxx.dll.a import library
#
type.register('LIB')
# FIXME: should not register both extensions on both platforms.
type.register('STATIC_LIB', ['a', 'lib'], 'LIB')
# The 'lib' prefix is used everywhere
type.set_generated_target_prefix('STATIC_LIB', [], 'lib')
# Use '.lib' suffix for windows
type.set_generated_target_suffix('STATIC_LIB', ['windows'], 'lib')
# Except with gcc.
type.set_generated_target_suffix('STATIC_LIB', ['gcc', 'windows'], 'a')
# Use xxx.lib for import libs
type.register('IMPORT_LIB', [], 'STATIC_LIB')
type.set_generated_target_prefix('IMPORT_LIB', [], '')
def debug():
global __debug
if __debug is None:
__debug = "--debug-configuration" in bjam.variable("ARGV")
return __debug
# It is not yet clear what to do with Cygwin on python port.
def on_cygwin():
return False
type.register('MANIFEST', ['manifest'])
feature.feature('embed-manifest',['on','off'], ['incidental', 'propagated']) ;
type.register('PDB',['pdb'])
################################################################################
#
# Public rules.
#
################################################################################
# Initialize a specific toolset version configuration. As the result, path to
# compiler and, possible, program names are set up, and will be used when that
# version of compiler is requested. For example, you might have:
#
# using msvc : 6.5 : cl.exe ;
# using msvc : 7.0 : Y:/foo/bar/cl.exe ;
#
# The version parameter may be omitted:
#
#
# On windows (mingw):
# libxxx.a static library
# libxxx.dll DLL
# libxxx.dll.a import library
#
# On cygwin i.e. cygwin
# libxxx.a static library
# cygxxx.dll DLL
# libxxx.dll.a import library
#
type.register('LIB')
# FIXME: should not register both extensions on both platforms.
type.register('STATIC_LIB', ['a', 'lib'], 'LIB')
# The 'lib' prefix is used everywhere
type.set_generated_target_prefix('STATIC_LIB', [], 'lib')
# Use '.lib' suffix for windows
type.set_generated_target_suffix('STATIC_LIB', ['windows'], 'lib')
# Except with gcc.
type.set_generated_target_suffix('STATIC_LIB', ['gcc', 'windows'], 'a')
# Use xxx.lib for import libs
type.register('IMPORT_LIB', [], 'STATIC_LIB')
type.set_generated_target_prefix('IMPORT_LIB', [], '')
type.set_generated_target_suffix('IMPORT_LIB', [], 'lib')
# Except with gcc (mingw or cygwin), where use libxxx.dll.a
def symlink(name, project, source, ps):
a = virtual_target.Action([source], "symlink.ln", ps)
return virtual_target.FileTarget(name, source.type(), project, a, exact=True)
def relink_file(project, source, ps):
action = source[0].action()
cloned_action = virtual_target.clone_action(action, project, "", ps)
targets = cloned_action.targets()
# We relink only on Unix, where exe or shared lib is always a single file.
assert len(targets) == 1
return targets[0]
# Declare installed version of the EXE type. Generator for this type will cause
# relinking to the new location.
b2.build.type.register('INSTALLED_EXE', [], 'EXE')
class InstalledExeGenerator(generators.Generator):
def __init__(self):
generators.Generator.__init__(self, "install-exe", False, ['EXE'], ['INSTALLED_EXE'])
def run(self, project, name, ps, source):
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.
# : # sources
# mypch.hpp
# : # requiremnts
# msvc:<source>mypch.cpp
# ;
#
# Add cpp-pch to sources:
#
# exe hello
# : main.cpp hello.cpp mypch
# ;
from b2.build import type, feature, generators
from b2.tools import builtin
type.register('PCH', ['pch'])
type.register('C_PCH', [], 'PCH')
type.register('CPP_PCH', [], 'PCH')
# Control precompiled header (PCH) generation.
feature.feature('pch',
['on', 'off'],
['propagated'])
feature.feature('pch-header', [], ['free', 'dependency'])
feature.feature('pch-file', [], ['free', 'dependency'])
class PchGenerator(generators.Generator):
"""
Base PCH generator. The 'run' method has the logic to prevent this generator
from being run unless it's being used for a top-level PCH target.
"""
else:
# See if the dll-path properties are not changed during
# install. If so, copy, don't relink.
need_relink = source[0].action() and 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)
return [get_manager().virtual_targets().register(copied)]
else:
a = source.action()
if not a:
# Non-derived file, just copy.