Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
 def basic_test(self):
     s = Settings({"os": ["Windows", "Linux"]})
     s.os = "Windows"
     with self.assertRaises(ConanException) as cm:
         self.sut.compiler = "kk"
     self.assertEqual(str(cm.exception),
                      bad_value_msg("settings.compiler", "kk", "['Visual Studio', 'gcc']"))
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
Archivo: paths.py Proyecto: WimK/conan
 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
Ejemplo n.º 6
0
 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
Ejemplo n.º 7
0
 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())
Ejemplo n.º 8
0
    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)
Ejemplo n.º 9
0
    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)
Ejemplo n.º 10
0
    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')
Ejemplo n.º 11
0
    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)
Ejemplo n.º 12
0
    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)
Ejemplo n.º 13
0
    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)
Ejemplo n.º 14
0
 def setUp(self):
     data = {"compiler": {
                         "Visual Studio": {
                                          "version": ["10", "11", "12"],
                                          "runtime": ["MD", "MT"]},
                         "gcc": {
                                "version": ["4.8", "4.9"],
                                "arch": {"x86": {"speed": ["A", "B"]},
                                         "x64": {"speed": ["C", "D"]}}}
                                },
             "os": ["Windows", "Linux"]}
     self.sut = Settings(data)
Ejemplo n.º 15
0
    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)
Ejemplo n.º 16
0
    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())
Ejemplo n.º 17
0
    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)
Ejemplo n.º 18
0
    def test_winsdk_version_override(self):
        settings = Settings.loads(default_settings_yml)
        settings.compiler = 'Visual Studio'
        settings.compiler.version = '15'
        settings.arch = 'x86_64'

        command = tools.vcvars_command(settings, winsdk_version='8.1')
        self.assertIn('vcvarsall.bat', command)
        self.assertIn('8.1', command)

        settings.compiler.version = '14'

        command = tools.vcvars_command(settings, winsdk_version='8.1')
        self.assertIn('vcvarsall.bat', command)
        self.assertIn('8.1', command)
Ejemplo n.º 19
0
    def upgrade_test(self):
        command = build_sln_command(Settings({}), sln_path='dummy.sln', targets=None, upgrade_project=True,
                                    build_type='Debug', arch='x86_64', parallel=False)
        self.assertIn('msbuild dummy.sln', command)
        self.assertIn('/p:Platform="x64"', command)
        self.assertIn('devenv dummy.sln /upgrade', command)
        self.assertNotIn('/m:%s' % cpu_count(), command)
        self.assertNotIn('/target:teapot', command)

        with tools.environment_append({"CONAN_SKIP_VS_PROJECTS_UPGRADE": "1"}):
            command = build_sln_command(Settings({}), sln_path='dummy.sln', targets=None,
                                        upgrade_project=True,
                                        build_type='Debug', arch='x86_64', parallel=False)
            self.assertIn('msbuild dummy.sln', command)
            self.assertIn('/p:Platform="x64"', command)
            self.assertNotIn('devenv dummy.sln /upgrade', command)
            self.assertNotIn('/m:%s' % cpu_count(), command)
            self.assertNotIn('/target:teapot', command)

        with tools.environment_append({"CONAN_SKIP_VS_PROJECTS_UPGRADE": "False"}):
            command = build_sln_command(Settings({}), sln_path='dummy.sln', targets=None,
                                        upgrade_project=True,
                                        build_type='Debug', arch='x86_64', parallel=False)
            self.assertIn('devenv dummy.sln /upgrade', command)
Ejemplo n.º 20
0
    def apple_frameworks_test(self):
        settings = Settings.loads(get_default_settings_yml())
        settings.os = "Macos"
        settings.compiler = "apple-clang"
        settings.compiler.version = "9.1"
        settings.compiler.libcxx = "libc++"
        settings.arch = "x86_64"
        settings.build_type = "Debug"
        conanfile = ConanFile(TestBufferConanOutput(), None)
        conanfile.initialize(Settings({}), EnvValues())
        ref = ConanFileReference.loads("MyPkg/0.1@lasote/stables")
        cpp_info = CppInfo(ref.name, "dummy_root_folder1")
        cpp_info.framework_paths.extend(
            ["path/to/Frameworks1", "path/to/Frameworks2"])
        cpp_info.frameworks = ["OpenGL", "OpenCL"]
        conanfile.deps_cpp_info.add(ref.name, cpp_info)
        conanfile.settings = settings

        generator = CMakeGenerator(conanfile)
        content = generator.content
        self.assertIn(
            'find_library(CONAN_FRAMEWORK_${_FRAMEWORK}_FOUND NAME ${_FRAMEWORK} PATHS'
            ' ${CONAN_FRAMEWORK_DIRS${SUFFIX}})', content)
        self.assertIn(
            'set(CONAN_FRAMEWORK_DIRS "path/to/Frameworks1"\n\t\t\t"path/to/Frameworks2" '
            '${CONAN_FRAMEWORK_DIRS})', content)
        self.assertIn(
            'set(CONAN_LIBS ${CONAN_LIBS} ${CONAN_SYSTEM_LIBS} '
            '${CONAN_FRAMEWORKS_FOUND})', content)

        generator = CMakeFindPackageGenerator(conanfile)
        content = generator.content
        content = content['FindMyPkg.cmake']
        self.assertIn(
            'conan_find_apple_frameworks(MyPkg_FRAMEWORKS_FOUND "${MyPkg_FRAMEWORKS}"'
            ' "${MyPkg_FRAMEWORK_DIRS}")', content)
