Ejemplo n.º 1
0
    def no_configuration_test(self):
        dummy = """GlobalSection
            EndGlobalSection
     GlobalSection(SolutionConfigurationPlatforms) = preSolution
        Debug|Win32 = Debug|Win32
        Debug|x64 = Debug|x64
        Release|Win32 = Release|Win32
        Release|x64 = Release|x64
    EndGlobalSection
"""
        folder = temp_folder()
        path = os.path.join(folder, "dummy.sln")
        save(path, dummy)
        new_out = StringIO()
        tools.set_global_instances(ConanOutput(new_out), None)
        command = build_sln_command(Settings({}), sln_path=path, targets=None, upgrade_project=False,
                                    build_type='Debug', arch="x86", parallel=False)
        self.assertIn('/p:Configuration=Debug /p:Platform="x86"', command)
        self.assertIn("WARN: ***** The configuration Debug|x86 does not exist in this solution *****",
                      new_out.getvalue())
        # use platforms
        new_out = StringIO()
        tools.set_global_instances(ConanOutput(new_out), None)
        command = build_sln_command(Settings({}), sln_path=path, targets=None, upgrade_project=False,
                                    build_type='Debug', arch="x86", parallel=False, platforms={"x86": "Win32"})
        self.assertIn('/p:Configuration=Debug /p:Platform="Win32"', command)
        self.assertNotIn("WARN", new_out.getvalue())
        self.assertNotIn("ERROR", new_out.getvalue())
Ejemplo n.º 2
0
 def no_build_type_test(self):
     with self.assertRaises(ConanException):
         build_sln_command(Settings({}),
                           sln_path='dummy.sln',
                           targets=None,
                           upgrade_project=False,
                           build_type=None,
                           arch='x86',
                           parallel=False)
Ejemplo n.º 3
0
    def build(self):
        if self.settings.os == "Windows" and self.version == "master":
            raise ConanException("Trunk builds are not supported on Windows (cannot build directly from master git repository).")

        if self.settings.compiler == "Visual Studio":
            env = VisualStudioBuildEnvironment(self)
            with tools.environment_append(env.vars):
                version = min(12, int(self.settings.compiler.version.value))
                version = 10 if version == 11 else version
                cd_build = "cd %s\\%s\\build\\vc%s" % (self.conanfile_directory, self.source_directory, version)
                build_command = build_sln_command(self.settings, "glew.sln")
                vcvars = vcvars_command(self.settings)
                self.run("%s && %s && %s" % (vcvars, cd_build, build_command.replace("x86", "Win32")))
        else:
            if self.settings.os == "Windows":
                replace_in_file("%s/build/cmake/CMakeLists.txt" % self.source_directory, \
                                "if(WIN32 AND (NOT MSVC_VERSION LESS 1600)", \
                                "if(WIN32 AND MSVC AND (NOT MSVC_VERSION LESS 1600)")

            if self.version == "master":
                self.run("make extensions")

            cmake = CMake(self)
            cmake.configure(source_dir="%s/build/cmake" % self.source_directory, defs={"BUILD_UTILS": "OFF"})
            cmake.build()
Ejemplo n.º 4
0
 def properties_file_test(self):
     command = build_sln_command(MockSettings({
         "compiler": "Visual Studio",
         "compiler.version": "17",
         "build_type": "Debug",
         "compiler.runtime": "MDd",
         "cppstd": "17"
     }),
                                 sln_path='dummy.sln',
                                 targets=None,
                                 upgrade_project=False,
                                 build_type='Debug',
                                 arch='armv7',
                                 parallel=False)
     self.assertTrue(
         command.startswith('msbuild "dummy.sln" /p:Configuration="Debug" '
                            '/p:Platform="ARM" '
                            '/p:ForceImportBeforeCppTargets='), command)
     path_tmp = command.split("/p:ForceImportBeforeCppTargets=")[1][
         1:-1]  # remove quotes
     self.assertTrue(os.path.exists(path_tmp))
     contents = load(path_tmp)
     self.assertIn("<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>",
                   contents)
     self.assertIn(
         "<AdditionalOptions>/std:c++17 %(AdditionalOptions)</AdditionalOptions>",
         contents)
