forked from csukuangfj/onnxruntime-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-wasm-static_lib.sh
executable file
·63 lines (52 loc) · 1.86 KB
/
build-wasm-static_lib.sh
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
62
63
#!/usr/bin/env bash
set -e
BUILD_DIR=${BUILD_DIR:=build/wasm-static_lib}
OUTPUT_DIR=${OUTPUT_DIR:=output/wasm-static_lib}
ONNXRUNTIME_SOURCE_DIR=${ONNXRUNTIME_SOURCE_DIR:=onnxruntime}
ONNXRUNTIME_VERSION=${ONNXRUNTIME_VERSION:=$(cat ONNXRUNTIME_VERSION)}
EMSDK_DIR=${EMSDK_DIR:=$ONNXRUNTIME_SOURCE_DIR/cmake/external/emsdk}
BUILD_OPTIONS=$BUILD_OPTIONS
cd $(dirname $0)
(
git submodule update --init --depth=1 $ONNXRUNTIME_SOURCE_DIR
cd $ONNXRUNTIME_SOURCE_DIR
if [ $ONNXRUNTIME_VERSION != $(cat VERSION_NUMBER) ]; then
git fetch origin tag v$ONNXRUNTIME_VERSION
git checkout v$ONNXRUNTIME_VERSION
fi
git submodule update --init --depth=1 --recursive
pushd $ONNXRUNTIME_SOURCE_DIR
ls -lh
cd core/mlas/lib
echo '#include "core/common/common.h"' | cat - q4common.h > a.txt
mv a.txt q4common.h
git diff ./q4common.h
popd
)
rm -f $BUILD_DIR/Release/libonnxruntime_webassembly.a
$ONNXRUNTIME_SOURCE_DIR/build.sh \
--build_dir $BUILD_DIR \
--config Release \
--build_wasm_static_lib \
--skip_tests \
--disable_wasm_exception_catching \
--disable_rtti \
--parallel \
$BUILD_OPTIONS
mkdir -p $OUTPUT_DIR/include
cp $ONNXRUNTIME_SOURCE_DIR/include/onnxruntime/core/session/*.h $OUTPUT_DIR/include
mkdir -p $OUTPUT_DIR/lib
cp $BUILD_DIR/Release/libonnxruntime_webassembly.a $OUTPUT_DIR/lib/libonnxruntime.a
# case $(uname -s) in
# Darwin | Linux) ;;
# *) CMAKE_OPTIONS="-G Ninja" ;;
# esac
# cmake \
# -S wasm-static_lib/tests \
# -B $BUILD_DIR/tests \
# -D CMAKE_TOOLCHAIN_FILE=$(pwd)/$EMSDK_DIR/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \
# -D ONNXRUNTIME_SOURCE_DIR=$(pwd)/$ONNXRUNTIME_SOURCE_DIR \
# -D ONNXRUNTIME_LIB_DIR=$(pwd)/$OUTPUT_DIR/lib \
# $CMAKE_OPTIONS
# cmake --build $BUILD_DIR/tests
# ctest --test-dir $BUILD_DIR/tests --verbose --no-tests=error