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

libid3tag: Use tenacityteam fork #26140

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
21 changes: 0 additions & 21 deletions recipes/libid3tag/all/CMakeLists.txt

This file was deleted.

6 changes: 3 additions & 3 deletions recipes/libid3tag/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sources:
"0.15.1b":
url: "https://downloads.sourceforge.net/project/mad/libid3tag/0.15.1b/libid3tag-0.15.1b.tar.gz"
sha256: 63da4f6e7997278f8a3fef4c6a372d342f705051d1eeb6a46a86b03610e26151
"0.16.3":
url: "https://codeberg.org/tenacityteam/libid3tag/archive/0.16.3.tar.gz"
sha256: "0561009778513a95d91dac33cee8418d6622f710450a7cb56a74636d53b588cb"
106 changes: 18 additions & 88 deletions recipes/libid3tag/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
import os

from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.apple import fix_apple_shared_install_name, is_apple_os
from conan.tools.build import cross_building
from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import chdir, copy, get, rm, replace_in_file
from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps
from conan.tools.layout import basic_layout
from conan.tools.microsoft import is_msvc
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.files import copy, get, rmdir

required_conan_version = ">=1.53.0"
required_conan_version = ">=2.4"


class LibId3TagConan(ConanFile):
name = "libid3tag"
description = "ID3 tag manipulation library."
license = "GPL-2.0-or-later"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://www.underbit.com/products/mad/"
homepage = "https://codeberg.org/tenacityteam/libid3tag/"
topics = ("mad", "id3", "MPEG", "audio", "decoder")
danimtb marked this conversation as resolved.
Show resolved Hide resolved
generators = "CMakeDeps", "CMakeToolchain"

package_type = "library"
settings = "os", "arch", "compiler", "build_type"
Expand All @@ -33,96 +27,32 @@ class LibId3TagConan(ConanFile):
"fPIC": True,
}

def export_sources(self):
copy(self, "CMakeLists.txt", self.recipe_folder, os.path.join(self.export_sources_folder, "src"))

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.libcxx")
self.settings.rm_safe("compiler.cppstd")
languages = ["C"]
Copy link
Contributor

@valgur valgur Dec 9, 2024

Choose a reason for hiding this comment

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

Nice! Would be great if this could be added to the package templates as well as the preferred alternative to self.settings.rm_safe("compiler.libcxx"); self.settings.rm_safe("compiler.cppstd").

implements = ["auto_shared_fpic"]

def layout(self):
if is_msvc(self):
cmake_layout(self, src_folder="src")
else:
basic_layout(self, src_folder="src")
cmake_layout(self, src_folder="src")

def requirements(self):
self.requires("zlib/[>=1.2.11 <2]")

def validate_build(self):
if cross_building(self) and is_apple_os(self) and self.options.shared:
# Cannot cross-build due to a very old version of libtool that does not
# correctly propagate `-sysroot` or `-arch` when creating a shared library
raise ConanInvalidConfiguration("Shared library cross-building is not supported on Apple platforms")

def build_requirements(self):
if not is_msvc(self):
self.tool_requires("gnu-config/cci.20210814")
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], strip_root=True)

def generate(self):
if is_msvc(self):
tc = CMakeToolchain(self)
tc.preprocessor_definitions["ID3TAG_EXPORT"] = "__declspec(dllexport)" if self.options.shared else ""
tc.generate()
deps = CMakeDeps(self)
deps.generate()
else:
venv = VirtualBuildEnv(self)
venv.generate()
tc = AutotoolsToolchain(self)
tc.generate()
deps = AutotoolsDeps(self)
deps.generate()