Ejemplo n.º 21
0
 def partial_build_test(self):
     conan_file = ConanFileMock()
     conan_file.settings = Settings()
     conan_file.should_configure = False
     conan_file.should_build = False
     conan_file.should_install = False
     cmake = CMake(conan_file, generator="Unix Makefiles")
     cmake.configure()
     self.assertIsNone(conan_file.command)
     cmake.build()
     self.assertIsNone(conan_file.command)
     cmake.install()
     self.assertIsNone(conan_file.command)
     conan_file.name = None
     cmake.patch_config_paths()
Ejemplo n.º 22
0
    def b2_empty_settings_test(self):
        conanfile = ConanFile(TestBufferConanOutput(), None)
        conanfile.initialize(Settings({}), EnvValues())

        generator = B2Generator(conanfile)

        content = {
            'conanbuildinfo.jam':
            _main_buildinfo_empty,
            'conanbuildinfo-d41d8cd98f00b204e9800998ecf8427e.jam':
            _variation_empty,
        }

        for ck, cv in generator.content.items():
            self.assertEqual(cv, content[ck])
Ejemplo n.º 23
0
    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)
Ejemplo n.º 24
0
    def variables_setup_test(self):

        conanfile = ConanFile(None, None, Settings({}), None)

        ref = ConanFileReference.loads("MyPkg/0.1@lasote/stables")
        cpp_info = CppInfo("dummy_root_folder1")
        cpp_info.defines = ["MYDEFINE1"]
        cpp_info.cflags.append("-Flag1=23")
        cpp_info.version = "1.3"
        cpp_info.description = "My cool description"

        conanfile.deps_cpp_info.update(cpp_info, ref.name)
        ref = ConanFileReference.loads("MyPkg2/0.1@lasote/stables")
        cpp_info = CppInfo("dummy_root_folder2")
        cpp_info.defines = ["MYDEFINE2"]
        cpp_info.version = "2.3"
        cpp_info.exelinkflags = ["-exelinkflag"]
        cpp_info.sharedlinkflags = ["-sharedlinkflag"]
        cpp_info.cppflags = ["-cppflag"]
        cpp_info.public_deps = ["MyPkg"]
        conanfile.deps_cpp_info.update(cpp_info, ref.name)
        generator = PkgConfigGenerator(conanfile)
        files = generator.content

        self.assertEquals(
            files["MyPkg2.pc"], """prefix=dummy_root_folder2
libdir=${prefix}/lib
includedir=${prefix}/include

Name: MyPkg2
Description: Conan package: MyPkg2
Version: 2.3
Libs: -L${libdir} -sharedlinkflag -exelinkflag
Cflags: -I${includedir} -cppflag -DMYDEFINE2
Requires: MyPkg
""")

        self.assertEquals(
            files["MyPkg.pc"], """prefix=dummy_root_folder1
libdir=${prefix}/lib
includedir=${prefix}/include

Name: MyPkg
Description: My cool description
Version: 1.3
Libs: -L${libdir}
Cflags: -I${includedir} -Flag1=23 -DMYDEFINE1
""")
Ejemplo n.º 25
0
    def test_target(self):
        output = ConanOutput(StringIO())
        command = build_sln_command(Settings({}),
                                    sln_path='dummy.sln',
                                    targets=['teapot'],
                                    upgrade_project=False,
                                    build_type='Debug',
                                    arch='armv8',
                                    parallel=False,
                                    output=output)

        self.assertIn('msbuild "dummy.sln"', command)
        self.assertIn('/p:Platform="ARM64"', command)
        self.assertNotIn('devenv "dummy.sln" /upgrade', command)
        self.assertNotIn('/m:%s' % cpu_count(output=output), command)
        self.assertIn('/target:teapot', command)
