Esempio n. 1
0
    def vvcars_command_test(self):
        fake_settings = settings.Settings({"os": "Windows", "arch": "x86_64"})

        # preference order with VS 15
        with (tools.environment_append({
                "CONAN_VS_INSTALLATION_PREFERENCE":
                "BuildTools, Community,Professional, Enterprise"
        })):
            command = tools.vcvars_command(settings=fake_settings,
                                           compiler_version="15")
            self.assertNotIn("Community", command)
            self.assertIn("VC/Auxiliary/Build/vcvarsall.bat", command)
            self.assertIn("Microsoft Visual Studio\\2017\\BuildTools", command)
            self.assertIn("VSCMD_START_DIR", command)

        with (tools.environment_append({
                "CONAN_VS_INSTALLATION_PREFERENCE":
                "Professional, Enterprise,Community"
        })):
            command = tools.vcvars_command(settings=fake_settings,
                                           compiler_version="15")
            self.assertNotIn("BuildTools", command)
            self.assertIn("VC/Auxiliary/Build/vcvarsall.bat", command)
            self.assertIn("Microsoft Visual Studio\\2017\\Community", command)
            self.assertIn("VSCMD_START_DIR", command)

        # With VS 14 order of preference does not apply
        command = tools.vcvars_command(settings=fake_settings,
                                       compiler_version="14")
        self.assertNotIn("VSCMD_START_DIR", command)
        self.assertIn("VC/vcvarsall.bat", command)
        self.assertIn("Microsoft Visual Studio 14.0\\", command)
Esempio n. 2
0
    def test_invalid(self):
        if platform.system() != "Windows":
            return

        fake_settings_yml = """
        os:
            WindowsStore:
                version: ["666"]
        arch: [x86]
        compiler:
            Visual Studio:
                runtime: [MD, MT, MTd, MDd]
                version: ["8", "9", "10", "11", "12", "14", "15"]

        build_type: [None, Debug, Release]
        """

        settings = Settings.loads(fake_settings_yml)
        settings.compiler = 'Visual Studio'
        settings.compiler.version = '14'
        settings.arch = 'x86'
        settings.os = 'WindowsStore'
        settings.os.version = '666'

        with self.assertRaises(ConanException):
            tools.vcvars_command(settings)
Esempio n. 3
0
    def test_arch(self):
        settings = Settings.loads(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)

        settings.arch_build = 'x86_64'
        settings.arch = 'x86'
        self.assert_vcvars_command(settings, "amd64_x86")
Esempio n. 4
0
    def test_no_msvc(self):
        settings = Settings.loads(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):
                tools.vcvars_command(settings)
Esempio n. 5
0
    def vcvars_raises_when_not_found_test(self):
        text = """
os: [Windows]
compiler:
    Visual Studio:
        version: ["5"]
        """
        settings = Settings.loads(text)
        settings.os = "Windows"
        settings.compiler = "Visual Studio"
        settings.compiler.version = "5"
        with self.assertRaisesRegexp(ConanException, "VS non-existing installation: Visual Studio 5"):
            tools.vcvars_command(settings)
