Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions docs/source/tutorials_source/sdk-integration-tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,24 +172,8 @@ def forward(self, x):
# 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``::
#
# cd executorch
# rm -rf cmake-out
# cmake -DCMAKE_INSTALL_PREFIX=cmake-out \
# -DCMAKE_BUILD_TYPE=Release \
# -DEXECUTORCH_BUILD_SDK=ON \
# -DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
# -Bcmake-out .
# cmake --build cmake-out -j9 --target install --config Release
#
# local example_dir=examples/sdk
# local build_dir=cmake-out/${example_dir}
# 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 \
# -B${build_dir} \
# ${example_dir}
# cmake --build ${build_dir} -j9 --config Release
# ${build_dir}/sdk_example_runner --bundled_program_path="bundled_program.bp"
# ./examples/sdk/build_sdk_example_runner.sh
# cmake-out/examples/sdk/sdk_example_runner --bundled_program_path="bundled_program.bp"

######################################################################
# Creating an Inspector
Expand Down
50 changes: 50 additions & 0 deletions examples/sdk/build_sdk_example_runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/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 sdk_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}"

main() {
cd "${EXECUTORCH_ROOT}"

rm -rf cmake-out
cmake -DCMAKE_INSTALL_PREFIX=cmake-out \
-DCMAKE_BUILD_TYPE=Release \
-DEXECUTORCH_BUILD_SDK=ON \
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
-Bcmake-out .
cmake --build cmake-out --target install --config Release

local example_dir=examples/sdk
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 \
-B"${build_dir}" \
"${example_dir}"
cmake --build "${build_dir}" --config Release

local runner="${PWD}/${build_dir}/sdk_example_runner"
if [[ ! -f "${runner}" ]]; then
echo "ERROR: Failed to build ${build_dir}/sdk_example_runner" >&2
exit 1
else
echo "Built ${build_dir}/sdk_example_runner"
fi
}

main "$@"