Skip to content

Commit

Permalink
(conan-io#15372) flac: add 1.4.2
Browse files Browse the repository at this point in the history
* flac: add 1.4.2

Flac 1.4.2 removed the build dependency on nasm

https://github.com/xiph/flac/releases/tag/1.4.2

Also switching to the official source download which we can't use for 1.3.3 because it does not include the CMake files.

* flac: delete CMake and pkgconfig files

* Fix shared builds

* Adapt patches

* Add patch descriptions and types

* Remove obsolete Conan version check

* Use rm_safe

* Use export_conandata_patches

* Apply suggestions from code review

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>

---------

Co-authored-by: Cr0ydon <git@cr0ydon.com>
Co-authored-by: chausner <chausner@users.noreply.github.com>
Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>
  • Loading branch information
4 people authored and sabelka committed Feb 12, 2023
1 parent 493b49a commit 597465d
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 8 deletions.
11 changes: 10 additions & 1 deletion recipes/flac/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
sources:
"1.4.2":
url: "https://github.com/xiph/flac/releases/download/1.4.2/flac-1.4.2.tar.xz"
sha256: "e322d58a1f48d23d9dd38f432672865f6f79e73a6f9cc5a5f57fcaa83eb5a8e4"
"1.3.3":
url: "https://github.com/xiph/flac/archive/1.3.3.tar.gz"
sha256: "668cdeab898a7dd43cf84739f7e1f3ed6b35ece2ef9968a5c7079fe9adfe1689"
patches:
"1.4.2":
- patch_file: "patches/fix-cmake-1.4.2.patch"
patch_description: "Adapts find_package commands and install destination paths in CMakeLists.txt files."
patch_type: "conan"
"1.3.3":
- patch_file: "patches/fix-cmake.patch"
- patch_file: "patches/fix-cmake-1.3.3.patch"
patch_description: "Various adaptations in CMakeLists.txt files to improve compatibility with Conan."
patch_type: "conan"
16 changes: 9 additions & 7 deletions recipes/flac/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import apply_conandata_patches, copy, get, rmdir
from conan.tools.files import apply_conandata_patches, export_conandata_patches, copy, get, rmdir
from conan.tools.scm import Version
import os

required_conan_version = ">=1.47.0"
required_conan_version = ">=1.54.0"


class FlacConan(ConanFile):
Expand All @@ -26,22 +27,21 @@ class FlacConan(ConanFile):
}

def export_sources(self):
for p in self.conan_data.get("patches", {}).get(self.version, []):
copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder)
export_conandata_patches(self)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
if self.options.shared:
del self.options.fPIC
self.options.rm_safe("fPIC")

def requirements(self):
self.requires("ogg/1.3.5")

def build_requirements(self):
if self.settings.arch in ["x86", "x86_64"]:
if Version(self.version) < "1.4.2" and self.settings.arch in ["x86", "x86_64"]:
self.tool_requires("nasm/2.15.05")

def layout(self):
Expand Down Expand Up @@ -79,6 +79,8 @@ def package(self):
copy(self, "*.h", src=os.path.join(self.source_folder, "include", "share", "grabbag"),
dst=os.path.join(self.package_folder, "include", "share", "grabbag"), keep_path=False)
rmdir(self, os.path.join(self.package_folder, "share"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "flac")
Expand All @@ -101,7 +103,7 @@ def package_info(self):
self.output.info("Appending PATH environment variable: {}".format(bin_path))
self.env_info.PATH.append(bin_path)

# TODO: to remove in conan v2 once cmake_find_package_* generators removed
# TODO: to remove in conan v2
self.cpp_info.filenames["cmake_find_package"] = "flac"
self.cpp_info.filenames["cmake_find_package_multi"] = "flac"
self.cpp_info.names["cmake_find_package"] = "FLAC"
Expand Down
File renamed without changes.
38 changes: 38 additions & 0 deletions recipes/flac/all/patches/fix-cmake-1.4.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -43,7 +43,7 @@ if(WITH_OGG)
endif()
else()
if(NOT TARGET Ogg::ogg)
- find_package(Ogg REQUIRED)
+ find_package(Ogg REQUIRED CONFIG)
else()
set(OGG_FOUND 1 CACHE INTERNAL "ogg has already been built")
endif()
--- a/src/flac/CMakeLists.txt
+++ b/src/flac/CMakeLists.txt
@@ -21,4 +21,4 @@ target_link_libraries(flacapp
utf8)

install(TARGETS flacapp EXPORT targets
- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
+ DESTINATION "${CMAKE_INSTALL_BINDIR}")
--- a/src/metaflac/CMakeLists.txt
+++ b/src/metaflac/CMakeLists.txt
@@ -14,4 +14,4 @@ add_executable(metaflac
target_link_libraries(metaflac FLAC getopt utf8)

install(TARGETS metaflac EXPORT targets
- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
+ DESTINATION "${CMAKE_INSTALL_BINDIR}")
--- a/src/share/getopt/CMakeLists.txt
+++ b/src/share/getopt/CMakeLists.txt
@@ -1,8 +1,7 @@
check_include_file("string.h" HAVE_STRING_H)

if(NOT WIN32)
- find_package(Intl)
endif()

add_library(getopt STATIC getopt.c getopt1.c)

2 changes: 2 additions & 0 deletions recipes/flac/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
versions:
"1.4.2":
folder: all
"1.3.3":
folder: all

0 comments on commit 597465d

Please sign in to comment.