-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.sh
More file actions
61 lines (48 loc) · 1.67 KB
/
build.sh
File metadata and controls
61 lines (48 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
./emsdk/emsdk activate latest
source ./emsdk/emsdk_env.sh
#compile c++ project
echo "Compiling C++ project..."
#get all cpp files in src folder
srcFiles=(\
./src/lightmapperWasm.cpp \
)
#make obj build dir if it doesnt exist
mkdir -p ./wasmdist/obj
#compile to obj files
objList=""
for i in "${srcFiles[@]}"
do
fileName=$(basename -- "$i")
objList="${objList} ./wasmdist/obj/${fileName}.o"
echo building "${fileName}.o"
echo building...
if [ "$1" == "prod" ]
then
emcc -c -std=c++17 -O3 -o ./wasmdist/obj/$fileName.o -I ./src/thirdparty $i &
else
emcc -c -std=c++17 -g -gsource-map -o ./wasmdist/obj/$fileName.o -I ./src/thirdparty $i &
fi
done
wait
#run linking
echo linking...
if [ "$1" == "prod" ]
then
emcc -s ALLOW_MEMORY_GROWTH=1 -s MODULARIZE=1 -s ENVIRONMENT='web' -s USE_ES6_IMPORT_META=0 -s EXPORT_ES6=1 -s MAX_WEBGL_VERSION=2 -s --bind -std=c++17 -O3 -o ./wasmdist/lightmapperWasm.mjs -I ./src/thirdparty $objList
else
emcc -s ALLOW_MEMORY_GROWTH=1 -s MODULARIZE=1 -s ENVIRONMENT='web' -s USE_ES6_IMPORT_META=0 -s EXPORT_ES6=1 -s MAX_WEBGL_VERSION=2 -s GL_ASSERTIONS=1 -s ASSERTIONS=1 --bind -std=c++17 -g -gsource-map -o ./wasmdist/lightmapperWasm.mjs -I ./src/thirdparty $objList
fi
#copy wasm file to test build folder
echo copy wasm module to test folder...
mkdir -p ./test/build/
cp ./wasmdist/lightmapperWasm.wasm ./test/build/
if [ "$1" != "prod" ]
then
cp ./wasmdist/lightmapperWasm.wasm.map ./test/build/
fi
cp ./wasmdist/lightmapperWasm.mjs ./test/build/
#copy test models to build folder
echo copy model files to test folder...
mkdir -p ./test/build/models
cp -r ./test/models/* ./test/build/models