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# Build size_test and show the size of it 9set -e 10 11# shellcheck source=/dev/null 12source "$(dirname "${BASH_SOURCE[0]}")/../.ci/scripts/utils.sh" 13 14cmake_install_executorch_lib() { 15 echo "Installing libexecutorch.a" 16 rm -rf cmake-out 17 18 retry cmake -DBUCK2="$BUCK2" \ 19 -DCMAKE_CXX_STANDARD_REQUIRED=ON \ 20 -DCMAKE_INSTALL_PREFIX=cmake-out \ 21 -DCMAKE_BUILD_TYPE=Release \ 22 -DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \ 23 -DOPTIMIZE_SIZE=ON \ 24 -DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \ 25 -Bcmake-out . 26 cmake --build cmake-out -j9 --target install --config Release 27} 28 29test_cmake_size_test() { 30 retry cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=cmake-out -Bcmake-out/test test 31 32 echo "Build size test" 33 cmake --build cmake-out/test -j9 --config Release 34 35 echo 'ExecuTorch with no ops binary size, unstripped:' 36 ls -al cmake-out/test/size_test 37 38 echo 'ExecuTorch with portable ops binary size, unstripped:' 39 ls -al cmake-out/test/size_test_all_ops 40} 41 42if [[ -z $BUCK2 ]]; then 43 BUCK2=buck2 44fi 45 46if [[ -z $PYTHON_EXECUTABLE ]]; then 47 PYTHON_EXECUTABLE=python3 48fi 49 50cmake_install_executorch_lib 51test_cmake_size_test 52