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

[nas] Network audio system #6388

Merged
merged 16 commits into from
Aug 17, 2021
6 changes: 6 additions & 0 deletions recipes/nas/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sources:
"1.9.4":
- url: "https://downloads.sourceforge.net/nas/nas-1.9.4.src.tar.gz"
sha256: "cf36ea63751ce86cfd3b76c1659ce0d6a361a2e7cb34069854e156532703b39d"
- url: "https://unlicense.org/UNLICENSE"
sha256: "7e12e5df4bae12cb21581ba157ced20e1986a0508dd10d0e8a4ab9a4cf94e85c"
117 changes: 117 additions & 0 deletions recipes/nas/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
from conans import ConanFile, tools, AutoToolsBuildEnvironment
from conans.errors import ConanInvalidConfiguration
import os

required_conan_version = ">=1.33.0"


class NasRecipe(ConanFile):
name = "nas"
description = "The Network Audio System is a network transparent, client/server audio transport system."
topics = ("audio", "sound")
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://www.radscan.com/nas.html"
license = "Unlicense"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _build_subfolder(self):
return "build_subfolder"

def configure(self):
if self.options.shared:
del self.options.fPIC
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd

def validate(self):
if self.settings.os not in ("FreeBSD", "Linux"):
raise ConanInvalidConfiguration("Recipe supports Linux only")

def requirements(self):
self.requires("xorg/system")

def build_requirements(self):
self.build_requires("bison/3.7.1")
self.build_requires("flex/2.6.4")
self.build_requires("imake/1.0.8")
self.build_requires("xorg-cf-files/1.0.7")
self.build_requires("xorg-makedepend/1.0.6")
self.build_requires("xorg-gccmakedep/1.0.3")

def source(self):
tools.get(**self.conan_data["sources"][self.version][0], destination=self._source_subfolder, strip_root=True)
tools.download(filename="LICENSE", **self.conan_data["sources"][self.version][1])

@property
def _user_info_build(self):
return getattr(self, "user_info_build", self.deps_user_info)

def _configure_autotools(self):
autotools = AutoToolsBuildEnvironment(self)
autotools.libs = []
return autotools

@property
def _imake_irulesrc(self):
return self._user_info_build["xorg-cf-files"].CONFIG_PATH

@property
def _imake_defines(self):
return "-DUsrLibDir={}".format(os.path.join(self.package_folder, "lib"))

@property
def _imake_make_args(self):
return ["IRULESRC={}".format(self._imake_irulesrc), "IMAKE_DEFINES={}".format(self._imake_defines)]

def build(self):
tools.replace_in_file(os.path.join(self._source_subfolder, "server", "dia", "main.c"),
"\nFILE *yyin", "\nextern FILE *yyin")
with tools.chdir(self._source_subfolder):
self.run("imake -DUseInstalled -I{} {}".format(self._imake_irulesrc, self._imake_defines), run_environment=True)
autotools = self._configure_autotools()
autotools.make(target="World",args=["-j1"] + self._imake_make_args)

def package(self):
self.copy("LICENSE", dst="licenses")

with tools.chdir(self._source_subfolder):
autotools = self._configure_autotools()
tmp_install = os.path.join(self.build_folder, "prefix")
install_args = [
"DESTDIR={}".format(tmp_install),
"INCDIR=/include",
"ETCDIR=/etc",
"USRLIBDIR=/lib",
"BINDIR=/bin",
] + self._imake_make_args
autotools.install(args=["-j1"] + install_args)

self.copy("*", src=os.path.join(tmp_install, "bin"), dst="bin")
self.copy("*", src=os.path.join(tmp_install, "include"), dst=os.path.join("include", "audio"))
self.copy("*", src=os.path.join(tmp_install, "lib"), dst="lib")

if self.options.shared:
tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.a")
else:
tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.so*")

def package_info(self):
self.cpp_info.libs = ["audio"]
jgsogo marked this conversation as resolved.
Show resolved Hide resolved
self.cpp_info.requires = ["xorg::xau"]

bin_path = os.path.join(self.package_folder, "bin")
self.output.info("Appending PATH environment variable: {}".format(bin_path))
self.env_info.path.append(bin_path)
8 changes: 8 additions & 0 deletions recipes/nas/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package C)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
16 changes: 16 additions & 0 deletions recipes/nas/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import os
from conans import ConanFile, CMake, tools

class NasTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"

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)
16 changes: 16 additions & 0 deletions recipes/nas/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <audio/audiolib.h>

#include <stdio.h>
#include <stdlib.h>

int main()
{
AuServer *aud = NULL;
printf("NAS test_package\n");
aud = AuOpenServer(NULL, 0, NULL, 0, NULL, NULL);
if (aud == NULL) {
return EXIT_SUCCESS; /* Ignore failure */
}
AuCloseServer(aud);
return EXIT_SUCCESS;
}
3 changes: 3 additions & 0 deletions recipes/nas/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"1.9.4":
folder: all