Ejemplo n.º 26
0
    def test_abs_path_unix(self):
        conanfile = ConanFile(Mock(), None)
        conanfile.initialize(Settings({}), EnvValues())
        ref = ConanFileReference.loads("pkg/0.1")
        cpp_info = CppInfo(ref.name, "/rootdir")
        cpp_info.includedirs = ["/an/absolute/dir"]
        cpp_info.filter_empty = False
        conanfile.deps_cpp_info.add(ref.name, cpp_info)

        master_content = TXTGenerator(conanfile).content
        after_cpp_info, _, _, _ = TXTGenerator.loads(master_content,
                                                     filter_empty=False)
        self.assertListEqual(after_cpp_info[ref.name].includedirs,
                             ["../an/absolute/dir"])
        self.assertListEqual(after_cpp_info[ref.name].include_paths,
                             ["/rootdir/../an/absolute/dir"])
Ejemplo n.º 27
0
    def test_81(self):
        if platform.system() != "Windows":
            return

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

        command = tools.vcvars_command(settings, output=self.output)
        self.assertIn('vcvarsall.bat', command)
        self.assertIn('x86', command)
        self.assertIn('store', command)
        self.assertIn('8.1', command)
Ejemplo n.º 28
0
    def test_81(self):
        if platform.system() != "Windows":
            return

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

        command = tools.vcvars_command(settings)
        self.assertIn('vcvarsall.bat', command)
        self.assertIn('x86', command)
        self.assertIn('store', command)
        self.assertIn('8.1', command)
Ejemplo n.º 29
0
    def test_10_custom_winsdk(self):
        settings = Settings.loads(get_default_settings_yml())
        settings.compiler = 'Visual Studio'
        settings.compiler.version = '14'
        settings.arch = 'x86'
        settings.os = 'WindowsStore'
        settings.os.version = '10.0'

        sdk_version = '10.0.18362.0'
        command = tools.vcvars_command(settings,
                                       winsdk_version=sdk_version,
                                       output=self.output)
        self.assertIn('vcvarsall.bat', command)
        self.assertIn('x86', command)
        self.assertIn('store', command)
        self.assertIn(sdk_version, command)
Ejemplo n.º 30
0
 def variables_setup_test(self):
     conanfile = ConanFile(None, None, Settings({}), None)
     ref = ConanFileReference.loads("MyPkg/0.1@lasote/stables")
     cpp_info = CppInfo("")
     cpp_info.defines = ["MYDEFINE1"]
     conanfile.deps_cpp_info.update(cpp_info, ref.name)
     ref = ConanFileReference.loads("MyPkg2/0.1@lasote/stables")
     cpp_info = CppInfo("")
     cpp_info.defines = ["MYDEFINE2"]
     conanfile.deps_cpp_info.update(cpp_info, ref.name)
     generator = SConsGenerator(conanfile)
     content = generator.content
     scons_lines = content.splitlines()
     self.assertIn("        \"CPPDEFINES\"  : [\'MYDEFINE2\', \'MYDEFINE1\'],", scons_lines)
     self.assertIn("        \"CPPDEFINES\"  : [\'MYDEFINE1\'],", scons_lines)
     self.assertIn("        \"CPPDEFINES\"  : [\'MYDEFINE2\'],", scons_lines)
Ejemplo n.º 31
0
    def requires_init_test(self):
        loader = ConanFileLoader(None, Settings(), None, OptionsValues.loads(""), Scopes(),
                                 None, None)
        tmp_dir = temp_folder()
        conanfile_path = os.path.join(tmp_dir, "conanfile.py")
        conanfile = """from conans import ConanFile
class MyTest(ConanFile):
    requires = {}
    def requirements(self):
        self.requires("MyPkg/0.1@user/channel")
"""
        for requires in ("''", "[]", "()", "None"):
            save(conanfile_path, conanfile.format(requires))
            result = loader.load_conan(conanfile_path, output=None, consumer=True)
            result.requirements()
            self.assertEqual("MyPkg/0.1@user/channel", str(result.requires))
Ejemplo n.º 32
0
 def partial_build_test(self):
     conan_file = ConanFileMock()
     conan_file.settings = Settings()
     conan_file.should_configure = False
     conan_file.should_build = False
     conan_file.package_folder = os.path.join(self.tempdir,
                                              "my_cache_package_folder")
     meson = Meson(conan_file)
     meson.configure()
     self.assertIsNone(conan_file.command)
     meson.build()
     self.assertIsNone(conan_file.command)
     meson.test()
     self.assertIsNone(conan_file.command)
     meson.install()
     self.assertIsNone(conan_file.command)
Ejemplo n.º 33
0
    def set_toolset_test(self):
        settings = Settings.loads(default_settings_yml)
        settings.os = "Windows"
        settings.compiler = "Visual Studio"
        settings.compiler.version = "15"
        settings.arch = "x86"

        conan_file = ConanFileMock()
        conan_file.settings = settings

        cmake = CMake(conan_file, toolset="v141")
        self.assertIn('-T "v141"', cmake.command_line)

        with tools.environment_append({"CONAN_CMAKE_TOOLSET": "v141"}):
            cmake = CMake(conan_file)
            self.assertIn('-T "v141"', cmake.command_line)
