Exemple #1
0
    def _update_settings_yml(self, old_version):

        from conans.client.conf import get_default_settings_yml
        settings_path = self.cache.settings_path
        if not os.path.exists(settings_path):
            self.out.warn("Migration: This conan installation doesn't have settings yet")
            self.out.warn("Nothing to migrate here, settings will be generated automatically")
            return

        var_name = "settings_{}".format(old_version.replace(".", "_"))

        def save_new():
            new_path = self.cache.settings_path + ".new"
            save(new_path, get_default_settings_yml())
            self.out.warn("*" * 40)
            self.out.warn("settings.yml is locally modified, can't be updated")
            self.out.warn("The new settings.yml has been stored in: %s" % new_path)
            self.out.warn("*" * 40)

        self.out.warn("Migration: Updating settings.yml")
        if hasattr(migrations_settings, var_name):
            version_default_contents = getattr(migrations_settings, var_name)
            if version_default_contents != get_default_settings_yml():
                current_settings = load(self.cache.settings_path)
                if current_settings != version_default_contents:
                    save_new()
                else:
                    save(self.cache.settings_path, get_default_settings_yml())
            else:
                self.out.info("Migration: Settings already up to date")
        else:
            # We don't have the value for that version, so don't override
            save_new()
Exemple #2
0
    def settings(self):
        """Returns {setting: [value, ...]} defining all the possible
           settings without values"""

        if not os.path.exists(self.settings_path):
            save(self.settings_path, normalize(get_default_settings_yml()))
            settings = Settings.loads(get_default_settings_yml())
        else:
            content = load(self.settings_path)
            settings = Settings.loads(content)

        return settings
Exemple #3
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())
        conanfile.settings = settings

        ref = ConanFileReference.loads("MyPkg/0.1@lasote/stables")
        cpp_info = CppInfo(ref.name, "dummy_root_folder1")
        cpp_info.frameworkdirs.extend(["path/to/Frameworks1", "path/to/Frameworks2"])
        cpp_info.frameworks = ["OpenGL", "OpenCL"]
        cpp_info.filter_empty = False
        conanfile.deps_cpp_info.add(ref.name, cpp_info)

        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 "dummy_root_folder1/Frameworks"\n'
                      '\t\t\t"dummy_root_folder1/path/to/Frameworks1"\n'
                      '\t\t\t"dummy_root_folder1/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)
        def validate_additional_dependencies(libname, additional_dep):
            tempdir = temp_folder()
            with chdir(tempdir):
                conanfile = ConanFile(TestBufferConanOutput(), None)
                conanfile.initialize(Settings({}), EnvValues())

                ref = ConanFileReference.loads("MyPkg/0.1@user/testing")
                cpp_info = CppInfo(ref.name, "dummy_root_folder1")
                cpp_info.libs = [libname]
                conanfile.deps_cpp_info.add(ref.name, cpp_info)

                settings = Settings.loads(get_default_settings_yml())
                settings.os = "Windows"
                settings.arch = "x86_64"
                settings.build_type = "Release"
                settings.compiler = "Visual Studio"
                settings.compiler.version = "15"
                settings.compiler.runtime = "MD"
                settings.compiler.toolset = "v141"
                conanfile.settings = settings

                generator = VisualStudioMultiGenerator(conanfile)
                generator.output_path = ""
                content = generator.content

                self.assertIn('conanbuildinfo_release_x64_v141.props', content.keys())

                content_release = content['conanbuildinfo_release_x64_v141.props']
                self.assertIn("<ConanLibraries>%s;</ConanLibraries>" % additional_dep,
                              content_release)
                self.assertIn("<AdditionalDependencies>"
                              "$(ConanLibraries)%(AdditionalDependencies)"
                              "</AdditionalDependencies>", content_release)
Exemple #5
0
 def test_settings_model(self):
     # First level setting 'cppstd' is no longer supported
     settings = Settings.loads(get_default_settings_yml())
     settings.cppstd = "11"
     with six.assertRaisesRegex(self, ConanV2Exception,
                                "Setting 'cppstd' is deprecated"):
         settings_preprocessor.preprocess(settings=settings)
Exemple #6
0
 def save_new():
     new_path = self.cache.settings_path + ".new"
     save(new_path, get_default_settings_yml())
     self.out.warn("*" * 40)
     self.out.warn("settings.yml is locally modified, can't be updated")
     self.out.warn("The new settings.yml has been stored in: %s" % new_path)
     self.out.warn("*" * 40)
 def test_windows_ce(self):
     settings = Settings.loads(get_default_settings_yml())
     settings.os = 'WindowsCE'
     settings.compiler = 'Visual Studio'
     settings.compiler.version = '15'
     settings.arch = 'armv4i'
     self.assert_vcvars_command(settings, "x86")
Exemple #8
0
def test_apple_cmake_osx_sysroot_sdk_mandatory(os, os_sdk, arch, expected_sdk):
    """
    Testing if CMAKE_OSX_SYSROOT is correctly set.
    Issue related: https://github.com/conan-io/conan/issues/10275
    """
    c = ConanFile(Mock(), None)
    c.settings = "os", "compiler", "build_type", "arch"
    c.initialize(Settings.loads(get_default_settings_yml()), EnvValues())
    c.settings.os = os
    c.settings.os.sdk = os_sdk
    c.settings.build_type = "Release"
    c.settings.arch = arch
    c.settings.compiler = "apple-clang"
    c.settings.compiler.version = "13.0"
    c.settings.compiler.libcxx = "libc++"
    c.settings.compiler.cppstd = "17"
    c.conf = Conf()
    c.folders.set_base_generators(".")
    c._conan_node = Mock()
    c._conan_node.dependencies = []

    with pytest.raises(ConanException) as excinfo:
        CMakeToolchain(c).content()
        assert "Please, specify a suitable value for os.sdk." % expected_sdk in str(
            excinfo.value)
Exemple #9
0
    def apple_frameworks_test(self):
        settings = Settings.loads(get_default_settings_yml())
        settings.compiler = "apple-clang"
        settings.os = "Macos"
        conanfile = ConanFile(TestBufferConanOutput(), None)
        conanfile.initialize(Settings({}), EnvValues())
        conanfile.settings = settings
        ref = ConanFileReference.loads("MyPkg/0.1@lasote/stables")
        cpp_info = CppInfo(ref.name, "/dummy_root_folder1")
        cpp_info.filter_empty = False
        cpp_info.frameworks = ['AudioUnit', 'AudioToolbox']
        cpp_info.version = "1.3"
        cpp_info.description = "My cool description"
        conanfile.deps_cpp_info.add(ref.name, cpp_info)

        generator = PkgConfigGenerator(conanfile)
        files = generator.content

        self.assertEqual(
            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} -Wl,-rpath,"${libdir}" -framework AudioUnit -framework AudioToolbox -F /dummy_root_folder1/Frameworks
Cflags: -I${includedir}
""")
Exemple #10
0
    def test_mac(self):
        install_dir = "/opt/intel"
        with mock.patch("platform.system", mock.MagicMock(return_value="Darwin")),\
            mock.patch("conans.client.tools.intel.intel_installation_path",
                       mock.MagicMock(return_value="/opt/intel")):
            settings = Settings.loads(get_default_settings_yml())
            settings.os = "Macos"
            settings.compiler = "intel"
            settings.compiler.base = "apple-clang"
            settings.arch = "ppc32"
            with self.assertRaises(ConanException):
                compilervars_command(MockConanfile(settings))

            path = os.path.join(install_dir, "bin", "compilervars.sh")

            settings.arch = "x86"
            cvars = compilervars_command(MockConanfile(settings))
            expected = 'COMPILERVARS_PLATFORM=mac COMPILERVARS_ARCHITECTURE=ia32 . ' \
                       '"%s" -arch ia32 -platform mac' % path
            self.assertEqual(expected, cvars)

            settings.arch = "x86_64"
            expected = 'COMPILERVARS_PLATFORM=mac COMPILERVARS_ARCHITECTURE=intel64 . ' \
                       '"%s" -arch intel64 -platform mac' % path
            cvars = compilervars_command(MockConanfile(settings))
            self.assertEqual(expected, cvars)
Exemple #11
0
def test_libcxx_abi_flag():
    c = ConanFile(Mock(), None)
    c.settings = "os", "compiler", "build_type", "arch"
    c.initialize(Settings.loads(get_default_settings_yml()), EnvValues())
    c.settings.build_type = "Release"
    c.settings.arch = "x86_64"
    c.settings.compiler = "gcc"
    c.settings.compiler.version = "11"
    c.settings.compiler.cppstd = "20"
    c.settings.compiler.libcxx = "libstdc++"
    c.settings.os = "Linux"
    c.conf = Conf()
    c.folders.set_base_generators(".")
    c._conan_node = Mock()
    c._conan_node.dependencies = []

    toolchain = CMakeToolchain(c)
    content = toolchain.content
    assert '_GLIBCXX_USE_CXX11_ABI=0' in content
    c.settings.compiler.libcxx = "libstdc++11"
    toolchain = CMakeToolchain(c)
    content = toolchain.content
    # by default, no flag is output anymore, it is assumed the compiler default
    assert 'GLIBCXX_USE_CXX11_ABI' not in content
    # recipe workaround for older distros
    toolchain.blocks["libcxx"].values["glibcxx"] = "1"
    content = toolchain.content
    assert '_GLIBCXX_USE_CXX11_ABI=1' in content

    # but maybe the conf is better
    c.conf["tools.gnu:define_libcxx11_abi"] = True
    toolchain = CMakeToolchain(c)
    content = toolchain.content
    assert '_GLIBCXX_USE_CXX11_ABI=1' in content
Exemple #12
0
def _detect_os_arch(result, output):
    from conans.client.conf import get_default_settings_yml
    from conans.model.settings import Settings

    the_os = detected_os()
    result.append(("os", the_os))
    result.append(("os_build", the_os))

    arch = detected_architecture()

    if arch:
        if arch.startswith('arm'):
            settings = Settings.loads(get_default_settings_yml())
            defined_architectures = settings.arch.values_range
            defined_arm_architectures = [
                v for v in defined_architectures if v.startswith("arm")
            ]

            for a in defined_arm_architectures:
                if arch.startswith(a):
                    arch = a
                    break
            else:
                output.error(
                    "Your ARM '%s' architecture is probably not defined in settings.yml\n"
                    "Please check your conan.conf and settings.yml files" %
                    arch)

        result.append(("arch", arch))
        result.append(("arch_build", arch))
Exemple #13
0
    def test_win(self):
        install_dir = "C:\\Intel"
        with mock.patch("platform.system", mock.MagicMock(return_value="Windows")),\
            mock.patch("conans.client.tools.intel.intel_installation_path",
                       mock.MagicMock(return_value=install_dir)):
            settings = Settings.loads(get_default_settings_yml())
            settings.os = "Windows"
            settings.compiler = "intel"
            settings.compiler.base = "Visual Studio"
            settings.arch = "ppc32"
            with self.assertRaises(ConanException):
                compilervars_command(MockConanfile(settings))

            path = os.path.join(install_dir, "bin", "compilervars.bat")

            settings.arch = "x86"
            cvars = compilervars_command(MockConanfile(settings))
            expected = '"%s" -arch ia32' % path
            self.assertEqual(expected, cvars)

            settings.compiler.base.version = "16"
            cvars = compilervars_command(MockConanfile(settings))
            expected = '"%s" -arch ia32 vs2019' % path
            self.assertEqual(expected, cvars)

            settings.arch = "x86_64"
            expected = '"%s" -arch intel64 vs2019' % path
            cvars = compilervars_command(MockConanfile(settings))
            self.assertEqual(expected, cvars)
Exemple #14
0
    def setUp(self):
        self.test_folder = temp_folder()
        self.layout_filepath = os.path.join(self.test_folder, "layout")
        self.editable_cpp_info = EditableLayout(self.layout_filepath)

        self.settings = Settings.loads(get_default_settings_yml())
        self.options = Options(PackageOptions({"shared": [True, False]}))
    def test_arch(self):
        settings = Settings.loads(get_default_settings_yml())
        settings.compiler = 'Visual Studio'
        settings.compiler.version = '14'

        settings.arch = 'x86'
        self.assert_vcvars_command(settings, "x86")
        with environment_append({"PreferredToolArchitecture": "x64"}):
            self.assert_vcvars_command(settings, "amd64_x86")

        settings.arch = 'x86_64'
        self.assert_vcvars_command(settings, "amd64")

        settings.arch = 'armv7'
        self.assert_vcvars_command(settings, "amd64_arm")

        settings.arch = 'armv8'
        self.assert_vcvars_command(settings, "amd64_arm64")

        settings.arch = 'mips'
        with self.assertRaises(ConanException):
            tools.vcvars_command(settings, output=self.output)

        settings.arch_build = 'x86_64'
        settings.arch = 'x86'
        self.assert_vcvars_command(settings, "amd64_x86")
Exemple #16
0
    def test_compiler_args(self):
        settings = Settings.loads(get_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.assertEqual(
            '-Dmydefine1 -I\\root\\include -I\\root\\path\\to\\include1'
            ' cxx_flag1 c_flag1 -O2 -Ob2 -DNDEBUG -link'
            ' -LIBPATH:\\root\\lib -LIBPATH:\\root\\path\\to\\lib1 mylib.lib',
            gen.content)

        settings = Settings.loads(get_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.assertEqual(
            '-Dmydefine1 -I/root/include -I/root/path/to/include1'
            ' cxx_flag1 c_flag1 -m32 -O3 -DNDEBUG'
            ' -Wl,-rpath,"/root/lib" -Wl,-rpath,"/root/path/to/lib1"'
            ' -L/root/lib -L/root/path/to/lib1 -lmylib'
            ' -F /root/Frameworks', gen.content)

        settings = Settings.loads(get_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.assertEqual(
            '-Dmydefine1 -I/root/include -I/root/path/to/include1'
            ' cxx_flag1 c_flag1 -m32 -O3 -DNDEBUG'
            ' -Wl,-rpath,"/root/lib" -Wl,-rpath,"/root/path/to/lib1"'
            ' -L/root/lib -L/root/path/to/lib1 -lmylib'
            ' -F /root/Frameworks', args.content)
Exemple #17
0
 def get_client(use_settings_v1=False, *args, **kwargs):
     # TODO: Initialize with the default behavior for Conan v2
     t = TestClient(*args, **kwargs)
     if use_settings_v1:
         t.save({
             os.path.join(t.cache_folder, CONAN_SETTINGS):
             get_default_settings_yml(force_v1=True)
         })
     return t
Exemple #18
0
    def test_no_version(self):
        settings = Settings.loads(get_default_settings_yml())
        settings.compiler = 'clang'
        settings.arch = 'x86_64'
        settings.os = 'Windows'

        command = vcvars_command(settings, output=self.output)
        self.assertIn('vcvarsall.bat', command)
        self.assertIn('amd64', command)
Exemple #19
0
    def test_migrations_matches_config(self):
        # Check that the current settings matches what is stored in the migrations file
        current_settings = get_default_settings_yml()
        v = Version(__version__)
        var_name = "settings_{}".format("_".join([v.major, v.minor, v.patch]))

        self.assertTrue(hasattr(migrations_settings, var_name),
                        "Migrations var '{}' not found".format(var_name))
        migrations_settings_content = getattr(migrations_settings, var_name)
        assert current_settings == migrations_settings_content
Exemple #20
0
    def test_simple(self):
        settings = Settings.loads(get_default_settings_yml())
        settings.compiler = 'clang'
        settings.compiler.version = '5.0'
        settings.arch = 'x86'
        settings.os = 'Windows'

        command = vcvars_command(settings, output=self.output)
        self.assertIn('vcvarsall.bat', command)
        self.assertIn('x86', command)
Exemple #21
0
    def test_no_msvc(self):
        settings = Settings.loads(get_default_settings_yml())
        settings.compiler = 'clang'
        settings.arch = 'x86_64'
        settings.os = 'Windows'

        with mock.patch('conans.client.tools.win.latest_vs_version_installed',
                        mock.MagicMock(return_value=None)):
            with self.assertRaises(ConanException):
                vcvars_command(settings, output=self.output)
Exemple #22
0
    def test_msvc_build_command(self):
        settings = Settings.loads(get_default_settings_yml())
        settings.os = "Windows"
        settings.compiler = "Visual Studio"
        settings.compiler.version = "14"

        # test build_type and arch override, for multi-config packages
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            cmd = tools.msvc_build_command(settings,
                                           "project.sln",
                                           build_type="Debug",
                                           arch="x86",
                                           output=self.output)
            self.assertEqual(len(w), 3)
            self.assertTrue(issubclass(w[0].category, DeprecationWarning))
        self.assertIn(
            'msbuild "project.sln" /p:Configuration="Debug" '
            '/p:UseEnv=false /p:Platform="x86"', cmd)
        self.assertIn('vcvarsall.bat', cmd)

        # tests errors if args not defined
        with six.assertRaisesRegex(self, ConanException,
                                   "Cannot build_sln_command"):
            with warnings.catch_warnings(record=True) as w:
                warnings.simplefilter("always")
                tools.msvc_build_command(settings,
                                         "project.sln",
                                         output=self.output)
                self.assertEqual(len(w), 2)
                self.assertTrue(issubclass(w[0].category, DeprecationWarning))
        settings.arch = "x86"
        with six.assertRaisesRegex(self, ConanException,
                                   "Cannot build_sln_command"):
            with warnings.catch_warnings(record=True) as w:
                warnings.simplefilter("always")
                tools.msvc_build_command(settings,
                                         "project.sln",
                                         output=self.output)
                self.assertEqual(len(w), 2)
                self.assertTrue(issubclass(w[0].category, DeprecationWarning))

        # successful definition via settings
        settings.build_type = "Debug"
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            cmd = tools.msvc_build_command(settings,
                                           "project.sln",
                                           output=self.output)
            self.assertEqual(len(w), 3)
            self.assertTrue(issubclass(w[0].category, DeprecationWarning))
        self.assertIn(
            'msbuild "project.sln" /p:Configuration="Debug" '
            '/p:UseEnv=false /p:Platform="x86"', cmd)
        self.assertIn('vcvarsall.bat', cmd)
Exemple #23
0
    def test_gcc(self):
        settings = Settings.loads(get_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.assertEqual(
            '-Dmydefine1 -I/root/include -I/root/path/to/include1'
            ' cxx_flag1 c_flag1 -m32 -O3 -s -DNDEBUG'
            ' -Wl,-rpath,"/root/lib" -Wl,-rpath,"/root/path/to/lib1"'
            ' -L/root/lib -L/root/path/to/lib1 -lmylib'
            ' -F /root/Frameworks -std=gnu++17', gcc.content)

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

        gcc = GCCGenerator(conan_file)
        self.assertEqual(
            '-Dmydefine1 -I/root/include -I/root/path/to/include1'
            ' cxx_flag1 c_flag1 -m64 -g'
            ' -Wl,-rpath,"/root/lib" -Wl,-rpath,"/root/path/to/lib1"'
            ' -L/root/lib -L/root/path/to/lib1 -lmylib'
            ' -D_GLIBCXX_USE_CXX11_ABI=1 -F /root/Frameworks -std=gnu++17',
            gcc.content)

        settings.compiler.libcxx = "libstdc++"
        gcc = GCCGenerator(conan_file)
        self.assertEqual(
            '-Dmydefine1 -I/root/include -I/root/path/to/include1'
            ' cxx_flag1 c_flag1 -m64 -g'
            ' -Wl,-rpath,"/root/lib" -Wl,-rpath,"/root/path/to/lib1"'
            ' -L/root/lib -L/root/path/to/lib1 -lmylib'
            ' -D_GLIBCXX_USE_CXX11_ABI=0 -F /root/Frameworks -std=gnu++17',
            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.assertEqual(
            '-Dmydefine1 -I/root/include -I/root/path/to/include1'
            ' cxx_flag1 c_flag1 -m32 -O3 -s -DNDEBUG'
            ' -Wl,-rpath,"/root/lib" -Wl,-rpath,"/root/path/to/lib1"'
            ' -L/root/lib -L/root/path/to/lib1 -lmylib'
            ' -D_GLIBCXX_USE_CXX11_ABI=0 -F /root/Frameworks -std=gnu++17',
            gcc.content)
Exemple #24
0
 def test_settings_model(self, use_settings_v1):
     # First level setting 'cppstd' is no longer supported
     settings = Settings.loads(get_default_settings_yml(force_v1=use_settings_v1))
     if use_settings_v1:
         settings.cppstd = "11"
         with six.assertRaisesRegex(self, ConanV2Exception, "Setting 'cppstd' is deprecated"):
             settings_preprocessor.preprocess(settings=settings)
     else:
         with six.assertRaisesRegex(self, ConanException, "'settings.cppstd' doesn't exist"):
             settings.cppstd = "11"
             settings_preprocessor.preprocess(settings=settings)
 def test_incompatible(self, initial_version, toolset):
     info = ConanInfo()
     settings = Settings.loads(get_default_settings_yml())
     info.settings = settings
     settings.compiler = "Visual Studio"
     settings.compiler.toolset = toolset
     settings.compiler.version = initial_version
     info.full_settings = info.settings
     info.vs_toolset_compatible()
     self.assertEqual(info.settings.compiler.version, initial_version)
     self.assertEqual(info.settings.compiler.toolset, toolset)
Exemple #26
0
 def test_vcvars_with_store_echo(self):
     settings = Settings.loads(get_default_settings_yml())
     settings.os = "WindowsStore"
     settings.os.version = "8.1"
     settings.compiler = "Visual Studio"
     settings.compiler.version = "14"
     cmd = tools.vcvars_command(settings, output=self.output)
     self.assertIn("store 8.1", cmd)
     with tools.environment_append({"VisualStudioVersion": "14"}):
         cmd = tools.vcvars_command(settings, output=self.output)
         self.assertEqual("echo Conan:vcvars already set", cmd)
Exemple #27
0
    def system_libs_test(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 -Ipath/to/include1 cxx_flag1 c_flag1 -m64 -O3 -s -DNDEBUG '
                         '-Wl,-rpath="path/to/lib1" -Lpath/to/lib1 -lmylib -lsystem_lib1',
                         args.content)
    def test_arch_override(self):
        settings = Settings.loads(get_default_settings_yml())
        settings.compiler = 'Visual Studio'
        settings.compiler.version = '14'
        settings.arch = 'mips64'

        self.assert_vcvars_command(settings, "x86", arch='x86')
        self.assert_vcvars_command(settings, "amd64", arch='x86_64')
        self.assert_vcvars_command(settings, "amd64_arm", arch='armv7')
        self.assert_vcvars_command(settings, "amd64_arm64", arch='armv8')

        with self.assertRaises(ConanException):
            tools.vcvars_command(settings, arch='mips', output=self.output)
Exemple #29
0
    def test_81(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 = '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)
Exemple #30
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.arch = "x86_64"
        settings.build_type = "Release"

        conan_file = self._get_conanfile(settings, frameworks=True)
        args = CompilerArgsGenerator(conan_file)
        self.assertEqual('-Dmydefine1 -Ipath/to/include1 cxx_flag1 c_flag1 -m64 -O3 -DNDEBUG '
                         '-Wl,-rpath,"path/to/lib1" -Lpath/to/lib1 -lmylib '
                         '-framework AVFoundation -framework VideoToolbox '
                         '-F path/to/Frameworks1 -F path/to/Frameworks2', args.content)