Ejemplo n.º 5
0
    def build(self):
        if self.settings.os == "Windows" and self.version == "master":
            raise ConanException(
                "Trunk builds are not supported on Windows (cannot build directly from master git repository)."
            )

        if self.settings.compiler == "Visual Studio":
            env = VisualStudioBuildEnvironment(self)
            with tools.environment_append(env.vars):
                version = min(12, int(self.settings.compiler.version.value))
                version = 10 if version == 11 else version
                cd_build = "cd %s\\%s\\build\\vc%s" % (
                    self.conanfile_directory, self.source_directory, version)
                build_command = build_sln_command(self.settings, "glew.sln")
                vcvars = vcvars_command(self.settings)
                self.run(
                    "%s && %s && %s" %
                    (vcvars, cd_build, build_command.replace("x86", "Win32")))
        else:
            if self.settings.os == "Windows":
                replace_in_file("%s/build/cmake/CMakeLists.txt" % self.source_directory, \
                                "if(WIN32 AND (NOT MSVC_VERSION LESS 1600)", \
                                "if(WIN32 AND MSVC AND (NOT MSVC_VERSION LESS 1600)")

            if self.version == "master":
                self.run("make extensions")

            cmake = CMake(self)
            cmake.configure(source_dir="%s/build/cmake" %
                            self.source_directory,
                            defs={"BUILD_UTILS": "OFF"})
            cmake.build()
Ejemplo n.º 6
0
    def build(self):
        if self.settings.os == "Windows" and self.version == "master":
            raise ConanException(
                "Trunk builds are not supported on Windows (cannot build directly from master git repository)."
            )

        if self.settings.compiler == "Visual Studio":
            env = VisualStudioBuildEnvironment(self)
            with tools.environment_append(env.vars):
                version = min(12, int(self.settings.compiler.version.value))
                version = 10 if version == 11 else version
                cd_build = "cd %s\\%s\\build\\vc%s" % (
                    self.conanfile_directory, self.source_directory, version)
                build_command = build_sln_command(self.settings, "glew.sln")
                vcvars = vcvars_command(self.settings)
                self.run(
                    "%s && %s && %s" %
                    (vcvars, cd_build, build_command.replace("x86", "Win32")))
        else:
            if self.version == "master":
                self.run("make extensions")

            replace_in_file(
                "%s/build/cmake/CMakeLists.txt" % self.source_directory,
                "include(GNUInstallDirs)", """
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
include(GNUInstallDirs)
""")
            cmake = CMake(self)
            cmake.configure(source_dir="%s/build/cmake" %
                            self.source_directory,
                            defs={"BUILD_UTILS": "OFF"})
            cmake.build()
Ejemplo n.º 7
0
 def parallel_test(self):
     command = build_sln_command(Settings({}), sln_path='dummy.sln', targets=None, upgrade_project=True,
                                 build_type='Debug', arch='armv7', parallel=False)
     self.assertIn('msbuild "dummy.sln"', command)
     self.assertIn('/p:Platform="ARM"', command)
     self.assertIn('devenv "dummy.sln" /upgrade', command)
     self.assertNotIn('/m:%s' % cpu_count(), command)
     self.assertNotIn('/target:teapot', command)
Ejemplo n.º 8
0
 def target_test(self):
     command = build_sln_command(Settings({}), sln_path='dummy.sln', targets=['teapot'], upgrade_project=False,
                                 build_type='Debug', arch='x86', parallel=False)
     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(), command)
     self.assertIn('/target:teapot', command)
Ejemplo n.º 9
0
 def parallel_test(self):
     command = build_sln_command(Settings({}), sln_path='dummy.sln', targets=None, upgrade_project=True,
                                 build_type='Debug', arch='armv7', parallel=False)
     self.assertIn('msbuild dummy.sln', command)
     self.assertIn('/p:Platform="ARM"', command)
     self.assertIn('devenv dummy.sln /upgrade', command)
     self.assertNotIn('/m:%s' % cpu_count(), command)
     self.assertNotIn('/target:teapot', command)
Ejemplo n.º 10
0
 def toolset_test(self):
     command = build_sln_command(Settings({}),
                                 sln_path='dummy.sln',
                                 targets=None,
                                 upgrade_project=False,
                                 build_type='Debug',
                                 arch='armv7',
                                 parallel=False,
                                 toolset="v110")
     self.assertEquals(
         'msbuild dummy.sln /p:Configuration=Debug /p:Platform="ARM" '
         '/p:PlatformToolset=v110', command)
