From bfe2c4397145d979432441bf73ec267846611cc4 Mon Sep 17 00:00:00 2001 From: Charles Cross Date: Wed, 13 Mar 2024 15:34:20 -0700 Subject: [PATCH 01/14] Adds libsndio recipe --- recipes/libsndio/all/conandata.yml | 4 + recipes/libsndio/all/conanfile.py | 120 +++++++++++++++++++++++++++++ recipes/libsndio/config.yml | 3 + 3 files changed, 127 insertions(+) create mode 100644 recipes/libsndio/all/conandata.yml create mode 100644 recipes/libsndio/all/conanfile.py create mode 100644 recipes/libsndio/config.yml diff --git a/recipes/libsndio/all/conandata.yml b/recipes/libsndio/all/conandata.yml new file mode 100644 index 0000000000000..7b145eb97bca1 --- /dev/null +++ b/recipes/libsndio/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.9.0": + url: "https://sndio.org/sndio-1.9.0.tar.gz" + sha256: "f30826fc9c07e369d3924d5fcedf6a0a53c0df4ae1f5ab50fe9cf280540f699a" diff --git a/recipes/libsndio/all/conanfile.py b/recipes/libsndio/all/conanfile.py new file mode 100644 index 0000000000000..8112cda9640cf --- /dev/null +++ b/recipes/libsndio/all/conanfile.py @@ -0,0 +1,120 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.env import VirtualBuildEnv, VirtualRunEnv +from conan.tools.files import apply_conandata_patches, chdir, copy, export_conandata_patches, get, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps, PkgConfigDeps +from conan.tools.layout import basic_layout +from conan.tools.scm import Version +from conan.tools.build import cross_building +import os + +required_conan_version = ">=1.53.0" + + +class LibsndioConan(ConanFile): + name = "libsndio" + license = "ISC" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://sndio.org/" + topics = ("sndio", "sound", "audio", "midi") + description = "A small audio and MIDI framework that provides a lightweight audio & MIDI server \ + and a user-space API to access either the server or the hardware directly in a uniform way." + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_alsa": [True, False] + } + default_options = { + "shared": True, + "fPIC": True, + "with_alsa": True + } + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + if self.options.get_safe("with_alsa"): + self.requires("libalsa/1.2.10") + + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def validate(self): + if self.settings.os != "Linux": + raise ConanInvalidConfiguration(f"{self.ref} only supports Linux") + + def build_requirements(self): + self.tool_requires("libtool/2.4.7") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + virtual_build_env = VirtualBuildEnv(self) + virtual_build_env.generate() + + # # inject requires env vars in build scope + # # it's required in case of native build when there is AutotoolsDeps & at least one dependency which might be shared, because configure tries to run a test executable + if not cross_building(self): + env = VirtualRunEnv(self) + env.generate(scope="build") + + tc = AutotoolsToolchain(self) + yes_no = lambda v: "yes" if v else "no" + + # Bundled `configure` script does not support these options, so remove + exclusions = ["--enable-shared", "--disable-static", "--sbindir", "--oldincludedir"] + tc.configure_args = [arg for arg in tc.configure_args if not any(exclusion in arg for exclusion in exclusions)] + + tc.configure_args.append("--datadir=${prefix}/res") + tc.configure_args.append("LDFLAGS=-lm") + + if self.options.get_safe("with_alsa"): + tc.configure_args.append("--enable-alsa") + + tc.generate() + + tc = PkgConfigDeps(self) + tc.generate() + + tc = AutotoolsDeps(self) + tc.generate() + + def build(self): + autotools = Autotools(self) + if Version(self.version) > "1.2.4": + autotools.configure() + autotools.make() + else: + with chdir(self, self.source_folder): + autotools.configure() + autotools.make() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + if Version(self.version) > "1.2.4": + autotools = Autotools(self) + autotools.install() + else: + with chdir(self, self.source_folder): + autotools = Autotools(self) + autotools.install() + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "bin")) + + def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "sndio") + self.cpp_info.set_property("cmake_target_name", "sndio::sndio") + self.cpp_info.set_property("pkg_config_name", "sndio") + self.cpp_info.libs = ["sndio"] + self.cpp_info.system_libs = ["dl", "m", "rt"] + + # TODO: to remove in conan v2? + self.cpp_info.names["cmake_find_package"] = "sndio" + self.cpp_info.names["cmake_find_package_multi"] = "sndio" + self.cpp_info.names["pkg_config"] = "sndio" diff --git a/recipes/libsndio/config.yml b/recipes/libsndio/config.yml new file mode 100644 index 0000000000000..95efce85442dd --- /dev/null +++ b/recipes/libsndio/config.yml @@ -0,0 +1,3 @@ +versions: + "1.9.0": + folder: "all" From a78244845b039015ff3da1bb6dcb7f49855dd836 Mon Sep 17 00:00:00 2001 From: Charles Cross Date: Thu, 14 Mar 2024 11:16:21 -0700 Subject: [PATCH 02/14] Adds test package --- .../libsndio/all/test_package/CMakeLists.txt | 7 +++++ .../libsndio/all/test_package/conanfile.py | 26 +++++++++++++++++++ .../libsndio/all/test_package/test_package.c | 24 +++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 recipes/libsndio/all/test_package/CMakeLists.txt create mode 100644 recipes/libsndio/all/test_package/conanfile.py create mode 100644 recipes/libsndio/all/test_package/test_package.c diff --git a/recipes/libsndio/all/test_package/CMakeLists.txt b/recipes/libsndio/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..29d5d52c61281 --- /dev/null +++ b/recipes/libsndio/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(sndio REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE sndio::sndio) diff --git a/recipes/libsndio/all/test_package/conanfile.py b/recipes/libsndio/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/libsndio/all/test_package/conanfile.py @@ -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") diff --git a/recipes/libsndio/all/test_package/test_package.c b/recipes/libsndio/all/test_package/test_package.c new file mode 100644 index 0000000000000..654cfcb593e78 --- /dev/null +++ b/recipes/libsndio/all/test_package/test_package.c @@ -0,0 +1,24 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) { + int ch; + unsigned mode = SIO_PLAY | SIO_REC; + struct sio_hdl *hdl; + + hdl = sio_open(NULL, mode, 0); + if (hdl == NULL) { + fprintf(stderr, "sio_open() failed\n"); + exit(0); + } else { + printf("sio_open() success" ); + } + sio_close(hdl); + return 0; +} From b91647859ee6427df599ded04dc78094fe3aa64f Mon Sep 17 00:00:00 2001 From: Charles Cross Date: Thu, 14 Mar 2024 11:16:49 -0700 Subject: [PATCH 03/14] Changes package to shared-library and adds support for passing conan dep info to sndio's configure script --- recipes/libsndio/all/conanfile.py | 50 ++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/recipes/libsndio/all/conanfile.py b/recipes/libsndio/all/conanfile.py index 8112cda9640cf..ea339715e0cec 100644 --- a/recipes/libsndio/all/conanfile.py +++ b/recipes/libsndio/all/conanfile.py @@ -19,25 +19,19 @@ class LibsndioConan(ConanFile): topics = ("sndio", "sound", "audio", "midi") description = "A small audio and MIDI framework that provides a lightweight audio & MIDI server \ and a user-space API to access either the server or the hardware directly in a uniform way." - package_type = "library" + package_type = "shared-library" settings = "os", "arch", "compiler", "build_type" options = { - "shared": [True, False], - "fPIC": [True, False], "with_alsa": [True, False] } default_options = { - "shared": True, - "fPIC": True, "with_alsa": True } - def configure(self): - if self.options.shared: - self.options.rm_safe("fPIC") - + def configure(self): if self.options.get_safe("with_alsa"): self.requires("libalsa/1.2.10") + self.options["libalsa/*"].shared = True self.settings.rm_safe("compiler.libcxx") self.settings.rm_safe("compiler.cppstd") @@ -63,23 +57,45 @@ def generate(self): env.generate(scope="build") tc = AutotoolsToolchain(self) - yes_no = lambda v: "yes" if v else "no" + + # Set expected config + tc.configure_args.append( "--datadir=${prefix}/res" ) # Bundled `configure` script does not support these options, so remove - exclusions = ["--enable-shared", "--disable-static", "--sbindir", "--oldincludedir"] + exclusions = ["--enable-shared", "--disable-shared", "--disable-static", "--enable-static", "--sbindir", "--oldincludedir"] tc.configure_args = [arg for arg in tc.configure_args if not any(exclusion in arg for exclusion in exclusions)] - tc.configure_args.append("--datadir=${prefix}/res") - tc.configure_args.append("LDFLAGS=-lm") - + # Add alsa support if self.options.get_safe("with_alsa"): tc.configure_args.append("--enable-alsa") + else: + tc.configure_args.append("--disable-alsa") + + # Inject conan dependency information into sndio configuration + dep_cflags = [] + dep_ldflags = [] + for dependency in reversed(self.dependencies.host.topological_sort.values()): + deps_cpp_info = dependency.cpp_info.aggregated_components() + + dep_cflags.extend( deps_cpp_info.cflags + deps_cpp_info.defines ) + for path in deps_cpp_info.includedirs: + dep_cflags.append( "-I%s" % path ) + + dep_ldflags.extend( deps_cpp_info.sharedlinkflags + deps_cpp_info.exelinkflags ) + for path in deps_cpp_info.libdirs: + dep_ldflags.append( "-L%s" % path ) + for lib in reversed(deps_cpp_info.libs + deps_cpp_info.system_libs): + dep_ldflags.append( "-l%s" % lib ) + + cflags = ' '.join([flag for flag in dep_cflags]) + ldflags = ' '.join([flag for flag in dep_ldflags]) + tc.configure_args.extend([ + f"CFLAGS={cflags}", + f"LDFLAGS={ldflags}" + ]) tc.generate() - tc = PkgConfigDeps(self) - tc.generate() - tc = AutotoolsDeps(self) tc.generate() From 9a72e7a7058cac0cf78aa0bc6cc516a2645472c4 Mon Sep 17 00:00:00 2001 From: Charles Cross Date: Thu, 14 Mar 2024 12:05:22 -0700 Subject: [PATCH 04/14] Addesses linting issues --- recipes/libsndio/all/conanfile.py | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/recipes/libsndio/all/conanfile.py b/recipes/libsndio/all/conanfile.py index ea339715e0cec..7b48fb5bf1ffc 100644 --- a/recipes/libsndio/all/conanfile.py +++ b/recipes/libsndio/all/conanfile.py @@ -1,9 +1,8 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration from conan.tools.env import VirtualBuildEnv, VirtualRunEnv -from conan.tools.files import apply_conandata_patches, chdir, copy, export_conandata_patches, get, rm, rmdir -from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps, PkgConfigDeps -from conan.tools.layout import basic_layout +from conan.tools.files import chdir, copy, get, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps from conan.tools.scm import Version from conan.tools.build import cross_building import os @@ -28,7 +27,7 @@ class LibsndioConan(ConanFile): "with_alsa": True } - def configure(self): + def configure(self): if self.options.get_safe("with_alsa"): self.requires("libalsa/1.2.10") self.options["libalsa/*"].shared = True @@ -70,22 +69,22 @@ def generate(self): tc.configure_args.append("--enable-alsa") else: tc.configure_args.append("--disable-alsa") - + # Inject conan dependency information into sndio configuration dep_cflags = [] dep_ldflags = [] for dependency in reversed(self.dependencies.host.topological_sort.values()): - deps_cpp_info = dependency.cpp_info.aggregated_components() - - dep_cflags.extend( deps_cpp_info.cflags + deps_cpp_info.defines ) - for path in deps_cpp_info.includedirs: - dep_cflags.append( "-I%s" % path ) - - dep_ldflags.extend( deps_cpp_info.sharedlinkflags + deps_cpp_info.exelinkflags ) - for path in deps_cpp_info.libdirs: - dep_ldflags.append( "-L%s" % path ) - for lib in reversed(deps_cpp_info.libs + deps_cpp_info.system_libs): - dep_ldflags.append( "-l%s" % lib ) + deps_cpp_info = dependency.cpp_info.aggregated_components() + + dep_cflags.extend( deps_cpp_info.cflags + deps_cpp_info.defines ) + for path in deps_cpp_info.includedirs: + dep_cflags.append( f"-I{path}" ) + + dep_ldflags.extend( deps_cpp_info.sharedlinkflags + deps_cpp_info.exelinkflags ) + for path in deps_cpp_info.libdirs: + dep_ldflags.append( f"-L{path}" ) + for lib in reversed(deps_cpp_info.libs + deps_cpp_info.system_libs): + dep_ldflags.append( f"-l{lib}" ) cflags = ' '.join([flag for flag in dep_cflags]) ldflags = ' '.join([flag for flag in dep_ldflags]) From 9d39cf62da1cae48fad5265f07069198aa3fe114 Mon Sep 17 00:00:00 2001 From: Charles Cross Date: Thu, 14 Mar 2024 12:50:17 -0700 Subject: [PATCH 05/14] Adds v1 test package --- .../libsndio/all/test_v1_package/CMakeLists.txt | 8 ++++++++ .../libsndio/all/test_v1_package/conanfile.py | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 recipes/libsndio/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/libsndio/all/test_v1_package/conanfile.py diff --git a/recipes/libsndio/all/test_v1_package/CMakeLists.txt b/recipes/libsndio/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/libsndio/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/libsndio/all/test_v1_package/conanfile.py b/recipes/libsndio/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libsndio/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) From 3cb7cca73f4f7cae55d259307e6d74cda1c1e224 Mon Sep 17 00:00:00 2001 From: Charles Cross Date: Fri, 15 Mar 2024 10:27:32 -0700 Subject: [PATCH 06/14] Removes reversal of library elements in ldflags construction Co-authored-by: ericLemanissier --- recipes/libsndio/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/libsndio/all/conanfile.py b/recipes/libsndio/all/conanfile.py index 7b48fb5bf1ffc..1065f359578ad 100644 --- a/recipes/libsndio/all/conanfile.py +++ b/recipes/libsndio/all/conanfile.py @@ -83,7 +83,7 @@ def generate(self): dep_ldflags.extend( deps_cpp_info.sharedlinkflags + deps_cpp_info.exelinkflags ) for path in deps_cpp_info.libdirs: dep_ldflags.append( f"-L{path}" ) - for lib in reversed(deps_cpp_info.libs + deps_cpp_info.system_libs): + for lib in deps_cpp_info.libs + deps_cpp_info.system_libs: dep_ldflags.append( f"-l{lib}" ) cflags = ' '.join([flag for flag in dep_cflags]) From 31b71ab3909cdb0d91a3779cbe4deeeaad00bf1c Mon Sep 17 00:00:00 2001 From: Charles Cross Date: Fri, 15 Mar 2024 15:10:35 -0700 Subject: [PATCH 07/14] Patches out all targets from makefile.in except libsndio --- recipes/libsndio/all/conanfile.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/recipes/libsndio/all/conanfile.py b/recipes/libsndio/all/conanfile.py index 1065f359578ad..cd89f985ea2ca 100644 --- a/recipes/libsndio/all/conanfile.py +++ b/recipes/libsndio/all/conanfile.py @@ -1,7 +1,7 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration from conan.tools.env import VirtualBuildEnv, VirtualRunEnv -from conan.tools.files import chdir, copy, get, rmdir +from conan.tools.files import chdir, copy, get, rmdir, replace_in_file from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps from conan.tools.scm import Version from conan.tools.build import cross_building @@ -45,6 +45,20 @@ def build_requirements(self): def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) + # Remove all targets other than libsndio + lines = [ + "cd sndiod && ${MAKE} install", + "cd sndioctl && ${MAKE} install", + "cd aucat && ${MAKE} install", + "cd midicat && ${MAKE} install", + "cd sndiod && ${MAKE}", + "cd sndioctl && ${MAKE}", + "cd aucat && ${MAKE}", + "cd midicat && ${MAKE}" + ] + for line in lines: + replace_in_file(self, os.path.join(self.source_folder, "Makefile.in"), line, "") + def generate(self): virtual_build_env = VirtualBuildEnv(self) virtual_build_env.generate() @@ -85,6 +99,7 @@ def generate(self): dep_ldflags.append( f"-L{path}" ) for lib in deps_cpp_info.libs + deps_cpp_info.system_libs: dep_ldflags.append( f"-l{lib}" ) + pass cflags = ' '.join([flag for flag in dep_cflags]) ldflags = ' '.join([flag for flag in dep_ldflags]) From 9656fd337d23fe21008c311eefc646510ba5836f Mon Sep 17 00:00:00 2001 From: Charles Cross Date: Fri, 15 Mar 2024 15:15:06 -0700 Subject: [PATCH 08/14] Removes leftover pass from debugging --- recipes/libsndio/all/conanfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes/libsndio/all/conanfile.py b/recipes/libsndio/all/conanfile.py index cd89f985ea2ca..d3d8c209257dc 100644 --- a/recipes/libsndio/all/conanfile.py +++ b/recipes/libsndio/all/conanfile.py @@ -99,7 +99,6 @@ def generate(self): dep_ldflags.append( f"-L{path}" ) for lib in deps_cpp_info.libs + deps_cpp_info.system_libs: dep_ldflags.append( f"-l{lib}" ) - pass cflags = ' '.join([flag for flag in dep_cflags]) ldflags = ' '.join([flag for flag in dep_ldflags]) From cc275fcd778085964be0c3e3513c416bb0d91b12 Mon Sep 17 00:00:00 2001 From: Charles Cross Date: Fri, 15 Mar 2024 16:03:05 -0700 Subject: [PATCH 09/14] Downloads license file from github permalink, as it is not contained in any distributed source tar --- recipes/libsndio/all/conandata.yml | 6 ++++-- recipes/libsndio/all/conanfile.py | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/recipes/libsndio/all/conandata.yml b/recipes/libsndio/all/conandata.yml index 7b145eb97bca1..d3067e4caf3f4 100644 --- a/recipes/libsndio/all/conandata.yml +++ b/recipes/libsndio/all/conandata.yml @@ -1,4 +1,6 @@ sources: "1.9.0": - url: "https://sndio.org/sndio-1.9.0.tar.gz" - sha256: "f30826fc9c07e369d3924d5fcedf6a0a53c0df4ae1f5ab50fe9cf280540f699a" + url: "https://github.com/ratchov/sndio/archive/refs/tags/v1.9.0.tar.gz" + sha256: "4e8d77069b651d7c4bb2a50ba49004bd7fcfdfec1516f88a76457f831c17a546" +license: + url: "https://github.com/ratchov/sndio/blob/a15be2c70311c703352c9d4ef2eca5219730ae06/LICENSE" \ No newline at end of file diff --git a/recipes/libsndio/all/conanfile.py b/recipes/libsndio/all/conanfile.py index d3d8c209257dc..62b7b144a248d 100644 --- a/recipes/libsndio/all/conanfile.py +++ b/recipes/libsndio/all/conanfile.py @@ -1,7 +1,7 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration from conan.tools.env import VirtualBuildEnv, VirtualRunEnv -from conan.tools.files import chdir, copy, get, rmdir, replace_in_file +from conan.tools.files import chdir, copy, get, rmdir, replace_in_file, download from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps from conan.tools.scm import Version from conan.tools.build import cross_building @@ -44,6 +44,7 @@ def build_requirements(self): def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) + download(self, self.conan_data["license"]["url"], "LICENSE" ) # Remove all targets other than libsndio lines = [ From f8283bc97909294d8e0107a15f4eb797a7f27cbb Mon Sep 17 00:00:00 2001 From: Charles Cross Date: Fri, 15 Mar 2024 16:04:50 -0700 Subject: [PATCH 10/14] Fixes linting issue --- recipes/libsndio/all/conandata.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/libsndio/all/conandata.yml b/recipes/libsndio/all/conandata.yml index d3067e4caf3f4..85a52863bf1bb 100644 --- a/recipes/libsndio/all/conandata.yml +++ b/recipes/libsndio/all/conandata.yml @@ -3,4 +3,4 @@ sources: url: "https://github.com/ratchov/sndio/archive/refs/tags/v1.9.0.tar.gz" sha256: "4e8d77069b651d7c4bb2a50ba49004bd7fcfdfec1516f88a76457f831c17a546" license: - url: "https://github.com/ratchov/sndio/blob/a15be2c70311c703352c9d4ef2eca5219730ae06/LICENSE" \ No newline at end of file + url: "https://github.com/ratchov/sndio/blob/a15be2c70311c703352c9d4ef2eca5219730ae06/LICENSE" From 1919280500d10f45b94b0f37050a55ac64a07e91 Mon Sep 17 00:00:00 2001 From: Charles Cross Date: Fri, 15 Mar 2024 16:18:09 -0700 Subject: [PATCH 11/14] Fixes license file download --- recipes/libsndio/all/conandata.yml | 10 ++++++---- recipes/libsndio/all/conanfile.py | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/recipes/libsndio/all/conandata.yml b/recipes/libsndio/all/conandata.yml index 85a52863bf1bb..17fe5ab522e62 100644 --- a/recipes/libsndio/all/conandata.yml +++ b/recipes/libsndio/all/conandata.yml @@ -1,6 +1,8 @@ sources: "1.9.0": - url: "https://github.com/ratchov/sndio/archive/refs/tags/v1.9.0.tar.gz" - sha256: "4e8d77069b651d7c4bb2a50ba49004bd7fcfdfec1516f88a76457f831c17a546" -license: - url: "https://github.com/ratchov/sndio/blob/a15be2c70311c703352c9d4ef2eca5219730ae06/LICENSE" + "source": + url: "https://github.com/ratchov/sndio/archive/refs/tags/v1.9.0.tar.gz" + sha256: "4e8d77069b651d7c4bb2a50ba49004bd7fcfdfec1516f88a76457f831c17a546" + "license": + url: "https://raw.githubusercontent.com/ratchov/sndio/e10e4f836b88f8d5ea2864845e3712f560e6bed6/LICENSE" + sha256: "4ae392ab9cfbf2d6ac8522f5f4b025685d60c824979fad783aaf72d55165730f" diff --git a/recipes/libsndio/all/conanfile.py b/recipes/libsndio/all/conanfile.py index 62b7b144a248d..d04712f0ab80d 100644 --- a/recipes/libsndio/all/conanfile.py +++ b/recipes/libsndio/all/conanfile.py @@ -43,8 +43,8 @@ def build_requirements(self): self.tool_requires("libtool/2.4.7") def source(self): - get(self, **self.conan_data["sources"][self.version], strip_root=True) - download(self, self.conan_data["license"]["url"], "LICENSE" ) + get(self, **self.conan_data["sources"][self.version]["source"], strip_root=True) + download(self, **self.conan_data["sources"][self.version]["license"], filename="LICENSE") # Remove all targets other than libsndio lines = [ From 6359318376f6c03201c0c66e9c74cda3d23867ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Rinc=C3=B3n=20Blanco?= Date: Mon, 18 Mar 2024 15:04:47 +0100 Subject: [PATCH 12/14] Improvementes --- recipes/libsndio/all/conanfile.py | 25 +++++++++++-------- .../libsndio/all/test_package/test_package.c | 2 +- .../all/test_v1_package/CMakeLists.txt | 8 ------ .../libsndio/all/test_v1_package/conanfile.py | 17 ------------- 4 files changed, 15 insertions(+), 37 deletions(-) delete mode 100644 recipes/libsndio/all/test_v1_package/CMakeLists.txt delete mode 100644 recipes/libsndio/all/test_v1_package/conanfile.py diff --git a/recipes/libsndio/all/conanfile.py b/recipes/libsndio/all/conanfile.py index d04712f0ab80d..9b5dafc639e3a 100644 --- a/recipes/libsndio/all/conanfile.py +++ b/recipes/libsndio/all/conanfile.py @@ -24,14 +24,10 @@ class LibsndioConan(ConanFile): "with_alsa": [True, False] } default_options = { - "with_alsa": True + "with_alsa": True, } def configure(self): - if self.options.get_safe("with_alsa"): - self.requires("libalsa/1.2.10") - self.options["libalsa/*"].shared = True - self.settings.rm_safe("compiler.libcxx") self.settings.rm_safe("compiler.cppstd") @@ -39,6 +35,13 @@ def validate(self): if self.settings.os != "Linux": raise ConanInvalidConfiguration(f"{self.ref} only supports Linux") + if self.options.with_alsa and not self.dependencies["libalsa"].options.get_safe("shared", False): + raise ConanInvalidConfiguration(f"{self.ref} requires libalsa to be built as a shared library") + + def requirements(self): + if self.options.get_safe("with_alsa"): + self.requires("libalsa/1.2.10", options={"shared": True}) + def build_requirements(self): self.tool_requires("libtool/2.4.7") @@ -73,7 +76,7 @@ def generate(self): tc = AutotoolsToolchain(self) # Set expected config - tc.configure_args.append( "--datadir=${prefix}/res" ) + tc.configure_args.append("--datadir=${prefix}/res") # Bundled `configure` script does not support these options, so remove exclusions = ["--enable-shared", "--disable-shared", "--disable-static", "--enable-static", "--sbindir", "--oldincludedir"] @@ -91,15 +94,15 @@ def generate(self): for dependency in reversed(self.dependencies.host.topological_sort.values()): deps_cpp_info = dependency.cpp_info.aggregated_components() - dep_cflags.extend( deps_cpp_info.cflags + deps_cpp_info.defines ) + dep_cflags.extend(deps_cpp_info.cflags + deps_cpp_info.defines) for path in deps_cpp_info.includedirs: - dep_cflags.append( f"-I{path}" ) + dep_cflags.append(f"-I{path}") - dep_ldflags.extend( deps_cpp_info.sharedlinkflags + deps_cpp_info.exelinkflags ) + dep_ldflags.extend(deps_cpp_info.sharedlinkflags + deps_cpp_info.exelinkflags) for path in deps_cpp_info.libdirs: - dep_ldflags.append( f"-L{path}" ) + dep_ldflags.append(f"-L{path}") for lib in deps_cpp_info.libs + deps_cpp_info.system_libs: - dep_ldflags.append( f"-l{lib}" ) + dep_ldflags.append(f"-l{lib}") cflags = ' '.join([flag for flag in dep_cflags]) ldflags = ' '.join([flag for flag in dep_ldflags]) diff --git a/recipes/libsndio/all/test_package/test_package.c b/recipes/libsndio/all/test_package/test_package.c index 654cfcb593e78..03387869c0a9d 100644 --- a/recipes/libsndio/all/test_package/test_package.c +++ b/recipes/libsndio/all/test_package/test_package.c @@ -14,7 +14,7 @@ int main(int argc, char *argv[]) { hdl = sio_open(NULL, mode, 0); if (hdl == NULL) { - fprintf(stderr, "sio_open() failed\n"); + fprintf(stderr, "sio_open() failed, but test is ok\n"); exit(0); } else { printf("sio_open() success" ); diff --git a/recipes/libsndio/all/test_v1_package/CMakeLists.txt b/recipes/libsndio/all/test_v1_package/CMakeLists.txt deleted file mode 100644 index 925ecbe19e448..0000000000000 --- a/recipes/libsndio/all/test_v1_package/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ - ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/libsndio/all/test_v1_package/conanfile.py b/recipes/libsndio/all/test_v1_package/conanfile.py deleted file mode 100644 index 38f4483872d47..0000000000000 --- a/recipes/libsndio/all/test_v1_package/conanfile.py +++ /dev/null @@ -1,17 +0,0 @@ -from conans import ConanFile, CMake, tools -import os - - -class TestPackageConan(ConanFile): - settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" - - def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() - - def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) From f8452d19d28e4376ff85635165f2a9633e5ff346 Mon Sep 17 00:00:00 2001 From: Charles Cross Date: Tue, 2 Apr 2024 11:49:16 -0700 Subject: [PATCH 13/14] Addresses review feedback, adding contextual comments and extending support to FreeBSD --- recipes/libsndio/all/conanfile.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/recipes/libsndio/all/conanfile.py b/recipes/libsndio/all/conanfile.py index 9b5dafc639e3a..884e008ea9cbd 100644 --- a/recipes/libsndio/all/conanfile.py +++ b/recipes/libsndio/all/conanfile.py @@ -32,8 +32,8 @@ def configure(self): self.settings.rm_safe("compiler.cppstd") def validate(self): - if self.settings.os != "Linux": - raise ConanInvalidConfiguration(f"{self.ref} only supports Linux") + if self.settings.os not in ["Linux", "FreeBSD"]: + raise ConanInvalidConfiguration(f"Unsupported OS for {self.ref}") if self.options.with_alsa and not self.dependencies["libalsa"].options.get_safe("shared", False): raise ConanInvalidConfiguration(f"{self.ref} requires libalsa to be built as a shared library") @@ -67,8 +67,8 @@ def generate(self): virtual_build_env = VirtualBuildEnv(self) virtual_build_env.generate() - # # inject requires env vars in build scope - # # it's required in case of native build when there is AutotoolsDeps & at least one dependency which might be shared, because configure tries to run a test executable + # Inject requires env vars in build scope + # It's required in case of native build when there is AutotoolsDeps & at least one dependency which might be shared, because configure tries to run a test executable if not cross_building(self): env = VirtualRunEnv(self) env.generate(scope="build") @@ -88,7 +88,11 @@ def generate(self): else: tc.configure_args.append("--disable-alsa") - # Inject conan dependency information into sndio configuration + # The original project source has a hand-written `configure` script that does not expose + # many hooks for specifying additional build flags and library dependencies. Because the script is + # not auto-generated with Autotools, the standard Conan workflow of using AutoolsDeps is not possible. + # The one hook the script does provide is a command line arg: `CC=*|CFLAGS=*|LDFLAGS=*|AR=*)`. + # We use this to inject the various flags, paths, and libraries that the Conan dependency tree specifies. dep_cflags = [] dep_ldflags = [] for dependency in reversed(self.dependencies.host.topological_sort.values()): From 61bab76d4eb58672c9433533029dd407ca9c7055 Mon Sep 17 00:00:00 2001 From: Charles Cross Date: Tue, 2 Apr 2024 11:51:02 -0700 Subject: [PATCH 14/14] Adjust whitespace according to review feedback Co-authored-by: Martin Valgur --- recipes/libsndio/all/conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/libsndio/all/conanfile.py b/recipes/libsndio/all/conanfile.py index 884e008ea9cbd..adf05fa3505c4 100644 --- a/recipes/libsndio/all/conanfile.py +++ b/recipes/libsndio/all/conanfile.py @@ -16,8 +16,8 @@ class LibsndioConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://sndio.org/" topics = ("sndio", "sound", "audio", "midi") - description = "A small audio and MIDI framework that provides a lightweight audio & MIDI server \ - and a user-space API to access either the server or the hardware directly in a uniform way." + description = ("A small audio and MIDI framework that provides a lightweight audio & MIDI server " + "and a user-space API to access either the server or the hardware directly in a uniform way.") package_type = "shared-library" settings = "os", "arch", "compiler", "build_type" options = {