Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libxml2: bump dependencies + use NMakeToolchain/NMakeDeps for msvc build #16169

Merged
merged 5 commits into from
Mar 21, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 13 additions & 19 deletions recipes/libxml2/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
from conan import ConanFile
from conan.tools.env import Environment, VirtualBuildEnv, VirtualRunEnv
from conan.tools.scm import Version
from conan.tools.apple import fix_apple_shared_install_name
from conan.tools.build import cross_building, build_jobs
from conan.tools.env import VirtualBuildEnv, VirtualRunEnv
from conan.tools.files import copy, get, rename, rm, rmdir, replace_in_file, save, chdir, mkdir
from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps, PkgConfigDeps
from conan.tools.layout import basic_layout
from conan.tools.microsoft import is_msvc, msvc_runtime_flag, unix_path, VCVars
from conan.tools.microsoft import is_msvc, msvc_runtime_flag, unix_path, NMakeDeps, NMakeToolchain
from conan.tools.scm import Version
import os

import itertools
import textwrap

required_conan_version = ">=1.53.0"
required_conan_version = ">=1.55.0"


class Libxml2Conan(ConanFile):
Expand Down Expand Up @@ -95,7 +96,7 @@ def requirements(self):
if self.options.zlib:
self.requires("zlib/1.2.13")
if self.options.lzma:
self.requires("xz_utils/5.2.5")
self.requires("xz_utils/5.4.0")
if self.options.iconv:
self.requires("libiconv/1.17", transitive_headers=True, transitive_libs=True)
if self.options.icu:
Expand All @@ -104,26 +105,22 @@ def requirements(self):
def build_requirements(self):
if not (is_msvc(self) or self._is_mingw_windows):
if self.options.zlib or self.options.lzma or self.options.icu:
self.tool_requires("pkgconf/1.9.3")
if not self.conf.get("tools.gnu:pkg_config", check_type=str):
self.tool_requires("pkgconf/1.9.3")
if self._settings_build.os == "Windows":
self.win_bash = True
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
self.tool_requires("msys2/cci.latest")

def source(self):
get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True)
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
if is_msvc(self):
tc = VCVars(self)
tc = NMakeToolchain(self)
tc.generate()
env = Environment()
# TODO: no conan v2 build helper for NMake yet (see https://github.com/conan-io/conan/issues/12188)
# So populate CL with AutotoolsToolchain cflags
c_flags = AutotoolsToolchain(self).cflags
if c_flags:
env.define("CL", c_flags)
env.vars(self).save_script("conanbuildenv_nmake")
deps = NMakeDeps(self)
deps.generate()
elif self._is_mingw_windows:
pass # nothing to do for mingw? it calls mingw-make directly
else:
Expand Down Expand Up @@ -277,10 +274,6 @@ def _patch_sources(self):
replace_in_file(self, os.path.join(self.source_folder, "win32", makefile),
"install-libs : all",
"install-libs :")
# relocatable shared lib on macOS
replace_in_file(self, os.path.join(self.source_folder, "configure"),
"-install_name \\$rpath/",
"-install_name @rpath/")

def build(self):
self._patch_sources()
Expand Down Expand Up @@ -333,6 +326,7 @@ def package(self):
rmdir(self, os.path.join(self.package_folder, "share"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
fix_apple_shared_install_name(self)

for header in ["win32config.h", "wsockcompat.h"]:
copy(self, pattern=header, src=os.path.join(self.source_folder, "include"),
Expand Down