Skip to content

Commit 289acbd

Browse files
authored
Support for cmdline flag to toggle Debug vs Release build types in cmake (#11662)
### Summary Adds support for command line option to toggle the cmake build mode from `Debug` vs `Release`. ### Test plan An example use case is shown in `examples/selective_build/test_selective_build.sh` in the `test_cmake_select_ops_in_model()` function. For example, you could run the following to build executorch and run the test in `Debug` mode: ``` CMAKE_BUILD_TYPE=Debug bash examples/selective_build/test_selective_build.sh cmake ```
1 parent 1860719 commit 289acbd

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

.ci/scripts/utils.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,14 @@ build_executorch_runner() {
156156
}
157157

158158
cmake_install_executorch_lib() {
159+
build_type="${1:-Release}"
159160
echo "Installing libexecutorch.a and libportable_kernels.a"
160161
clean_executorch_install_folders
161162
retry cmake -DCMAKE_INSTALL_PREFIX=cmake-out \
162-
-DCMAKE_BUILD_TYPE=Release \
163+
-DCMAKE_BUILD_TYPE=${build_type} \
163164
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
164165
-Bcmake-out .
165-
cmake --build cmake-out -j9 --target install --config Release
166+
cmake --build cmake-out -j9 --target install --config ${build_type}
166167
}
167168

168169
download_stories_model_artifacts() {

examples/selective_build/test_selective_build.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,15 @@ test_cmake_select_ops_in_model() {
167167
local example_dir=examples/selective_build
168168
local build_dir=cmake-out/${example_dir}
169169
rm -rf ${build_dir}
170-
retry cmake -DCMAKE_BUILD_TYPE=Release \
170+
retry cmake -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \
171171
-DEXECUTORCH_SELECT_OPS_FROM_MODEL="./mv2.pte" \
172172
-DCMAKE_INSTALL_PREFIX=cmake-out \
173173
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
174174
-B${build_dir} \
175175
${example_dir}
176176

177177
echo "Building ${example_dir}"
178-
cmake --build ${build_dir} -j9 --config Release
178+
cmake --build ${build_dir} -j9 --config $CMAKE_BUILD_TYPE
179179

180180
echo 'Running selective build test'
181181
${build_dir}/selective_build_test --model_path="./mv2.pte"
@@ -194,9 +194,14 @@ then
194194
PYTHON_EXECUTABLE=python3
195195
fi
196196

197+
if [[ -z $CMAKE_BUILD_TYPE ]];
198+
then
199+
CMAKE_BUILD_TYPE=Release
200+
fi
201+
197202
if [[ $1 == "cmake" ]];
198203
then
199-
cmake_install_executorch_lib
204+
cmake_install_executorch_lib $CMAKE_BUILD_TYPE
200205
test_cmake_select_all_ops
201206
test_cmake_select_ops_in_list
202207
test_cmake_select_ops_in_yaml

0 commit comments

Comments
 (0)