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 cadence_runner and prints its path. 9 10set -euo pipefail 11 12SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" 13readonly SCRIPT_DIR 14 15readonly EXECUTORCH_ROOT="${SCRIPT_DIR}/../.." 16 17# Allow overriding the number of build jobs. Default to 9. 18export CMAKE_BUILD_PARALLEL_LEVEL="${CMAKE_BUILD_PARALLEL_LEVEL:-9}" 19 20main() { 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_DEVTOOLS=ON \ 27 -DEXECUTORCH_ENABLE_EVENT_TRACER=ON \ 28 -DEXECUTORCH_ENABLE_LOGGING=ON \ 29 -Bcmake-out . 30 cmake --build cmake-out --target install --config Release -j16 31 32 local example_dir=backends/cadence 33 local build_dir="cmake-out/${example_dir}" 34 local cmake_prefix_path="${PWD}/cmake-out/lib/cmake/ExecuTorch;${PWD}/cmake-out/third-party/gflags" 35 rm -rf ${build_dir} 36 cmake -DCMAKE_PREFIX_PATH="${cmake_prefix_path}" \ 37 -DCMAKE_BUILD_TYPE=Release \ 38 -DEXECUTORCH_CADENCE_CPU_RUNNER=ON \ 39 -DEXECUTORCH_ENABLE_LOGGING=ON \ 40 -B"${build_dir}" \ 41 "${example_dir}" 42 cmake --build "${build_dir}" --config Release -j16 43 44 local runner="${PWD}/${build_dir}/cadence_runner" 45 if [[ ! -f "${runner}" ]]; then 46 echo "ERROR: Failed to build ${build_dir}/cadence_runner" >&2 47 exit 1 48 else 49 echo "Built ${build_dir}/cadence_runner" 50 fi 51} 52 53main "$@" 54