Ejemplo n.º 34
0
    def test_system_libs(self):
        settings = Settings.loads(get_default_settings_yml())
        settings.os = "Linux"
        settings.compiler = "gcc"
        settings.compiler.version = "8"
        settings.arch = "x86_64"
        settings.build_type = "Release"

        conan_file = self._get_conanfile(settings, system_libs=True)
        args = CompilerArgsGenerator(conan_file)
        self.assertEqual(
            '-Dmydefine1 -I/root/include -I/root/path/to/include1'
            ' cxx_flag1 c_flag1 -m64 -O3 -s -DNDEBUG'
            ' -Wl,-rpath,"/root/lib" -Wl,-rpath,"/root/path/to/lib1"'
            ' -L/root/lib -L/root/path/to/lib1 -lmylib -lsystem_lib1'
            ' -F /root/Frameworks', args.content)
Ejemplo n.º 35
0
 def partial_build_test(self):
     conan_file = ConanFileMock()
     deps_cpp_info = namedtuple(
         "Deps", "libs, include_paths, lib_paths, defines, cflags, "
         "cppflags, sharedlinkflags, exelinkflags, sysroot")
     conan_file.deps_cpp_info = deps_cpp_info([], [], [], [], [], [], [],
                                              [], "")
     conan_file.settings = Settings()
     be = AutoToolsBuildEnvironment(conan_file)
     conan_file.should_configure = False
     conan_file.should_build = False
     conan_file.should_install = False
     be.configure()
     self.assertIsNone(conan_file.command)
     be.make()
     self.assertIsNone(conan_file.command)
Ejemplo n.º 36
0
 def validate_additional_dependencies(lib, additional_dep):
     conanfile = ConanFile(TestBufferConanOutput(), None)
     conanfile.initialize(Settings({}), EnvValues())
     ref = ConanFileReference.loads("MyPkg/0.1@user/testing")
     cpp_info = CppInfo("dummy_root_folder1")
     cpp_info.libs = [lib]
     conanfile.deps_cpp_info.update(cpp_info, ref.name)
     generator = VisualStudioGenerator(conanfile)
     content = generator.content
     self.assertIn(
         "<ConanLibraries>%s;</ConanLibraries>" % additional_dep,
         content)
     self.assertIn(
         "<AdditionalDependencies>"
         "$(ConanLibraries)%(AdditionalDependencies)"
         "</AdditionalDependencies>", content)
Ejemplo n.º 37
0
 def test_frameworks(self):
     conanfile = ConanFile(TestBufferConanOutput(), None)
     conanfile.initialize(Settings({}), EnvValues())
     framework_path = os.getcwd(
     )  # must exist, otherwise filtered by framework_paths
     cpp_info = CppInfo("MyPkg", "/rootpath")
     cpp_info.frameworks = ["HelloFramework"]
     cpp_info.frameworkdirs = [framework_path]
     conanfile.deps_cpp_info.add("MyPkg", DepCppInfo(cpp_info))
     generator = QmakeGenerator(conanfile)
     content = generator.content
     qmake_lines = content.splitlines()
     self.assertIn('CONAN_FRAMEWORKS += -framework HelloFramework',
                   qmake_lines)
     self.assertIn('CONAN_FRAMEWORK_PATHS += -F%s' % framework_path,
                   qmake_lines)
Ejemplo n.º 38
0
    def test_absolute_directory(self):
        conanfile = ConanFile(TestBufferConanOutput(), None)
        conanfile.initialize(Settings({}), EnvValues())
        ref = ConanFileReference.loads("pkg/0.1")
        cpp_info = CppInfo(ref.name, "C:/my/root/path")
        cpp_info.includedirs = ["D:/my/path/to/something"]
        cpp_info.filter_empty = False
        conanfile.deps_cpp_info.add(ref.name, cpp_info)

        master_content = TXTGenerator(conanfile).content
        after_cpp_info, _, _, _ = TXTGenerator.loads(master_content,
                                                     filter_empty=False)
        self.assertListEqual(after_cpp_info[ref.name].includedirs,
                             ["D:/my/path/to/something"])
        self.assertListEqual(after_cpp_info[ref.name].include_paths,
                             ["D:/my/path/to/something"])
Ejemplo n.º 39
0
    def test_names_per_generator(self):
        cpp_info = CppInfo("pkg_name", "root")
        cpp_info.name = "name"
        cpp_info.names["txt"] = "txt_name"
        cpp_info.names["cmake_find_package"] = "SpecialName"
        cpp_info.filenames["cmake_find_package"] = "SpecialFileName"
        conanfile = ConanFile(TestBufferConanOutput(), None)
        conanfile.initialize(Settings({}), EnvValues())
        conanfile.deps_cpp_info.add("pkg_name", DepCppInfo(cpp_info))
        content = TXTGenerator(conanfile).content
        parsed_deps_cpp_info, _, _, _ = TXTGenerator.loads(content, filter_empty=False)

        parsed_cpp_info = parsed_deps_cpp_info["pkg_name"]
        self.assertEqual(parsed_cpp_info.get_name("txt"), "txt_name")
        self.assertEqual(parsed_cpp_info.get_name("cmake_find_package"), "SpecialName")
        self.assertEqual(parsed_cpp_info.get_filename("cmake_find_package"), "SpecialFileName")
        self.assertEqual(parsed_cpp_info.get_name("pkg_config"), "pkg_name")
Ejemplo n.º 40
0
    def test_sysroot(self):

        settings = Settings.loads(default_settings_yml)
        conan_file = ConanFileMock()
        conan_file.settings = settings
        settings.os = "Windows"
        settings.compiler = "Visual Studio"
        settings.compiler.version = "12"
        settings.arch = "x86"
        settings.os = "Windows"
        cmake = CMake(conan_file)
        self.assertNotIn("-DCMAKE_SYSROOT=", cmake.flags) if platform.system() == "Windows" else ""

        # Now activate cross build and check sysroot
        with(tools.environment_append({"CONAN_CMAKE_SYSTEM_NAME": "Android"})):
            cmake = CMake(conan_file)
            self.assertEquals(cmake.definitions["CMAKE_SYSROOT"], "/path/to/sysroot")
Ejemplo n.º 41
0
    def test_winsdk_version_override(self):
        if platform.system() != "Windows":
            return
        settings = Settings.loads(default_settings_yml)
        settings.compiler = 'Visual Studio'
        settings.compiler.version = '15'
        settings.arch = 'x86_64'

        command = tools.vcvars_command(settings, winsdk_version='8.1')
        self.assertIn('vcvarsall.bat', command)
        self.assertIn('8.1', command)

        settings.compiler.version = '14'

        command = tools.vcvars_command(settings, winsdk_version='8.1')
        self.assertIn('vcvarsall.bat', command)
        self.assertNotIn('8.1', command)
Ejemplo n.º 42
0
    def loads_default_test(self):
        settings = Settings.loads("""os: [Windows, Linux, Macos, Android, FreeBSD]
arch: [x86, x86_64, arm]
compiler:
    gcc:
        version: ["4.8", "4.9", "5.0"]
    Visual Studio:
        runtime: [None, MD, MT, MTd, MDd]
        version: ["10", "11", "12"]
    clang:
        version: ["3.5", "3.6", "3.7"]

build_type: [None, Debug, Release]""")
        settings.compiler = "clang"
        settings.compiler.version = "3.5"
        self.assertEqual(settings.compiler, "clang")
        self.assertEqual(settings.compiler.version, "3.5")
Ejemplo n.º 43
0
    def valid_xml_test(self):
        conanfile = ConanFile(None, None)
        conanfile.initialize(Settings({}), EnvValues())
        ref = ConanFileReference.loads("MyPkg/0.1@user/testing")
        cpp_info = CppInfo("dummy_root_folder1")
        conanfile.deps_cpp_info.update(cpp_info, ref.name)
        ref = ConanFileReference.loads("My.Fancy-Pkg_2/0.1@user/testing")
        cpp_info = CppInfo("dummy_root_folder2")
        conanfile.deps_cpp_info.update(cpp_info, ref.name)
        generator = VisualStudioGenerator(conanfile)

        content = generator.content
        xml.etree.ElementTree.fromstring(content)

        self.assertIn('<PropertyGroup Label="Conan-RootDirs">', content)
        self.assertIn("<Conan-MyPkg-Root>dummy_root_folder1</Conan-MyPkg-Root>", content)
        self.assertIn("<Conan-My-Fancy-Pkg_2-Root>dummy_root_folder2</Conan-My-Fancy-Pkg_2-Root>", content)
Ejemplo n.º 44
0
 def variables_setup_test(self):
     conanfile = ConanFile(None, None, Settings({}), None)
     ref = ConanFileReference.loads("MyPkg/0.1@lasote/stables")
     cpp_info = CppInfo("dummy_root_folder1")
     cpp_info.defines = ["MYDEFINE1"]
     conanfile.deps_cpp_info.update(cpp_info, ref)
     ref = ConanFileReference.loads("MyPkg2/0.1@lasote/stables")
     cpp_info = CppInfo("dummy_root_folder2")
     cpp_info.defines = ["MYDEFINE2"]
     conanfile.deps_cpp_info.update(cpp_info, ref)
     generator = CMakeGenerator(conanfile)
     content = generator.content
     cmake_lines = content.splitlines()
     self.assertIn("set(CONAN_DEFINES_MYPKG -DMYDEFINE1)", cmake_lines)
     self.assertIn("set(CONAN_DEFINES_MYPKG2 -DMYDEFINE2)", cmake_lines)
     self.assertIn("set(CONAN_COMPILE_DEFINITIONS_MYPKG MYDEFINE1)", cmake_lines)
     self.assertIn("set(CONAN_COMPILE_DEFINITIONS_MYPKG2 MYDEFINE2)", cmake_lines)
