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: validate dat package file exists #14980

Merged
merged 19 commits into from
Feb 14, 2023
Merged
Changes from 5 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
42 changes: 25 additions & 17 deletions recipes/icu/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
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.gnu.get_gnu_triplet import _get_gnu_triplet # Ugly but not currently exported in Conan 2.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conan-io/conan#12546 is marked for 1.57 so I poked the dev team to see what might come of it 🤞

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
import glob
import os
import shutil
import hashlib

required_conan_version = ">=1.53.0"
required_conan_version = ">=1.54.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
required_conan_version = ">=1.54.0"
required_conan_version = ">=1.57.0"


def sha256sum(file_path):
System-Arch marked this conversation as resolved.
Show resolved Hide resolved
with open(file_path, "rb") as fh:
digest = hashlib.new("sha256")
while True:
data = fh.read(8192)
if not data:
break
digest.update(data)
return digest.hexdigest()
System-Arch marked this conversation as resolved.
Show resolved Hide resolved

class ICUConan(ConanFile):
name = "icu"
Expand Down Expand Up @@ -72,8 +81,8 @@ def layout(self):
basic_layout(self, src_folder="src")

def package_id(self):
if self.options.dat_package_file:
dat_package_file_sha256 = sha256sum(str(self.options.dat_package_file))
if self.info.options.dat_package_file:
dat_package_file_sha256 = sha256sum(str(self.info.options.dat_package_file))
System-Arch marked this conversation as resolved.
Show resolved Hide resolved
self.info.options.dat_package_file = dat_package_file_sha256

def build_requirements(self):
Expand All @@ -94,8 +103,8 @@ def generate(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 (self.settings.get_safe("compiler") == "Visual Studio" and self.settings.get_safe("compiler.version") >= "12") or \
(self.settings.get_safe("compiler") == "msvc" and self.settings.get_safe("compiler.version") >= "180"):
System-Arch marked this conversation as resolved.
Show resolved Hide resolved
tc.extra_cflags.append("-FS")
tc.extra_cxxflags.append("-FS")
if not self.options.shared:
Expand All @@ -119,18 +128,18 @@ 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)):
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))
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))
gnu_triplet = _get_gnu_triplet("Macos", str(self.settings.arch))
tc.configure_args.append(f"--host={gnu_triplet}")
elif is_msvc(self):
# ICU doesn't like GNU triplet of conan for msvc (see https://github.com/conan-io/conan/issues/12546)
host = get_gnu_triplet(str(self.settings.os), str(self.settings.arch), "gcc")
build = get_gnu_triplet(str(self._settings_build.os), str(self._settings_build.arch), "gcc")
host = _get_gnu_triplet(str(self.settings.os), str(self.settings.arch), "gcc")
build = _get_gnu_triplet(str(self._settings_build.os), str(self._settings_build.arch), "gcc")
tc.configure_args.extend([
f"--host={host}",
f"--build={build}",
Expand Down Expand Up @@ -201,22 +210,21 @@ def build(self):

@property
def _data_filename(self):
vtag = self.version.split(".")[0]
vtag = str(self.version).split('.', maxsplit=1)[0]
System-Arch marked this conversation as resolved.
Show resolved Hide resolved
return f"icudt{vtag}l.dat"

@property
def _data_path(self):
data_dir_name = "icu"
if self.settings.os == "Windows" and self.settings.build_type == "Debug":
data_dir_name += "d"
data_dir = os.path.join(self.package_folder, "lib", data_dir_name, self.version)
data_dir = os.path.join(self.package_folder, "lib", data_dir_name, str(self.version))
prince-chrismc marked this conversation as resolved.
Show resolved Hide resolved
return os.path.join(data_dir, self._data_filename)

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