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


Python Settings.loads方法代码示例

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


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

示例1: test_clean_sh_path

# 需要导入模块: from conans.model.settings import Settings [as 别名]
# 或者: from conans.model.settings.Settings import loads [as 别名]
    def test_clean_sh_path(self):

        if platform.system() != "Windows":
            return

        os.environ["PATH"] = os.environ.get("PATH", "") + os.pathsep + self.tempdir
        save(os.path.join(self.tempdir, "sh.exe"), "Fake sh")
        conanfile = ConanFileMock()
        settings = Settings.loads(default_settings_yml)
        settings.os = "Windows"
        settings.compiler = "Visual Studio"
        settings.compiler.version = "12"
        settings.arch = "x86"
        conanfile.settings = settings

        cmake = CMake(conanfile)
        cmake.configure()
        self.assertIn(self.tempdir, conanfile.path)

        cmake.generator = "MinGW Makefiles"
        cmake.configure()
        self.assertNotIn(self.tempdir, conanfile.path)

        # Automatic gcc
        settings = Settings.loads(default_settings_yml)
        settings.os = "Windows"
        settings.compiler = "gcc"
        settings.compiler.version = "5.4"
        settings.arch = "x86"
        conanfile.settings = settings

        cmake = CMake(conanfile)
        cmake.configure()
        self.assertNotIn(self.tempdir, conanfile.path)
开发者ID:nesono,项目名称:conan,代码行数:36,代码来源:cmake_test.py

示例2: test_none__sub_subsetting

# 需要导入模块: from conans.model.settings import Settings [as 别名]
# 或者: from conans.model.settings.Settings import loads [as 别名]
    def test_none__sub_subsetting(self):
        yml = """os:
    None:
        subsystem: [None, cygwin]
    Windows:
"""
        with self.assertRaisesRegexp(ConanException,
                                     "settings.yml: None setting can't have subsettings"):
            Settings.loads(yml)
开发者ID:19317362,项目名称:conan,代码行数:11,代码来源:settings_test.py

示例3: test_os_split

# 需要导入模块: from conans.model.settings import Settings [as 别名]
# 或者: from conans.model.settings.Settings import loads [as 别名]
    def test_os_split(self):
        settings = Settings.loads("""os:
    Windows:
    Linux:
    Macos:
        version: [1, 2]
    Android:
""")
        other_settings = Settings.loads("os: [Windows, Linux]")
        settings.os = "Windows"
        other_settings.os = "Windows"
        self.assertEqual(settings.values.sha, other_settings.values.sha)
开发者ID:19317362,项目名称:conan,代码行数:14,代码来源:settings_test.py

示例4: settings

# 需要导入模块: from conans.model.settings import Settings [as 别名]
# 或者: from conans.model.settings.Settings import loads [as 别名]
 def settings(self):
     """Returns {setting: [value, ...]} defining all the possible
        settings and their values"""
     if not self._settings:
         if not os.path.exists(self.settings_path):
             save(self.settings_path, default_settings_yml)
             settings = Settings.loads(default_settings_yml)
         else:
             content = load(self.settings_path)
             settings = Settings.loads(content)
         settings.values = self.conan_config.settings_defaults
         self._settings = settings
     return self._settings
开发者ID:WimK,项目名称:conan,代码行数:15,代码来源:paths.py

示例5: settings

# 需要导入模块: from conans.model.settings import Settings [as 别名]
# 或者: from conans.model.settings.Settings import loads [as 别名]
 def settings(self):
     """Returns {setting: [value, ...]} defining all the possible
        settings and their values"""
     if not self._settings:
         # TODO: Read default environment settings
         if not os.path.exists(self.settings_path):
             save(self.settings_path, normalize(default_settings_yml))
             settings = Settings.loads(default_settings_yml)
         else:
             content = load(self.settings_path)
             settings = Settings.loads(content)
         self.conan_config.settings_defaults(settings)
         self._settings = settings
     return self._settings
开发者ID:nesono,项目名称:conan,代码行数:16,代码来源:client_cache.py

示例6: vcvars_constrained_test

