-
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
[util-linux-libuuid] Add util-linux-libuuid package #17664
Merged
conan-center-bot
merged 10 commits into
conan-io:master
from
samuel-emrys:recipe/17337-util-linux-libuuid
Jun 21, 2023
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
54322da
[util-linux-libuuid] Add util-linux-libuuid package
samuel-emrys bea16f8
[util-linux-libuuid] Add minimum compatible compiler versions
samuel-emrys 6ae778f
[util-linux-libuuid] Add apple-clang to minimum compiler list
samuel-emrys 7452b0d
[util-linux-libuuid] Add failover for min_version call to return 0 if…
samuel-emrys ed8abe6
[util-linux-libuuid] Add dependency on gettext for Macos to bring in …
samuel-emrys ced042b
[util-linux-libuuid] Use libgettext instead of gettext for libintl
samuel-emrys 26b528d
[util-linux-libuuid] Invalidate macos builds
samuel-emrys 27625d7
[util-linux-libuuid] Modify version to use util-linux version rather …
samuel-emrys 431d2b1
Update CMake targets to match upstream
samuel-emrys c4a0fc8
[util-linux-libuuid] Fix consumer find_package to match new target name
samuel-emrys 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
"2.39": | ||
url: "https://github.com/util-linux/util-linux/archive/refs/tags/v2.39.tar.gz" | ||
sha256: "186cb427cd6b4654f381357b60af7ffb0ae9bb50d7af7d87e0723858f7318b80" |
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 |
---|---|---|
@@ -0,0 +1,134 @@ | ||
from conan import ConanFile | ||
from conan.errors import ConanInvalidConfiguration | ||
from conan.tools.apple import fix_apple_shared_install_name | ||
from conan.tools.env import VirtualBuildEnv | ||
from conan.tools.files import copy, get, rm, rmdir, chdir | ||
from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps | ||
from conan.tools.layout import basic_layout | ||
from conan.tools.scm import Version | ||
import os | ||
|
||
required_conan_version = ">=1.53.0" | ||
|
||
|
||
class UtilLinuxLibuuidConan(ConanFile): | ||
name = "util-linux-libuuid" | ||
description = "Universally unique id library" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/util-linux/util-linux.git" | ||
license = "BSD-3-Clause" | ||
topics = "id", "identifier", "unique", "uuid" | ||
package_type = "library" | ||
provides = "libuuid" | ||
settings = "os", "arch", "compiler", "build_type" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
} | ||
|
||
@property | ||
def _has_sys_file_header(self): | ||
return self.settings.os in ["FreeBSD", "Linux", "Macos"] | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def configure(self): | ||
if self.options.shared: | ||
self.options.rm_safe("fPIC") | ||
self.settings.rm_safe("compiler.cppstd") | ||
self.settings.rm_safe("compiler.libcxx") | ||
|
||
def layout(self): | ||
basic_layout(self, src_folder="src") | ||
|
||
def _minimum_compiler_version(self, compiler, build_type): | ||
min_version = { | ||
"gcc": { | ||
"Release": "4", | ||
"Debug": "8", | ||
}, | ||
"clang": { | ||
"Release": "3", | ||
"Debug": "3", | ||
}, | ||
"apple-clang": { | ||
"Release": "5", | ||
"Debug": "5", | ||
}, | ||
} | ||
return min_version.get(str(compiler), {}).get(str(build_type), "0") | ||
|
||
def validate(self): | ||
min_version = self._minimum_compiler_version(self.settings.compiler, self.settings.build_type) | ||
if Version(self.settings.compiler.version) < min_version: | ||
raise ConanInvalidConfiguration(f"{self.settings.compiler} {self.settings.compiler.version} does not meet the minimum version requirement of version {min_version}") | ||
if self.settings.os == "Windows": | ||
raise ConanInvalidConfiguration(f"{self.ref} is not supported on Windows") | ||
if self.settings.os == "Macos": | ||
# FIXME: Add Macos compatibility. This is currently breaking because builds are unable to find libtool-2 | ||
# This is a bit puzzling given `libtool` is a tool_requires, and I haven't been able to replicate this error | ||
# locally. | ||
raise ConanInvalidConfiguration(f"{self.ref} is not currently supported on Macos. Please contribute this functionality if you require it.") | ||
|
||
def requirements(self): | ||
if self.settings.os == "Macos": | ||
# Required because libintl.{a,dylib} is not distributed via libc on Macos | ||
self.requires("libgettext/0.21") | ||
|
||
def build_requirements(self): | ||
self.tool_requires("libtool/2.4.7") | ||
self.tool_requires("m4/1.4.19") | ||
self.tool_requires("pkgconf/1.9.3") | ||
self.tool_requires("bison/3.8.2") | ||
self.tool_requires("autoconf/2.71") | ||
self.tool_requires("automake/1.16.5") | ||
|
||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
|
||
def generate(self): | ||
env = VirtualBuildEnv(self) | ||
env.generate() | ||
|
||
tc = AutotoolsToolchain(self) | ||
tc.configure_args.append("--disable-all-programs") | ||
tc.configure_args.append("--enable-libuuid") | ||
if self._has_sys_file_header: | ||
tc.extra_defines.append("HAVE_SYS_FILE_H") | ||
if "x86" in self.settings.arch: | ||
tc.extra_cflags.append("-mstackrealign") | ||
tc.generate() | ||
|
||
deps = AutotoolsDeps(self) | ||
deps.generate() | ||
|
||
def build(self): | ||
with chdir(self, self.source_folder): | ||
self.run("./autogen.sh") | ||
autotools = Autotools(self) | ||
autotools.configure() | ||
autotools.make() | ||
|
||
def package(self): | ||
copy(self, "COPYING.BSD-3-Clause", src=os.path.join(self.source_folder, "Documentation", "licenses"), dst=os.path.join(self.package_folder, "licenses")) | ||
autotools = Autotools(self) | ||
autotools.install() | ||
rm(self, "*.la", os.path.join(self.package_folder, "lib")) | ||
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) | ||
rmdir(self, os.path.join(self.package_folder, "bin")) | ||
rmdir(self, os.path.join(self.package_folder, "sbin")) | ||
rmdir(self, os.path.join(self.package_folder, "share")) | ||
fix_apple_shared_install_name(self) | ||
|
||
def package_info(self): | ||
self.cpp_info.set_property("pkg_config_name", "uuid") | ||
self.cpp_info.set_property("cmake_target_name", "libuuid::libuuid") | ||
self.cpp_info.set_property("cmake_file_name", "libuuid") | ||
samuel-emrys marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.cpp_info.libs = ["uuid"] | ||
self.cpp_info.includedirs.append(os.path.join("include", "uuid")) |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
project(test_package LANGUAGES C) | ||
|
||
find_package(libuuid REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} test_package.c) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE libuuid::libuuid) | ||
samuel-emrys marked this conversation as resolved.
Show resolved
Hide resolved
|
||
target_compile_features(${PROJECT_NAME} PRIVATE c_std_99) |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import CMake, cmake_layout | ||
import os | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" | ||
test_type = "explicit" | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str) | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if can_run(self): | ||
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") | ||
self.run(bin_path, env="conanrun") |
33 changes: 33 additions & 0 deletions
33
recipes/util-linux-libuuid/all/test_package/test_package.c
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <stdio.h> | ||
|
||
#include "uuid/uuid.h" | ||
|
||
int main(int argc, char *argv[]) { | ||
uuid_t uuid; | ||
uuid_generate_time_safe(uuid); | ||
|
||
char uuid_str[37]; | ||
uuid_unparse_lower(uuid, uuid_str); | ||
printf("generate uuid=%s\n", uuid_str); | ||
|
||
uuid_t uuid2; | ||
uuid_parse(uuid_str, uuid2); | ||
|
||
int rv; | ||
rv = uuid_compare(uuid, uuid2); | ||
printf("uuid_compare() result=%d\n", rv); | ||
|
||
uuid_t uuid3; | ||
uuid_parse("1b4e28ba-2fa1-11d2-883f-0016d3cca427", uuid3); | ||
rv = uuid_compare(uuid, uuid3); | ||
printf("uuid_compare() result=%d\n", rv); | ||
|
||
rv = uuid_is_null(uuid); | ||
printf("uuid_null() result=%d\n", rv); | ||
|
||
uuid_clear(uuid); | ||
rv = uuid_is_null(uuid); | ||
printf("uuid_null() result=%d\n", rv); | ||
|
||
return 0; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"2.39": | ||
folder: all |
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.
Very bad idea to explicitly reference automake, autoconf and m4, it doesn't scale in build requirements, it's well known. Why this recipe doesn't follow other autoconf recipes guidelines?
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.
I'm not experienced with automake. I used a few other recipes as guidelines but they obviously haven't incorporated the practices you're talking about and it didn't come up in review. It would be useful if those were documented somewhere easily discoverable. Feel free to submit a new PR with the necessary changes if that's a better way of managing these.
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.
A good reference is autotools recipes template.
(sorry, I won't fix this, I don't have the time. It will break when someone will bump automake version in libtool recipe)
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.
Good to know, but it wouldn't have addressed this - it has an explicit example requiring automake, and no discussion of when it shouldn't be required.
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.
There is a comment explaining when it's required: https://github.com/conan-io/conan-center-index/blob/60fa77f44eafacf99b7f1d43650f13dd8db5d971/docs/package_templates/autotools_package/all/conanfile.py#L93C1-L96