コード例 #1
0
ファイル: cpp_std_flags_test.py プロジェクト: zhongpan/conan
 def test_apple_clang_cppstd_defaults(self):
     self.assertEqual(cppstd_default("apple-clang", "2"), "gnu98")
     self.assertEqual(cppstd_default("apple-clang", "3"), "gnu98")
     self.assertEqual(cppstd_default("apple-clang", "4"), "gnu98")
     self.assertEqual(cppstd_default("apple-clang", "5"), "gnu98")
     self.assertEqual(cppstd_default("apple-clang", "6"), "gnu98")
     self.assertEqual(cppstd_default("apple-clang", "7"), "gnu98")
     self.assertEqual(cppstd_default("apple-clang", "8"), "gnu98")
     self.assertEqual(cppstd_default("apple-clang", "9"), "gnu98")
     self.assertEqual(cppstd_default("apple-clang", "10"), "gnu98")
     self.assertEqual(cppstd_default("apple-clang", "11"), "gnu98")
コード例 #2
0
 def test_clang_cppstd_defaults(self):
     self.assertEqual(cppstd_default("clang", "2"), "gnu98")
     self.assertEqual(cppstd_default("clang", "2.1"), "gnu98")
     self.assertEqual(cppstd_default("clang", "3.0"), "gnu98")
     self.assertEqual(cppstd_default("clang", "3.1"), "gnu98")
     self.assertEqual(cppstd_default("clang", "3.4"), "gnu98")
     self.assertEqual(cppstd_default("clang", "3.5"), "gnu98")
     self.assertEqual(cppstd_default("clang", "5"), "gnu98")
     self.assertEqual(cppstd_default("clang", "5.1"), "gnu98")
     self.assertEqual(cppstd_default("clang", "6"), "gnu14")
     self.assertEqual(cppstd_default("clang", "7"), "gnu14")
コード例 #3
0
ファイル: cpp_std_flags_test.py プロジェクト: 19317362/conan
 def test_clang_cppstd_defaults(self):
     self.assertEquals(cppstd_default("clang", "2"), "gnu98")
     self.assertEquals(cppstd_default("clang", "2.1"), "gnu98")
     self.assertEquals(cppstd_default("clang", "3.0"), "gnu98")
     self.assertEquals(cppstd_default("clang", "3.1"), "gnu98")
     self.assertEquals(cppstd_default("clang", "3.4"), "gnu98")
     self.assertEquals(cppstd_default("clang", "3.5"), "gnu98")
     self.assertEquals(cppstd_default("clang", "5"), "gnu98")
     self.assertEquals(cppstd_default("clang", "5.1"), "gnu98")
     self.assertEquals(cppstd_default("clang", "7"), "gnu14")
コード例 #4
0
ファイル: cpp_std_flags_test.py プロジェクト: 19317362/conan
 def test_apple_clang_cppstd_defaults(self):
     self.assertEquals(cppstd_default("apple-clang", "2"), "gnu98")
     self.assertEquals(cppstd_default("apple-clang", "3"), "gnu98")
     self.assertEquals(cppstd_default("apple-clang", "4"), "gnu98")
     self.assertEquals(cppstd_default("apple-clang", "5"), "gnu98")
     self.assertEquals(cppstd_default("apple-clang", "6"), "gnu98")
     self.assertEquals(cppstd_default("apple-clang", "7"), "gnu98")
     self.assertEquals(cppstd_default("apple-clang", "8"), "gnu98")
     self.assertEquals(cppstd_default("apple-clang", "9"), "gnu98")
コード例 #5
0
ファイル: cpp_std_flags_test.py プロジェクト: wjt2015/conan
def _make_cppstd_default(compiler, compiler_version, compiler_base=None):
    settings = MockSettings({
        "compiler": compiler,
        "compiler.version": compiler_version
    })
    if compiler_base:
        settings.values["compiler.base"] = compiler_base
    return cppstd_default(settings)