# 需要导入模块: from conans.model.settings import Settings [as 别名]
# 或者: from conans.model.settings.Settings import loads [as 别名]
    def vcvars_constrained_test(self):
        text = """os: [Windows]
compiler:
    Visual Studio:
        version: ["14"]
        """
        settings = Settings.loads(text)
        settings.os = "Windows"
        settings.compiler = "Visual Studio"
        with self.assertRaisesRegexp(ConanException,
                                     "compiler.version setting required for vcvars not defined"):
            tools.vcvars_command(settings)

        new_out = StringIO()
        tools.set_global_instances(ConanOutput(new_out), None)
        settings.compiler.version = "14"
        with tools.environment_append({"vs140comntools": "path/to/fake"}):
            tools.vcvars_command(settings)
            with tools.environment_append({"VisualStudioVersion": "12"}):
                with self.assertRaisesRegexp(ConanException,
                                             "Error, Visual environment already set to 12"):
                    tools.vcvars_command(settings)

            with tools.environment_append({"VisualStudioVersion": "12"}):
                # Not raising
                tools.vcvars_command(settings, force=True)
开发者ID:19317362,项目名称:conan,代码行数:28,代码来源:tools_test.py

示例7: test_deprecated_behaviour

# 需要导入模块: from conans.model.settings import Settings [as 别名]
# 或者: from conans.model.settings.Settings import loads [as 别名]
    def test_deprecated_behaviour(self):
        """"Remove when deprecate the old settings parameter to CMake and conanfile to configure/build/test"""
        settings = Settings.loads(default_settings_yml)
        settings.os = "Windows"
        settings.compiler = "Visual Studio"
        settings.compiler.version = "12"
        settings.arch = "x86"
        settings.os = "Windows"

        dot_dir = "." if sys.platform == 'win32' else "'.'"

        cross = "-DCMAKE_SYSTEM_NAME=\"Windows\" " if platform.system() != "Windows" else ""

        conan_file = ConanFileMock()
        conan_file.settings = settings
        cmake = CMake(settings)
        cmake.configure(conan_file)
        cores = '-DCONAN_CXX_FLAGS="/MP{0}" -DCONAN_C_FLAGS="/MP{0}" '.format(tools.cpu_count())
        self.assertEqual('cd {0} && cmake -G "Visual Studio 12 2013" {1}-DCONAN_EXPORTED="1" '
                         '-DCONAN_COMPILER="Visual Studio" -DCONAN_COMPILER_VERSION="12" {2}'
                         '-Wno-dev {0}'.format(dot_dir, cross, cores),
                         conan_file.command)

        cmake.build(conan_file)
        self.assertEqual('cmake --build %s' % dot_dir, conan_file.command)
        cmake.test()
        self.assertEqual('cmake --build %s %s' % (dot_dir, CMakeTest.scape('--target RUN_TESTS')), conan_file.command)
开发者ID:nesono,项目名称:conan,代码行数:29,代码来源:cmake_test.py

示例8: loads_default_test

# 需要导入模块: from conans.model.settings import Settings [as 别名]
# 或者: from conans.model.settings.Settings import loads [as 别名]
    def loads_default_test(self):
        settings = Settings.loads(default_settings_yml)
        settings.compiler = "Visual Studio"
        settings.compiler.version = "12"
        settings.arch = "x86"

        cmake = CMake(settings)
        self.assertEqual('-G "Visual Studio 12"   -DCONAN_COMPILER="Visual Studio" '
                         '-DCONAN_COMPILER_VERSION="12" -Wno-dev', cmake.command_line)
        self.assertEqual('', cmake.build_config)
        settings.build_type = "Debug"
        self.assertEqual('-G "Visual Studio 12"   -DCONAN_COMPILER="Visual Studio" '
                         '-DCONAN_COMPILER_VERSION="12" -Wno-dev', cmake.command_line)
        self.assertEqual('--config Debug', cmake.build_config)

        settings.arch = "x86_64"
        self.assertEqual('-G "Visual Studio 12 Win64"   -DCONAN_COMPILER="Visual Studio" '
                         '-DCONAN_COMPILER_VERSION="12" -Wno-dev', cmake.command_line)

        settings.os = "Windows"
        settings.compiler = "gcc"
        settings.compiler.version = "4.8"
        self.assertEqual('-G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug  -DCONAN_COMPILER="gcc" '
                         '-DCONAN_COMPILER_VERSION="4.8" -Wno-dev', cmake.command_line)

        settings.os = "Linux"
        settings.arch = "x86"
        self.assertEqual('-G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug  -DCONAN_COMPILER="gcc" '
                         '-DCONAN_COMPILER_VERSION="4.8" -DCONAN_CXX_FLAGS=-m32 '
                         '-DCONAN_SHARED_LINK_FLAGS=-m32 -DCONAN_C_FLAGS=-m32 -Wno-dev',
                         cmake.command_line)