Esempio n. 6
0
    def test_arch_override(self):
        settings = Settings.loads(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')
Esempio n. 7
0
    def vcvars_raises_when_not_found_test(self):
        text = """
os: [Windows]
compiler:
    Visual Studio:
        version: ["5"]
        """
        settings = Settings.loads(text)
        settings.os = "Windows"
        settings.compiler = "Visual Studio"
        settings.compiler.version = "5"
        with self.assertRaisesRegexp(ConanException, "VS non-existing installation: Visual Studio 5"):
            tools.vcvars_command(settings)
Esempio n. 8
0
    def vcvars_constrained_test(self):
        text = """os: [Windows]
compiler:
    Visual Studio:
        version: ["14"]
        """
        settings = Settings.loads(text)
        settings.os = "Windows"
        settings.compiler = "Visual Studio"
        with self.assertRaisesRegexp(ConanException,
                                     "compiler.version setting required for vcvars not defined"):
            tools.vcvars_command(settings)

        new_out = StringIO()
        tools.set_global_instances(ConanOutput(new_out), None)
        settings.compiler.version = "14"
        with tools.environment_append({"vs140comntools": "path/to/fake"}):
            tools.vcvars_command(settings)
            with tools.environment_append({"VisualStudioVersion": "12"}):
                with self.assertRaisesRegexp(ConanException,
                                             "Error, Visual environment already set to 12"):
                    tools.vcvars_command(settings)

            with tools.environment_append({"VisualStudioVersion": "12"}):
                # Not raising
                tools.vcvars_command(settings, force=True)
Esempio n. 9
0
    def vcvars_constrained_test(self):
        text = """os: [Windows]
compiler:
    Visual Studio:
        version: ["14"]
        """
        settings = Settings.loads(text)
        settings.os = "Windows"
        settings.compiler = "Visual Studio"
        with self.assertRaisesRegexp(
                ConanException,
                "compiler.version setting required for vcvars not defined"):
            tools.vcvars_command(settings)

        new_out = StringIO()
        tools.set_global_instances(ConanOutput(new_out), None)
        settings.compiler.version = "14"
        with tools.environment_append({"vs140comntools": "path/to/fake"}):
            tools.vcvars_command(settings)
            if platform.system() != "Windows":
                self.assertIn("VS non-existing installation",
                              new_out.getvalue())

            with tools.environment_append({"VisualStudioVersion": "12"}):
                with self.assertRaisesRegexp(
                        ConanException,
                        "Error, Visual environment already set to 12"):
                    tools.vcvars_command(settings)

            with tools.environment_append({"VisualStudioVersion": "12"}):
                # Not raising
                tools.vcvars_command(settings, force=True)
Esempio n. 10
0
    def test_winsdk_version_override(self):
        settings = Settings.loads(default_settings_yml)
        settings.compiler = 'Visual Studio'
        settings.compiler.version = '15'
        settings.arch = 'x86_64'

        command = tools.vcvars_command(settings, winsdk_version='8.1')
        self.assertIn('vcvarsall.bat', command)
        self.assertIn('8.1', command)

        settings.compiler.version = '14'

        command = tools.vcvars_command(settings, winsdk_version='8.1')
        self.assertIn('vcvarsall.bat', command)
        self.assertIn('8.1', command)
Esempio n. 11
0
    def _build_msvc(self, args):
        build_command = find_executable("jom.exe")
        if build_command:
            build_args = ["-j", str(tools.cpu_count())]
        else:
            build_command = "nmake.exe"
            build_args = []
        self.output.info("Using '%s %s' to build" % (build_command, " ".join(build_args)))

        env = {}
        env.update({'PATH': ['%s/qtbase/bin' % self.source_folder,
                             '%s/gnuwin32/bin' % self.source_folder,
                             '%s/qtrepotools/bin' % self.source_folder]})

        env_build = VisualStudioBuildEnvironment(self)
        env.update(env_build.vars)

        with tools.environment_append(env):
            vcvars = tools.vcvars_command(self.settings)

            args += ["-opengl %s" % self.options.opengl]
            if self.options.openssl == "no":
                args += ["-no-openssl"]
            elif self.options.openssl == "yes":
                args += ["-openssl"]
            else:
                args += ["-openssl-linked"]

            self.run("cd %s && %s && set" % (self.source_dir, vcvars))
            self.run("cd %s && %s && configure %s"
                     % (self.source_dir, vcvars, " ".join(args)))
            self.run("cd %s && %s && %s %s"
                     % (self.source_dir, vcvars, build_command, " ".join(build_args)))
            self.run("cd %s && %s && %s install" % (self.source_dir, vcvars, build_command))
Esempio n. 12
0
    def visual_build(self, config_options_string):
        self.run_in_src("perl --version")

        self.output.warn(
            "----------CONFIGURING OPENSSL FOR WINDOWS. %s-------------" %
            self.version)
        debug = "debug-" if self.settings.build_type == "Debug" else ""
        arch = "32" if self.settings.arch == "x86" else "64A"
        configure_type = debug + "VC-WIN" + arch
        no_asm = "no-asm" if self.options.no_asm else ""
        # Will output binaries to ./binaries
        vcvars = tools.vcvars_command(self.settings)
        config_command = "%s && perl Configure %s %s --prefix=../binaries" % (
            vcvars, configure_type, no_asm)
        whole_command = "%s %s" % (config_command, config_options_string)
        self.output.warn(whole_command)
        self.run_in_src(whole_command)

        if not self.options.no_asm and self.settings.arch == "x86":
            # The 64 bits builds do not require the do_nasm
            # http://p-nand-q.com/programming/windows/building_openssl_with_visual_studio_2013.html
            self.run_in_src(r"%s && ms\do_nasm" % vcvars)
        else:
            if arch == "64A":
                self.run_in_src(r"%s && ms\do_win64a" % vcvars)
            else:
                self.run_in_src(r"%s && ms\do_ms" % vcvars)
        runtime = self.settings.compiler.runtime

        # Replace runtime in ntdll.mak and nt.mak
        def replace_runtime_in_file(filename):
            runtimes = ["MDd", "MTd", "MD", "MT"]
            for e in runtimes:
                try:
                    tools.replace_in_file(filename, "/%s" % e, "/%s" % runtime)
                    self.output.warn("replace vs runtime %s in %s" %
                                     ("/%s" % e, filename))
                    return  # we found a runtime argument in the file, so we can exit the function
                except:
                    pass
            raise Exception("Could not find any vs runtime in file")

        replace_runtime_in_file("./openssl-%s/ms/ntdll.mak" % self.version)
        replace_runtime_in_file("./openssl-%s/ms/nt.mak" % self.version)

        make_command = "nmake -f ms\\ntdll.mak" if self.options.shared else "nmake -f ms\\nt.mak "
        self.output.warn("----------MAKE OPENSSL %s-------------" %
                         self.version)
        self.run_in_src("%s && %s" % (vcvars, make_command))
        self.run_in_src("%s && %s install" % (vcvars, make_command))
        # Rename libs with the arch
        renames = {
            "./binaries/lib/libeay32.lib":
            "./binaries/lib/libeay32%s.lib" % runtime,
            "./binaries/lib/ssleay32.lib":
            "./binaries/lib/ssleay32%s.lib" % runtime
        }
        for old, new in renames.items():
            if os.path.exists(old):
                os.rename(old, new)
Esempio n. 13
0
 def _make_install_cmd(self):
     if is_msvc(self):
         vcvars = tools.vcvars_command(self.settings)
         make_install_cmd = vcvars + ' && nmake install'
     else:
         make_install_cmd = '{make} install'.format(make=self._make_program)
     return make_install_cmd
Esempio n. 14
0
 def build(self):
     arch = "ia32" if self.settings.arch == "x86" else "intel64"
     if self.settings.compiler == "Visual Studio":
         vcvars = tools.vcvars_command(self.settings)
         self.run("%s && cd tbb && mingw32-make arch=%s" % (vcvars, arch))
     else:
         self.run("cd tbb && make arch=%s" % (arch))
Esempio n. 15
0
 def _build_msvc(self):
     env_build = VisualStudioBuildEnvironment(self)
     with tools.environment_append(env_build.vars):
         vcvars = tools.vcvars_command(self.settings)
         for make_dir, _ in self._msvc_build_dirs:
             with tools.chdir(make_dir):
                 self.run("%s && nmake /f makefile NEW_COMPILER=1 CPU=%s" % (vcvars, self._msvc_cpu))
Esempio n. 16
0
    def build(self):
        prepare_env_cmd = vcvars_command(self.settings)
        cmake = CMake(self.settings)
        if self.settings.compiler != "Visual Studio":
            # TODO: Restrict settings
            raise ConanException("Not valid compiler")

        generator = {
            "14": "Visual Studio 14 2015",
            "12": "Visual Studio 12 2013",
            "10": "Visual Studio 10 2010"
        }[str(self.settings.compiler.version)]

        if self.settings.compiler.version != "14":
            tools.replace_in_file(
                "vcpkg/scripts/cmake/vcpkg_configure_cmake.cmake",
                "Visual Studio 14 2015", generator)

        # self._build_only_selected_build_type_patch()

        # Patch recipes for support any visual studio
        if self.settings.compiler.version != "14":
            # Boost toolset
            if self.name == "boost":
                tools.replace_in_file(
                    "vcpkg/ports/boost/portfile.cmake", "--toolset=msvc",
                    "--toolset=msvc-%s.0" % self.settings.compiler.version)

        self.run('%s && cmake %s -DPORT=%s -DTARGET_TRIPLET=%s -DCMD=BUILD' %
                 (prepare_env_cmd, cmake.command_line, self.name,
                  self._get_triplet()))
        self.run("%s && cmake --build . %s" %
                 (prepare_env_cmd, cmake.build_config))
 def _make_install_cmd(self):
     if self.settings.compiler == 'Visual Studio':
         vcvars = tools.vcvars_command(self.settings)
         make_install_cmd = vcvars + ' && nmake install'
     else:
         make_install_cmd = '{make} install'.format(make=self._make_program)
     return make_install_cmd
Esempio n. 18
0
    def build(self):
        if self.options.header_only:
            self.output.warn("Header only package, skipping build")
            return

        flags = self.boostrap()

        self.patch_project_jam()

        flags.extend(self.get_build_flags())

        # JOIN ALL FLAGS
        b2_flags = " ".join(flags)

        command = "b2" if self.settings.os == "Windows" else "./b2"

        without_python = "--without-python" if not self.options.python else ""
        full_command = "cd %s && %s %s -j%s --abbreviate-paths %s -d2" % (
            self.FOLDER_NAME, command, b2_flags, tools.cpu_count(),
            without_python
        )  # -d2 is to print more debug info and avoid travis timing out without output

        if self.settings.os == "Windows" and self.settings.compiler == "Visual Studio":
            full_command = "%s && %s" % (tools.vcvars_command(
                self.settings), full_command)

        self.output.warn(full_command)
        self.run(full_command)
Esempio n. 19
0
    def build(self):
        pybin = "py -2" if self.settings.os == "Windows" else "python"
        installFolder = self.build_folder + "/install"
        bitness = "--enable-64bit" if self.settings.arch == "x86_64" else ""
        debugging = "--enable-debugging" if self.settings.build_type == "Debug" else ""

        configureStatic = "%s waf configure --libs-only --disable-java --disable-python --prefix=%s %s %s" % (
            pybin, installFolder, bitness, debugging)
        configureShared = "%s waf configure --libs-only --disable-java --disable-python --prefix=%s %s %s --shared" % (
            pybin, installFolder, bitness, debugging)
        buildAll = "%s waf install" % pybin
        buildNitfC = "%s waf install --target=nitf-c" % pybin

        if self.settings.os == "Windows" and self.settings.compiler == "Visual Studio":
            vsenv = VisualStudioBuildEnvironment(self)
            with tools.environment_append(vsenv.vars):
                vcvars = tools.vcvars_command(self.settings)
                self.run("%s && %s" % (vcvars, configureStatic), cwd="nitro")
                if self.options.shared:
                    self.run("%s && %s" % (vcvars, buildAll), cwd="nitro")
                    self.run("%s && %s" % (vcvars, configureShared),
                             cwd="nitro")
                self.run("%s && %s" % (vcvars, buildNitfC), cwd="nitro")
        else:
            self.run(configureStatic, cwd="nitro")
            if self.options.shared:
                self.run(buildAll, cwd="nitro")
                self.run(configureShared, cwd="nitro")
            self.run(buildNitfC, cwd="nitro")
Esempio n. 20
0
    def _build_visual(self):
        crypto_dep = self.deps_cpp_info[str(self.options.crypto_library)]
        crypto_incdir = crypto_dep.include_paths[0]
        crypto_libdir = crypto_dep.lib_paths[0]
        libs = map(lambda lib : lib + ".lib", crypto_dep.libs)
        system_libs = map(lambda lib : lib + ".lib", crypto_dep.system_libs)

        nmake_flags = [
                "TLIBS=\"%s %s\"" % (" ".join(libs), " ".join(system_libs)),
                "LTLIBPATHS=/LIBPATH:%s" % crypto_libdir,
                "OPTS=\"-I%s -DSQLITE_HAS_CODEC\"" % (crypto_incdir),
                "NO_TCL=1",
                "USE_AMALGAMATION=1",
                "OPT_FEATURE_FLAGS=-DSQLCIPHER_CRYPTO_OPENSSL",
                "SQLITE_TEMP_STORE=%s" % self._temp_store_nmake_value,
                "TCLSH_CMD=%s" % self.deps_env_info.TCLSH,
                ]

        main_target = "dll" if self.options.shared else "sqlcipher.lib"

        if self.settings.compiler.runtime in ["MD", "MDd"]:
            nmake_flags.append("USE_CRT_DLL=1")
        if self.settings.build_type == "Debug":
            nmake_flags.append("DEBUG=2")
        nmake_flags.append("FOR_WIN10=1")
        platforms = {"x86": "x86", "x86_64": "x64"}
        nmake_flags.append("PLATFORM=%s" % platforms[self.settings.arch.value])
        vcvars = tools.vcvars_command(self.settings)
        self.run("%s && nmake /f Makefile.msc %s %s" % (vcvars, main_target, " ".join(nmake_flags)), cwd=self._source_subfolder)
Esempio n. 21
0
 def build(self):
     with tools.chdir(self._source_subfolder):
         self.run(
             "{python} build.py prepare".format(python=self.options.python))
         if tools.os_info.is_macos or tools.os_info.is_linux:
             if tools.os_info.is_macos:
                 cfg = ("{python} configure.py" +
                        " --deployment-target=10.12" + " -b {prefix}/bin" +
                        " -d {prefix}/lib-dynload" +
                        " -e {prefix}/include" + " -v {prefix}/share/sip")
             if tools.os_info.is_linux:
                 cfg = ("{python} configure.py" + " -b {prefix}/bin" +
                        " -d {prefix}/site-packages" +
                        " -e {prefix}/include" + " -v {prefix}/share/sip")
             self.run(
                 cfg.format(prefix=tools.unix_path(self.package_folder),
                            python=self.options.python))
             self.run("make -j%d" % tools.cpu_count())
         if tools.os_info.is_windows:
             self.run(
                 ("{python} configure.py" + " -b {prefix}/bin" +
                  " -d {prefix}/site-packages" + " -e {prefix}/include" +
                  " -v {prefix}/share/sip").format(
                      prefix=self.package_folder,
                      python=self.options.python))
             # cannot be bothered to fix build of siplib which we don't use anyway
             vcvarsall_cmd = tools.vcvars_command(self)
             with tools.chdir("sipgen"):
                 self.run("{vcv} && nmake".format(vcv=vcvarsall_cmd))
Esempio n. 22
0
    def build_windows(self):

        with tools.chdir(os.path.join('sources', 'win32')):
            vcvars = tools.vcvars_command(self.settings)
            compiler = "msvc" if self.settings.compiler == "Visual Studio" else "gcc"
            debug = "yes" if self.settings.build_type == "Debug" else "no"

            includes = ";".join(self.deps_cpp_info["libiconv"].include_paths +
                                self.deps_cpp_info["zlib"].include_paths)
            libs = ";".join(self.deps_cpp_info["libiconv"].lib_paths +
                            self.deps_cpp_info["zlib"].lib_paths)
            configure_command = "%s && cscript configure.js " \
                    "zlib=1 compiler=%s cruntime=/%s debug=%s include=\"%s\" lib=\"%s\"" % (
                                    vcvars,
                                    compiler,
                                    self.settings.compiler.runtime,
                                    debug,
                                    includes,
                                    libs)
            self.output.warn(configure_command)
            self.run(configure_command)

            # Fix library names because they can be not just zlib.lib
            tools.replace_in_file(
                "Makefile.msvc", "LIBS = $(LIBS) zlib.lib",
                "LIBS = $(LIBS) %s.lib" % self.deps_cpp_info['zlib'].libs[0])
            tools.replace_in_file(
                "Makefile.msvc", "LIBS = $(LIBS) iconv.lib",
                "LIBS = $(LIBS) %s" % self.deps_cpp_info['libiconv'].libs[0])

            if self.settings.compiler == "Visual Studio":
                self.run("%s && nmake /f Makefile.msvc" % (vcvars))
            else:
                self.run("%s && make -f Makefile.mingw" % (vcvars))
Esempio n. 23
0
    def build(self):
        def add_cflag(value):
            tools.replace_in_file("Makefile", "CFLAGS = ",
                                  "CFLAGS = %s " % value)

        arch = self.settings.arch
        if self.settings.os == "Windows":
            with (tools.vcvars(self.settings)):
                nmake = tools.which('nmake')
                if not nmake:
                    raise Exception(
                        "This package needs 'nmake' in Windows in the path to build"
                    )
        else:
            make = tools.get_env("CONAN_MAKE_PROGRAM",
                                 tools.which("make") or tools.which('nmake'))
            if not make:
                raise Exception(
                    "This package needs 'make' in Linux/Macos in the path to build"
                )

        if self.settings.os == "Windows":
            if self.options.shared:
                self.output.warn(
                    "shared option is disabled for Windows. Setting to false")
                self.options.shared = False

        with tools.chdir(self._source_subfolder):
            os.rename("makefile.u", "Makefile")

            if self.options.fPIC or self.options.shared:
                add_cflag('-fPIC')

            if self.settings.os == "Macos":
                if self.options.shared:
                    # create the dynamic library; undefined dynamic lookup is needed
                    # because the runtime will call Fortran _MAIN__
                    tools.replace_in_file("Makefile", "libf2c.so: $(OFILES)",
                                          "libf2c.dylib: $(OFILES)")
                    tools.replace_in_file(
                        "Makefile", "$(CC) -shared -o libf2c.so $(OFILES)",
                        "$(CC) -dynamiclib -all_load -headerpad_max_install_names -undefined dynamic_lookup -single_module -o libf2c.dylib $(OFILES)"
                    )
                    self._targets.append("libf2c.dylib")
                else:
                    self._targets.append("libf2c.a")
            elif self.settings.os == "Linux":
                add_cflag('-DNON_UNIX_STDIO')
                if self.options.shared:
                    self._targets.append("libf2c.so")
                else:
                    self._targets.append("libf2c.a")

            if self.settings.os == "Windows":
                vcvars = tools.vcvars_command(self.settings)
                build_command = "nmake -f makefile.vc"
                self.run("%s && %s" % (vcvars, build_command))
            else:
                self.run("%s arch=%s %s" %
                         (make, arch, " ".join(self._targets)))
Esempio n. 24
0
    def build_windows(self):
        iconv_headers_paths = self.deps_cpp_info["winiconv"].include_paths[0]
        iconv_lib_paths= " ".join(['lib="%s"' % lib for lib in self.deps_cpp_info["winiconv"].lib_paths])

        vc_command = vcvars_command(self.settings)
        compiler = "msvc" if self.settings.compiler == "Visual Studio" else self.settings.compiler == "gcc"
        debug = "yes" if self.settings.build_type == "Debug" else "no"

        configure_command = "%s && cd %s/win32 && cscript configure.js " \
                            "zlib=1 compiler=%s cruntime=/%s debug=%s include=\"%s\" %s" % (vc_command,
                                                                               self.ZIP_FOLDER_NAME,
                                                                               compiler,
                                                                               self.settings.compiler.runtime,
                                                                               debug,
                                                                               iconv_headers_paths,
                                                                               iconv_lib_paths)
        self.output.warn(configure_command)
        self.run(configure_command)

        makefile_path = os.path.join(self.ZIP_FOLDER_NAME, "win32", "Makefile.msvc")
        # Zlib library name is not zlib.lib always, it depends on configuration
        replace_in_file(makefile_path, "LIBS = $(LIBS) zlib.lib", "LIBS = $(LIBS) %s.lib" % self.deps_cpp_info["zlib"].libs[0])

        make_command = "nmake /f Makefile.msvc" if self.settings.compiler == "Visual Studio" else "make -f Makefile.mingw"
        make_command = "%s && cd %s/win32 && %s" % (vc_command, self.ZIP_FOLDER_NAME, make_command)
        self.output.warn(make_command)
        self.run(make_command)
Esempio n. 25
0
 def get_make_install_cmd(self):
     if self.settings.os == 'Windows':
         vcvars = tools.vcvars_command(self.settings)
         make_install_cmd = vcvars + ' && nmake install'
     else:
         make_install_cmd = 'make install'
     return make_install_cmd
Esempio n. 26
0
    def windows_build(self):
        # Follow instructions in https://github.com/jtv/libpqxx/blob/master/win32/INSTALL.txt
        common_file = os.path.join(self.pq_source_dir, 'win32', 'common')
        with open(common_file, "w") as f:
            f.write('PGSQLSRC="{}"\n'.format(
                self.deps_cpp_info["postgresql"].rootpath))
            f.write('PGSQLINC=$(PGSQLSRC)\include\n')
            f.write('LIBPQINC=$(PGSQLSRC)\include\n')

            f.write('LIBPQPATH=$(PGSQLSRC)\lib\n')
            f.write('LIBPQDLL=libpq.dll\n')
            f.write('LIBPQLIB=libpq.lib\n')

            f.write('LIBPQDPATH=$(PGSQLSRC)\lib\n')
            f.write('LIBPQDDLL=libpq.dll\n')
            f.write('LIBPQDLIB=libpq.lib\n')

        target_dir = os.path.join(self.pq_source_dir, 'include', 'pqxx')
        with tools.chdir(
                os.path.join(self.pq_source_dir, 'config', 'sample-headers',
                             'compiler', 'VisualStudio2013', 'pqxx')):
            shutil.copy('config-internal-compiler.h', target_dir + "/")
            shutil.copy('config-public-compiler.h', target_dir + "/")

        vcvars = tools.vcvars_command(self.settings)
        self.run(vcvars)
        env = VisualStudioBuildEnvironment(self)
        with tools.environment_append(env.vars):
            with tools.chdir(self.pq_source_dir):
                target = "DLL" if self.options.shared else "STATIC"
                target += str(self.settings.build_type).upper()
                command = 'nmake /f win32/vc-libpqxx.mak %s' % target
                self.output.info(command)
                self.run(command)
Esempio n. 27
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()
Esempio n. 28
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()
Esempio n. 29
0
 def _build_nmake(self, target="release"):
     opts = []
     # https://core.tcl.tk/tips/doc/trunk/tip/477.md
     if not self.options.shared:
         opts.append("static")
     if self.settings.build_type == "Debug":
         opts.append("symbols")
     if "MD" in self.settings.compiler.runtime:
         opts.append("msvcrt")
     else:
         opts.append("nomsvcrt")
     if "d" not in self.settings.compiler.runtime:
         opts.append("unchecked")
     vcvars_command = tools.vcvars_command(self.settings)
     self.run(
         '{vcvars} && nmake -nologo -f "{cfgdir}/makefile.vc" shell INSTALLDIR="{pkgdir}" OPTS={opts} {target}'
         .format(
             vcvars=vcvars_command,
             cfgdir=self._get_configure_dir("win"),
             pkgdir=self.package_folder,
             opts=",".join(opts),
             target=target,
         ),
         cwd=self._get_configure_dir("win"),
     )
Esempio n. 30
0
 def build(self):
     if self.settings.os == "Windows":
         PATH = "{0};{1}".format(self.env.get("PYTHON_DIR"), os.environ["PATH"])
     else:
         PATH = "{0}:{1}".format(os.path.join(self.env.get("PYTHON_DIR"), "bin"), os.environ["PATH"])
     with tools.chdir(self._source_subfolder):
         with tools.environment_append({"PATH": PATH}):
             self.run("python --version")
             self.run("python configure.py --sip-module={module} {static}"
                 "--bindir={bindir} --destdir={destdir} --incdir={incdir} "
                 "--sipdir={sipdir} --pyidir={pyidir}".format(
                     module="PyQt5.sip",
                     static="--static " if not self.options.shared else '',
                     bindir=os.path.join(self.build_folder, "bin"),
                     destdir=os.path.join(self.build_folder, "site-packages"),
                     incdir=os.path.join(self.build_folder, "include"),
                     sipdir=os.path.join(self.build_folder, "sip"),
                     pyidir=os.path.join(self.build_folder, "site-packages", "PyQt5"),
                 ),
                 run_environment=True)
             if self.settings.os == "Windows":
                 vcvars = tools.vcvars_command(self.settings)
                 self.run("{0} && nmake".format(vcvars))
                 self.run("{0} && nmake install".format(vcvars))
             else:
                 self.run("make", run_environment=True)
                 self.run("make install", run_environment=True)
Esempio n. 31
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()
Esempio n. 32
0
 def _build_msvc(self):
     env_build = VisualStudioBuildEnvironment(self)
     with tools.environment_append(env_build.vars):
         vcvars = tools.vcvars_command(self.settings)
         with tools.chdir("CPP/7zip"):
             self.run("%s && nmake /f makefile PLATFORM=%s" % (
             vcvars, self._msvc_platforms[str(self.settings.arch_build)]))
Esempio n. 33
0
    def boostrap(self):
        with_toolset = {
            "apple-clang": "darwin"
        }.get(str(self.settings.compiler), str(self.settings.compiler))
        command = "bootstrap" if self.settings.os == "Windows" \
                              else "./bootstrap.sh --with-toolset=%s" % with_toolset

        if self.settings.os == "Windows" and self.settings.compiler == "Visual Studio":
            command = "%s && %s" % (tools.vcvars_command(
                self.settings), command)

        flags = []
        if self.settings.os == "Windows" and self.settings.compiler == "gcc":
            command += " mingw"
            flags.append("--layout=system")

        try:
            self.run("cd %s && %s" % (self.FOLDER_NAME, command))
        except:
            self.run("cd %s && type bootstrap.log" %
                     self.FOLDER_NAME if self.settings.os ==
                     "Windows" else "cd %s && cat bootstrap.log" %
                     self.FOLDER_NAME)
            raise
        return flags
Esempio n. 34
0
    def vcvars_constrained_test(self):
        if platform.system() != "Windows":
            return
        text = """os: [Windows]
compiler:
    Visual Studio:
        version: ["14"]
        """
        settings = Settings.loads(text)
        settings.os = "Windows"
        settings.compiler = "Visual Studio"
        with self.assertRaisesRegexp(ConanException,
                                     "compiler.version setting required for vcvars not defined"):
            tools.vcvars_command(settings)
        settings.compiler.version = "14"
        cmd = tools.vcvars_command(settings)
        self.assertIn("vcvarsall.bat", cmd)
        with tools.environment_append({"VisualStudioVersion": "12"}):
            with self.assertRaisesRegexp(ConanException,
                                         "Error, Visual environment already set to 12"):
                tools.vcvars_command(settings)
Esempio n. 35
0
 def vcvars_echo_test(self):
     if platform.system() != "Windows":
         return
     settings = Settings.loads(default_settings_yml)
     settings.os = "Windows"
     settings.compiler = "Visual Studio"
     settings.compiler.version = "14"
     cmd = tools.vcvars_command(settings)
     output = TestBufferConanOutput()
     runner = TestRunner(output)
     runner(cmd + " && set vs140comntools")
     self.assertIn("vcvarsall.bat", str(output))
     self.assertIn("VS140COMNTOOLS=", str(output))
     with tools.environment_append({"VisualStudioVersion": "14"}):
         output = TestBufferConanOutput()
         runner = TestRunner(output)
         cmd = tools.vcvars_command(settings)
         runner(cmd + " && set vs140comntools")
         self.assertNotIn("vcvarsall.bat", str(output))
         self.assertIn("Conan:vcvars already set", str(output))
         self.assertIn("VS140COMNTOOLS=", str(output))
Esempio n. 36
0
    def test_arch_override(self):
        if platform.system() != "Windows":
            return
        settings = Settings.loads(default_settings_yml)
        settings.compiler = 'Visual Studio'
        settings.compiler.version = '14'
        settings.arch = 'mips64'

        command = tools.vcvars_command(settings, arch='x86')
        self.assertIn('vcvarsall.bat', command)
        self.assertIn('x86', command)

        command = tools.vcvars_command(settings, arch='x86_64')
        self.assertIn('vcvarsall.bat', command)
        self.assertIn('amd64', command)

        command = tools.vcvars_command(settings, arch='armv7')
        self.assertIn('vcvarsall.bat', command)
        self.assertNotIn('arm64', command)
        self.assertIn('arm', command)

        command = tools.vcvars_command(settings, arch='armv8')
        self.assertIn('vcvarsall.bat', command)
        self.assertIn('arm64', command)

        with self.assertRaises(ConanException):
            tools.vcvars_command(settings, arch='mips')
Esempio n. 37
0
    def _build_msvc(self, args):
        build_command = find_executable("jom.exe")
        if build_command:
            build_args = ["-j", str(cpu_count())]
        else:
            build_command = "nmake.exe"
            build_args = []
        self.output.info("Using '%s %s' to build" % (build_command, " ".join(build_args)))

        env = {}
        env.update({'PATH': ['%s/qtbase/bin' % self.conanfile_directory,
                             '%s/gnuwin32/bin' % self.conanfile_directory,
                             '%s/qtrepotools/bin' % self.conanfile_directory]})
        # it seems not enough to set the vcvars for older versions
        if self.settings.compiler == "Visual Studio":
            if self.settings.compiler.version == "14":
                env.update({'QMAKESPEC': 'win32-msvc2015'})
                args += ["-platform win32-msvc2015"]
            if self.settings.compiler.version == "12":
                env.update({'QMAKESPEC': 'win32-msvc2013'})
                args += ["-platform win32-msvc2013"]
            if self.settings.compiler.version == "11":
                env.update({'QMAKESPEC': 'win32-msvc2012'})
                args += ["-platform win32-msvc2012"]
            if self.settings.compiler.version == "10":
                env.update({'QMAKESPEC': 'win32-msvc2010'})
                args += ["-platform win32-msvc2010"]

        env_build = VisualStudioBuildEnvironment(self)
        env.update(env_build.vars)

        # Workaround for conan-io/conan#1408
        for name, value in env.items():
            if not value:
                del env[name]
        with tools.environment_append(env):
            vcvars = tools.vcvars_command(self.settings)

            args += ["-opengl %s" % self.options.opengl]
            if self.options.openssl == "no":
                args += ["-no-openssl"]
            elif self.options.openssl == "yes":
                args += ["-openssl"]
            else:
                args += ["-openssl-linked"]

            self.run("cd %s && %s && set" % (self.source_dir, vcvars))
            self.run("cd %s && %s && configure %s"
                     % (self.source_dir, vcvars, " ".join(args)))
            self.run("cd %s && %s && %s %s"
                     % (self.source_dir, vcvars, build_command, " ".join(build_args)))
            self.run("cd %s && %s && %s install" % (self.source_dir, vcvars, build_command))
Esempio n. 38
0
    def test_81(self):
        if platform.system() != "Windows":
            return

        settings = Settings.loads(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)
        self.assertIn('vcvarsall.bat', command)
        self.assertIn('x86', command)
        self.assertIn('store', command)
        self.assertIn('8.1', command)
Esempio n. 39
0
    def test_10(self):
        if platform.system() != "Windows":
            return
        sdk_version = tools.find_windows_10_sdk()
        if not sdk_version:
            return

        settings = Settings.loads(default_settings_yml)
        settings.compiler = 'Visual Studio'
        settings.compiler.version = '14'
        settings.arch = 'x86'
        settings.os = 'WindowsStore'
        settings.os.version = '10.0'

        command = tools.vcvars_command(settings)
        self.assertIn('vcvarsall.bat', command)
        self.assertIn('x86', command)
        self.assertIn('store', command)
        self.assertIn(sdk_version, command)
Esempio n. 40
0
    def build(self):
        if self.settings.os == "Linux" or self.settings.os == "Macos":

            autotools = AutoToolsBuildEnvironment(self)
            env_vars = autotools.vars.copy()

            # required to correctly find static libssl on Linux
            if self.options.with_openssl and self.settings.os == "Linux":
                env_vars['OPENSSL_LIBADD'] = '-ldl'

            # disable rpath build
            tools.replace_in_file(os.path.join(self._source_subfolder, "configure"), r"-install_name \$rpath/", "-install_name ")

            # compose configure options
            configure_args = []
            if not self.options.shared:
                configure_args.append("--disable-shared")
            configure_args.append("--enable-openssl" if self.options.with_openssl else "--disable-openssl")
            if self.options.disable_threads:
                configure_args.append("--disable-thread-support")

            with tools.environment_append(env_vars):

                with tools.chdir(self._source_subfolder):
                    # set LD_LIBRARY_PATH
                    with tools.environment_append(RunEnvironment(self).vars):
                        autotools.configure(args=configure_args)
                        autotools.make()

        elif self.settings.os == "Windows":
            vcvars = tools.vcvars_command(self.settings)
            suffix = ''
            if self.options.with_openssl:
                suffix = "OPENSSL_DIR=" + self.deps_cpp_info['OpenSSL'].rootpath
            # add runtime directives to runtime-unaware nmakefile
            tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile.nmake"),
                                  'LIBFLAGS=/nologo',
                                  'LIBFLAGS=/nologo\n'
                                  'CFLAGS=$(CFLAGS) /%s' % str(self.settings.compiler.runtime))
            # do not build tests. static_libs is the only target, no shared libs at all
            make_command = "nmake %s -f Makefile.nmake static_libs" % suffix
            with tools.chdir(self._source_subfolder):
                self.run("%s && %s" % (vcvars, make_command))
