Exemplo n.º 1
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))
Exemplo n.º 2
0
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
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
 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)
Exemplo n.º 6
0
 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)
Exemplo n.º 7
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)
Exemplo n.º 8
0
 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)
Exemplo n.º 9
0
 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)
Exemplo n.º 10
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)
Exemplo n.º 11
0
 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)
Exemplo n.º 12
0
    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")
Exemplo n.º 13
0
Arquivo: win.py Projeto: 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
Exemplo n.º 14
0
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
Exemplo n.º 15
0
 def error_targets_argument_Test(self):
     conanfile = MockConanfile(MockSettings({}))
     msbuild = MSBuild(conanfile)
     with self.assertRaises(TypeError):
         msbuild.get_command("dummy.sln", targets="sometarget")