コード例 #1
0
    def build(self):
        self._patch_sources()
        autotools = AutoToolsBuildEnvironment(self)
        args = ["-Y", os.path.join(self.source_folder, self._source_subfolder)]
        kwargs = {
            "APR":
            self.deps_cpp_info["apr"].rootpath.replace("\\", "/"),
            "APU":
            self.deps_cpp_info["apr-util"].rootpath.replace("\\", "/"),
            "OPENSSL":
            self.deps_cpp_info["openssl"].rootpath.replace("\\", "/"),
            "PREFIX":
            self.package_folder.replace("\\", "/"),
            "LIBDIR":
            os.path.join(self.package_folder, "lib").replace("\\", "/"),
            "ZLIB":
            self.deps_cpp_info["zlib"].rootpath.replace("\\", "/"),
            "DEBUG":
            self.settings.build_type == "Debug",
            "APR_STATIC":
            not self.options["apr"].shared,
            "CFLAGS":
            " ".join(self.deps_cpp_info.cflags +
                     (["-fPIC"] if self.options.get_safe("fPIC") else []) +
                     autotools.flags),
            "LINKFLAGS":
            " ".join(self.deps_cpp_info.sharedlinkflags) + " " + " ".join(
                self._lib_path_arg(l) for l in self.deps_cpp_info.lib_paths),
            "CPPFLAGS":
            " ".join("-D{}".format(d) for d in autotools.defines) + " " +
            " ".join("-I'{}'".format(inc.replace("\\", "/"))
                     for inc in self.deps_cpp_info.include_paths),
            "CC":
            self._cc,
            "SOURCE_LAYOUT":
            "False",
        }

        if self.settings.compiler == "Visual Studio":
            kwargs.update({
                "TARGET_ARCH":
                str(self.settings.arch),
                "MSVC_VERSION":
                "{:.1f}".format(
                    float(tools.msvs_toolset(self.settings).lstrip("v")) / 10),
            })

        escape_str = lambda x: "\"{}\"".format(x)
        with tools.chdir(self._source_subfolder):
            with self._build_context():
                self.run("scons {} {}".format(
                    " ".join(escape_str(s) for s in args),
                    " ".join("{}={}".format(k, escape_str(v))
                             for k, v in kwargs.items())),
                         run_environment=True)
コード例 #2
0
 def _get_build_type(self):
     """
     Gets a string describing this build.
     Raises a ConanInvalidConfiguration if the settings are not supported.
     """
     if self.settings.compiler == "Visual Studio":
         return "MSVC" + tools.msvs_toolset(self)[1:]
     elif self.settings.os_build == "Linux":
         return "Linux"
     else:
         raise ConanInvalidConfiguration(
             "Unsupported compiler + os: {}, {}".format(
                 self.settings.compiler, self.settings.os_build))
コード例 #3
0
def _default_compiler_name(conanfile):
    # needs more work since currently only windows and linux is supported
    compiler = conanfile.settings.get_safe('compiler')
    the_os = conanfile.settings.get_safe('os')
    if the_os == 'Windows':
        if compiler == 'gcc':
            return 'mingw'
        if compiler == 'Visual Studio':
            if tools.msvs_toolset(conanfile) == 'ClangCL':
                return 'clang-cl'
            return 'cl'
        if compiler == 'clang':
            return 'clang-cl'
        raise ConanException('unknown windows compiler')

    return compiler
コード例 #4
0
ファイル: conanfile.py プロジェクト: neherlab/nextclade
 def _library_name(self):
     libname = "jemalloc"
     if self.settings.compiler == "Visual Studio":
         if self.options.shared:
             if self.settings.build_type == "Debug":
                 libname += "d"
         else:
             toolset = tools.msvs_toolset(self.settings)
             toolset_number = "".join(c for c in toolset if c in string.digits)
             libname += "-vc{}-{}".format(toolset_number, self._msvc_build_type)
     else:
         if self.settings.os == "Windows":
             if not self.options.shared:
                 libname += "_s"
         else:
             if not self.options.shared and self.options.fPIC:
                 libname += "_pic"
     return libname
コード例 #5
0
 def _patch_sources(self):
     for patch in self.conan_data["patches"][self.version]:
         tools.patch(**patch)
     if self.settings.compiler == "Visual Studio":
         with tools.chdir(os.path.join(self._source_subfolder, "src")):
             for fn in os.listdir("."):
                 if not fn.endswith(".vcxproj"):
                     continue
                 tools.replace_in_file(fn, "v141", tools.msvs_toolset(self))
                 tools.replace_in_file(
                     fn,
                     "<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>",
                     "")
     if self.settings.os == "Windows":
         # Add ".exe" suffix to calls from cl65 to other utilities
         for fn, var in (("cc65", "CC65"), ("ca65", "CA65"),
                         ("co65", "CO65"), ("ld65", "LD65"), ("grc65",
                                                              "GRC")):
             v = "{},".format(var).ljust(5)
             tools.replace_in_file(
                 os.path.join(self._source_subfolder, "src", "cl65",
                              "main.c"),
                 "CmdInit (&{v} CmdPath, \"{n}\");".format(v=v, n=fn),
                 "CmdInit (&{v} CmdPath, \"{n}.exe\");".format(v=v, n=fn))
コード例 #6
0
 def _check_msvc(self):
     if (tools.msvs_toolset(self) == "v140"
             or self.settings.compiler == "Visual Studio"
             and tools.Version(self.settings.compiler.version) < "15"):
         raise ConanInvalidConfiguration(
             "Unsupported Visual Studio Compiler or Toolset")