Ejemplo n.º 11
0
 def toolset_test(self):
     command = build_sln_command(MockSettings({"compiler": "Visual Studio",
                                               "compiler.version": "17",
                                               "build_type": "Debug",
                                               "compiler.runtime": "MDd",
                                               "cppstd": "17"}),
                                 sln_path='dummy.sln', targets=None,
                                 upgrade_project=False, build_type='Debug', arch='armv7',
                                 parallel=False, toolset="v110")
     self.assertTrue(command.startswith('msbuild dummy.sln /p:Configuration=Debug '
                                        '/p:Platform="ARM" '
                                        '/p:PlatformToolset=v110 '
                                        '/p:ForceImportBeforeCppTargets='), command)
Ejemplo n.º 12
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.º 13
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.º 14
0
 def properties_file_test(self):
     command = build_sln_command(MockSettings({"compiler": "Visual Studio",
                                               "compiler.version": "17",
                                               "build_type": "Debug",
                                               "compiler.runtime": "MDd",
                                               "cppstd": "17"}),
                                 sln_path='dummy.sln', targets=None,
                                 upgrade_project=False, build_type='Debug', arch='armv7',
                                 parallel=False)
     self.assertTrue(command.startswith('msbuild dummy.sln /p:Configuration=Debug '
                                        '/p:Platform="ARM" '
                                        '/p:ForceImportBeforeCppTargets='), command)
     path_tmp = command.split("/p:ForceImportBeforeCppTargets=")[1][1:-1]  # remove quotes
     self.assertTrue(os.path.exists(path_tmp))
     contents = load(path_tmp)
     self.assertIn("<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>", contents)
     self.assertIn("<AdditionalOptions>-Zi -Ob0 -Od /std:c++17 %(AdditionalOptions)</AdditionalOptions>",
                   contents)
Ejemplo n.º 15
0
    def build(self):
        if self.settings.compiler == "Visual Studio":
            env = VisualStudioBuildEnvironment(self)
            with tools.environment_append(env.vars):
                with tools.chdir(os.path.join(self.source_subfolder, "win32", "VS2015")):
                    vcvars = tools.vcvars_command(self.settings)
                    btype = "%s%s%s" % (self.settings.build_type, "DLL" if self.options.shared else "", "_fixed" if self.options.shared and self.options.fixed_point else "")
                    # Instead of using "replace" here below, would we could add the "arch" parameter, but it doesn't work when we are also
                    # using the build_type parameter on conan 0.29.2 (conan bug?)
                    build_command = tools.build_sln_command(self.settings, "opus.sln", build_type = btype).replace("x86", "Win32")
                    self.output.info("Build command: %s" % build_command)
                    self.run("%s && %s" % (vcvars, build_command))
        else:
            env = AutoToolsBuildEnvironment(self)

            if self.settings.os != "Windows":
                env.fpic = self.options.fPIC

            with tools.environment_append(env.vars):

                with tools.chdir(self.source_subfolder):
                    if self.settings.os == "Macos":
                        tools.replace_in_file("configure", r"-install_name \$rpath/", "-install_name ")

                    if self.settings.os == "Windows":
                        tools.run_in_windows_bash(self, "./configure%s" % (" --enable-fixed-point" if self.options.fixed_point else ""))
                        tools.run_in_windows_bash(self, "make")
                    else:
                        configure_options = " --prefix=%s" % os.path.join(self.build_folder, self.install_subfolder)
                        if self.options.fixed_point:
                            configure_options += " --enable-fixed-point"
                        if self.options.shared:
                            configure_options += " --disable-static --enable-shared"
                        else:
                            configure_options += " --disable-shared --enable-static"
                        self.run("chmod +x configure")
                        self.run("./configure%s" % configure_options)
                        self.run("make")
                        self.run("make install")
