From 8f80ba42e8e67336d8e55add14e7e6b462fa35b1 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Mon, 30 Mar 2020 18:16:03 +0200 Subject: [PATCH] Updated the opus build and enforced as emscripten web build --- asm/.gitignore | 4 +++- asm/CMakeLists.txt | 4 ++-- asm/build.sh | 20 ++++++++++++++++++++ asm/libraries/opus | 2 +- asm/make_opus.sh | 35 ++++++++++++++++++++++++++++------- 5 files changed, 54 insertions(+), 11 deletions(-) create mode 100644 asm/build.sh diff --git a/asm/.gitignore b/asm/.gitignore index c9ac95d3..706d8e4c 100644 --- a/asm/.gitignore +++ b/asm/.gitignore @@ -1,2 +1,4 @@ generated/ -build/ \ No newline at end of file +build_/ +libraries/opus/build_ +libraries/opus/out \ No newline at end of file diff --git a/asm/CMakeLists.txt b/asm/CMakeLists.txt index 9b17feb1..23aca041 100644 --- a/asm/CMakeLists.txt +++ b/asm/CMakeLists.txt @@ -8,7 +8,7 @@ set(CMAKE_C_COMPILER "emcc") set(CMAKE_C_LINK_EXECUTABLE "emcc") set(CMAKE_CXX_FLAGS "-O3 --llvm-lto 1 --memory-init-file 0 -s WASM=1 -s ASSERTIONS=1") # -s ALLOW_MEMORY_GROWTH=1 -O3 set(CMAKE_VERBOSE_MAKEFILE ON) -set(CMAKE_EXE_LINKER_FLAGS "-s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\", \"Pointer_stringify\"]'") # +set(CMAKE_EXE_LINKER_FLAGS "-s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\", \"Pointer_stringify\"]' -s ENVIRONMENT='web'") # #add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/generated/") @@ -18,4 +18,4 @@ include_directories(libraries/opus/include/) add_definitions(-DLTM_DESC) add_executable(TeaWeb-Worker-Codec-Opus src/opus.cpp) -target_link_libraries(TeaWeb-Worker-Codec-Opus ${CMAKE_CURRENT_SOURCE_DIR}/libraries/opus/.libs/libopus.a) +target_link_libraries(TeaWeb-Worker-Codec-Opus ${CMAKE_CURRENT_SOURCE_DIR}/libraries/opus/out/lib/libopus.a) diff --git a/asm/build.sh b/asm/build.sh new file mode 100644 index 00000000..b6365d56 --- /dev/null +++ b/asm/build.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +[[ ! -d libraries/opus/out/ ]] && { echo "Missing opus build. Please build it before!"; exit 1; } +[[ ! -f libraries/opus/out/lib/libopus.a ]] && { echo "Missing opus static library. Please unsure your opus build was successfull."; exit 1; } + +[[ -d build_ ]] && { + rm -r build_ || { echo "failed to remove old build directory"; exit 1; } +} +mkdir build_ || exit 1 +cd build_ || exit 1 + +emcmake cmake .. || { + echo "Failed to execute cmake" + exit 1 +} + +emmake make || { + echo "Failed to build file" + exit 1 +} \ No newline at end of file diff --git a/asm/libraries/opus b/asm/libraries/opus index 655cc54c..923bebde 160000 --- a/asm/libraries/opus +++ b/asm/libraries/opus @@ -1 +1 @@ -Subproject commit 655cc54c564b84ef2827f0b2152ce3811046201e +Subproject commit 923bebde197f42ba8e55cb055dce3ff22bbea54d diff --git a/asm/make_opus.sh b/asm/make_opus.sh index b3efd4bf..d2b64667 100755 --- a/asm/make_opus.sh +++ b/asm/make_opus.sh @@ -1,11 +1,32 @@ #!/usr/bin/env bash -base_dir=`pwd` -cd "$(dirname $0)/libraries/opus/" +cd "$(dirname $0)/libraries/opus/" || { echo "Failed to enter the opus directory."; exit 1; } -git checkout v1.1.2 -./autogen.sh -emconfigure ./configure --disable-extra-programs --disable-doc --disable-rtcd -emmake make +[[ -d build_ ]] && { + rm -r build_ || { echo "failed to remove old build directory"; exit 1; } +} +mkdir build_ || exit 1 +cd build_ || exit 1 -cd ${base_dir} \ No newline at end of file +# Native SIMD isn't supported yet by most browsers (only experimental) +# So there is no need to build with that, it will make stuff even worse +simd_flags="-DOPUS_X86_MAY_HAVE_AVX=OFF -DOPUS_X86_MAY_HAVE_SSE4_1=OFF -DOPUS_X86_MAY_HAVE_SSE2=OFF -DOPUS_X86_MAY_HAVE_SSE=OFF" +emcmake cmake .. -DCMAKE_INSTALL_PREFIX="$(pwd)/../out/" -DOPUS_STACK_PROTECTOR=OFF ${simd_flags} || { + echo "failed to execute cmake" + exit 1 +} + +emmake make || { + echo "failed to build opus" + exit 1 +} +emmake make install || { + echo "failed to \"install\" opus" + exit 1 +} + +# Old: +#git checkout v1.1.2 +#./autogen.sh +#emconfigure ./configure --disable-extra-programs --disable-doc --disable-rtcd +#emmake make \ No newline at end of file