コード例 #6
0
ファイル: default_cppstd_test.py プロジェクト: yfxu1990/conan
 def test_value_default(self):
     # Explicit value (equals to default) passed to setting 'compiler.cppstd'
     cppstd = cppstd_default(self.compiler, self.compiler_version)
     id_with, output = self._get_id(
         settings_values={"compiler.cppstd": cppstd})
     self.assertIn(">>>> settings: ['compiler', 'os']", output)
     self.assertIn(">>>> cppstd: None", output)
     self.assertIn(">>>> compiler.cppstd: gnu14", output)
     self.assertEqual(self.id_default, id_with)
コード例 #7
0
ファイル: settings.py プロジェクト: zhongpan/conan
    def deduced_cppstd():
        cppstd = conanfile.settings.get_safe("compiler.cppstd")
        if cppstd:
            return cppstd

        compiler = conanfile.settings.get_safe("compiler")
        compiler_version = conanfile.settings.get_safe("compiler.version")
        if not compiler or not compiler_version:
            raise ConanException(
                "Could not obtain cppstd because there is no declared "
                "compiler in the 'settings' field of the recipe.")
        return cppstd_default(compiler, compiler_version)
コード例 #8
0
 def test_gcc_cppstd_defaults(self):
     self.assertEqual(cppstd_default("gcc", "4"), "gnu98")
     self.assertEqual(cppstd_default("gcc", "5"), "gnu98")
     self.assertEqual(cppstd_default("gcc", "6"), "gnu14")
     self.assertEqual(cppstd_default("gcc", "6.1"), "gnu14")
     self.assertEqual(cppstd_default("gcc", "7.3"), "gnu14")
     self.assertEqual(cppstd_default("gcc", "8.1"), "gnu14")
コード例 #9
0
ファイル: info.py プロジェクト: eriknorh/conan-contrib
    def default_std_matching(self):
        """
        If we are building with gcc 7, and we specify -s cppstd=gnu14, it's the default, so the
        same as specifying None, packages are the same
        """

        if self.full_settings.cppstd and \
                self.full_settings.compiler and \
                self.full_settings.compiler.version:
            default = cppstd_default(str(self.full_settings.compiler),
                                     str(self.full_settings.compiler.version))
            if default == str(self.full_settings.cppstd):
                self.settings.cppstd = None
コード例 #10
0
ファイル: info.py プロジェクト: 19317362/conan
    def default_std_matching(self):
        """
        If we are building with gcc 7, and we specify -s cppstd=gnu14, it's the default, so the
        same as specifying None, packages are the same
        """

        if self.full_settings.cppstd and \
                self.full_settings.compiler and \
                self.full_settings.compiler.version:
            default = cppstd_default(str(self.full_settings.compiler),
                                     str(self.full_settings.compiler.version))
            if default == str(self.full_settings.cppstd):
                self.settings.cppstd = None
コード例 #11
0
def main(recipe):
    settings = {'os': 'Linux',
                'arch': 'x86_64',
                'compiler': 'gcc',
                'compiler.version': '8',
                'compiler.libcxx': 'libstdc++11',
                'build_type': 'Release'}
    # Iterate all the 'cppstd' (start with the default one) to discover which one to build
    #   - first the default, then the rest
    default_cppstd = cppstd_default(settings['compiler'], settings['compiler.version'])
    cppstd_to_iterate = [it for it in ALL_CPPSTD if it != default_cppstd] + [default_cppstd, ]
    cppstd_to_iterate.reverse()

    list_to_compile = []
    already_seen = set()
    for it in cppstd_to_iterate:
        #   - run 'conan package_id' for each profile
        sys.stdout.write(f" - cppstd: {it}\n")
        with tempfile.NamedTemporaryFile(mode='w', delete=False) as profile:
            profile.write("[settings]\n")
            for key, value in settings.items():
                profile.write(f"{key}={value}\n")
            profile.write(f"compiler.cppstd={it}\n")
            profile.close()
            profile_file = profile.name

            out, _ = subprocess.Popen(['conan', 'package_id', recipe, '--profile', profile_file], stdout=subprocess.PIPE, shell=False).communicate()
            out = out.decode('utf-8')
            os.unlink(profile_file)

        #   - get 'package_id' and compatible ones
        own_pkg_id = None
        compatible = []
        for line in out.splitlines():
            if line.startswith("Package ID:"):
                own_pkg_id = line.split(":", 1)[1].strip()
            elif line.startswith(" - "):
                compatible.append(line[3:].strip())
        
        sys.stdout.write(f"   + {own_pkg_id}\n")
        sys.stdout.write(f"   + {', '.join(compatible)}\n")

        if not own_pkg_id in already_seen:
            list_to_compile.append(it)

        already_seen.add(own_pkg_id)
        already_seen.update(compatible)

        sys.stdout.write(f"   >> to compile: {', '.join(list_to_compile)}\n")
        sys.stdout.write(f"   >> already seen: {', '.join(already_seen)}\n")
