From 6af8d21d6bee7db2650bd4bb8fef9ed2fb1b9408 Mon Sep 17 00:00:00 2001 From: nircoe Date: Wed, 6 Aug 2025 22:52:36 +0300 Subject: [PATCH 1/4] [Build]: Fix Emscripten threading support for WebAssembly builds --- CMakeLists.txt | 2 ++ src/CMakeLists.txt | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d53c93..df01b25 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) include(FetchContent) include(cmake/soundcoe_config.cmake) +find_package(Threads REQUIRED) + message(STATUS "[soundcoe] Fetching OpenAL-Soft from source...") FetchContent_Declare( diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bcf8066..4874956 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,4 +22,18 @@ target_link_libraries(soundcoe soundcoe_headers OpenAL logcoe -) \ No newline at end of file + Threads::Threads +) + +if(${CMAKE_SYSTEM_NAME} MATCHES "Emscripten") + target_compile_options(soundcoe PRIVATE + -pthread + -sUSE_PTHREADS=1 + -sSHARED_MEMORY=1 + ) + target_link_options(soundcoe INTERFACE + -pthread + -sUSE_PTHREADS=1 + -sSHARED_MEMORY=1 + ) +endif() \ No newline at end of file From 9e97c96db43fc71c3ce047d87569c248ec836f48 Mon Sep 17 00:00:00 2001 From: nircoe Date: Tue, 12 Aug 2025 21:54:38 +0300 Subject: [PATCH 2/4] Fix web build support --- CMakeLists.txt | 29 ++++++++++++++++++----------- cmake/openal_config.cmake | 16 +--------------- src/CMakeLists.txt | 31 +++++++++++++++---------------- 3 files changed, 34 insertions(+), 42 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index df01b25..736d83b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,17 +10,24 @@ include(cmake/soundcoe_config.cmake) find_package(Threads REQUIRED) -message(STATUS "[soundcoe] Fetching OpenAL-Soft from source...") - -FetchContent_Declare( - openal - GIT_REPOSITORY https://github.com/kcat/openal-soft.git - GIT_TAG 1.24.3 -) - -configure_openal() -FetchContent_MakeAvailable(openal) -ignore_external_warnings(OpenAL) +# Configure OpenAL: Use Emscripten's built-in OpenAL or fetch OpenAL-Soft +if(${CMAKE_SYSTEM_NAME} MATCHES "Emscripten") + message(STATUS "[soundcoe] Using Emscripten's built-in OpenAL implementation") + # Emscripten provides its own OpenAL implementation via -lopenal linker flag + # No need to fetch or configure OpenAL-Soft +else() + message(STATUS "[soundcoe] Fetching OpenAL-Soft from source...") + + FetchContent_Declare( + openal + GIT_REPOSITORY https://github.com/kcat/openal-soft.git + GIT_TAG 1.24.3 + ) + + configure_openal() + FetchContent_MakeAvailable(openal) + ignore_external_warnings(OpenAL) +endif() message(STATUS "[soundcoe] Fetching logcoe from source...") diff --git a/cmake/openal_config.cmake b/cmake/openal_config.cmake index bd8da0e..ca69c3e 100644 --- a/cmake/openal_config.cmake +++ b/cmake/openal_config.cmake @@ -37,21 +37,7 @@ endfunction() # Configure OpenAL-Soft based on target platform function(configure_openal_for_platform) - if(${CMAKE_SYSTEM_NAME} MATCHES "Emscripten") - # ================================================================ - # Emscripten/Web Build - Use Emscripten's built-in OpenAL - # ================================================================ - message(STATUS "[soundcoe] Configuring OpenAL-Soft for Emscripten/Web build") - - # Disable tests for web builds due to testcoe incompatibility with Emscripten - set(SOUNDCOE_BUILD_TESTS OFF CACHE BOOL "Tests disabled for Emscripten" FORCE) - message(STATUS "[soundcoe] Tests disabled for Emscripten due to testcoe compatibility issues") - - # Disable ALL native backends except NULL backend - disable_all_backends_except("NULL") - disable_all_require_flags() - - elseif(WIN32) + if(WIN32) # ================================================================ # Windows Build # ================================================================ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4874956..0e998dc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,23 +17,22 @@ target_include_directories(soundcoe ${CMAKE_CURRENT_SOURCE_DIR}/../external ) -target_link_libraries(soundcoe - PUBLIC - soundcoe_headers - OpenAL - logcoe - Threads::Threads -) - +# Link libraries based on platform if(${CMAKE_SYSTEM_NAME} MATCHES "Emscripten") - target_compile_options(soundcoe PRIVATE - -pthread - -sUSE_PTHREADS=1 - -sSHARED_MEMORY=1 + target_link_libraries(soundcoe + PUBLIC + soundcoe_headers + logcoe + Threads::Threads ) - target_link_options(soundcoe INTERFACE - -pthread - -sUSE_PTHREADS=1 - -sSHARED_MEMORY=1 + # Link with Emscripten's built-in OpenAL implementation + target_link_options(soundcoe PUBLIC -lopenal) +else() + target_link_libraries(soundcoe + PUBLIC + soundcoe_headers + OpenAL + logcoe + Threads::Threads ) endif() \ No newline at end of file From a3e0a866ad2843ccd35339a34b323b8e4e33a62c Mon Sep 17 00:00:00 2001 From: nircoe Date: Tue, 12 Aug 2025 22:09:18 +0300 Subject: [PATCH 3/4] enable tests on web pipeline --- .github/workflows/ci-web.yml | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-web.yml b/.github/workflows/ci-web.yml index 9278625..9655e42 100644 --- a/.github/workflows/ci-web.yml +++ b/.github/workflows/ci-web.yml @@ -59,8 +59,9 @@ jobs: cd build emcmake cmake .. \ -G Ninja \ - -DCMAKE_BUILD_TYPE=Release - echo "Note: Tests are automatically disabled for Emscripten builds due to testcoe compatibility issues" + -DCMAKE_BUILD_TYPE=Release \ + -DSOUNDCOE_BUILD_TESTS=ON + echo "Note: Enabling tests to verify functional web audio support" shell: bash - name: Build WebAssembly artifacts @@ -69,6 +70,22 @@ jobs: emmake ninja shell: bash + - name: Run tests + run: | + cd build + echo "=== Running soundcoe tests in Emscripten environment ===" + + # Try to run the test executable + if [ -f tests/soundcoe_tests ]; then + echo "Test executable found: tests/soundcoe_tests" + # Note: Running tests in Node.js environment (Emscripten default) + node tests/soundcoe_tests.js || echo "Some tests may fail due to web environment limitations" + else + echo "Test executable not found" + ls -la tests/ || echo "No tests directory found" + fi + shell: bash + - name: Validate WebAssembly artifacts run: | echo "=== Validating WebAssembly build artifacts ===" @@ -82,14 +99,13 @@ jobs: # Validate soundcoe library was built SOUNDCOE_LIB=$(find . -name "libsoundcoe.a" -type f) if [ -n "$SOUNDCOE_LIB" ]; then - echo "✅ soundcoe library built successfully at: $SOUNDCOE_LIB" + echo "soundcoe library built successfully at: $SOUNDCOE_LIB" else - echo "❌ soundcoe library missing" + echo "soundcoe library missing" exit 1 fi - echo "✅ WebAssembly build validation completed" - echo "Note: Tests are disabled for Emscripten due to testcoe compatibility issues" + echo "WebAssembly build and test validation completed" shell: bash From 9a42552c438e1a005ea7d2f13edaa4fbd1a56d01 Mon Sep 17 00:00:00 2001 From: nircoe Date: Tue, 12 Aug 2025 22:20:13 +0300 Subject: [PATCH 4/4] disable tests on web pipelines testcoe doesnt support web build because of backward-cpp --- .github/workflows/ci-web.yml | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci-web.yml b/.github/workflows/ci-web.yml index 9655e42..a9706ee 100644 --- a/.github/workflows/ci-web.yml +++ b/.github/workflows/ci-web.yml @@ -59,9 +59,8 @@ jobs: cd build emcmake cmake .. \ -G Ninja \ - -DCMAKE_BUILD_TYPE=Release \ - -DSOUNDCOE_BUILD_TESTS=ON - echo "Note: Enabling tests to verify functional web audio support" + -DCMAKE_BUILD_TYPE=Release + echo "Note: Tests disabled for Emscripten due to testcoe/backward-cpp unwind conflicts" shell: bash - name: Build WebAssembly artifacts @@ -70,22 +69,6 @@ jobs: emmake ninja shell: bash - - name: Run tests - run: | - cd build - echo "=== Running soundcoe tests in Emscripten environment ===" - - # Try to run the test executable - if [ -f tests/soundcoe_tests ]; then - echo "Test executable found: tests/soundcoe_tests" - # Note: Running tests in Node.js environment (Emscripten default) - node tests/soundcoe_tests.js || echo "Some tests may fail due to web environment limitations" - else - echo "Test executable not found" - ls -la tests/ || echo "No tests directory found" - fi - shell: bash - - name: Validate WebAssembly artifacts run: | echo "=== Validating WebAssembly build artifacts ===" @@ -105,7 +88,8 @@ jobs: exit 1 fi - echo "WebAssembly build and test validation completed" + echo "WebAssembly build validation completed" + echo "Note: Tests disabled for Emscripten due to testcoe/backward-cpp unwind conflicts" shell: bash