コード例 #1
0
ファイル: win.py プロジェクト: ttencate/conan
def build_sln_command(settings, sln_path, targets=None, upgrade_project=True, build_type=None,
                      arch=None, parallel=True, toolset=None, platforms=None, output=None,
                      verbosity=None, definitions=None):
    """
    Use example:
        build_command = build_sln_command(self.settings, "myfile.sln", targets=["SDL2_image"])
        command = "%s && %s" % (tools.vcvars_command(self.settings), build_command)
        self.run(command)
    """
    conan_v2_behavior("'tools.build_sln_command' is deprecated, use 'MSBuild()' helper instead")
    from conans.client.build.msbuild import MSBuild
    tmp = MSBuild(settings)
    output = default_output(output, fn_name='conans.client.tools.win.build_sln_command')
    tmp._output = output

    # Generate the properties file
    props_file_contents = tmp._get_props_file_contents(definitions)
    tmp_path = os.path.join(mkdir_tmp(), ".conan_properties")
    save(tmp_path, props_file_contents)

    # Build command
    command = tmp.get_command(sln_path, tmp_path,
                              targets=targets, upgrade_project=upgrade_project,
                              build_type=build_type, arch=arch, parallel=parallel,
                              toolset=toolset, platforms=platforms, use_env=False,
                              verbosity=verbosity)

    return command
コード例 #2
0
ファイル: msbuild_test.py プロジェクト: mingzhizhiren/conan
 def verbosity_explicit_test(self):
     settings = MockSettings({"build_type": "Debug",
                              "compiler": "Visual Studio",
                              "arch": "x86_64"})
     conanfile = MockConanfile(settings)
     msbuild = MSBuild(conanfile)
     command = msbuild.get_command("projecshould_flags_testt_file.sln", verbosity="quiet")
     self.assertIn('/verbosity:quiet', command)
コード例 #3
0
ファイル: msbuild_test.py プロジェクト: ericLemanissier/conan
 def test_verbosity_default(self):
     settings = MockSettings({"build_type": "Debug",
                              "compiler": "Visual Studio",
                              "arch": "x86_64"})
     conanfile = MockConanfile(settings)
     msbuild = MSBuild(conanfile)
     command = msbuild.get_command("projecshould_flags_testt_file.sln")
     self.assertIn('/verbosity:minimal', command)
コード例 #4
0
ファイル: msbuild_test.py プロジェクト: mingzhizhiren/conan
 def without_runtime_test(self):
     settings = MockSettings({"build_type": "Debug",
                              "compiler": "Visual Studio",
                              "arch": "x86_64"})
     conanfile = MockConanfile(settings)
     msbuild = MSBuild(conanfile)
     template = msbuild._get_props_file_contents()
     self.assertNotIn("<RuntimeLibrary>", template)
コード例 #5
0
ファイル: msbuild_test.py プロジェクト: mingzhizhiren/conan
 def verbosity_env_test(self):
     settings = MockSettings({"build_type": "Debug",
                              "compiler": "Visual Studio",
                              "arch": "x86_64"})
     with tools.environment_append({"CONAN_MSBUILD_VERBOSITY": "detailed"}):
         conanfile = MockConanfile(settings)
         msbuild = MSBuild(conanfile)
         command = msbuild.get_command("projecshould_flags_testt_file.sln")
         self.assertIn('/verbosity:detailed', command)
コード例 #6
0
ファイル: msbuild_test.py プロジェクト: mingzhizhiren/conan
 def explicit_toolset_test(self, expected_toolset):
     settings = MockSettings({"build_type": "Debug",
                              "compiler": "Visual Studio",
                              "compiler.version": "15",
                              "arch": "x86_64"})
     conanfile = MockConanfile(settings)
     msbuild = MSBuild(conanfile)
     command = msbuild.get_command("project_should_flags_test_file.sln", toolset=expected_toolset)
     self.assertIn('/p:PlatformToolset="%s"' % expected_toolset, command)
コード例 #7
0
ファイル: msbuild_test.py プロジェクト: mingzhizhiren/conan
 def custom_properties_test(self):
     settings = MockSettings({"build_type": "Debug",
                              "compiler": "Visual Studio",
                              "arch": "x86_64"})
     conanfile = MockConanfile(settings)
     msbuild = MSBuild(conanfile)
     command = msbuild.get_command("project_file.sln", properties={"MyProp1": "MyValue1",
                                                                   "MyProp2": "MyValue2"})
     self.assertIn('/p:MyProp1="MyValue1"', command)
     self.assertIn('/p:MyProp2="MyValue2"', command)
コード例 #8
0
 def test_binary_logging_on(self):
     settings = MockSettings({"build_type": "Debug",
                              "compiler": "Visual Studio",
                              "compiler.version": "15",
                              "arch": "x86_64",
                              "compiler.runtime": "MDd"})
     conanfile = MockConanfile(settings)
     msbuild = MSBuild(conanfile)
     command = msbuild.get_command("dummy.sln", output_binary_log=True)
     self.assertIn("/bl", command)
