Skip to content

Commit

Permalink
Add docker build system
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-gavrilescu committed Sep 18, 2019
1 parent 46a6e2b commit 63e29d3
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@
*.exe
*.out
*.app

# VisualCode config
.vscode
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM trzeci/emscripten:sdk-tag-1.38.30-64bit

RUN apt-get update && \
apt-get install -y libtool && \
apt-get install -y autotools-dev && \
apt-get install -y autoconf && \
apt-get install -y automake
53 changes: 53 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash

set -e

export OPTIMIZE="-Os"
export LDFLAGS=${OPTIMIZE}
export CFLAGS=${OPTIMIZE}
export CXXFLAGS=${OPTIMIZE}

ENTRY_POINT="rnnoise.js"

echo "============================================="
echo "Compiling wasm bindings"
echo "============================================="
(
cd rnnoise

# Clean possible autotools clutter that might affect the configurations step
git clean -f -d
./autogen.sh

# For some reason setting the CFLAGS export doesn't apply optimization to all compilation steps
# so we need to explicitly pass it to configure.
emconfigure ./configure CFLAGS=${OPTIMIZE}
emmake make clean
emmake make V=1

# Compile librnnoise generated LLVM bytecode to wasm
emcc \
${OPTIMIZE} \
-s STRICT=1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s MALLOC=emmalloc \
-s MODULARIZE=1 \
-s EXPORT_ES6=1 \
-s EXPORTED_FUNCTIONS="['_rnnoise_process_frame', '_rnnoise_init', '_rnnoise_destroy', '_rnnoise_create', '_malloc', '_free']" \
.libs/librnnoise.so \
-o ./$ENTRY_POINT

# Create output folder
rm -rf ../dist
mkdir -p ../dist

# Move artifacts
mv $ENTRY_POINT ../dist/index.js
mv rnnoise.wasm ../dist/

# Clean cluttter
git clean -f -d
)
echo "============================================="
echo "Compiling wasm bindings done"
echo "============================================="
15 changes: 15 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added dist/rnnoise.wasm
Binary file not shown.
23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "rnnoise-wasm",
"description": "Rnnoise sub-module compiled with emscripten as web assembly module",
"version": "0.0.1",
"repository": {
"type": "git",
"url": "git+https://github.com/andrei-gavrilescu/rnnoise-wasm.git"
},
"main": "./dist/",
"scripts": {
"build:dockerimage": "docker image inspect -f '.' emscripten-autotools || docker build -t emscripten-autotools .",
"build:emscripten": "docker run --rm -v $(pwd):/src emscripten-autotools bash -x ./build.sh",
"build": "npm run build:dockerimage && npm run build:emscripten"
},
"dependencies": {},
"devDependencies": {},
"licenses": [
{
"type": "Apache-2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0"
}
]
}

0 comments on commit 63e29d3

Please sign in to comment.