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


Python CXXCompiler.addCompileFlagIfSupported方法代码示例

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


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

示例1: Configuration

# 需要导入模块: from libcxx.compiler import CXXCompiler [as 别名]
# 或者: from libcxx.compiler.CXXCompiler import addCompileFlagIfSupported [as 别名]

#.........这里部分代码省略.........
        if use_color is None:
            use_color = os.environ.get('LIBCXX_COLOR_DIAGNOSTICS')
        if use_color is None:
            return
        if use_color != '':
            self.lit_config.fatal('Invalid value for color_diagnostics "%s".'
                                  % use_color)
        color_flag = '-fdiagnostics-color=always'
        # Check if the compiler supports the color diagnostics flag. Issue a
        # warning if it does not since color diagnostics have been requested.
        if not self.cxx.hasCompileFlag(color_flag):
            self.lit_config.warning(
                'color diagnostics have been requested but are not supported '
                'by the compiler')
        else:
            self.cxx.flags += [color_flag]

    def configure_debug_mode(self):
        debug_level = self.get_lit_conf('debug_level', None)
        if not debug_level:
            return
        if debug_level not in ['0', '1']:
            self.lit_config.fatal('Invalid value for debug_level "%s".'
                                  % debug_level)
        self.cxx.compile_flags += ['-D_LIBCPP_DEBUG=%s' % debug_level]

    def configure_warnings(self):
        enable_warnings = self.get_lit_bool('enable_warnings', False)
        if enable_warnings:
            self.cxx.compile_flags += [
                '-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER',
                '-Wall', '-Werror'
            ]
            self.cxx.addCompileFlagIfSupported('-Wno-attributes')
            if self.cxx.type == 'clang' or self.cxx.type == 'apple-clang':
                self.cxx.addCompileFlagIfSupported('-Wno-pessimizing-move')
                self.cxx.addCompileFlagIfSupported('-Wno-c++11-extensions')
                self.cxx.addCompileFlagIfSupported('-Wno-user-defined-literals')
            std = self.get_lit_conf('std', None)
            if std in ['c++98', 'c++03']:
                # The '#define static_assert' provided by libc++ in C++03 mode
                # causes an unused local typedef whenever it is used.
                self.cxx.addCompileFlagIfSupported('-Wno-unused-local-typedef')

    def configure_sanitizer(self):
        san = self.get_lit_conf('use_sanitizer', '').strip()
        if san:
            # Search for llvm-symbolizer along the compiler path first
            # and then along the PATH env variable.
            symbolizer_search_paths = os.environ.get('PATH', '')
            cxx_path = lit.util.which(self.cxx.path)
            if cxx_path is not None:
                symbolizer_search_paths = (
                    os.path.dirname(cxx_path) +
                    os.pathsep + symbolizer_search_paths)
            llvm_symbolizer = lit.util.which('llvm-symbolizer',
                                             symbolizer_search_paths)
            # Setup the sanitizer compile flags
            self.cxx.flags += ['-g', '-fno-omit-frame-pointer']
            if self.target_info.platform() == 'linux':
                self.cxx.link_flags += ['-ldl']
            if san == 'Address':
                self.cxx.flags += ['-fsanitize=address']
                if llvm_symbolizer is not None:
                    self.env['ASAN_SYMBOLIZER_PATH'] = llvm_symbolizer
                self.config.available_features.add('asan')
开发者ID:jcai,项目名称:android-ndk,代码行数:70,代码来源:config.py


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