当前位置: 首页>>代码示例>>Python>>正文


Python Preprocessor.out方法代码示例

本文整理汇总了Python中mozbuild.preprocessor.Preprocessor.out方法的典型用法代码示例。如果您正苦于以下问题:Python Preprocessor.out方法的具体用法?Python Preprocessor.out怎么用?Python Preprocessor.out使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mozbuild.preprocessor.Preprocessor的用法示例。


在下文中一共展示了Preprocessor.out方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import out [as 别名]
def main():
    parser = argparse.ArgumentParser(description='Find duplicate files in directory.')
    parser.add_argument('--warning', '-w', action='store_true',
                        help='Only warn about duplicates, do not exit with an error')
    parser.add_argument('--file', '-f', action='append', dest='dupes_files', default=[],
                        help='Add exceptions to the duplicate list from this file')
    parser.add_argument('-D', action=DefinesAction)
    parser.add_argument('-U', action='append', default=[])
    parser.add_argument('directory',
                        help='The directory to check for duplicates in')

    args = parser.parse_args()

    allowed_dupes = []
    for filename in args.dupes_files:
        pp = Preprocessor()
        pp.context.update(buildconfig.defines['ALLDEFINES'])
        if args.D:
            pp.context.update(args.D)
        for undefine in args.U:
            if undefine in pp.context:
                del pp.context[undefine]
        pp.out = StringIO()
        pp.do_filter('substitution')
        pp.do_include(filename)
        allowed_dupes.extend([line.partition('#')[0].rstrip()
                              for line in pp.out.getvalue().splitlines()])

    find_dupes(args.directory, bail=not args.warning, allowed_dupes=allowed_dupes)
开发者ID:luke-chang,项目名称:gecko-1,代码行数:31,代码来源:find-dupes.py

示例2: main

# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import out [as 别名]
def main(output, input_file):
    pp = Preprocessor()
    pp.context.update({
        'VERSION': 'xul%s' % buildconfig.substs['MOZILLA_SYMBOLVERSION'],
    })
    pp.out = output
    pp.do_include(input_file)
开发者ID:luke-chang,项目名称:gecko-1,代码行数:9,代码来源:gen_symverscript.py

示例3: main

# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import out [as 别名]
def main(output, input_file):
    pp = Preprocessor()
    pp.context.update(buildconfig.defines['ALLDEFINES'])

    substs = buildconfig.substs

    # Substs taken verbatim.
    substs_vars = (
        'BIN_SUFFIX',
    )
    for var in substs_vars:
        pp.context[var] = '"%s"' % substs[var]

    # Derived values.
    for key, condition in (
            ('IS_MAC', substs['OS_ARCH'] == 'Darwin'),
            ('IS_LINUX', substs['OS_ARCH'] == 'Linux'),
            ('IS_TEST_BUILD', substs.get('ENABLE_TESTS') == '1'),
            ('IS_DEBUG_BUILD', substs.get('MOZ_DEBUG') == '1'),
            ('CRASHREPORTER', substs.get('MOZ_CRASHREPORTER')),
            ('IS_ASAN', substs.get('MOZ_ASAN'))):
        if condition:
            pp.context[key] = '1'
        else:
            pp.context[key] = '0'

    pp.context.update({
        'XPC_BIN_PATH': '"%s/dist/bin"' % buildconfig.topobjdir,
        'CERTS_SRC_DIR': '"%s/build/pgo/certs"' % buildconfig.topsrcdir,
    })

    pp.out = output
    pp.do_include(input_file)
开发者ID:Noctem,项目名称:gecko-dev,代码行数:35,代码来源:gen_automation.py

示例4: main

# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import out [as 别名]
def main(output, input_file, version):
    pp = Preprocessor()
    pp.context.update({
        'VERSION': version,
    })
    pp.out = output
    pp.do_include(input_file)
开发者ID:Noctem,项目名称:gecko-dev,代码行数:9,代码来源:gen_symverscript.py

示例5: preprocess

# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import out [as 别名]
def preprocess(input, parser, defines={}):
    '''
    Preprocess the file-like input with the given defines, and send the
    preprocessed output line by line to the given parser.
    '''
    pp = Preprocessor()
    pp.context.update(defines)
    pp.do_filter('substitution')
    pp.out = PreprocessorOutputWrapper(pp, parser)
    pp.do_include(input)
开发者ID:MekliCZ,项目名称:positron,代码行数:12,代码来源:__init__.py

示例6: main

# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import out [as 别名]
def main(output, input_file):
    pp = Preprocessor()
    pp.context.update({
        'FFI_EXEC_TRAMPOLINE_TABLE': '0',
        'HAVE_LONG_DOUBLE': '0',
        'TARGET': buildconfig.substs['FFI_TARGET'],
        'VERSION': '',
    })
    pp.do_filter('substitution')
    pp.setMarker(None)
    pp.out = output
    pp.do_include(input_file)
开发者ID:Noctem,项目名称:gecko-dev,代码行数:14,代码来源:subst_header.py

示例7: main

# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import out [as 别名]
def main(output, input_file):
    pp = Preprocessor()
    pp.context.update(
        {
            "FFI_EXEC_TRAMPOLINE_TABLE": "0",
            "HAVE_LONG_DOUBLE": "0",
            "TARGET": buildconfig.substs["FFI_TARGET"],
            "VERSION": "",
        }
    )
    pp.do_filter("substitution")
    pp.setMarker(None)
    pp.out = output
    pp.do_include(input_file)
开发者ID:subsevenx2001,项目名称:gecko-dev,代码行数:16,代码来源:subst_header.py

示例8: _consume_jar_manifest

# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import out [as 别名]
    def _consume_jar_manifest(self, obj, defines):
        # Ideally, this would all be handled somehow in the emitter, but
        # this would require all the magic surrounding l10n and addons in
        # the recursive make backend to die, which is not going to happen
        # any time soon enough.
        # Notably missing:
        # - DEFINES from config/config.mk
        # - L10n support
        # - The equivalent of -e when USE_EXTENSION_MANIFEST is set in
        #   moz.build, but it doesn't matter in dist/bin.
        pp = Preprocessor()
        pp.context.update(defines)
        pp.context.update(self.environment.defines)
        pp.context.update(
            AB_CD='en-US',
            BUILD_FASTER=1,
        )
        pp.out = JarManifestParser()
        pp.do_include(obj.path)
        self.backend_input_files |= pp.includes

        for jarinfo in pp.out:
            install_target = obj.install_target
            if jarinfo.base:
                install_target = mozpath.normpath(
                    mozpath.join(install_target, jarinfo.base))
            for e in jarinfo.entries:
                if e.is_locale:
                    if jarinfo.relativesrcdir:
                        path = mozpath.join(self.environment.topsrcdir,
                                            jarinfo.relativesrcdir)
                    else:
                        path = mozpath.dirname(obj.path)
                    src = mozpath.join( path, 'en-US', e.source)
                elif e.source.startswith('/'):
                    src = mozpath.join(self.environment.topsrcdir,
                                       e.source[1:])
                else:
                    src = mozpath.join(mozpath.dirname(obj.path), e.source)

                if '*' in e.source:
                    if e.preprocess:
                        raise Exception('%s: Wildcards are not supported with '
                                        'preprocessing' % obj.path)
                    def _prefix(s):
                        for p in s.split('/'):
                            if '*' not in p:
                                yield p + '/'
                    prefix = ''.join(_prefix(src))

                    self._install_manifests[install_target] \
                        .add_pattern_symlink(
                        prefix,
                        src[len(prefix):],
                        mozpath.join(jarinfo.name, e.output))
                    continue

                if not os.path.exists(src):
                    if e.is_locale:
                        raise Exception(
                            '%s: Cannot find %s' % (obj.path, e.source))
                    if e.source.startswith('/'):
                        src = mozpath.join(self.environment.topobjdir,
                                           e.source[1:])
                    else:
                        # This actually gets awkward if the jar.mn is not
                        # in the same directory as the moz.build declaring
                        # it, but it's how it works in the recursive make,
                        # not that anything relies on that, but it's simpler.
                        src = mozpath.join(obj.objdir, e.source)
                    self._dependencies['install-%s' % install_target] \
                        .append(mozpath.relpath(
                        src, self.environment.topobjdir))

                if e.preprocess:
                    kwargs = {}
                    if src.endswith('.css'):
                        kwargs['marker'] = '%'
                    self._add_preprocess(
                        obj,
                        src,
                        mozpath.join(jarinfo.name, mozpath.dirname(e.output)),
                        mozpath.basename(e.output),
                        defines=defines,
                        **kwargs)
                else:
                    self._install_manifests[install_target].add_symlink(
                        src,
                        mozpath.join(jarinfo.name, e.output))

            manifest = mozpath.normpath(mozpath.join(install_target,
                                                     jarinfo.name))
            manifest += '.manifest'
            for m in jarinfo.chrome_manifests:
                self._manifest_entries[manifest].add(
                    m.replace('%', mozpath.basename(jarinfo.name) + '/'))

            if jarinfo.name != 'chrome':
                manifest = mozpath.normpath(mozpath.join(install_target,
                                                         'chrome.manifest'))