Ejemplo n.º 16
0
    def build(self):
        if self.settings.compiler == "Visual Studio":

            env = VisualStudioBuildEnvironment(self)
            with tools.environment_append(env.vars):

                if self.options.shared:
                    vs_suffix = "_dynamic"
                else:
                    vs_suffix = "_static"

                libdirs = "<AdditionalLibraryDirectories>"
                libdirs_ext = "<AdditionalLibraryDirectories>$(LIB);"
                if self.options.shared:
                    replace_in_file(
                        "%s\\%s\\win32\\VS2010\\libvorbis\\libvorbis%s.vcxproj"
                        % (self.conanfile_directory, self.sources_folder,
                           vs_suffix), libdirs, libdirs_ext)
                    replace_in_file(
                        "%s\\%s\\win32\\VS2010\\libvorbis\\libvorbis%s.vcxproj"
                        % (self.conanfile_directory, self.sources_folder,
                           vs_suffix), "libogg.lib", "ogg.lib")
                if self.options.shared:
                    replace_in_file(
                        "%s\\%s\\win32\\VS2010\\libvorbisfile\\libvorbisfile%s.vcxproj"
                        % (self.conanfile_directory, self.sources_folder,
                           vs_suffix), libdirs, libdirs_ext)
                    replace_in_file(
                        "%s\\%s\\win32\\VS2010\\libvorbisfile\\libvorbisfile%s.vcxproj"
                        % (self.conanfile_directory, self.sources_folder,
                           vs_suffix), "libogg.lib", "ogg.lib")
                replace_in_file(
                    "%s\\%s\\win32\\VS2010\\vorbisdec\\vorbisdec%s.vcxproj" %
                    (self.conanfile_directory, self.sources_folder, vs_suffix),
                    libdirs, libdirs_ext)

                if self.options.shared:
                    replace_in_file(
                        "%s\\%s\\win32\\VS2010\\vorbisdec\\vorbisdec%s.vcxproj"
                        % (self.conanfile_directory, self.sources_folder,
                           vs_suffix), "libogg.lib", "ogg.lib")
                else:
                    replace_in_file(
                        "%s\\%s\\win32\\VS2010\\vorbisdec\\vorbisdec%s.vcxproj"
                        % (self.conanfile_directory, self.sources_folder,
                           vs_suffix), "libogg_static.lib", "ogg.lib")

                replace_in_file(
                    "%s\\%s\\win32\\VS2010\\vorbisenc\\vorbisenc%s.vcxproj" %
                    (self.conanfile_directory, self.sources_folder, vs_suffix),
                    libdirs, libdirs_ext)
                if self.options.shared:
                    replace_in_file(
                        "%s\\%s\\win32\\VS2010\\vorbisenc\\vorbisenc%s.vcxproj"
                        % (self.conanfile_directory, self.sources_folder,
                           vs_suffix), "libogg.lib", "ogg.lib")
                else:
                    replace_in_file(
                        "%s\\%s\\win32\\VS2010\\vorbisenc\\vorbisenc%s.vcxproj"
                        % (self.conanfile_directory, self.sources_folder,
                           vs_suffix), "libogg_static.lib", "ogg.lib")

                vcvars = tools.vcvars_command(self.settings)
                cd_build = "cd %s\\%s\\win32\\VS2010" % (
                    self.conanfile_directory, self.sources_folder)
                build_command = build_sln_command(self.settings,
                                                  "vorbis%s.sln" % vs_suffix)
                self.run(
                    "%s && %s && %s" %
                    (vcvars, cd_build, build_command.replace("x86", "Win32")))

        else:
            base_path = ("%s/" % self.conanfile_directory
                         ) if self.settings.os != "Windows" else ""
            cd_build = "cd %s%s" % (base_path, self.sources_folder)

            env = AutoToolsBuildEnvironment(self)

            if self.settings.os != "Windows":
                env.fpic = self.options.fPIC

            with tools.environment_append(env.vars):

                if self.settings.os == "Macos":
                    old_str = '-install_name \\$rpath/\\$soname'
                    new_str = '-install_name \\$soname'
                    replace_in_file(
                        "%s/%s/configure" %
                        (self.conanfile_directory, self.sources_folder),
                        old_str, new_str)

                if self.settings.os == "Windows":
                    run_in_windows_bash(self, "%s && ./configure" % cd_build)
                    run_in_windows_bash(self, "%s && make" % cd_build)
                else:
                    configure_options = " --prefix=%s" % self.package_folder
                    if self.options.shared:
                        configure_options += " --disable-static --enable-shared"
                    else:
                        configure_options += " --disable-shared --enable-static"
                    self.run("%s && chmod +x ./configure" % cd_build)
                    self.run("%s && chmod +x ./install-sh" % cd_build)
                    self.run("%s && ./configure%s" %
                             (cd_build, configure_options))
                    self.run("%s && make" % cd_build)
                    self.run("%s && make install" % cd_build)
Ejemplo n.º 17
0
 def no_build_type_test(self):
     with self.assertRaises(ConanException):
         build_sln_command(Settings({}), sln_path='dummy.sln', targets=None, upgrade_project=False,
                           build_type=None, arch='x86', parallel=False)
Ejemplo n.º 18
0
 def test_build_sln_command(self):
     with six.assertRaisesRegex(
             self, ConanV2Exception,
             "Conan v2 incompatible: 'tools.build_sln_command' is deprecated"
     ):
         tools.build_sln_command(settings=None, sln_path=None)