开发者ID:samarjeet,项目名称:conan,代码行数:33,代码来源:cmake_test.py

示例9: test_invalid

# 需要导入模块: from conans.model.settings import Settings [as 别名]
# 或者: from conans.model.settings.Settings import loads [as 别名]
    def test_invalid(self):
        if platform.system() != "Windows":
            return

        fake_settings_yml = """
        os:
            WindowsStore:
                version: ["666"]
        arch: [x86]
        compiler:
            Visual Studio:
                runtime: [MD, MT, MTd, MDd]
                version: ["8", "9", "10", "11", "12", "14", "15"]

        build_type: [None, Debug, Release]
        """

        settings = Settings.loads(fake_settings_yml)
        settings.compiler = 'Visual Studio'
        settings.compiler.version = '14'
        settings.arch = 'x86'
        settings.os = 'WindowsStore'
        settings.os.version = '666'

        with self.assertRaises(ConanException):
            tools.vcvars_command(settings)
开发者ID:19317362,项目名称:conan,代码行数:28,代码来源:vcvars_store_test.py

示例10: test_arch_override

# 需要导入模块: from conans.model.settings import Settings [as 别名]
# 或者: from conans.model.settings.Settings import loads [as 别名]
    def test_arch_override(self):
        if platform.system() != "Windows":
            return
        settings = Settings.loads(default_settings_yml)
        settings.compiler = 'Visual Studio'
        settings.compiler.version = '14'
        settings.arch = 'mips64'

        command = tools.vcvars_command(settings, arch='x86')
        self.assertIn('vcvarsall.bat', command)
        self.assertIn('x86', command)

        command = tools.vcvars_command(settings, arch='x86_64')
        self.assertIn('vcvarsall.bat', command)
        self.assertIn('amd64', command)

        command = tools.vcvars_command(settings, arch='armv7')
        self.assertIn('vcvarsall.bat', command)
        self.assertNotIn('arm64', command)
        self.assertIn('arm', command)

        command = tools.vcvars_command(settings, arch='armv8')
        self.assertIn('vcvarsall.bat', command)
        self.assertIn('arm64', command)

        with self.assertRaises(ConanException):
            tools.vcvars_command(settings, arch='mips')
开发者ID:19317362,项目名称:conan,代码行数:29,代码来源:vcvars_arch_test.py

示例11: test_shared

# 需要导入模块: from conans.model.settings import Settings [as 别名]
# 或者: from conans.model.settings.Settings import loads [as 别名]
    def test_shared(self):
        settings = Settings.loads(default_settings_yml)
        settings.os = "Windows"
        settings.compiler = "Visual Studio"
        settings.compiler.version = "12"
        settings.arch = "x86"
        settings.os = "Windows"

        conan_file = ConanFileMock(shared=True)
        conan_file.settings = settings
        cmake = CMake(conan_file)

        self.assertEquals(cmake.definitions["BUILD_SHARED_LIBS"], "ON")

        conan_file = ConanFileMock(shared=False)
        conan_file.settings = settings
        cmake = CMake(conan_file)

        self.assertEquals(cmake.definitions["BUILD_SHARED_LIBS"], "OFF")

        conan_file = ConanFileMock(shared=None)
        conan_file.settings = settings
        cmake = CMake(conan_file)

        self.assertNotIn("BUILD_SHARED_LIBS", cmake.definitions)
开发者ID:nesono,项目名称:conan,代码行数:27,代码来源:cmake_test.py

示例12: test_none_value

# 需要导入模块: from conans.model.settings import Settings [as 别名]
# 或者: from conans.model.settings.Settings import loads [as 别名]
 def test_none_value(self):
     yml = "os: [None, Windows]"
     settings = Settings.loads(yml)
     # Same sha as if settings were empty
     self.assertEqual(settings.values.sha, Settings.loads("").values.sha)
     settings.validate()
     self.assertTrue(settings.os == None)
     self.assertEqual("", settings.values.dumps())
     settings.os = "None"
     self.assertEqual(settings.values.sha, Settings.loads("").values.sha)
     settings.validate()
     self.assertTrue(settings.os == "None")
     self.assertEqual("os=None", settings.values.dumps())
     settings.os = "Windows"
     self.assertTrue(settings.os == "Windows")
     self.assertEqual("os=Windows", settings.values.dumps())