コード例 #7
0
    def _build_msvc(self):
        for patch in self.conan_data.get("patches", {}).get(self.version, {}):
            tools.patch(**patch)

        # FIXME: package LiquidRescale  aka liblqr
        tools.replace_in_file(
            os.path.join("VisualMagick", "lqr", "Config.txt"),
            "#define MAGICKCORE_LQR_DELEGATE",
            "",
        )
        # FIXME: package LibRaw
        tools.replace_in_file(
            os.path.join("VisualMagick", "libraw", "Config.txt"),
            "#define MAGICKCORE_RAW_R_DELEGATE",
            "",
        )

        # FIXME: package FLIF (FLIF: Free Lossless Image Format)
        tools.replace_in_file(
            os.path.join("VisualMagick", "flif", "Config.txt"),
            "#define MAGICKCORE_FLIF_DELEGATE",
            "",
        )

        # FIXME: package librsvg
        tools.replace_in_file(
            os.path.join("VisualMagick", "librsvg", "Config.txt"),
            "#define MAGICKCORE_RSVG_DELEGATE",
            "",
        )

        if not self.options.shared:
            for module in self._modules:
                tools.replace_in_file(
                    os.path.join("VisualMagick", module, "Config.txt"),
                    "[DLL]",
                    "[STATIC]",
                )
            tools.replace_in_file(
                os.path.join("VisualMagick", "coders", "Config.txt"),
                "[DLLMODULE]",
                "[STATIC]\n[DEFINES]\n_MAGICKLIB_",
            )

        if self.settings.arch == "x86_64":
            project = os.path.join("VisualMagick", "configure",
                                   "configure.vcxproj")
            tools.replace_in_file(project, "Win32", "x64")
            tools.replace_in_file(project, "/MACHINE:I386", "/MACHINE:x64")

        with tools.chdir(os.path.join("VisualMagick", "configure")):

            toolset = tools.msvs_toolset(self)
            tools.replace_in_file(
                "configure.vcxproj",
                "<PlatformToolset>v120</PlatformToolset>",
                "<PlatformToolset>%s</PlatformToolset>" % toolset,
            )

            msbuild = MSBuild(self)
            # fatal error C1189: #error:  Please use the /MD switch for _AFXDLL builds
            msbuild.build_env.flags = ["/MD"]
            msbuild.build(
                project_file="configure.vcxproj",
                platforms={"x86": "Win32"},
                force_vcvars=True,
            )

            # https://github.com/ImageMagick/ImageMagick-Windows/blob/master/AppVeyor/Build.ps1
            command = ["configure.exe", "/noWizard"]
            msvc_version = {
                9: "/VS2002",
                10: "/VS2010",
                11: "/VS2012",
                12: "/VS2013",
                14: "/VS2015",
                15: "/VS2017",
                16: "/VS2019",
                17: "/VS2022",
            }.get(int(str(self.settings.compiler.version)))
            runtime = {
                "MT": "/smt",
                "MTd": "/smtd",
                "MD": "/dmt",
                "MDd": "/mdt"
            }.get(str(self.settings.compiler.runtime))
            command.append(runtime)
            command.append(msvc_version)
            command.append("/hdri" if self.options.hdri else "/noHdri")
            command.append("/Q%s" % self.options.quantum_depth)
            if self.settings.arch == "x86_64":
                command.append("/x64")
            command = " ".join(command)

            self.output.info(command)
            self.run(command, run_environment=True)

        # disable incorrectly detected OpenCL
        baseconfig = os.path.join(self._source_subfolder, "MagickCore",
                                  "magick-baseconfig.h")
        tools.replace_in_file(
            baseconfig,
            "#define MAGICKCORE__OPENCL",
            "#undef MAGICKCORE__OPENCL",
            strict=False,
        )
        tools.replace_in_file(
            baseconfig,
            "#define MAGICKCORE_HAVE_CL_CL_H",
            "#undef MAGICKCORE_HAVE_CL_CL_H",
            strict=False,
        )

        suffix = {
            "MT": "StaticMT",
            "MTd": "StaticMTD",
            "MD": "DynamicMT",
            "MDd": "DynamicMT",
        }.get(str(self.settings.compiler.runtime))

        # GdiPlus requires C++, but ImageMagick has *.c files
        project = ("IM_MOD_emf_%s.vcxproj" % suffix if self.options.shared else
                   "CORE_coders_%s.vcxproj" % suffix)
        tools.replace_in_file(
            os.path.join("VisualMagick", "coders", project),
            '<ClCompile Include="..\\..\\ImageMagick\\coders\\emf.c">',
            '<ClCompile Include="..\\..\\ImageMagick\\coders\\emf.c">\n'
            "<CompileAs>CompileAsCpp</CompileAs>",
        )

        for module in self._modules:
            with tools.chdir(os.path.join("VisualMagick", module)):
                msbuild = MSBuild(self)
                msbuild.build(
                    project_file="CORE_%s_%s.vcxproj" % (module, suffix),
                    upgrade_project=False,
                    platforms={
                        "x86": "Win32",
                        "x86_64": "x64"
                    },
                )

        with tools.chdir(os.path.join("VisualMagick", "coders")):
            pattern = ("IM_MOD_*_%s.vcxproj" % suffix if self.options.shared
                       else "CORE_coders_%s.vcxproj" % suffix)
            projects = glob.glob(pattern)
            for project in projects:
                msbuild = MSBuild(self)
                msbuild.build(
                    project_file=project,
                    upgrade_project=False,
                    platforms={
                        "x86": "Win32",
                        "x86_64": "x64"
                    },
                )