⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 boostbuild.py

📁 Boost provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work
💻 PY
📖 第 1 页 / 共 3 页
字号:
# Copyright 2002-2005 Vladimir Prus.# Copyright 2002-2003 Dave Abrahams.# Copyright 2006 Rene Rivera.# Distributed under the Boost Software License, Version 1.0.#    (See accompanying file LICENSE_1_0.txt or copy at#         http://www.boost.org/LICENSE_1_0.txt)import TestCmdimport copyimport fnmatchimport globimport mathimport osimport reimport shutilimport stringimport StringIOimport sysimport tempfileimport timeimport tracebackimport treeimport typesannotations = []def print_annotation(name, value):    """Writes some named bits of information about test run.    """    print name + " {{{"    print value    print "}}}"def flush_annotations():    global annotations    for ann in annotations:        print_annotation(ann[0], ann[1])    annotations = []defer_annotations = 0def set_defer_annotations(n):    global defer_annotations    defer_annotations = ndef annotation(name, value):    """Records an annotation about the test run.    """    annotations.append((name, value))    if not defer_annotations:        flush_annotations()def get_toolset():    toolset = None;    for arg in sys.argv[1:]:        if not arg.startswith('-'):            toolset = arg    return toolset or 'gcc'# Detect the host OS.windows = Falseif os.environ.get('OS', '').lower().startswith('windows') or \       os.__dict__.has_key('uname') and \       os.uname()[0].lower().startswith('cygwin'):    windows = Truesuffixes = {}# Prepare the map of suffixesdef prepare_suffix_map(toolset):    global windows    global suffixes    suffixes = {'.exe': '', '.dll': '.so', '.lib': '.a', '.obj': '.o'}    suffixes['.implib'] = '.no_implib_files_on_this_platform'    if windows:        suffixes = {}        if toolset in ["gcc"]:            suffixes['.lib'] = '.a' # static libs have '.a' suffix with mingw...            suffixes['.obj'] = '.o'        suffixes['.implib'] = '.lib'    if os.__dict__.has_key('uname') and (os.uname()[0] == 'Darwin'):        suffixes['.dll'] = '.dylib'def re_remove(sequence, regex):    me = re.compile(regex)    result = filter(lambda x: me.match(x), sequence)    if 0 == len(result):        raise ValueError()    for r in result:        sequence.remove(r)def glob_remove(sequence, pattern):    result = fnmatch.filter(sequence, pattern)    if 0 == len(result):        raise ValueError()    for r in result:        sequence.remove(r)# Configuration stating whether Boost Build is expected to automatically prepend# prefixes to built library targets.lib_prefix = Truedll_prefix = Trueif windows:    dll_prefix = False## FIXME: this is copy-pasted from TestSCons.py# Should be moved to TestCmd.py?#if os.name == 'posix':    def _failed(self, status=0):        if self.status is None:            return None        if os.WIFSIGNALED(status):            return None        return _status(self) != status    def _status(self):        if os.WIFEXITED(self.status):            return os.WEXITSTATUS(self.status)        else:            return -1elif os.name == 'nt':    def _failed(self, status=0):        return not self.status is None and self.status != status    def _status(self):        return self.statusclass Tester(TestCmd.TestCmd):    """Main tester class for Boost Build.    Optional arguments:    `arguments`                   - Arguments passed to the run executable.    `executable`                  - Name of the executable to invoke.    `match`                       - Function to use for compating actual and                                    expected file contents.    `boost_build_path`            - Boost build path to be passed to the run                                    executable.    `translate_suffixes`          - Whether to update suffixes on the the file                                    names passed from the test script so they                                    match those actually created by the current                                    toolset. For example, static library files                                    are specified by using the .lib suffix but                                    when the 'gcc' toolset is used it actually                                    creates them using the .a suffix.    `pass_toolset`                - Whether the test system should pass the                                    specified toolset to the run executable.    `use_test_config`             - Whether the test system should tell the run                                    executable to read in the test_config.jam                                    configuration file.    `ignore_toolset_requirements` - Whether the test system should tell the run                                    executable to ignore toolset requirements.    `workdir`                     - indicates an absolute directory where the                                    test will be run from.    Optional arguments inherited from the base class:    `description`                 - Test description string displayed in case of                                    a failed test.    `subdir'                      - List of subdirectories to automatically                                    create under the working directory. Each                                    subdirectory needs to be specified                                    separately parent coming before its child.    `verbose`                     - Flag that may be used to enable more verbose                                    test system output. Note that it does not                                    also enable more verbose build system                                    output like the --verbose command line                                    option does.    """    def __init__(self, arguments="", executable="bjam",        match=TestCmd.match_exact, boost_build_path=None,        translate_suffixes=True, pass_toolset=True, use_test_config=True,        ignore_toolset_requirements=True, workdir="", **keywords):        self.original_workdir = os.getcwd()        if workdir != '' and not os.path.isabs(workdir):            raise "Parameter workdir <"+workdir+"> must point to an absolute directory: "        self.last_build_time_start = 0        self.last_build_time_finish = 0        self.translate_suffixes = translate_suffixes        self.use_test_config = use_test_config        self.toolset = get_toolset()        self.pass_toolset = pass_toolset        self.ignore_toolset_requirements = ignore_toolset_requirements        prepare_suffix_map(pass_toolset and self.toolset or 'gcc')        if not '--default-bjam' in sys.argv:            jam_build_dir = ""            if os.name == 'nt':                jam_build_dir = "bin.ntx86"            elif (os.name == 'posix') and os.__dict__.has_key('uname'):                if os.uname()[0].lower().startswith('cygwin'):                    jam_build_dir = "bin.cygwinx86"                    if 'TMP' in os.environ and os.environ['TMP'].find('~') != -1:                        print 'Setting $TMP to /tmp to get around problem with short path names'                        os.environ['TMP'] = '/tmp'                elif os.uname()[0] == 'Linux':                    cpu = os.uname()[4]                    if re.match("i.86", cpu):                        jam_build_dir = "bin.linuxx86";                    else:                        jam_build_dir = "bin.linux" + os.uname()[4]                elif os.uname()[0] == 'SunOS':                    jam_build_dir = "bin.solaris"                elif os.uname()[0] == 'Darwin':                    if os.uname()[4] == 'i386':                        jam_build_dir = "bin.macosxx86"                    else:                        jam_build_dir = "bin.macosxppc"                elif os.uname()[0] == "AIX":                    jam_build_dir = "bin.aix"                elif os.uname()[0] == "IRIX64":                    jam_build_dir = "bin.irix"                elif os.uname()[0] == "FreeBSD":                    jam_build_dir = "bin.freebsd"                elif os.uname()[0] == "OSF1":                    jam_build_dir = "bin.osf"                else:                    raise "Don't know directory where Jam is built for this system: " + os.name + "/" + os.uname()[0]            else:                raise "Don't know directory where Jam is built for this system: " + os.name            # Find where jam_src is located. Try for the debug version if it is            # lying around.            dirs = [os.path.join('../../../jam/src', jam_build_dir + '.debug'),                    os.path.join('../../../jam/src', jam_build_dir),                    os.path.join('../../jam_src', jam_build_dir + '.debug'),                    os.path.join('../../jam_src', jam_build_dir),                    os.path.join('../jam_src', jam_build_dir + '.debug'),                    os.path.join('../jam_src', jam_build_dir)]            for d in dirs:                if os.path.exists(d):                    jam_build_dir = d                    break            else:                print "Cannot find built Boost.Jam"                os.exit(1)        verbosity = ['-d0', '--quiet']        if '--verbose' in sys.argv:            keywords['verbose'] = True            verbosity = ['-d+2']        if boost_build_path is None:            boost_build_path = self.original_workdir        program_list = []        if '--default-bjam' in sys.argv:            program_list.append(executable)            inpath_bjam = True        else:            program_list.append(os.path.join(jam_build_dir, executable))            inpath_bjam = None        program_list.append('-sBOOST_BUILD_PATH="' + boost_build_path + '"')        if verbosity:            program_list += verbosity        if arguments:            program_list += arguments.split(" ")        TestCmd.TestCmd.__init__(            self            , program=program_list            , match=match            , workdir=workdir            , inpath=inpath_bjam            , **keywords)        os.chdir(self.workdir)    def cleanup(self):        try:            TestCmd.TestCmd.cleanup(self)            os.chdir(self.original_workdir)        except AttributeError:            # When this is called during TestCmd.TestCmd.__del__ we can have            # both 'TestCmd' and 'os' unavailable in our scope. Do nothing in            # this case.            pass    #    # Methods that change the working directory's content.    #    def set_tree(self, tree_location):

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -