Пример #1
0
    def test_skip_toolset(self):
        settings = MockSettings({"build_type": "Debug",
                                 "compiler": "Visual Studio",
                                 "compiler.version": "15",
                                 "arch": "x86_64"})

        class Runner(object):

            def __init__(self):
                self.commands = []

            def __call__(self, *args, **kwargs):
                self.commands.append(args[0])

        with chdir(tools.mkdir_tmp()):
            runner = Runner()
            conanfile = MockConanfile(settings, runner=runner)
            msbuild = MSBuild(conanfile)
            msbuild.build("myproject", toolset=False)
            self.assertEqual(len(runner.commands), 1)
            self.assertNotIn("PlatformToolset", runner.commands[0])

            runner = Runner()
            conanfile = MockConanfile(settings, runner=runner)
            msbuild = MSBuild(conanfile)
            msbuild.build("myproject", toolset="mytoolset")
            self.assertEqual(len(runner.commands), 1)
            self.assertIn('/p:PlatformToolset="mytoolset"', runner.commands[0])
Пример #2
0
    def test_arch_override(self):
        settings = MockSettings({"build_type": "Release",
                                 "compiler": "Visual Studio",
                                 "compiler.version": "15",
                                 "compiler.runtime": "MDd",
                                 "os": "Windows",
                                 "arch": "x86_64"})
        conanfile = ConanFileMock()
        conanfile.settings = settings
        props_file_path = os.path.join(temp_folder(), "conan_build.props")

        msbuild = MSBuild(conanfile)
        msbuild.build("project_file.sln", property_file_name=props_file_path)
        self.assertIn("vcvarsall.bat\" amd64", conanfile.command)
        self.assertIn("/p:Platform=\"x64\"", conanfile.command)
        msbuild.build("project_file.sln", arch="x86", property_file_name=props_file_path)
        self.assertIn("vcvarsall.bat\" x86", conanfile.command)
        self.assertIn("/p:Platform=\"x86\"", conanfile.command)