Esempio n. 41
0
    def command_line_env(self):
        if self.os == "Linux" or self.os == "Macos" or self.os == "FreeBSD" or self.os == "SunOS":
            if self.compiler == "gcc" or "clang" in str(self.compiler) or "sun-cc" in str(self.compiler):
                return self._gcc_env()
        elif self.os == "Windows":
            commands = []
            commands.append("@echo off")
            vcvars = ""
            if self.compiler == "Visual Studio":
                cl_args = " ".join(['/I"%s"' % lib for lib in self._deps_cpp_info.include_paths])
                lib_paths = ";".join(['%s' % lib for lib in self._deps_cpp_info.lib_paths])
                commands.append('if defined LIB (SET "LIB=%LIB%;{0}") else (SET "LIB={0}")'.
                                format(lib_paths))
                commands.append('if defined CL (SET "CL=%CL% {0}") else (SET "CL={0}")'.
                                format(cl_args))
                vcvars = tools.vcvars_command(self._settings)
                if vcvars:
                    vcvars += " && "
            elif self.compiler == "gcc":
                include_paths = ";".join(['%s'
                                          % lib for lib in self._deps_cpp_info.include_paths])
                commands.append('if defined C_INCLUDE_PATH (SET "C_INCLUDE_PATH=%C_INCLUDE_PATH%;{0}")'
                                ' else (SET "C_INCLUDE_PATH={0}")'.format(include_paths))
                commands.append('if defined CPLUS_INCLUDE_PATH '
                                '(SET "CPLUS_INCLUDE_PATH=%CPLUS_INCLUDE_PATH%;{0}")'
                                ' else (SET "CPLUS_INCLUDE_PATH={0}")'.format(include_paths))

                lib_paths = ";".join([lib for lib in self._deps_cpp_info.lib_paths])
                commands.append('if defined LIBRARY_PATH (SET "LIBRARY_PATH=%LIBRARY_PATH%;{0}")'
                                ' else (SET "LIBRARY_PATH={0}")'.format(lib_paths))

            commands.extend(get_setenv_variables_commands(self._deps_env_info, "SET"))
            save("_conan_env.bat", "\r\n".join(commands))
            command = "%scall _conan_env.bat" % vcvars
            return command

        return " && ".join(get_setenv_variables_commands(self._deps_env_info))
Esempio n. 42
0
 def _append_vs_if_needed(self, command):
     if self._compiler == "Visual Studio" and self.backend == "ninja":
         command = "%s && %s" % (tools.vcvars_command(self._conanfile.settings), command)
     return command