コード例 #12
0
    def deduced_cppstd():
        cppstd = conanfile.settings.get_safe("compiler.cppstd")
        if cppstd:
            return cppstd

        compiler = conanfile.settings.get_safe("compiler")
        compiler_version = conanfile.settings.get_safe("compiler.version")
        if not compiler or not compiler_version:
            raise ConanException(
                "Could not obtain cppstd because there is no declared "
                "compiler in the 'settings' field of the recipe.")
        cppstd = cppstd_default(conanfile.settings)
        if cppstd is None:
            raise ConanInvalidConfiguration(
                "Could not detect the current default cppstd for "
                "the compiler {}-{}.".format(compiler, compiler_version))
        return cppstd
コード例 #13
0
ファイル: info.py プロジェクト: Enhex/conan
    def default_std_matching(self):
        """
        If we are building with gcc 7, and we specify -s cppstd=gnu14, it's the default, so the
        same as specifying None, packages are the same
        """
        if self.full_settings.compiler == "msvc":
            # This post-processing of package_id was a hack to introduce this in a non-breaking way
            # This whole function will be removed in Conan 2.0, and the responsibility will be
            # of the input profile
            return
        if (self.full_settings.compiler
                and self.full_settings.compiler.version):
            default = cppstd_default(self.full_settings)

            if str(self.full_settings.cppstd) == default:
                self.settings.cppstd = None

            if str(self.full_settings.compiler.cppstd) == default:
                self.settings.compiler.cppstd = None
コード例 #14
0
ファイル: cpp_std_flags_test.py プロジェクト: 19317362/conan
 def test_gcc_cppstd_defaults(self):
     self.assertEquals(cppstd_default("gcc", "4"), "gnu98")
     self.assertEquals(cppstd_default("gcc", "5"), "gnu98")
     self.assertEquals(cppstd_default("gcc", "6"), "gnu98")
     self.assertEquals(cppstd_default("gcc", "6.1"), "gnu14")
     self.assertEquals(cppstd_default("gcc", "7.3"), "gnu14")
コード例 #15
0
ファイル: cpp_std_flags_test.py プロジェクト: 19317362/conan
 def test_visual_cppstd_defaults(self):
     self.assertEquals(cppstd_default("Visual Studio", "11"), None)
     self.assertEquals(cppstd_default("Visual Studio", "12"), None)
     self.assertEquals(cppstd_default("Visual Studio", "13"), None)
     self.assertEquals(cppstd_default("Visual Studio", "14"), "14")
     self.assertEquals(cppstd_default("Visual Studio", "15"), "14")
コード例 #16
0
def _make_cppstd_default(compiler, compiler_version):
    settings = MockSettings({"compiler": compiler,
                             "compiler.version": compiler_version})
    return cppstd_default(settings)
コード例 #17
0
 def test_visual_cppstd_defaults(self):
     self.assertEquals(cppstd_default("Visual Studio", "11"), None)
     self.assertEquals(cppstd_default("Visual Studio", "12"), None)
     self.assertEquals(cppstd_default("Visual Studio", "13"), None)
     self.assertEquals(cppstd_default("Visual Studio", "14"), "14")
     self.assertEquals(cppstd_default("Visual Studio", "15"), "14")
コード例 #18
0
ファイル: default_cppstd_test.py プロジェクト: Imerso3D/conan
def _make_cppstd_default(compiler, compiler_version):
    settings = Settings.loads(get_default_settings_yml())
    settings.compiler = compiler
    settings.compiler.version = compiler_version
    return cppstd_default(settings)