Skip to content

Commit e492625

Browse files
Simplify SDK tutorial by moving cmake commands to a script (#3438) (#3492)
Summary: As titled. Tested the commands on mac locally and they worked. Pull Request resolved: #3438 Reviewed By: Jack-Khuu Differential Revision: D56792240 Pulled By: Olivia-liu fbshipit-source-id: dd62ea2fc788c5e1867d1e50037d7b4fd7e3a3f9 (cherry picked from commit a4ffd96) Co-authored-by: Olivia Liu <[email protected]> Co-authored-by: Peixuan Liu <[email protected]>
1 parent 7fc70aa commit e492625

File tree

2 files changed

+52
-18
lines changed

2 files changed

+52
-18
lines changed

docs/source/tutorials_source/sdk-integration-tutorial.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -172,24 +172,8 @@ def forward(self, x):
172172
# Use CMake (follow `these instructions <../runtime-build-and-cross-compilation.html#configure-the-cmake-build>`__ to set up cmake) to execute the Bundled Program to generate the ``ETDump``::
173173
#
174174
# cd executorch
175-
# rm -rf cmake-out
176-
# cmake -DCMAKE_INSTALL_PREFIX=cmake-out \
177-
# -DCMAKE_BUILD_TYPE=Release \
178-
# -DEXECUTORCH_BUILD_SDK=ON \
179-
# -DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
180-
# -Bcmake-out .
181-
# cmake --build cmake-out -j9 --target install --config Release
182-
#
183-
# local example_dir=examples/sdk
184-
# local build_dir=cmake-out/${example_dir}
185-
# CMAKE_PREFIX_PATH="${PWD}/cmake-out/lib/cmake/ExecuTorch;${PWD}/cmake-out/third-party/gflags"
186-
# rm -rf ${build_dir}
187-
# cmake -DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" \
188-
# -DCMAKE_BUILD_TYPE=Release \
189-
# -B${build_dir} \
190-
# ${example_dir}
191-
# cmake --build ${build_dir} -j9 --config Release
192-
# ${build_dir}/sdk_example_runner --bundled_program_path="bundled_program.bp"
175+
# ./examples/sdk/build_sdk_example_runner.sh
176+
# cmake-out/examples/sdk/sdk_example_runner --bundled_program_path="bundled_program.bp"
193177

194178
######################################################################
195179
# Creating an Inspector
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
# Builds sdk_example_runner and prints its path.
9+
10+
set -euo pipefail
11+
12+
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
13+
readonly SCRIPT_DIR
14+
15+
readonly EXECUTORCH_ROOT="${SCRIPT_DIR}/../.."
16+
17+
# Allow overriding the number of build jobs. Default to 9.
18+
export CMAKE_BUILD_PARALLEL_LEVEL="${CMAKE_BUILD_PARALLEL_LEVEL:-9}"
19+
20+
main() {
21+
cd "${EXECUTORCH_ROOT}"
22+
23+
rm -rf cmake-out
24+
cmake -DCMAKE_INSTALL_PREFIX=cmake-out \
25+
-DCMAKE_BUILD_TYPE=Release \
26+
-DEXECUTORCH_BUILD_SDK=ON \
27+
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
28+
-Bcmake-out .
29+
cmake --build cmake-out --target install --config Release
30+
31+
local example_dir=examples/sdk
32+
local build_dir="cmake-out/${example_dir}"
33+
local cmake_prefix_path="${PWD}/cmake-out/lib/cmake/ExecuTorch;${PWD}/cmake-out/third-party/gflags"
34+
rm -rf ${build_dir}
35+
cmake -DCMAKE_PREFIX_PATH="${cmake_prefix_path}" \
36+
-DCMAKE_BUILD_TYPE=Release \
37+
-B"${build_dir}" \
38+
"${example_dir}"
39+
cmake --build "${build_dir}" --config Release
40+
41+
local runner="${PWD}/${build_dir}/sdk_example_runner"
42+
if [[ ! -f "${runner}" ]]; then
43+
echo "ERROR: Failed to build ${build_dir}/sdk_example_runner" >&2
44+
exit 1
45+
else
46+
echo "Built ${build_dir}/sdk_example_runner"
47+
fi
48+
}
49+
50+
main "$@"

0 commit comments

Comments
 (0)