def build(self):
if is_msvc(self):
# https://github.com/markjeee/libid3tag/blob/master/id3tag.h#L355-L358
replace_in_file(self, os.path.join(self.source_folder, "id3tag.h"),
"extern char", "ID3TAG_EXPORT extern char")
cmake = CMake(self)
cmake.configure()
cmake.build()
else:
for gnu_config in [
self.conf.get("user.gnu-config:config_guess", check_type=str),
self.conf.get("user.gnu-config:config_sub", check_type=str),
]:
if gnu_config:
copy(self, os.path.basename(gnu_config), os.path.dirname(gnu_config), self.source_folder)
with chdir(self, self.source_folder):
autotools = Autotools(self)
autotools.configure()
autotools.make()
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
for license_file in ["COPYRIGHT", "COPYING", "CREDITS"]:
copy(self, license_file, self.source_folder, os.path.join(self.package_folder, "licenses"))
if is_msvc(self):
cmake = CMake(self)
cmake.install()
else:
with chdir(self, self.source_folder):
autotools = Autotools(self)
autotools.install()
rm(self, "*.la", self.package_folder, recursive=True)
fix_apple_shared_install_name(self)

cmake = CMake(self)
cmake.install()

rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))

def package_info(self):
if is_msvc(self):
self.cpp_info.libs = ["libid3tag"]
self.cpp_info.defines.append("ID3TAG_EXPORT=" + ("__declspec(dllimport)" if self.options.shared else ""))
else:
self.cpp_info.libs = ["id3tag"]
self.cpp_info.libs = ["id3tag"]
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
self.cpp_info.libs = ["id3tag"]
self.cpp_info.set_property("cmake_file_name", "id3tag")
self.cpp_info.set_property("cmake_target_name", "id3tag::id3tag")
self.cpp_info.set_property("pkg_config_name", "id3tag")
self.cpp_info.libs = ["id3tag"]

I would recommend including this info even if it matches the defaults. It makes it clear that these are the actual official target names and not just implicit values generated by Conan.

Copy link
Member

Choose a reason for hiding this comment

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

But the actual package name is libid3tag, so these would be necessary if the upstream are defining the targets as id3tag

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I missed that part, since I copied these from my older PR.
Either way, these are valid:

Please do double check these details when reviewing, as it's going to be a breaking change for the consumers or will at least needs a "backwards compatible" fix when corrected later.

10 changes: 8 additions & 2 deletions recipes/libid3tag/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
generators = "CMakeDeps", "VirtualRunEnv"
test_type = "explicit"

def requirements(self):
Expand All @@ -15,6 +15,12 @@ def requirements(self):
def layout(self):
cmake_layout(self)

def generate(self):
tc = CMakeToolchain(self)
if self.settings.os == "Windows" and self.dependencies[self.tested_reference_str].options.shared:
Copy link
Member

Choose a reason for hiding this comment

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

Not sure about the complexity of the test, specially when this doesn't seem something that the recipe is managing.

tc.preprocessor_definitions["CCI_SKIP_GLOBALS"] = 1
tc.generate()

def build(self):
cmake = CMake(self)
cmake.configure()
Expand Down
13 changes: 10 additions & 3 deletions recipes/libid3tag/all/test_package/test_package.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@

int main()
{
printf("id3tag version: %s\n", id3_version);
printf("id3tag copyright: %s\n", id3_copyright);
printf("id3tag author: %s\n", id3_author);
printf("id3tag version: %s\n", ID3_VERSION);
printf("id3tag author: %s\n", ID3_AUTHOR);
#ifndef CCI_SKIP_GLOBALS
// Ensure extern variables also work.
// This is disabled for shared due to Window
// WINDOWS_EXPORT_ALL_SYMBOLS still needs __declspec usage
// for global data symbols as per CMake docs
// but upstream does not use it
printf("id3tag build: %s\n", id3_build);
#endif

struct id3_tag tag;
id3_tag_version(&tag);

printf("id3tag default tag version: %d\n", tag.version);
return 0;
}
2 changes: 1 addition & 1 deletion recipes/libid3tag/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
versions:
"0.15.1b":
"0.16.3":
folder: all