Skip to content

Commit

Permalink
nas: working on Linux (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
madebr authored Aug 16, 2021
1 parent 724d556 commit 8becd5e
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 28 deletions.
50 changes: 31 additions & 19 deletions recipes/nas/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from conans import ConanFile, tools, AutoToolsBuildEnvironment
from conans.errors import ConanInvalidConfiguration
import os
import shutil


class NasRecipe(ConanFile):
Expand Down Expand Up @@ -36,7 +35,7 @@ def configure(self):
del self.settings.compiler.cppstd

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

def requirements(self):
Expand All @@ -47,39 +46,52 @@ def build_requirements(self):
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], strip_root=True, destination=self._source_subfolder)
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)
return autotools

def build(self):
with tools.chdir(self._source_subfolder):
env_build = AutoToolsBuildEnvironment(self)
self.run("xmkmf")
env_build.make(target="World")
self.run("imake -DUseInstalled -I{} -DUsrLibDir={}".format(os.path.join(self._user_info_build["xorg-cf-files"].CONFIG_PATH), os.path.join(self.package_folder, "lib")), run_environment=True)
autotools = self._configure_autotools()
with tools.environment_append(autotools.vars):
env_build.make(target="World")

def package(self):
self.copy("LICENSE", dst="licenses")
tmp_install = os.path.join(self.build_folder, "tmp-install")

tmp_install = os.path.join(self.build_folder, "prefix")
with tools.chdir(self._source_subfolder):
env_build = AutoToolsBuildEnvironment(self)
env_build_vars = env_build.vars
env_build_vars["DESTDIR"] = tmp_install
env_build.install(vars=env_build_vars)
autotools = self._configure_autotools()
env_build_vars = autotools.vars
with tools.environment_append(env_build_vars):
autotools.install(args=[
"DESTDIR={}".format(tmp_install), "INCDIR=/include", "ETCDIR=/etc", "USRLIBDIR=/lib", "BINDIR=/bin"])

self.copy("*", src=os.path.join(tmp_install, "usr"), dst=self.package_folder)
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")

shutil.rmtree(os.path.join(self.package_folder, "lib", "X11"))
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 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"]

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

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

add_executable(example test_package.c)
target_link_libraries(example ${CONAN_LIBS})
add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
2 changes: 1 addition & 1 deletion recipes/nas/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ def build(self):

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "example")
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
15 changes: 10 additions & 5 deletions recipes/nas/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
#include <audio/audiolib.h>

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

#include <audio/audiolib.h>

int main(void)
int main()
{
AuServer *aud = NULL;
printf("NAS test_package\n");
AuServer* aud = AuOpenServer(NULL, 0, NULL, 0, NULL, NULL);
return 0;
aud = AuOpenServer(NULL, 0, NULL, 0, NULL, NULL);
if (aud == NULL) {
return EXIT_SUCCESS; /* Ignore failure */
}
AuCloseServer(aud);
return EXIT_SUCCESS;
}

0 comments on commit 8becd5e

Please sign in to comment.