开发者ID:19317362,项目名称:conan,代码行数:18,代码来源:settings_test.py

示例13: vcvars_raises_when_not_found_test

# 需要导入模块: from conans.model.settings import Settings [as 别名]
# 或者: from conans.model.settings.Settings import loads [as 别名]
    def vcvars_raises_when_not_found_test(self):
        text = """
os: [Windows]
compiler:
    Visual Studio:
        version: ["5"]
        """
        settings = Settings.loads(text)
        settings.os = "Windows"
        settings.compiler = "Visual Studio"
        settings.compiler.version = "5"
        with self.assertRaisesRegexp(ConanException, "VS non-existing installation: Visual Studio 5"):
            tools.vcvars_command(settings)
开发者ID:19317362,项目名称:conan,代码行数:15,代码来源:tools_test.py

示例14: test_none_subsetting

# 需要导入模块: from conans.model.settings import Settings [as 别名]
# 或者: from conans.model.settings.Settings import loads [as 别名]
    def test_none_subsetting(self):
        yml = """os:
    None:
    Windows:
        subsystem: [None, cygwin]
"""
        settings = Settings.loads(yml)
        # Same sha as if settings were empty
        self.assertEqual(settings.values.sha, Settings.loads("").values.sha)
        settings.validate()
        self.assertTrue(settings.os == None)
        self.assertEqual("", settings.values.dumps())
        settings.os = "None"
        self.assertEqual(settings.values.sha, Settings.loads("").values.sha)
        settings.validate()
        self.assertTrue(settings.os == "None")
        self.assertEqual("os=None", settings.values.dumps())
        settings.os = "Windows"
        self.assertTrue(settings.os.subsystem == None)
        self.assertEqual("os=Windows", settings.values.dumps())
        settings.os.subsystem = "cygwin"
        self.assertEqual("os=Windows\nos.subsystem=cygwin", settings.values.dumps())
开发者ID:19317362,项目名称:conan,代码行数:24,代码来源:settings_test.py

示例15: compiler_args_test

# 需要导入模块: from conans.model.settings import Settings [as 别名]
# 或者: from conans.model.settings.Settings import loads [as 别名]
    def compiler_args_test(self):
        settings = Settings.loads(default_settings_yml)
        settings.os = "Windows"
        settings.compiler = "Visual Studio"
        settings.compiler.version = "15"
        settings.arch = "x86"
        settings.build_type = "Release"

        conan_file = self._get_conanfile(settings)
        gen = CompilerArgsGenerator(conan_file)
        self.assertEquals('-Dmydefine1 -Ipath\\to\\include1 cxx_flag1 c_flag1 -O2 -Ob2 -DNDEBUG '
                          '-link -LIBPATH:path\\to\\lib1 mylib.lib', gen.content)

        settings = Settings.loads(default_settings_yml)
        settings.os = "Macos"
        settings.compiler = "apple-clang"
        settings.compiler.version = "9.0"
        settings.arch = "x86"
        settings.build_type = "Release"
        conan_file = self._get_conanfile(settings)
        gen = CompilerArgsGenerator(conan_file)
        self.assertEquals('-Dmydefine1 -Ipath/to/include1 cxx_flag1 c_flag1 -m32 -O3 -DNDEBUG '
                          '-Wl,-rpath,"path/to/lib1" -Lpath/to/lib1 -lmylib', gen.content)

        settings = Settings.loads(default_settings_yml)
        settings.os = "Linux"
        settings.os_build = "Macos"
        settings.compiler = "apple-clang"
        settings.compiler.version = "9.0"
        settings.arch = "x86"
        settings.build_type = "Release"

        conan_file = self._get_conanfile(settings)
        args = CompilerArgsGenerator(conan_file)
        self.assertEquals('-Dmydefine1 -Ipath/to/include1 cxx_flag1 c_flag1 -m32 -O3 -DNDEBUG '
                          '-Wl,-rpath,"path/to/lib1" '
                          '-Lpath/to/lib1 -lmylib', args.content)
开发者ID:19317362,项目名称:conan,代码行数:39,代码来源:compiler_args_test.py


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