-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathbuild-static_lib.sh
executable file
·55 lines (48 loc) · 1.7 KB
/
build-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
#!/usr/bin/env bash
set -e
SOURCE_DIR=${SOURCE_DIR:=static_lib}
BUILD_DIR=${BUILD_DIR:=build/static_lib}
OUTPUT_DIR=${OUTPUT_DIR:=output/static_lib}
ONNXRUNTIME_SOURCE_DIR=${ONNXRUNTIME_SOURCE_DIR:=onnxruntime}
ONNXRUNTIME_VERSION=${ONNXRUNTIME_VERSION:=$(cat ONNXRUNTIME_VERSION)}
CMAKE_OPTIONS=$CMAKE_OPTIONS
CMAKE_BUILD_OPTIONS=$CMAKE_BUILD_OPTIONS
case $(uname -s) in
Darwin) CPU_COUNT=$(sysctl -n hw.physicalcpu) ;;
Linux) CPU_COUNT=$(grep ^cpu\\scores /proc/cpuinfo | uniq | awk '{print $4}') ;;
*) CPU_COUNT=$NUMBER_OF_PROCESSORS ;;
esac
PARALLEL_JOB_COUNT=${PARALLEL_JOB_COUNT:=$CPU_COUNT}
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
)
cmake \
-S $SOURCE_DIR \
-B $BUILD_DIR \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_CONFIGURATION_TYPES=Release \
-D CMAKE_INSTALL_PREFIX=$OUTPUT_DIR \
-D ONNXRUNTIME_SOURCE_DIR=$(pwd)/$ONNXRUNTIME_SOURCE_DIR \
--compile-no-warning-as-error \
$CMAKE_OPTIONS
cmake \
--build $BUILD_DIR \
--config Release \
--parallel $PARALLEL_JOB_COUNT \
$CMAKE_BUILD_OPTIONS
cmake --install $BUILD_DIR --config Release
cmake \
-S $SOURCE_DIR/tests \
-B $BUILD_DIR/tests \
-D ONNXRUNTIME_SOURCE_DIR=$(pwd)/$ONNXRUNTIME_SOURCE_DIR \
-D ONNXRUNTIME_INCLUDE_DIR=$(pwd)/$OUTPUT_DIR/include \
-D ONNXRUNTIME_LIB_DIR=$(pwd)/$OUTPUT_DIR/lib
cmake --build $BUILD_DIR/tests
ctest --test-dir $BUILD_DIR/tests --build-config Debug --verbose --no-tests=error