#.........这里部分代码省略.........
开发者ID:psvramaraju,项目名称:gecko-dev,代码行数:103,代码来源:fastermake.py

示例9: _consume_jar_manifest

# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import out [as 别名]
    def _consume_jar_manifest(self, obj):
        # Ideally, this would all be handled somehow in the emitter, but
        # this would require all the magic surrounding l10n and addons in
        # the recursive make backend to die, which is not going to happen
        # any time soon enough.
        # Notably missing:
        # - DEFINES from config/config.mk
        # - L10n support
        # - The equivalent of -e when USE_EXTENSION_MANIFEST is set in
        #   moz.build, but it doesn't matter in dist/bin.
        pp = Preprocessor()
        if obj.defines:
            pp.context.update(obj.defines.defines)
        pp.context.update(self.environment.defines)
        pp.context.update(
            AB_CD='en-US',
            BUILD_FASTER=1,
        )
        pp.out = JarManifestParser()
        try:
            pp.do_include(obj.path.full_path)
        except DeprecatedJarManifest as e:
            raise DeprecatedJarManifest('Parsing error while processing %s: %s'
                                        % (obj.path.full_path, e.message))
        self.backend_input_files |= pp.includes

        for jarinfo in pp.out:
            jar_context = Context(
                allowed_variables=VARIABLES, config=obj._context.config)
            jar_context.push_source(obj._context.main_path)
            jar_context.push_source(obj.path.full_path)

            install_target = obj.install_target
            if jarinfo.base:
                install_target = mozpath.normpath(
                    mozpath.join(install_target, jarinfo.base))
            jar_context['FINAL_TARGET'] = install_target
            if obj.defines:
                jar_context['DEFINES'] = obj.defines.defines
            files = jar_context['FINAL_TARGET_FILES']
            files_pp = jar_context['FINAL_TARGET_PP_FILES']

            for e in jarinfo.entries:
                if e.is_locale:
                    if jarinfo.relativesrcdir:
                        src = '/%s' % jarinfo.relativesrcdir
                    else:
                        src = ''
                    src = mozpath.join(src, 'en-US', e.source)
                else:
                    src = e.source

                src = Path(jar_context, src)

                if '*' not in e.source and not os.path.exists(src.full_path):
                    if e.is_locale:
                        raise Exception(
                            '%s: Cannot find %s' % (obj.path, e.source))
                    if e.source.startswith('/'):
                        src = Path(jar_context, '!' + e.source)
                    else:
                        # This actually gets awkward if the jar.mn is not
                        # in the same directory as the moz.build declaring
                        # it, but it's how it works in the recursive make,
                        # not that anything relies on that, but it's simpler.
                        src = Path(obj._context, '!' + e.source)

                output_basename = mozpath.basename(e.output)
                if output_basename != src.target_basename:
                    src = RenamedSourcePath(jar_context,
                                            (src, output_basename))
                path = mozpath.dirname(mozpath.join(jarinfo.name, e.output))

                if e.preprocess:
                    if '*' in e.source:
                        raise Exception('%s: Wildcards are not supported with '
                                        'preprocessing' % obj.path)
                    files_pp[path] += [src]
                else:
                    files[path] += [src]

            if files:
                self.consume_object(FinalTargetFiles(jar_context, files))
            if files_pp:
                self.consume_object(
                    FinalTargetPreprocessedFiles(jar_context, files_pp))

            for m in jarinfo.chrome_manifests:
                entry = parse_manifest_line(
                    mozpath.dirname(jarinfo.name),
                    m.replace('%', mozpath.basename(jarinfo.name) + '/'))
                self.consume_object(ChromeManifestEntry(
                    jar_context, '%s.manifest' % jarinfo.name, entry))
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:95,代码来源:common.py

