forked from pytorch/executorch
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild_example_runner.sh
executable file
·82 lines (67 loc) · 2.22 KB
/
build_example_runner.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
# Builds example_runner and prints its path.
set -euo pipefail
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
readonly SCRIPT_DIR
readonly EXECUTORCH_ROOT="${SCRIPT_DIR}/../.."
# Allow overriding the number of build jobs. Default to 9.
export CMAKE_BUILD_PARALLEL_LEVEL="${CMAKE_BUILD_PARALLEL_LEVEL:-9}"
BUILD_COREML=OFF
usage() {
echo "Builds example runner."
echo "Options:"
echo " --coreml Include this flag to enable Core ML backend when building the Developer Tools."
exit 0
}
for arg in "$@"; do
case $arg in
-h|--help) usage ;;
--coreml) BUILD_COREML=ON ;;
*)
esac
done
main() {
cd "${EXECUTORCH_ROOT}"
./install_executorch.sh --clean
if [[ "${BUILD_COREML}" == "ON" ]]; then
cmake -DCMAKE_INSTALL_PREFIX=cmake-out \
-DCMAKE_BUILD_TYPE=Release \
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
-DEXECUTORCH_BUILD_COREML=ON \
-Dprotobuf_BUILD_TESTS=OFF \
-Dprotobuf_BUILD_EXAMPLES=OFF \
-DEXECUTORCH_ENABLE_LOGGING=ON \
-Bcmake-out .
else
cmake -DCMAKE_INSTALL_PREFIX=cmake-out \
-DCMAKE_BUILD_TYPE=Release \
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
-Bcmake-out .
fi
cmake --build cmake-out --target install --config Release
local example_dir=examples/devtools
local build_dir="cmake-out/${example_dir}"
local cmake_prefix_path="${PWD}/cmake-out/lib/cmake/ExecuTorch;${PWD}/cmake-out/third-party/gflags"
rm -rf ${build_dir}
cmake -DCMAKE_PREFIX_PATH="${cmake_prefix_path}" \
-DCMAKE_BUILD_TYPE=Release \
-DEXECUTORCH_BUILD_COREML=$BUILD_COREML \
-B"${build_dir}" \
"${example_dir}"
cmake --build "${build_dir}" --config Release
local runner="${PWD}/${build_dir}/example_runner"
if [[ ! -f "${runner}" ]]; then
echo "ERROR: Failed to build ${build_dir}/example_runner" >&2
exit 1
else
echo "Built ${build_dir}/example_runner"
fi
}
main "$@"