コード例 #9
0
ファイル: msbuild_test.py プロジェクト: ericLemanissier/conan
 def test_skip_only_none_definitions(self):
     # https://github.com/conan-io/conan/issues/6728
     settings = MockSettings({"build_type": "Debug",
                              "compiler": "Visual Studio",
                              "arch": "x86_64",
                              "compiler.runtime": "MDd"})
     conanfile = MockConanfile(settings)
     msbuild = MSBuild(conanfile)
     template = msbuild._get_props_file_contents(definitions={"foo": 0, "bar": False})
     self.assertIn("<PreprocessorDefinitions>foo=0;bar=False;%(PreprocessorDefinitions)",
                   template)
コード例 #10
0
ファイル: msbuild_test.py プロジェクト: ericLemanissier/conan
 def test_windows_ce(self):
     settings = MockSettings({"build_type": "Debug",
                              "compiler": "Visual Studio",
                              "compiler.version": "9",
                              "os": "WindowsCE",
                              "os.platform": "YOUR PLATFORM SDK (ARMV4)",
                              "arch": "armv4"})
     conanfile = MockConanfile(settings)
     msbuild = MSBuild(conanfile)
     command = msbuild.get_command("test.sln")
     self.assertIn('/p:Platform="YOUR PLATFORM SDK (ARMV4)"', command)
コード例 #11
0
ファイル: msbuild_test.py プロジェクト: ericLemanissier/conan
    def test_definitions(self):
        settings = MockSettings({"build_type": "Debug",
                                 "compiler": "Visual Studio",
                                 "arch": "x86_64",
                                 "compiler.runtime": "MDd"})
        conanfile = MockConanfile(settings)
        msbuild = MSBuild(conanfile)
        template = msbuild._get_props_file_contents(definitions={'_WIN32_WINNT': "0x0501"})

        self.assertIn("<PreprocessorDefinitions>"
                      "_WIN32_WINNT=0x0501;"
                      "%(PreprocessorDefinitions)</PreprocessorDefinitions>", template)
コード例 #12
0
 def test_binary_logging_on_with_filename(self):
     bl_filename = "a_special_log.log"
     settings = MockSettings({"build_type": "Debug",
                              "compiler": "Visual Studio",
                              "compiler.version": "15",
                              "arch": "x86_64",
                              "compiler.runtime": "MDd"})
     conanfile = MockConanfile(settings)
     msbuild = MSBuild(conanfile)
     command = msbuild.get_command("dummy.sln", output_binary_log=bl_filename)
     expected_command = '/bl:"%s"' % bl_filename
     self.assertIn(expected_command, command)
コード例 #13
0
ファイル: msbuild_test.py プロジェクト: ericLemanissier/conan
 def test_intel(self):
     settings = MockSettings({"build_type": "Debug",
                              "compiler": "intel",
                              "compiler.version": "19.1",
                              "compiler.base": "Visual Studio",
                              "compiler.base.version": "15",
                              "arch": "x86_64"})
     expected_toolset = "Intel C++ Compiler 19.1"
     conanfile = MockConanfile(settings)
     msbuild = MSBuild(conanfile)
     command = msbuild.get_command("project_should_flags_test_file.sln")
     self.assertIn('/p:PlatformToolset="%s"' % expected_toolset, command)
コード例 #14
0
ファイル: msbuild_test.py プロジェクト: mingzhizhiren/conan
    def definitions_no_value_test(self):
        settings = MockSettings({"build_type": "Debug",
                                 "compiler": "Visual Studio",
                                 "arch": "x86_64",
                                 "compiler.runtime": "MDd"})
        conanfile = MockConanfile(settings)
        msbuild = MSBuild(conanfile)
        template = msbuild._get_props_file_contents(definitions={'_DEBUG': None})

        self.assertIn("<PreprocessorDefinitions>"
                      "_DEBUG;"
                      "%(PreprocessorDefinitions)</PreprocessorDefinitions>", template)
コード例 #15
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])
コード例 #16
0
    def test_binary_logging_not_supported(self, mock_get_version):
        mock_get_version.return_value = Version("14")

        mocked_settings = MockSettings({"build_type": "Debug",
                                        "compiler": "Visual Studio",
                                        "compiler.version": "15",
                                        "arch": "x86_64",
                                        "compiler.runtime": "MDd"})
        conanfile = MockConanfile(mocked_settings)
        except_text = "MSBuild version detected (14) does not support 'output_binary_log' ('/bl')"
        msbuild = MSBuild(conanfile)

        with self.assertRaises(ConanException) as exc:
            msbuild.get_command("dummy.sln", output_binary_log=True)
        self.assertIn(except_text, str(exc.exception))