示例10: generate

# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import out [as 别名]
def generate(output, *args):
    pp = Preprocessor()
    pp.out = output
    pp.handleCommandLine(list(args), True)
    return set(pp.includes)
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:7,代码来源:preprocessor.py

示例11: generate_symbols_file

# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import out [as 别名]
def generate_symbols_file(output, *args):
    ''' '''
    parser = argparse.ArgumentParser()
    parser.add_argument('input')
    parser.add_argument('-D', action=DefinesAction)
    parser.add_argument('-U', action='append', default=[])
    args = parser.parse_args(args)
    input = os.path.abspath(args.input)

    pp = Preprocessor()
    pp.context.update(buildconfig.defines)
    if args.D:
        pp.context.update(args.D)
    for undefine in args.U:
        if undefine in pp.context:
            del pp.context[undefine]
    # Hack until MOZ_DEBUG_FLAGS are simply part of buildconfig.defines
    if buildconfig.substs['MOZ_DEBUG']:
        pp.context['DEBUG'] = '1'
    # Ensure @[email protected] works as expected (see the Windows section further below)
    if buildconfig.substs['OS_TARGET'] == 'WINNT':
        pp.context['DATA'] = 'DATA'
    else:
        pp.context['DATA'] = ''
    pp.out = StringIO()
    pp.do_filter('substitution')
    pp.do_include(input)

    symbols = [s.strip() for s in pp.out.getvalue().splitlines() if s.strip()]

    if buildconfig.substs['OS_TARGET'] == 'WINNT':
        # A def file is generated for MSVC link.exe that looks like the
        # following:
        # LIBRARY library.dll
        # EXPORTS
        #   symbol1
        #   symbol2
        #   ...
        #
        # link.exe however requires special markers for data symbols, so in
        # that case the symbols look like:
        #   data_symbol1 DATA
        #   data_symbol2 DATA
        #   ...
        #
        # In the input file, this is just annotated with the following syntax:
        #   data_symbol1 @[email protected]
        #   data_symbol2 @[email protected]
        #   ...
        # The DATA variable is "simply" expanded by the preprocessor, to
        # nothing on non-Windows, such that we only get the symbol name on
        # those platforms, and to DATA on Windows, so that the "DATA" part
        # is, in fact, part of the symbol name as far as the symbols variable
        # is concerned.
        libname, ext = os.path.splitext(os.path.basename(output.name))
        assert ext == '.def'
        output.write('LIBRARY %s\nEXPORTS\n  %s\n'
                     % (libname, '\n  '.join(symbols)))
    elif buildconfig.substs['GCC_USE_GNU_LD']:
        # A linker version script is generated for GNU LD that looks like the
        # following:
        # {
        # global:
        #   symbol1;
        #   symbol2;
        #   ...
        # local:
        #   *;
        # };
        output.write('{\nglobal:\n  %s;\nlocal:\n  *;\n};'
                     % ';\n  '.join(symbols))
    elif buildconfig.substs['OS_TARGET'] == 'Darwin':
        # A list of symbols is generated for Apple ld that simply lists all
        # symbols, with an underscore prefix.
        output.write(''.join('_%s\n' % s for s in symbols))

    return set(pp.includes)
开发者ID:MekliCZ,项目名称:positron,代码行数:79,代码来源:generate_symbols_file.py


注:本文中的mozbuild.preprocessor.Preprocessor.out方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。