-
-
Notifications
You must be signed in to change notification settings - Fork 425
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
libmysofa: add package #6076
Merged
Merged
libmysofa: add package #6076
Changes from 21 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
5150c11
init
luadebug b9ff099
fixup
luadebug 84119fb
revise
luadebug ab37339
re-check
luadebug b9bbb85
check old solution
luadebug b57b147
test
luadebug 5bbf84f
check
luadebug 55411be
check
luadebug 0377d7e
export surface
luadebug 0abccb5
h
luadebug 8651f7c
pic off
luadebug 30bde53
"-DCMAKE_POLICY_DEFAULT_CMP0057=NEW"
luadebug 91b9fc7
fix export
luadebug 6755319
test
luadebug 38bceec
check without pos-i-code
luadebug d8ad5d3
follow upstream
luadebug f9acc79
check ems & bsd
luadebug 50f44b2
h
luadebug e8d086a
!wasm & is_plat("cross", "bsd")
luadebug 58a518c
revise
luadebug 4ce755e
follow upstream
luadebug 7db8cf4
test CI
luadebug af4848a
retry
luadebug 34fc324
return os.rm("share/default.sofa")
luadebug 50f04de
Update xmake.lua
luadebug 6196998
rerun ci
luadebug acf5536
CRLF -> LF
luadebug bb5aa1e
Merge branch 'port' of https://github.com/luadebug/xmake-repo into port
luadebug 65105aa
test ci
luadebug 3748064
check wasm for defined(__UBUNTU__)
luadebug d18e48e
test ci
luadebug File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,258 @@ | ||
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt | ||
index dcaa92a..76fd021 100644 | ||
--- a/src/CMakeLists.txt | ||
+++ b/src/CMakeLists.txt | ||
@@ -10,38 +10,39 @@ endmacro(use_c99) | ||
|
||
use_c99() | ||
|
||
+find_package(ZLIB REQUIRED) | ||
configure_file(config.h.in config.h) | ||
-include_directories(${CMAKE_CURRENT_BINARY_DIR}) | ||
+include_directories(${CMAKE_CURRENT_BINARY_DIR} ${ZLIB_INCLUDE_DIRS}) | ||
|
||
if(NOT MSVC) | ||
- if(NOT WIN32) | ||
+ if(NOT WIN32 AND NOT EMSCRIPTEN) | ||
find_library(MATH m) | ||
else() | ||
set(MATH "") | ||
endif() | ||
- include(FindZLIB) | ||
else() | ||
set(MATH "") | ||
+ if(0) | ||
find_program(NUGET nuget) | ||
if(NUGET) | ||
execute_process(COMMAND ${NUGET} install zlib) | ||
endif() | ||
include_directories( | ||
${PROJECT_SOURCE_DIR}/windows/third-party/zlib-1.2.11/include/) | ||
+ endif() | ||
endif() | ||
|
||
if(NOT MSVC) | ||
- if(NOT WIN32) | ||
+ if(NOT WIN32 AND NOT EMSCRIPTEN) | ||
find_library(MATH m) | ||
else() | ||
set(MATH "") | ||
endif() | ||
- include(FindZLIB) | ||
- include_directories(${ZLIB_INCLUDE_DIRS}) | ||
set(PKG_CONFIG_PRIVATELIBS "-lm ${PKG_CONFIG_PRIVATELIBS}") | ||
set(PKG_CONFIG_PRIVATELIBS "-lz ${PKG_CONFIG_PRIVATELIBS}") | ||
else() | ||
set(MATH "") | ||
+ if(0) | ||
find_program(NUGET nuget) | ||
if(NOT NUGET) | ||
message( | ||
@@ -53,6 +54,7 @@ else() | ||
endif() | ||
include_directories( | ||
${PROJECT_SOURCE_DIR}/windows/third-party/zlib-1.2.11/include/) | ||
+ endif() | ||
endif() | ||
|
||
set(libsrc | ||
@@ -80,6 +82,7 @@ set(libsrc | ||
set(public-headers | ||
hrtf/mysofa.h | ||
) | ||
+install(FILES "${public-headers}" DESTINATION include) | ||
|
||
if(BUILD_STATIC_LIBS) | ||
add_library(mysofa-static STATIC ${libsrc}) | ||
@@ -88,7 +91,7 @@ target_include_directories(mysofa-static | ||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/hrtf>" | ||
$<INSTALL_INTERFACE:include/> | ||
) | ||
-target_link_libraries(mysofa-static LINK_PRIVATE ${MATH} ${ZLIB_LIBRARIES}) | ||
+target_link_libraries(mysofa-static LINK_PRIVATE ${MATH} ZLIB::ZLIB) | ||
set_target_properties( | ||
mysofa-static | ||
PROPERTIES OUTPUT_NAME mysofa CLEAN_DIRECT_OUTPUT 1 POSITION_INDEPENDENT_CODE | ||
@@ -169,6 +172,11 @@ else() | ||
mysofa_export.h) | ||
endif() | ||
|
||
+install( | ||
+ FILES ${PROJECT_BINARY_DIR}/src/mysofa_export.h | ||
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
+) | ||
+ | ||
if(BUILD_TESTS) | ||
add_executable(mysofa2json tests/sofa2json.c tests/json.c) | ||
if(BUILD_STATIC_LIBS) | ||
diff --git a/src/hrtf/mysofa.h b/src/hrtf/mysofa.h | ||
index 206e77b..82bc9d9 100644 | ||
--- a/src/hrtf/mysofa.h | ||
+++ b/src/hrtf/mysofa.h | ||
@@ -14,6 +14,7 @@ extern "C" { | ||
#include <stdint.h> | ||
#include <stddef.h> | ||
|
||
+#include "mysofa_export.h" | ||
#define MYSOFA_DEFAULT_NEIGH_STEP_ANGLE 0.5f | ||
#define MYSOFA_DEFAULT_NEIGH_STEP_RADIUS 0.01f | ||
|
||
@@ -127,44 +128,44 @@ enum { | ||
MYSOFA_ONLY_SOURCES_WITH_MC_SUPPORTED | ||
}; | ||
|
||
-struct MYSOFA_HRTF *mysofa_load(const char *filename, int *err); | ||
-struct MYSOFA_HRTF *mysofa_load_data(const char *data, size_t size, int *err); | ||
+MYSOFA_EXPORT struct MYSOFA_HRTF *mysofa_load(const char *filename, int *err); | ||
+MYSOFA_EXPORT struct MYSOFA_HRTF *mysofa_load_data(const char *data, size_t size, int *err); | ||
|
||
-int mysofa_check(struct MYSOFA_HRTF *hrtf); | ||
-char *mysofa_getAttribute(struct MYSOFA_ATTRIBUTE *attr, char *name); | ||
-void mysofa_tospherical(struct MYSOFA_HRTF *hrtf); | ||
-void mysofa_tocartesian(struct MYSOFA_HRTF *hrtf); | ||
-void mysofa_free(struct MYSOFA_HRTF *hrtf); | ||
+MYSOFA_EXPORT int mysofa_check(struct MYSOFA_HRTF *hrtf); | ||
+MYSOFA_EXPORT char *mysofa_getAttribute(struct MYSOFA_ATTRIBUTE *attr, char *name); | ||
+MYSOFA_EXPORT void mysofa_tospherical(struct MYSOFA_HRTF *hrtf); | ||
+MYSOFA_EXPORT void mysofa_tocartesian(struct MYSOFA_HRTF *hrtf); | ||
+MYSOFA_EXPORT void mysofa_free(struct MYSOFA_HRTF *hrtf); | ||
|
||
-struct MYSOFA_LOOKUP *mysofa_lookup_init(struct MYSOFA_HRTF *hrtf); | ||
-int mysofa_lookup(struct MYSOFA_LOOKUP *lookup, float *coordinate); | ||
-void mysofa_lookup_free(struct MYSOFA_LOOKUP *lookup); | ||
+MYSOFA_EXPORT struct MYSOFA_LOOKUP *mysofa_lookup_init(struct MYSOFA_HRTF *hrtf); | ||
+MYSOFA_EXPORT int mysofa_lookup(struct MYSOFA_LOOKUP *lookup, float *coordinate); | ||
+MYSOFA_EXPORT void mysofa_lookup_free(struct MYSOFA_LOOKUP *lookup); | ||
|
||
-struct MYSOFA_NEIGHBORHOOD * | ||
+MYSOFA_EXPORT struct MYSOFA_NEIGHBORHOOD * | ||
mysofa_neighborhood_init(struct MYSOFA_HRTF *hrtf, | ||
struct MYSOFA_LOOKUP *lookup); | ||
-struct MYSOFA_NEIGHBORHOOD *mysofa_neighborhood_init_withstepdefine( | ||
+MYSOFA_EXPORT struct MYSOFA_NEIGHBORHOOD *mysofa_neighborhood_init_withstepdefine( | ||
struct MYSOFA_HRTF *hrtf, struct MYSOFA_LOOKUP *lookup, | ||
float neighbor_angle_step, float neighbor_radius_step); | ||
-int *mysofa_neighborhood(struct MYSOFA_NEIGHBORHOOD *neighborhood, int pos); | ||
-void mysofa_neighborhood_free(struct MYSOFA_NEIGHBORHOOD *neighborhood); | ||
+MYSOFA_EXPORT int *mysofa_neighborhood(struct MYSOFA_NEIGHBORHOOD *neighborhood, int pos); | ||
+MYSOFA_EXPORT void mysofa_neighborhood_free(struct MYSOFA_NEIGHBORHOOD *neighborhood); | ||
|
||
-float *mysofa_interpolate(struct MYSOFA_HRTF *hrtf, float *cordinate, | ||
+MYSOFA_EXPORT float *mysofa_interpolate(struct MYSOFA_HRTF *hrtf, float *cordinate, | ||
int nearest, int *neighborhood, float *fir, | ||
float *delays); | ||
|
||
-int mysofa_resample(struct MYSOFA_HRTF *hrtf, float samplerate); | ||
-float mysofa_loudness(struct MYSOFA_HRTF *hrtf); | ||
-int mysofa_minphase(struct MYSOFA_HRTF *hrtf, float threshold); | ||
+MYSOFA_EXPORT int mysofa_resample(struct MYSOFA_HRTF *hrtf, float samplerate); | ||
+MYSOFA_EXPORT float mysofa_loudness(struct MYSOFA_HRTF *hrtf); | ||
+MYSOFA_EXPORT int mysofa_minphase(struct MYSOFA_HRTF *hrtf, float threshold); | ||
|
||
-struct MYSOFA_EASY *mysofa_cache_lookup(const char *filename, float samplerate); | ||
-struct MYSOFA_EASY *mysofa_cache_store(struct MYSOFA_EASY *, | ||
+MYSOFA_EXPORT struct MYSOFA_EASY *mysofa_cache_lookup(const char *filename, float samplerate); | ||
+MYSOFA_EXPORT struct MYSOFA_EASY *mysofa_cache_store(struct MYSOFA_EASY *, | ||
const char *filename, float samplerate); | ||
-void mysofa_cache_release(struct MYSOFA_EASY *); | ||
-void mysofa_cache_release_all(void); | ||
+MYSOFA_EXPORT void mysofa_cache_release(struct MYSOFA_EASY *); | ||
+MYSOFA_EXPORT void mysofa_cache_release_all(void); | ||
|
||
-void mysofa_c2s(float values[3]); | ||
-void mysofa_s2c(float values[3]); | ||
+MYSOFA_EXPORT void mysofa_c2s(float values[3]); | ||
+MYSOFA_EXPORT void mysofa_s2c(float values[3]); | ||
|
||
struct MYSOFA_EASY { | ||
struct MYSOFA_HRTF *hrtf; | ||
@@ -173,38 +174,38 @@ struct MYSOFA_EASY { | ||
float *fir; | ||
}; | ||
|
||
-struct MYSOFA_EASY *mysofa_open(const char *filename, float samplerate, | ||
+MYSOFA_EXPORT struct MYSOFA_EASY *mysofa_open(const char *filename, float samplerate, | ||
int *filterlength, int *err); | ||
-struct MYSOFA_EASY *mysofa_open_no_norm(const char *filename, float samplerate, | ||
+MYSOFA_EXPORT struct MYSOFA_EASY *mysofa_open_no_norm(const char *filename, float samplerate, | ||
int *filterlength, int *err); | ||
-struct MYSOFA_EASY *mysofa_open_advanced(const char *filename, float samplerate, | ||
+MYSOFA_EXPORT struct MYSOFA_EASY *mysofa_open_advanced(const char *filename, float samplerate, | ||
int *filterlength, int *err, bool norm, | ||
float neighbor_angle_step, | ||
float neighbor_radius_step); | ||
-struct MYSOFA_EASY *mysofa_open_data(const char *data, long size, | ||
+MYSOFA_EXPORT struct MYSOFA_EASY *mysofa_open_data(const char *data, long size, | ||
float samplerate, int *filterlength, | ||
int *err); | ||
-struct MYSOFA_EASY *mysofa_open_data_no_norm(const char *data, long size, | ||
+MYSOFA_EXPORT struct MYSOFA_EASY *mysofa_open_data_no_norm(const char *data, long size, | ||
float samplerate, | ||
int *filterlength, int *err); | ||
-struct MYSOFA_EASY *mysofa_open_data_advanced( | ||
+MYSOFA_EXPORT struct MYSOFA_EASY *mysofa_open_data_advanced( | ||
const char *data, long size, float samplerate, int *filterlength, int *err, | ||
bool norm, float neighbor_angle_step, float neighbor_radius_step); | ||
-struct MYSOFA_EASY *mysofa_open_cached(const char *filename, float samplerate, | ||
+MYSOFA_EXPORT struct MYSOFA_EASY *mysofa_open_cached(const char *filename, float samplerate, | ||
int *filterlength, int *err); | ||
-void mysofa_getfilter_short(struct MYSOFA_EASY *easy, float x, float y, float z, | ||
+MYSOFA_EXPORT void mysofa_getfilter_short(struct MYSOFA_EASY *easy, float x, float y, float z, | ||
short *IRleft, short *IRright, int *delayLeft, | ||
int *delayRight); | ||
-void mysofa_getfilter_float(struct MYSOFA_EASY *easy, float x, float y, float z, | ||
+MYSOFA_EXPORT void mysofa_getfilter_float(struct MYSOFA_EASY *easy, float x, float y, float z, | ||
float *IRleft, float *IRright, float *delayLeft, | ||
float *delayRight); | ||
-void mysofa_getfilter_float_nointerp(struct MYSOFA_EASY *easy, float x, float y, | ||
+MYSOFA_EXPORT void mysofa_getfilter_float_nointerp(struct MYSOFA_EASY *easy, float x, float y, | ||
float z, float *IRleft, float *IRright, | ||
float *delayLeft, float *delayRight); | ||
-void mysofa_close(struct MYSOFA_EASY *easy); | ||
-void mysofa_close_cached(struct MYSOFA_EASY *easy); | ||
+MYSOFA_EXPORT void mysofa_close(struct MYSOFA_EASY *easy); | ||
+MYSOFA_EXPORT void mysofa_close_cached(struct MYSOFA_EASY *easy); | ||
|
||
-void mysofa_getversion(int *major, int *minor, int *patch); | ||
+MYSOFA_EXPORT void mysofa_getversion(int *major, int *minor, int *patch); | ||
|
||
#ifdef __cplusplus | ||
} | ||
diff --git a/src/hrtf/portable_endian.h b/src/hrtf/portable_endian.h | ||
index d1e76f5..5fb4b55 100644 | ||
--- a/src/hrtf/portable_endian.h | ||
+++ b/src/hrtf/portable_endian.h | ||
@@ -13,7 +13,7 @@ | ||
|
||
#endif | ||
|
||
-#if defined(__linux__) || defined(__CYGWIN__) | ||
+#if defined(__linux__) || defined(__CYGWIN__) || defined(__illumos__) | ||
|
||
# include <endian.h> | ||
|
||
@@ -41,23 +41,10 @@ | ||
# define __LITTLE_ENDIAN LITTLE_ENDIAN | ||
# define __PDP_ENDIAN PDP_ENDIAN | ||
|
||
-#elif defined(__OpenBSD__) | ||
+#elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) | ||
|
||
# include <sys/endian.h> | ||
|
||
-#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) | ||
- | ||
-# include <sys/endian.h> | ||
- | ||
-# define be16toh(x) betoh16(x) | ||
-# define le16toh(x) letoh16(x) | ||
- | ||
-# define be32toh(x) betoh32(x) | ||
-# define le32toh(x) letoh32(x) | ||
- | ||
-# define be64toh(x) betoh64(x) | ||
-# define le64toh(x) letoh64(x) | ||
- | ||
#elif defined(__WINDOWS__) | ||
|
||
# include <windows.h> |
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,35 @@ | ||
package("libmysofa") | ||
set_homepage("https://github.com/hoene/libmysofa") | ||
set_description("Reader for AES SOFA files to get better HRTFs") | ||
set_license("BSD-3-Clause") | ||
|
||
add_urls("https://github.com/hoene/libmysofa/archive/refs/tags/$(version).tar.gz", | ||
"https://github.com/hoene/libmysofa.git") | ||
|
||
add_versions("v1.3.2", "6c5224562895977e87698a64cb7031361803d136057bba35ed4979b69ab4ba76") | ||
|
||
add_patches("v1.3.2", "patches/v1.3.2/fix-build.patch", "5b78f981ea5fabfdc33625ede95c2b9a5edba0f570e69f063c0a59d94a551a2e") | ||
|
||
add_deps("cmake", "zlib") | ||
|
||
if is_plat("linux", "bsd") then | ||
add_syslinks("m", "pthread") | ||
end | ||
luadebug marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
on_install(function (package) | ||
if package:is_plat("wasm", "cross") then | ||
io.replace("src/CMakeLists.txt", [[find_library(MATH m)]], [[set(MATH "")]], {plain = true}) | ||
end | ||
os.rm("windows/third-party/zlib-1.2.11") | ||
os.rm("share/default.sofa") | ||
os.cp("share/MIT_KEMAR_normal_pinna.sofa", "share/default.sofa") | ||
luadebug marked this conversation as resolved.
Show resolved
Hide resolved
|
||
local configs = {"-DBUILD_TESTS=OFF", "-DCMAKE_POLICY_DEFAULT_CMP0057=NEW"} | ||
table.insert(configs, "-DBUILD_STATIC_LIBS=" .. (package:config("shared") and "OFF" or "ON")) | ||
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) | ||
luadebug marked this conversation as resolved.
Show resolved
Hide resolved
|
||
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) | ||
import("package.tools.cmake").install(package, configs) | ||
end) | ||
|
||
on_test(function (package) | ||
assert(package:has_cfuncs("mysofa_open", {includes = "mysofa.h"})) | ||
end) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be there
|| defined(__EMSCRIPTEN__)
or its better limit wasm build ? https://github.com/hobuinc/laz-perf/blob/2b68700d33bf981d257d6101d96714620c64019c/cpp/lazperf/portable_endian.hpp#L15maybe
|| defined(__GNU__)
as well. Though it looks very preferable to just replace existing file with this one.Well it seems it helped WASM CI for some reason.