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


Python CXXCompiler.dumpMacros方法代码示例

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


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

示例1: Configuration

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

#.........这里部分代码省略.........
            self.cxx.flags += ["-target", self.config.target_triple]

    def configure_compile_flags_header_includes(self):
        support_path = os.path.join(self.libcxx_src_root, "test/support")
        self.cxx.compile_flags += ["-include", os.path.join(support_path, "nasty_macros.hpp")]
        self.configure_config_site_header()
        libcxx_headers = self.get_lit_conf("libcxx_headers", os.path.join(self.libcxx_src_root, "include"))
        if not os.path.isdir(libcxx_headers):
            self.lit_config.fatal("libcxx_headers='%s' is not a directory." % libcxx_headers)
        self.cxx.compile_flags += ["-I" + libcxx_headers]

    def configure_config_site_header(self):
        # Check for a possible __config_site in the build directory. We
        # use this if it exists.
        if self.libcxx_obj_root is None:
            return
        config_site_header = os.path.join(self.libcxx_obj_root, "__config_site")
        if not os.path.isfile(config_site_header):
            return
        contained_macros = self.parse_config_site_and_add_features(config_site_header)
        self.lit_config.note("Using __config_site header %s with macros: %r" % (config_site_header, contained_macros))
        # FIXME: This must come after the call to
        # 'parse_config_site_and_add_features(...)' in order for it to work.
        self.cxx.compile_flags += ["-include", config_site_header]

    def parse_config_site_and_add_features(self, header):
        """ parse_config_site_and_add_features - Deduce and add the test
            features that that are implied by the #define's in the __config_site
            header. Return a dictionary containing the macros found in the
            '__config_site' header.
        """
        # Parse the macro contents of __config_site by dumping the macros
        # using 'c++ -dM -E' and filtering the predefines.
        predefines = self.cxx.dumpMacros()
        macros = self.cxx.dumpMacros(header)
        feature_macros_keys = set(macros.keys()) - set(predefines.keys())
        feature_macros = {}
        for k in feature_macros_keys:
            feature_macros[k] = macros[k]
        # We expect the header guard to be one of the definitions
        assert "_LIBCPP_CONFIG_SITE" in feature_macros
        del feature_macros["_LIBCPP_CONFIG_SITE"]
        # The __config_site header should be non-empty. Otherwise it should
        # have never been emitted by CMake.
        assert len(feature_macros) > 0
        # Transform each macro name into the feature name used in the tests.
        # Ex. _LIBCPP_HAS_NO_THREADS -> libcpp-has-no-threads
        for m in feature_macros:
            if m == "_LIBCPP_ABI_VERSION":
                self.config.available_features.add("libcpp-abi-version-v%s" % feature_macros[m])
                continue
            assert m.startswith("_LIBCPP_HAS_") or m == "_LIBCPP_ABI_UNSTABLE"
            m = m.lower()[1:].replace("_", "-")
            self.config.available_features.add(m)
        return feature_macros

    def configure_compile_flags_exceptions(self):
        enable_exceptions = self.get_lit_bool("enable_exceptions", True)
        if not enable_exceptions:
            self.config.available_features.add("libcpp-no-exceptions")
            self.cxx.compile_flags += ["-fno-exceptions"]

    def configure_compile_flags_rtti(self):
        enable_rtti = self.get_lit_bool("enable_rtti", True)
        if not enable_rtti:
            self.config.available_features.add("libcpp-no-rtti")
开发者ID:mpark,项目名称:libcxx,代码行数:70,代码来源:config.py

示例2: Configuration

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

