From 9584db3aae5618cd943f9ab7e1298038e7db9c11 Mon Sep 17 00:00:00 2001 From: Olivia Liu Date: Tue, 30 Apr 2024 14:31:21 -0700 Subject: [PATCH 1/2] move commands from tutorial to a script --- .../sdk-integration-tutorial.py | 20 +------- examples/sdk/build_sdk_example_runner.sh | 50 +++++++++++++++++++ 2 files changed, 52 insertions(+), 18 deletions(-) create mode 100644 examples/sdk/build_sdk_example_runner.sh diff --git a/docs/source/tutorials_source/sdk-integration-tutorial.py b/docs/source/tutorials_source/sdk-integration-tutorial.py index cd45f806fbf..ccc2e480ad0 100644 --- a/docs/source/tutorials_source/sdk-integration-tutorial.py +++ b/docs/source/tutorials_source/sdk-integration-tutorial.py @@ -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 diff --git a/examples/sdk/build_sdk_example_runner.sh b/examples/sdk/build_sdk_example_runner.sh new file mode 100644 index 00000000000..291febb36db --- /dev/null +++ b/examples/sdk/build_sdk_example_runner.sh @@ -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 "$@" From dfc11cf038d1112639099342f93e48af86408600 Mon Sep 17 00:00:00 2001 From: Olivia Liu Date: Tue, 30 Apr 2024 15:15:06 -0700 Subject: [PATCH 2/2] chmod +x --- examples/sdk/build_sdk_example_runner.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 examples/sdk/build_sdk_example_runner.sh diff --git a/examples/sdk/build_sdk_example_runner.sh b/examples/sdk/build_sdk_example_runner.sh old mode 100644 new mode 100755