Ejemplo n.º 45
0
 def escaped_flags_test(self):
     conanfile = ConanFile(TestBufferConanOutput(), None)
     conanfile.initialize(Settings({}), EnvValues())
     ref = ConanFileReference.loads("MyPkg/0.1@lasote/stables")
     cpp_info = CppInfo(ref.name, "dummy_root_folder1")
     cpp_info.includedirs.append("other_include_dir")
     cpp_info.cxxflags = ["-load", r"C:\foo\bar.dll"]
     cpp_info.cflags = ["-load", r"C:\foo\bar2.dll"]
     cpp_info.defines = ['MY_DEF=My string', 'MY_DEF2=My other string']
     conanfile.deps_cpp_info.add(ref.name, cpp_info)
     generator = CMakeGenerator(conanfile)
     content = generator.content
     cmake_lines = content.splitlines()
     self.assertIn(r'set(CONAN_C_FLAGS_MYPKG "-load C:\\foo\\bar2.dll")', cmake_lines)
     self.assertIn(r'set(CONAN_CXX_FLAGS_MYPKG "-load C:\\foo\\bar.dll")', cmake_lines)
     self.assertIn(r'set(CONAN_DEFINES_MYPKG "-DMY_DEF=My string"', cmake_lines)
     self.assertIn('\t\t\t"-DMY_DEF2=My other string")', cmake_lines)
Ejemplo n.º 46
0
    def test_sysroot(self):

        settings = Settings.loads(default_settings_yml)
        conan_file = ConanFileMock()
        conan_file.settings = settings
        settings.os = "Windows"
        settings.compiler = "Visual Studio"
        settings.compiler.version = "12"
        settings.arch = "x86"
        settings.os = "Windows"
        cmake = CMake(conan_file)
        self.assertNotIn("-DCMAKE_SYSROOT=", cmake.flags) if platform.system() == "Windows" else ""

        # Now activate cross build and check sysroot
        with(tools.environment_append({"CONAN_CMAKE_SYSTEM_NAME": "Android"})):
            cmake = CMake(conan_file)
            self.assertEquals(cmake.definitions["CMAKE_SYSROOT"], "/path/to/sysroot")
Ejemplo n.º 47
0
    def positive_test(self):
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")

            output = ConanOutput(StringIO())
            command = build_sln_command(Settings({}), sln_path='dummy.sln', targets=None,
                                        upgrade_project=False, build_type='Debug', arch='x86',
                                        parallel=False, output=output)

            self.assertEqual(len(w), 1)
            self.assertTrue(issubclass(w[0].category, DeprecationWarning))

        self.assertIn('msbuild "dummy.sln"', command)
        self.assertIn('/p:Platform="x86"', command)
        self.assertNotIn('devenv "dummy.sln" /upgrade', command)
        self.assertNotIn('/m:%s' % cpu_count(output=output), command)
        self.assertNotIn('/target:teapot', command)
Ejemplo n.º 48
0
    def test_10(self):
        sdk_version = tools.find_windows_10_sdk()
        if not sdk_version:
            return

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

        command = tools.vcvars_command(settings, output=self.output)
        self.assertIn('vcvarsall.bat', command)
        self.assertIn('x86', command)
        self.assertIn('store', command)
        self.assertIn(sdk_version, command)
    def loads_default_test(self):
        settings = Settings.loads("""os: [Windows, Linux, Macos, Android]
arch: [x86, x86_64, arm]
compiler:
    gcc:
        version: ["4.8", "4.9", "5.0"]
    Visual Studio:
        runtime: [None, MD, MT, MTd, MDd]
        version: ["10", "11", "12"]
    clang:
        version: ["3.5", "3.6", "3.7"]

build_type: [None, Debug, Release]""")
        settings.compiler = "clang"
        settings.compiler.version = "3.5"
        self.assertEqual(settings.compiler, "clang")
        self.assertEqual(settings.compiler.version, "3.5")
Ejemplo n.º 50
0
    def no_arch_test(self):
        with self.assertRaises(ConanException):
            with warnings.catch_warnings(record=True) as w:
                warnings.simplefilter("always")

                new_out = StringIO()
                build_sln_command(Settings({}),
                                  sln_path='dummy.sln',
                                  targets=None,
                                  upgrade_project=False,
                                  build_type='Debug',
                                  arch=None,
                                  parallel=False,
                                  output=ConanOutput(new_out))

                self.assertEqual(len(w), 1)
                self.assertTrue(issubclass(w[0].category, DeprecationWarning))