コード例 #17
0
ファイル: msbuild_test.py プロジェクト: mingzhizhiren/conan
    def properties_injection_test(self):
        # https://github.com/conan-io/conan/issues/4471
        settings = MockSettings({"build_type": "Debug",
                                 "compiler": "Visual Studio",
                                 "arch": "x86_64"})
        conanfile = MockConanfile(settings)
        msbuild = MSBuild(conanfile)
        command = msbuild.get_command("dummy.sln", props_file_path="conan_build.props")

        match = re.search('/p:ForceImportBeforeCppTargets="(.+?)"', command)
        self.assertTrue(
            match, "Haven't been able to find the ForceImportBeforeCppTargets")

        props_file_path = match.group(1)
        self.assertTrue(os.path.isabs(props_file_path))
        self.assertEquals(os.path.basename(props_file_path), "conan_build.props")
コード例 #18
0
    def dont_mess_with_build_type_test(self):
        settings = MockSettings({"build_type": "Debug",
                                 "compiler": "Visual Studio",
                                 "arch": "x86_64"})
        conanfile = MockConanfile(settings)
        msbuild = MSBuild(conanfile)
        self.assertEquals(msbuild.build_env.flags, ["-Zi", "-Ob0", "-Od"])
        template = msbuild._get_props_file_contents()

        self.assertIn("-Ob0", template)
        self.assertIn("-Od", template)

        msbuild.build_env.flags = ["-Zi"]
        template = msbuild._get_props_file_contents()

        self.assertNotIn("-Ob0", template)
        self.assertNotIn("-Od", template)
コード例 #19
0
 def test_get_version(self):
     settings = MockSettings({"build_type": "Debug",
                              "compiler": "Visual Studio",
                              "compiler.version": "15",
                              "arch": "x86_64",
                              "compiler.runtime": "MDd"})
     version = MSBuild.get_version(settings)
     six.assertRegex(self, version, r"(\d+\.){2,3}\d+")
     self.assertGreater(version, "15.1")
コード例 #20
0
ファイル: msbuild_test.py プロジェクト: ericLemanissier/conan
    def test_dont_mess_with_build_type(self):
        settings = MockSettings({"build_type": "Debug",
                                 "compiler": "Visual Studio",
                                 "arch": "x86_64",
                                 "compiler.runtime": "MDd"})
        conanfile = MockConanfile(settings)
        msbuild = MSBuild(conanfile)
        self.assertEqual(msbuild.build_env.flags, [])
        template = msbuild._get_props_file_contents()

        self.assertNotIn("-Ob0", template)
        self.assertNotIn("-Od", template)

        msbuild.build_env.flags = ["-Zi"]
        template = msbuild._get_props_file_contents()

        self.assertNotIn("-Ob0", template)
        self.assertNotIn("-Od", template)
        self.assertIn("-Zi", template)
        self.assertIn("<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>", template)
コード例 #21
0
ファイル: win.py プロジェクト: wdobbe/conan
def build_sln_command(settings,
                      sln_path,
                      targets=None,
                      upgrade_project=True,
                      build_type=None,
                      arch=None,
                      parallel=True,
                      toolset=None,
                      platforms=None):
    """
    Use example:
        build_command = build_sln_command(self.settings, "myfile.sln", targets=["SDL2_image"])
        command = "%s && %s" % (tools.vcvars_command(self.settings), build_command)
        self.run(command)
    """
    from conans.client.build.msbuild import MSBuild
    tmp = MSBuild(settings)
    tmp._output = _global_output

    # Generate the properties file
    props_file_contents = tmp._get_props_file_contents()
    tmp_path = os.path.join(mkdir_tmp(), ".conan_properties")
    save(tmp_path, props_file_contents)

    # Build command
    command = tmp.get_command(sln_path,
                              tmp_path,
                              targets=targets,
                              upgrade_project=upgrade_project,
                              build_type=build_type,
                              arch=arch,
                              parallel=parallel,
                              toolset=toolset,
                              platforms=platforms,
                              use_env=False)

    return command
コード例 #22
0
ファイル: win.py プロジェクト: 19317362/conan
def build_sln_command(settings, sln_path, targets=None, upgrade_project=True, build_type=None,
                      arch=None, parallel=True, toolset=None, platforms=None):
    """
    Use example:
        build_command = build_sln_command(self.settings, "myfile.sln", targets=["SDL2_image"])
        command = "%s && %s" % (tools.vcvars_command(self.settings), build_command)
        self.run(command)
    """
    from conans.client.build.msbuild import MSBuild
    tmp = MSBuild(settings)
    tmp._output = _global_output

    # Generate the properties file
    props_file_contents = tmp._get_props_file_contents()
    tmp_path = os.path.join(mkdir_tmp(), ".conan_properties")
    save(tmp_path, props_file_contents)

    # Build command
    command = tmp.get_command(sln_path, tmp_path,
                              targets=targets, upgrade_project=upgrade_project,
                              build_type=build_type, arch=arch, parallel=parallel,
                              toolset=toolset, platforms=platforms, use_env=False)

    return command
コード例 #23
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)
コード例 #24
0
 def error_targets_argument_Test(self):
     conanfile = MockConanfile(MockSettings({}))
     msbuild = MSBuild(conanfile)
     with self.assertRaises(TypeError):
         msbuild.get_command("dummy.sln", targets="sometarget")