#.........这里部分代码省略.........
            self.config.available_features.add(
                'with_system_cxx_lib=%s' % self.config.target_triple)

        # Insert the platform name into the available features as a lower case.
        self.config.available_features.add(target_platform)

        # Simulator testing can take a really long time for some of these tests
        # so add a feature check so we can REQUIRES: long_tests in them
        self.long_tests = self.get_lit_bool('long_tests')
        if self.long_tests is None:
            # Default to running long tests.
            self.long_tests = True
            self.lit_config.note(
                "inferred long_tests as: %r" % self.long_tests)

        if self.long_tests:
            self.config.available_features.add('long_tests')

        # Run a compile test for the -fsized-deallocation flag. This is needed
        # in test/std/language.support/support.dynamic/new.delete
        if self.cxx.hasCompileFlag('-fsized-deallocation'):
            self.config.available_features.add('fsized-deallocation')

        if self.cxx.hasCompileFlag('-faligned-allocation'):
            self.config.available_features.add('-faligned-allocation')
        else:
            # FIXME remove this once more than just clang-4.0 support
            # C++17 aligned allocation.
            self.config.available_features.add('no-aligned-allocation')

        if self.get_lit_bool('has_libatomic', False):
            self.config.available_features.add('libatomic')

        macros = self.cxx.dumpMacros()
        if '__cpp_if_constexpr' not in macros:
            self.config.available_features.add('libcpp-no-if-constexpr')

        if '__cpp_structured_bindings' not in macros:
            self.config.available_features.add('libcpp-no-structured-bindings')

    def configure_compile_flags(self):
        no_default_flags = self.get_lit_bool('no_default_flags', False)
        if not no_default_flags:
            self.configure_default_compile_flags()
        # This include is always needed so add so add it regardless of
        # 'no_default_flags'.
        support_path = os.path.join(self.libcxx_src_root, 'test/support')
        self.cxx.compile_flags += ['-I' + support_path]
        # Configure extra flags
        compile_flags_str = self.get_lit_conf('compile_flags', '')
        self.cxx.compile_flags += shlex.split(compile_flags_str)
        # FIXME: Can we remove this?
        if self.is_windows:
            self.cxx.compile_flags += ['-D_CRT_SECURE_NO_WARNINGS']

    def configure_default_compile_flags(self):
        # Try and get the std version from the command line. Fall back to
        # default given in lit.site.cfg is not present. If default is not
        # present then force c++11.
        std = self.get_lit_conf('std')
        if not std:
            # Choose the newest possible language dialect if none is given.
            possible_stds = ['c++1z', 'c++14', 'c++11', 'c++03']
            if self.cxx.type == 'gcc':
                maj_v, _, _ = self.cxx.version
                maj_v = int(maj_v)
开发者ID:AstroVPK,项目名称:LLVM-4.0.0,代码行数:70,代码来源:config.py

示例3: Configuration

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

#.........这里部分代码省略.........
        support_path = os.path.join(self.libcxx_src_root, 'test/support')
        self.cxx.compile_flags += ['-I' + support_path]
        self.cxx.compile_flags += ['-include', os.path.join(support_path, 'nasty_macros.hpp')]
        self.configure_config_site_header()
        libcxx_headers = self.get_lit_conf(
            'libcxx_headers', os.path.join(self.libcxx_src_root, 'include'))
        if not os.path.isdir(libcxx_headers):
            self.lit_config.fatal("libcxx_headers='%s' is not a directory."
                                  % libcxx_headers)
        self.cxx.compile_flags += ['-I' + libcxx_headers]

    def configure_config_site_header(self):
        # Check for a possible __config_site in the build directory. We
        # use this if it exists.
        config_site_header = os.path.join(self.libcxx_obj_root, '__config_site')
        if not os.path.isfile(config_site_header):
            return
        contained_macros = self.parse_config_site_and_add_features(
            config_site_header)
        self.lit_config.note('Using __config_site header %s with macros: %r'
            % (config_site_header, contained_macros))
        # FIXME: This must come after the call to
        # 'parse_config_site_and_add_features(...)' in order for it to work.
        self.cxx.compile_flags += ['-include', config_site_header]

    def parse_config_site_and_add_features(self, header):
        """ parse_config_site_and_add_features - Deduce and add the test
            features that that are implied by the #define's in the __config_site
            header. Return a dictionary containing the macros found in the
            '__config_site' header.
        """
        # Parse the macro contents of __config_site by dumping the macros
        # using 'c++ -dM -E' and filtering the predefines.
        predefines = self.cxx.dumpMacros()
        macros = self.cxx.dumpMacros(header)
        feature_macros_keys = set(macros.keys()) - set(predefines.keys())
        feature_macros = {}
        for k in feature_macros_keys:
            feature_macros[k] = macros[k]
        # We expect the header guard to be one of the definitions
        assert '_LIBCPP_CONFIG_SITE' in feature_macros
        del feature_macros['_LIBCPP_CONFIG_SITE']
        # The __config_site header should be non-empty. Otherwise it should
        # have never been emitted by CMake.
        assert len(feature_macros) > 0
        # Transform each macro name into the feature name used in the tests.
        # Ex. _LIBCPP_HAS_NO_THREADS -> libcpp-has-no-threads
        for m in feature_macros:
            if m == '_LIBCPP_ABI_VERSION':
                self.config.available_features.add('libcpp-abi-version-v%s'
                    % feature_macros[m])
                continue
            assert m.startswith('_LIBCPP_HAS_') or m == '_LIBCPP_ABI_UNSTABLE'
            m = m.lower()[1:].replace('_', '-')
            self.config.available_features.add(m)
        return feature_macros



    def configure_compile_flags_exceptions(self):
        enable_exceptions = self.get_lit_bool('enable_exceptions', True)
        if not enable_exceptions:
            self.config.available_features.add('libcpp-no-exceptions')
            self.cxx.compile_flags += ['-fno-exceptions']

    def configure_compile_flags_rtti(self):
