Skip to content

Commit

Permalink
(#22441) pulseaudio 17.0
Browse files Browse the repository at this point in the history
* pulseaudio 17.0

* Update conanfile.py

* remove gettext

* enable non-linux

* remove unused deps

* don't require xorg on non linux

* remove alsa dependency

* pulseaudio is always shared

https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/blob/v17.0/src/meson.build?ref_type=tags#L201
https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/blob/v17.0/src/pulse/meson.build?ref_type=tags#L83

* Revert "remove gettext"

This reverts commit 667e54d.

* gettext is a requirement (not a tool_requirement)

* Revert "enable non-linux"

This reverts commit bc57129.

* Apply suggestions from code review

Co-authored-by: Uilian Ries <[email protected]>

---------

Co-authored-by: Uilian Ries <[email protected]>
  • Loading branch information
ericLemanissier and uilianries authored Mar 8, 2024
1 parent 18ffa8f commit 3b36ae8
Show file tree
Hide file tree
Showing 6 changed files with 194 additions and 0 deletions.
2 changes: 2 additions & 0 deletions recipes/pulseaudio/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"17.0":
folder: meson
"14.2":
folder: all
"14.0":
Expand Down
4 changes: 4 additions & 0 deletions recipes/pulseaudio/meson/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"17.0":
url: "https://www.freedesktop.org/software/pulseaudio/releases/pulseaudio-17.0.tar.xz"
sha256: "053794d6671a3e397d849e478a80b82a63cb9d8ca296bd35b73317bb5ceb87b5"
147 changes: 147 additions & 0 deletions recipes/pulseaudio/meson/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import cross_building
from conan.tools.env import VirtualBuildEnv, VirtualRunEnv
from conan.tools.files import copy, get, rm, rmdir
from conan.tools.gnu import PkgConfigDeps
from conan.tools.meson import Meson, MesonToolchain
from conan.tools.layout import basic_layout
import os

required_conan_version = ">=1.53.0"


class PulseAudioConan(ConanFile):
name = "pulseaudio"
description = "PulseAudio is a sound system for POSIX OSes, meaning that it is a proxy for sound applications."
topics = ("sound", "audio", "sound-server")
url = "https://github.com/conan-io/conan-center-index"
homepage = "http://pulseaudio.org/"
license = "LGPL-2.1"

package_type = "shared-library"
settings = "os", "arch", "compiler", "build_type"
options = {
"with_glib": [True, False],
"with_fftw": [True, False],
"with_x11": [True, False],
"with_openssl": [True, False],
"with_dbus": [True, False],
}
default_options = {
"with_glib": False,
"with_fftw": False,
"with_x11": True,
"with_openssl": True,
"with_dbus": False,
}

def config_options(self):
if self.settings.os not in ['Linux', 'FreeBSD']:
del self.options.with_x11

def configure(self):
self.settings.rm_safe("compiler.libcxx")
self.settings.rm_safe("compiler.cppstd")
if not self.options.with_dbus:
del self.options.with_fftw

def layout(self):
basic_layout(self, src_folder="src")

def requirements(self):
self.requires("libgettext/0.22")
self.requires("libiconv/1.17")
self.requires("libsndfile/1.2.2")
if self.options.with_glib:
self.requires("glib/2.78.1")
if self.options.get_safe("with_fftw"):
self.requires("fftw/3.3.10")
if self.options.get_safe("with_x11"):
self.requires("xorg/system")
if self.options.with_openssl:
self.requires("openssl/[>=1.1 <4]")
if self.options.with_dbus:
self.requires("dbus/1.15.8")

def validate(self):
if self.settings.os != "Linux":
raise ConanInvalidConfiguration(f"{self.ref} recipe is only compatible with Linux right now. Contributions are welcome.")

if self.options.get_safe("with_fftw"):
if not self.dependencies["fftw"].options.precision_single:
raise ConanInvalidConfiguration(
"Pulse audio uses fftw single precision. "
"Either set option -o fftw/*:precision_single=True or -o pulseaudio/*:with_fftw=False"
)

def build_requirements(self):
self.tool_requires("meson/1.3.1")
if not self.conf.get("tools.gnu:pkg_config", check_type=str):
self.tool_requires("pkgconf/2.0.3")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
env = VirtualBuildEnv(self)
env.generate()
if not cross_building(self):
env = VirtualRunEnv(self)
env.generate(scope="build")

tc = MesonToolchain(self)
tc.project_options['udevrulesdir']="${prefix}/bin/udev/rules.d"
tc.project_options['systemduserunitdir'] = os.path.join(self.build_folder, 'ignore')
for lib in ["x11", "openssl", "dbus", "glib", "fftw"]:
tc.project_options[lib] = "enabled" if self.options.get_safe(f"with_{lib}") else "disabled"
tc.project_options['database'] = 'simple'
tc.project_options['tests'] = False
tc.project_options['man'] = False
tc.project_options['doxygen'] = False
tc.project_options["daemon"] = False
tc.generate()
pkg = PkgConfigDeps(self)
pkg.generate()

def build(self):
meson = Meson(self)
meson.configure()
meson.build()

def package(self):
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
meson = Meson(self)
meson.install()
rmdir(self, os.path.join(self.package_folder, "etc"))
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"))
rm(self, "*.la", os.path.join(self.package_folder, "lib"), recursive=True)

def package_info(self):
self.cpp_info.components["pulse"].set_property("pkg_config_name", "libpulse")
self.cpp_info.components["pulse"].libs = ["pulse", f"pulsecommon-{self.version}"]
self.cpp_info.components["pulse"].libdirs.append(os.path.join("lib", "pulseaudio"))
self.cpp_info.components["pulse"].requires = ["libiconv::libiconv", "libsndfile::libsndfile", "libgettext::libgettext"]
if self.options.get_safe("with_fftw"):
self.cpp_info.components["pulse"].requires.append("fftw::fftw")
if self.options.get_safe("with_x11"):
self.cpp_info.components["pulse"].requires.append("xorg::xorg")
if self.options.with_openssl:
self.cpp_info.components["pulse"].requires.append("openssl::openssl")
if self.options.with_dbus:
self.cpp_info.components["pulse"].requires.append("dbus::dbus")

self.cpp_info.components["pulse-simple"].set_property("pkg_config_name", "libpulse-simple")
self.cpp_info.components["pulse-simple"].libs = ["pulse-simple"]
self.cpp_info.components["pulse-simple"].defines.append("_REENTRANT")
self.cpp_info.components["pulse-simple"].requires = ["pulse"]

if self.options.with_glib:
self.cpp_info.components["pulse-mainloop-glib"].set_property("pkg_config_name", "libpulse-mainloop-glib")
self.cpp_info.components["pulse-mainloop-glib"].libs = ["pulse-mainloop-glib"]
self.cpp_info.components["pulse-mainloop-glib"].defines.append("_REENTRANT")
self.cpp_info.components["pulse-mainloop-glib"].requires = ["pulse", "glib::glib-2.0"]

# FIXME: add cmake generators when conan can generate PULSEAUDIO_INCLUDE_DIR PULSEAUDIO_LIBRARY vars
7 changes: 7 additions & 0 deletions recipes/pulseaudio/meson/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES C)

find_package(pulseaudio REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE pulseaudio::pulseaudio)
26 changes: 26 additions & 0 deletions recipes/pulseaudio/meson/test_package/conanfile.py
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 requirements(self):
self.requires(self.tested_reference_str)

def layout(self):
cmake_layout(self)

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")
8 changes: 8 additions & 0 deletions recipes/pulseaudio/meson/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <stdio.h>
#include <pulse/pulseaudio.h>

int main()
{
printf("pulse audio verions %s\n", pa_get_library_version());
return 0;
}

0 comments on commit 3b36ae8

Please sign in to comment.