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

icu: modernize more for conan v2 #15778

Merged
merged 1 commit into from
Feb 7, 2023
Merged
Changes from all 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
35 changes: 18 additions & 17 deletions recipes/icu/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
from conan import ConanFile
from conan.tools.apple import is_apple_os
from conan.tools.build import cross_building
from conan.tools.build import cross_building, stdcpp_library
from conan.tools.env import Environment, VirtualBuildEnv
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, mkdir, rename, replace_in_file, rm, rmdir, save
from conan.tools.gnu import Autotools, AutotoolsToolchain
from conan.tools.layout import basic_layout
from conan.tools.microsoft import is_msvc, unix_path
from conan.tools.scm import Version
from conans.tools import get_gnu_triplet, sha256sum, stdcpp_library
from conans.tools import get_gnu_triplet
import glob
import hashlib
import os
import shutil

required_conan_version = ">=1.53.0"
required_conan_version = ">=1.57.0"


class ICUConan(ConanFile):
Expand Down Expand Up @@ -71,10 +72,17 @@ def configure(self):
def layout(self):
basic_layout(self, src_folder="src")

@staticmethod
def _sha256sum(file_path):
m = hashlib.sha256()
with open(file_path, "rb") as fh:
for data in iter(lambda: fh.read(8192), b""):
m.update(data)
return m.hexdigest()

def package_id(self):
if self.options.dat_package_file:
dat_package_file_sha256 = sha256sum(str(self.options.dat_package_file))
self.info.options.dat_package_file = dat_package_file_sha256
if self.info.options.dat_package_file:
self.info.options.dat_package_file = self._sha256sum(str(self.info.options.dat_package_file))

def build_requirements(self):
if self._settings_build.os == "Windows":
Expand All @@ -86,16 +94,15 @@ def build_requirements(self):
self.tool_requires(self.ref)

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):
env = VirtualBuildEnv(self)
env.generate()

tc = AutotoolsToolchain(self)
if (self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) >= "12") or \
(self.settings.compiler == "msvc" and Version(self.settings.compiler.version) >= "180"):
if (str(self.settings.compiler) == "Visual Studio" and Version(self.settings.compiler.version) >= "12") or \
(str(self.settings.compiler) == "msvc" and Version(self.settings.compiler.version) >= "180"):
tc.extra_cflags.append("-FS")
tc.extra_cxxflags.append("-FS")
if not self.options.shared:
Expand All @@ -119,11 +126,6 @@ def generate(self):
if cross_building(self):
base_path = unix_path(self, self.dependencies.build["icu"].package_folder)
tc.configure_args.append(f"--with-cross-build={base_path}")
if (not is_msvc(self)):
# --with-cross-build above prevents tc.generate() from setting --build option.
# Workaround for https://github.com/conan-io/conan/issues/12642
gnu_triplet = get_gnu_triplet(str(self._settings_build.os), str(self._settings_build.arch), str(self.settings.compiler))
tc.configure_args.append(f"--build={gnu_triplet}")
if self.settings.os in ["iOS", "tvOS", "watchOS"]:
gnu_triplet = get_gnu_triplet("Macos", str(self.settings.arch))
tc.configure_args.append(f"--host={gnu_triplet}")
Expand Down Expand Up @@ -215,8 +217,7 @@ def _data_path(self):
def package(self):
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
autotools = Autotools(self)
# TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed
autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"])
autotools.install()

dll_files = glob.glob(os.path.join(self.package_folder, "lib", "*.dll"))
if dll_files:
Expand Down