开发者ID:potswa,项目名称:libcxx,代码行数:70,代码来源:config.py

示例4: Configuration

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

#.........这里部分代码省略.........

    def configure_compile_flags_header_includes(self):
        support_path = os.path.join(self.libcxx_src_root, "test/support")
        self.cxx.compile_flags += ["-I" + support_path]
        self.cxx.compile_flags += ["-include", os.path.join(support_path, "nasty_macros.hpp")]
        self.configure_config_site_header()
        libcxx_headers = self.get_lit_conf("libcxx_headers", os.path.join(self.libcxx_src_root, "include"))
        if not os.path.isdir(libcxx_headers):
            self.lit_config.fatal("libcxx_headers='%s' is not a directory." % libcxx_headers)
        self.cxx.compile_flags += ["-I" + libcxx_headers]

    def configure_config_site_header(self):
        # Check for a possible __config_site in the build directory. We
        # use this if it exists.
        if self.libcxx_obj_root is None:
            return
        config_site_header = os.path.join(self.libcxx_obj_root, "__config_site")
        if not os.path.isfile(config_site_header):
            return
        contained_macros = self.parse_config_site_and_add_features(config_site_header)
        self.lit_config.note("Using __config_site header %s with macros: %r" % (config_site_header, contained_macros))
        # FIXME: This must come after the call to
        # 'parse_config_site_and_add_features(...)' in order for it to work.
        self.cxx.compile_flags += ["-include", config_site_header]

    def parse_config_site_and_add_features(self, header):
        """ parse_config_site_and_add_features - Deduce and add the test
            features that that are implied by the #define's in the __config_site
            header. Return a dictionary containing the macros found in the
            '__config_site' header.
        """
        # Parse the macro contents of __config_site by dumping the macros
        # using 'c++ -dM -E' and filtering the predefines.
        predefines = self.cxx.dumpMacros()
        macros = self.cxx.dumpMacros(header)
        feature_macros_keys = set(macros.keys()) - set(predefines.keys())
        feature_macros = {}
        for k in feature_macros_keys:
            feature_macros[k] = macros[k]
        # We expect the header guard to be one of the definitions
        assert "_LIBCPP_CONFIG_SITE" in feature_macros
        del feature_macros["_LIBCPP_CONFIG_SITE"]
        # The __config_site header should be non-empty. Otherwise it should
        # have never been emitted by CMake.
        assert len(feature_macros) > 0
        # Transform each macro name into the feature name used in the tests.
        # Ex. _LIBCPP_HAS_NO_THREADS -> libcpp-has-no-threads
        for m in feature_macros:
            if m == "_LIBCPP_ABI_VERSION":
                self.config.available_features.add("libcpp-abi-version-v%s" % feature_macros[m])
                continue
            assert m.startswith("_LIBCPP_HAS_") or m == "_LIBCPP_ABI_UNSTABLE"
            m = m.lower()[1:].replace("_", "-")
            self.config.available_features.add(m)
        return feature_macros

    def configure_compile_flags_exceptions(self):
        enable_exceptions = self.get_lit_bool("enable_exceptions", True)
        if not enable_exceptions:
            self.config.available_features.add("libcpp-no-exceptions")
            self.cxx.compile_flags += ["-fno-exceptions"]

    def configure_compile_flags_rtti(self):
        enable_rtti = self.get_lit_bool("enable_rtti", True)
        if not enable_rtti:
            self.config.available_features.add("libcpp-no-rtti")
开发者ID:Nomad280279,项目名称:libcxx,代码行数:70,代码来源:config.py


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