Ejemplo n.º 51
0
    def setUp(self):
        self.output = TestBufferConanOutput()
        self.loader = ConanFileLoader(None, Settings.loads(""), Profile())
        self.retriever = Retriever(self.loader, self.output)
        self.remote_search = MockSearchRemote()
        self.resolver = RequireResolver(self.output, self.retriever, self.remote_search)
        self.builder = DepsGraphBuilder(self.retriever, self.output, self.loader, self.resolver)

        for v in ["0.1", "0.2", "0.3", "1.1", "1.1.2", "1.2.1", "2.1", "2.2.1"]:
            say_content = """
from conans import ConanFile

class SayConan(ConanFile):
    name = "Say"
    version = "%s"
""" % v
            say_ref = ConanFileReference.loads("Say/%s@memsharded/testing" % v)
            self.retriever.conan(say_ref, say_content)
Ejemplo n.º 52
0
    def deleted_os_test(self):
        partial_settings = """
os: [Linux]
arch: [x86_64]
compiler:
    gcc:
        version: ["4.9"]
build_type: [ Release]
"""
        settings = Settings.loads(partial_settings)
        settings.os = "Linux"
        settings.compiler = "gcc"
        settings.compiler.version = "4.9"
        settings.arch = "x86_64"

        cmake = CMake(settings)
        self.assertEqual('-G "Unix Makefiles"   -DCONAN_COMPILER="gcc" '
                         '-DCONAN_COMPILER_VERSION="4.9" -Wno-dev', cmake.command_line)
Ejemplo n.º 53
0
 def settings_are_generated_tests(self):
     settings = Settings.loads(default_settings_yml)
     settings.os = "Windows"
     settings.compiler = "Visual Studio"
     settings.compiler.version = "12"
     settings.compiler.runtime = "MD"
     settings.arch = "x86"
     settings.build_type = "Debug"
     conanfile = ConanFile(None, None, Settings({}), None)
     conanfile.settings = settings
     generator = CMakeGenerator(conanfile)
     content = generator.content
     cmake_lines = content.splitlines()
     self.assertIn('set(CONAN_SETTINGS_BUILD_TYPE "Debug")', cmake_lines)
     self.assertIn('set(CONAN_SETTINGS_ARCH "x86")', cmake_lines)
     self.assertIn('set(CONAN_SETTINGS_COMPILER "Visual Studio")', cmake_lines)
     self.assertIn('set(CONAN_SETTINGS_COMPILER_VERSION "12")', cmake_lines)
     self.assertIn('set(CONAN_SETTINGS_COMPILER_RUNTIME "MD")', cmake_lines)
     self.assertIn('set(CONAN_SETTINGS_OS "Windows")', cmake_lines)
Ejemplo n.º 54
0
    def test_10(self):
        if platform.system() != "Windows":
            return
        sdk_version = tools.find_windows_10_sdk()
        if not sdk_version:
            return

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

        command = tools.vcvars_command(settings)
        self.assertIn('vcvarsall.bat', command)
        self.assertIn('x86', command)
        self.assertIn('store', command)
        self.assertIn(sdk_version, command)
Ejemplo n.º 55
0
    def gcc_test(self):
        settings = Settings.loads(default_settings_yml)
        settings.os = "Linux"
        settings.compiler = "gcc"
        settings.compiler.version = "6.3"
        settings.arch = "x86"
        settings.build_type = "Release"
        settings.cppstd = "gnu17"

        conan_file = self._get_conanfile(settings)
        gcc = GCCGenerator(conan_file)
        self.assertEquals('-Dmydefine1 -Ipath/to/include1 cxx_flag1 c_flag1 -m32 -O3 -s -DNDEBUG '
                          '-Wl,-rpath="path/to/lib1" '
                          '-Lpath/to/lib1 -lmylib -std=gnu++1z', gcc.content)

        settings.arch = "x86_64"
        settings.build_type = "Debug"
        settings.compiler.libcxx = "libstdc++11"

        gcc = GCCGenerator(conan_file)
        self.assertEquals('-Dmydefine1 -Ipath/to/include1 cxx_flag1 c_flag1 -m64 -g '
                          '-Wl,-rpath="path/to/lib1" -Lpath/to/lib1 -lmylib '
                          '-D_GLIBCXX_USE_CXX11_ABI=1 -std=gnu++1z',
                          gcc.content)

        settings.compiler.libcxx = "libstdc++"
        gcc = GCCGenerator(conan_file)
        self.assertEquals('-Dmydefine1 -Ipath/to/include1 cxx_flag1 c_flag1 -m64 -g '
                          '-Wl,-rpath="path/to/lib1" -Lpath/to/lib1 -lmylib '
                          '-D_GLIBCXX_USE_CXX11_ABI=0 -std=gnu++1z',
                          gcc.content)

        settings.os = "Windows"
        settings.compiler = "Visual Studio"
        settings.compiler.version = "15"
        settings.arch = "x86"
        settings.build_type = "Release"
        gcc = GCCGenerator(conan_file)
        # GCC generator ignores the compiler setting, it is always gcc
        self.assertEquals('-Dmydefine1 -Ipath/to/include1 cxx_flag1 c_flag1 -m32 -O3 -s '
                          '-DNDEBUG -Wl,-rpath="path/to/lib1" -Lpath/to/lib1 -lmylib',
                          gcc.content)
