-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* tinyalsa: conan2 * Remove 1.1.1, use CMake to build * Set src_folder * Remove tinyalsa 1.1.1 * Add v1 test package * Revert "Remove tinyalsa 1.1.1" This reverts commit c0034d1. * Revert "Set src_folder" This reverts commit 686a648. * Revert "Remove 1.1.1, use CMake to build" This reverts commit 244b84b. * Add patches for fixing clang build * Simplify removing extra packaged files * Patch source should just be a URL Co-authored-by: Uilian Ries <uilianries@gmail.com> * Readd + deprecate with_utils option * Restore with_utils option --------- Co-authored-by: Uilian Ries <uilianries@gmail.com>
- Loading branch information
1 parent
762606a
commit e70ab4a
Showing
9 changed files
with
236 additions
and
46 deletions.
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
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,68 +1,78 @@ | ||
from conans import ConanFile, tools, AutoToolsBuildEnvironment | ||
from conans.errors import ConanInvalidConfiguration | ||
from conan import ConanFile | ||
from conan.tools.files import get, export_conandata_patches, apply_conandata_patches, chdir, copy, rm, rmdir | ||
from conan.tools.gnu import Autotools, AutotoolsToolchain | ||
from conan.tools.layout import basic_layout | ||
from conan.tools.scm import Version | ||
from conan.errors import ConanInvalidConfiguration | ||
import os | ||
|
||
required_conan_version = ">=1.33.0" | ||
required_conan_version = ">=1.53.0" | ||
|
||
class TinyAlsaConan(ConanFile): | ||
name = "tinyalsa" | ||
description = "A small library to interface with ALSA in the Linux kernel" | ||
license = "BSD-3-Clause" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/tinyalsa/tinyalsa" | ||
topics = ("tiny", "alsa", "sound", "audio", "tinyalsa") | ||
description = "A small library to interface with ALSA in the Linux kernel" | ||
exports_sources = ["patches/*",] | ||
options = {"shared": [True, False], "with_utils": [True, False]} | ||
default_options = {'shared': False, 'with_utils': False} | ||
package_type = "library" | ||
settings = "os", "compiler", "build_type", "arch" | ||
options = {"shared": [True, False], "with_utils": [True, False]} | ||
default_options = {"shared": False, "with_utils": False} | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
def layout(self): | ||
basic_layout(self, src_folder="src") | ||
|
||
def validate(self): | ||
if self.settings.os != "Linux": | ||
raise ConanInvalidConfiguration("{} only works for Linux.".format(self.name)) | ||
|
||
def configure(self): | ||
del self.settings.compiler.libcxx | ||
del self.settings.compiler.cppstd | ||
self.settings.rm_safe("compiler.libcxx") | ||
self.settings.rm_safe("compiler.cppstd") | ||
|
||
def export_sources(self): | ||
export_conandata_patches(self) | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
|
||
def generate(self): | ||
tc = AutotoolsToolchain(self) | ||
tc.generate() | ||
|
||
def build(self): | ||
for patch in self.conan_data.get("patches", {}).get(self.version, []): | ||
tools.patch(**patch) | ||
with tools.chdir(self._source_subfolder): | ||
env_build = AutoToolsBuildEnvironment(self) | ||
env_build.make() | ||
apply_conandata_patches(self) | ||
with chdir(self, self.source_folder): | ||
at = Autotools(self) | ||
at.make() | ||
|
||
def package(self): | ||
self.copy("NOTICE", dst="licenses", src=self._source_subfolder) | ||
copy(self, "NOTICE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) | ||
|
||
with tools.chdir(self._source_subfolder): | ||
env_build = AutoToolsBuildEnvironment(self) | ||
env_build_vars = env_build.vars | ||
env_build_vars['PREFIX'] = self.package_folder | ||
env_build.install(vars=env_build_vars) | ||
with chdir(self, self.source_folder): | ||
at = Autotools(self) | ||
at.install(args=[f"DESTDIR={self.package_folder}", "PREFIX="]) | ||
|
||
tools.rmdir(os.path.join(self.package_folder, "share")) | ||
rmdir(self, os.path.join(self.package_folder, "share")) | ||
|
||
if not self.options.with_utils: | ||
tools.rmdir(os.path.join(self.package_folder, "bin")) | ||
pattern_to_remove = "*.a" if self.options.shared else "*.so" | ||
rm(self, pattern_to_remove, os.path.join(self.package_folder, "lib")) | ||
|
||
with tools.chdir(os.path.join(self.package_folder, "lib")): | ||
files = os.listdir() | ||
for f in files: | ||
if (self.options.shared and f.endswith(".a")) or (not self.options.shared and not f.endswith(".a")): | ||
os.unlink(f) | ||
if not self.options.with_utils: | ||
rmdir(self, os.path.join(self.package_folder, "bin")) | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = ["tinyalsa"] | ||
if tools.Version(self.version) >= "2.0.0": | ||
if Version(self.version) >= "2.0.0": | ||
self.cpp_info.system_libs.append("dl") | ||
|
||
if self.options.with_utils: | ||
bin_path = os.path.join(self.package_folder, "bin") | ||
self.output.info('Appending PATH environment variable: %s' % bin_path) | ||
self.output.info(f"Appending PATH environment variable: {bin_path}") | ||
self.env_info.path.append(bin_path) | ||
|
||
# Needed for compatibility with v1.x - Remove when 2.0 becomes the default | ||
bin_path = os.path.join(self.package_folder, "bin") | ||
self.output.info(f'Appending PATH environment variable: {bin_path}') | ||
self.env_info.PATH.append(bin_path) |
46 changes: 46 additions & 0 deletions
46
recipes/tinyalsa/all/patches/tinyalsa-1.1.1-fix-hardcoded-gcc.patch
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,46 @@ | ||
diff --git a/examples/Makefile b/examples/Makefile | ||
index 807d4c8..32a8a9b 100644 | ||
--- a/examples/Makefile | ||
+++ b/examples/Makefile | ||
@@ -1,6 +1,5 @@ | ||
CROSS_COMPILE ?= | ||
|
||
-CC = $(CROSS_COMPILE)gcc | ||
CFLAGS = -Wall -Wextra -Werror -Wfatal-errors -I ../include | ||
|
||
VPATH = ../src | ||
diff --git a/src/Makefile b/src/Makefile | ||
index d33c9f1..0e5c054 100644 | ||
--- a/src/Makefile | ||
+++ b/src/Makefile | ||
@@ -7,9 +7,6 @@ LIBDIR := $(LIBDIR)/$(DEB_HOST_MULTIARCH) | ||
endif | ||
|
||
CROSS_COMPILE = | ||
-CC = $(CROSS_COMPILE)gcc | ||
-AR = $(CROSS_COMPILE)ar | ||
-LD = $(CROSS_COMPILE)gcc | ||
|
||
WARNINGS = -Wall -Wextra -Werror -Wfatal-errors | ||
INCLUDE_DIRS = -I ../include | ||
@@ -37,7 +34,7 @@ libtinyalsa.so.1: libtinyalsa.so.1.1.1 | ||
ln -sf $< $@ | ||
|
||
libtinyalsa.so.1.1.1: $(OBJECTS) | ||
- $(LD) $(LDFLAGS) -shared -Wl,-soname,libtinyalsa.so.1 $^ -o $@ | ||
+ $(CC) $(LDFLAGS) -shared -Wl,-soname,libtinyalsa.so.1 $^ -o $@ | ||
|
||
.PHONY: clean | ||
clean: | ||
diff --git a/utils/Makefile b/utils/Makefile | ||
index ad4bc5c..ab90c79 100644 | ||
--- a/utils/Makefile | ||
+++ b/utils/Makefile | ||
@@ -4,7 +4,6 @@ BINDIR ?= $(PREFIX)/bin | ||
MANDIR ?= $(PREFIX)/man | ||
|
||
CROSS_COMPILE ?= | ||
-CC = $(CROSS_COMPILE)gcc | ||
|
||
CFLAGS += -Wall -Wextra -Werror -Wfatal-errors | ||
CFLAGS += -I ../include |
40 changes: 40 additions & 0 deletions
40
recipes/tinyalsa/all/patches/tinyalsa-1.1.1-fix-make-clang-build.patch
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,40 @@ | ||
diff --git a/utils/Makefile b/utils/Makefile | ||
index ad4bc5c..fb52cd3 100644 | ||
--- a/utils/Makefile | ||
+++ b/utils/Makefile | ||
@@ -8,21 +8,30 @@ CC = $(CROSS_COMPILE)gcc | ||
|
||
CFLAGS += -Wall -Wextra -Werror -Wfatal-errors | ||
CFLAGS += -I ../include | ||
-CFLAGS += -L ../src | ||
CFLAGS += -O2 | ||
|
||
+LDFLAGS += -L ../src | ||
+ | ||
VPATH = ../src:../include/tinyalsa | ||
|
||
.PHONY: all | ||
all: -ltinyalsa tinyplay tinycap tinymix tinypcminfo | ||
|
||
-tinyplay: tinyplay.c pcm.h mixer.h asoundlib.h libtinyalsa.a | ||
+tinyplay: tinyplay.o libtinyalsa.a | ||
+ | ||
+tinyplay.o: tinyplay.c pcm.h mixer.h asoundlib.h | ||
+ | ||
+tinycap: tinycap.o libtinyalsa.a | ||
+ | ||
+tinycap.o: tinycap.c pcm.h mixer.h asoundlib.h | ||
+ | ||
+tinymix: tinymix.o libtinyalsa.a | ||
|
||
-tinycap: tinycap.c pcm.h mixer.h asoundlib.h libtinyalsa.a | ||
+tinymix.o: tinymix.c pcm.h mixer.h asoundlib.h | ||
|
||
-tinymix: tinymix.c pcm.h mixer.h asoundlib.h libtinyalsa.a | ||
+tinypcminfo: tinypcminfo.o libtinyalsa.a | ||
|
||
-tinypcminfo: tinypcminfo.c pcm.h mixer.h asoundlib.h libtinyalsa.a | ||
+tinypcminfo.o: tinypcminfo.c pcm.h mixer.h asoundlib.h | ||
|
||
.PHONY: clean | ||
clean: |
46 changes: 46 additions & 0 deletions
46
recipes/tinyalsa/all/patches/tinyalsa-2.0.0-fix-hardcoded-gcc.patch
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,46 @@ | ||
diff --git a/examples/Makefile b/examples/Makefile | ||
index 650966d..1f68ff6 100644 | ||
--- a/examples/Makefile | ||
+++ b/examples/Makefile | ||
@@ -1,6 +1,5 @@ | ||
CROSS_COMPILE ?= | ||
|
||
-CC = $(CROSS_COMPILE)gcc | ||
CFLAGS = -Wall -Wextra -Werror -Wfatal-errors -I ../include | ||
|
||
VPATH = ../src | ||
diff --git a/src/Makefile b/src/Makefile | ||
index aaa84b8..ac86400 100644 | ||
--- a/src/Makefile | ||
+++ b/src/Makefile | ||
@@ -6,9 +6,6 @@ ifdef DEB_HOST_MULTIARCH | ||
LIBDIR := $(LIBDIR)/$(DEB_HOST_MULTIARCH) | ||
endif | ||
|
||
-CC = $(CROSS_COMPILE)gcc | ||
-AR = $(CROSS_COMPILE)ar | ||
-LD = $(CROSS_COMPILE)gcc | ||
|
||
WARNINGS = -Wall -Wextra -Werror -Wfatal-errors | ||
INCLUDE_DIRS = -I ../include | ||
@@ -49,7 +46,7 @@ libtinyalsa.so.$(LIBVERSION_MAJOR): libtinyalsa.so.$(LIBVERSION) | ||
ln -sf $< $@ | ||
|
||
libtinyalsa.so.$(LIBVERSION): $(OBJECTS) | ||
- $(LD) $(LDFLAGS) -shared -Wl,-soname,libtinyalsa.so.$(LIBVERSION_MAJOR) $^ -o $@ | ||
+ $(CC) $(LDFLAGS) -shared -Wl,-soname,libtinyalsa.so.$(LIBVERSION_MAJOR) $^ -o $@ | ||
|
||
.PHONY: clean | ||
clean: | ||
diff --git a/utils/Makefile b/utils/Makefile | ||
index f733c39..38a9cb5 100644 | ||
--- a/utils/Makefile | ||
+++ b/utils/Makefile | ||
@@ -4,7 +4,6 @@ BINDIR ?= $(PREFIX)/bin | ||
MANDIR ?= $(PREFIX)/man | ||
|
||
CROSS_COMPILE ?= | ||
-CC = $(CROSS_COMPILE)gcc | ||
|
||
CFLAGS += -Wall -Wextra -Werror -Wfatal-errors | ||
CFLAGS += -I ../include |
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
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,16 +1,32 @@ | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import CMake, cmake_layout | ||
from conan.tools.files import load, save | ||
import os | ||
from conans import ConanFile, CMake, tools | ||
|
||
class LibalsaTestConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake", "cmake_find_package_multi" | ||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str, run=True) | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def generate(self): | ||
save(self, os.path.join(self.build_folder, "with_utils"), | ||
str(self.dependencies["tinyalsa"].options.with_utils)) | ||
|
||
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", "example") | ||
self.run(bin_path, run_environment=True) | ||
if can_run(self): | ||
bin_path = os.path.join(self.cpp.build.bindirs[0], "example") | ||
self.run(bin_path, env="conanrun") | ||
if load(self, os.path.join(self.build_folder, "with_utils")) == "True": | ||
self.run("tinymix --help", env="conanrun") |
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.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) |
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,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", "example") | ||
self.run(bin_path, run_environment=True) |