-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
conan-center-bot
merged 19 commits into
conan-io:master
from
System-Arch:System-Arch-icu-1
Feb 14, 2023
Merged
Changes from 5 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f640d5b
ICU Conan 2.0 compatibility tweaks
System-Arch 5af9fd6
Fix lint issues
System-Arch 803ad74
Fixed typo
System-Arch 5069d3b
Removed unused import
System-Arch e9bfc9f
Try dropping back to 1.54
System-Arch ccd3fa3
Apply suggestions from code review
System-Arch a7ebe4d
Removed workarounds for conan-io/conan:#12642 and conan-io/conan:#12884
System-Arch 395647a
Update file hash per code review feedback
System-Arch f735e10
Fix argument to open()
System-Arch 8f1285d
self.version.major needs parens in Conan 1.x
System-Arch 080af98
Revert use of version.major until 1.x support is dropped
System-Arch 0964a97
Treat settings.compiler.version as str to test inequality
System-Arch a9b14de
Apply suggestions from code review
System-Arch 1b1ce52
import Version
System-Arch 5751b6e
Validate existence of dat_package_file per code review suggesion
System-Arch a46b1d2
Merge branch 'master' into System-Arch-icu-1
6b37ff9
Apply suggestions from code review
prince-chrismc 7fde1d5
missing import and leave old cross build stuff
eb31859
missing import
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||||||
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" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
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" | ||||||
|
@@ -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): | ||||||
|
@@ -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: | ||||||
|
@@ -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}", | ||||||
|
@@ -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: | ||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 🤞