Ejemplo n.º 56
0
 def multi_os_test(self):
     settings = Settings.loads("""os:
         Windows:
         Linux:
             distro: [RH6, RH7]
         Macos:
             codename: [Mavericks, Yosemite]
     """)
     settings.os = "Windows"
     self.assertEqual(settings.os, "Windows")
     settings.os = "Linux"
     settings.os.distro = "RH6"
     self.assertTrue(settings.os.distro == "RH6")
     with self.assertRaises(ConanException):
         settings.os.distro = "Other"
     with self.assertRaises(ConanException):
         settings.os.codename = "Yosemite"
     settings.os = "Macos"
     settings.os.codename = "Yosemite"
     self.assertTrue(settings.os.codename == "Yosemite")
Ejemplo n.º 57
0
    def loads_test(self):
        settings = Settings.loads("""
compiler:
    Visual Studio:
        runtime: [MD, MT]
        version:
            '10':
                arch: ["32"]
            '11':
                &id1
                arch: ["32", "64"]
            '12':
                *id1
    gcc:
        arch:
            x64:
                speed: [C, D]
            x86:
                speed: [A, B]
        version: ['4.8', '4.9']
os: [Windows, Linux]
""")
        settings.values_list = [('compiler', 'Visual Studio'),
                          ('compiler.version', '10'),
                          ('compiler.version.arch', '32')]
        self.assertEqual(settings.values_list,
                         [('compiler', 'Visual Studio'),
                          ('compiler.version', '10'),
                          ('compiler.version.arch', '32')])

        settings.compiler.version = "10"
        settings.compiler.version.arch = "32"
        settings.compiler.version = "11"
        settings.compiler.version.arch = "64"
        settings.compiler.version = "12"
        settings.compiler.version.arch = "64"

        self.assertEqual(settings.values_list,
                         [('compiler', 'Visual Studio'),
                          ('compiler.version', '12'),
                          ('compiler.version.arch', '64')])
Ejemplo n.º 58
0
    def vcvars_constrained_test(self):
        if platform.system() != "Windows":
            return
        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)
        settings.compiler.version = "14"
        cmd = tools.vcvars_command(settings)
        self.assertIn("vcvarsall.bat", cmd)
        with tools.environment_append({"VisualStudioVersion": "12"}):
            with self.assertRaisesRegexp(ConanException,
                                         "Error, Visual environment already set to 12"):
                tools.vcvars_command(settings)
Ejemplo n.º 59
0
 def vcvars_echo_test(self):
     if platform.system() != "Windows":
         return
     settings = Settings.loads(default_settings_yml)
     settings.os = "Windows"
     settings.compiler = "Visual Studio"
     settings.compiler.version = "14"
     cmd = tools.vcvars_command(settings)
     output = TestBufferConanOutput()
     runner = TestRunner(output)
     runner(cmd + " && set vs140comntools")
     self.assertIn("vcvarsall.bat", str(output))
     self.assertIn("VS140COMNTOOLS=", str(output))
     with tools.environment_append({"VisualStudioVersion": "14"}):
         output = TestBufferConanOutput()
         runner = TestRunner(output)
         cmd = tools.vcvars_command(settings)
         runner(cmd + " && set vs140comntools")
         self.assertNotIn("vcvarsall.bat", str(output))
         self.assertIn("Conan:vcvars already set", str(output))
         self.assertIn("VS140COMNTOOLS=", str(output))
Ejemplo n.º 60
0
    def deleted_os_test(self):
        partial_settings = """
os: [Linux]
arch: [x86_64]
compiler:
    gcc:
        version: ["4.9"]
build_type: [ Release]
"""
        settings = Settings.loads(partial_settings)
        settings.os = "Linux"
        settings.compiler = "gcc"
        settings.compiler.version = "4.9"
        settings.arch = "x86_64"
        conan_file = ConanFileMock()
        conan_file.settings = settings

        cmake = CMake(conan_file)
        cross = "-DCMAKE_SYSTEM_NAME=\"Linux\" -DCMAKE_SYSROOT=\"/path/to/sysroot\" " if platform.system() != "Linux" else ""
        self.assertEqual('-G "Unix Makefiles" %s-DCONAN_EXPORTED="1" -DCONAN_COMPILER="gcc" '
                         '-DCONAN_COMPILER_VERSION="4.9" -DCONAN_CXX_FLAGS="-m64" '
                         '-DCONAN_SHARED_LINKER_FLAGS="-m64" -DCONAN_C_FLAGS="-m64" -Wno-dev' % cross,
                         cmake.command_line)