Skip to content

Commit 4214942

Browse files
authored
Switch non-top-level ExecuTorch builds (size test, examples, etc.) from executorch_srcs.cmake to build_variables.bzl (#13391)
Had to make some minor fixes for compatibility with non-top-level-build context.
1 parent 56f24c6 commit 4214942

File tree

9 files changed

+22
-60
lines changed

9 files changed

+22
-60
lines changed

examples/apple/mps/CMakeLists.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,10 @@ if(NOT CMAKE_TOOLCHAIN_FILE MATCHES ".*(iOS|ios\.toolchain)\.cmake$")
7676
)
7777

7878
#
79-
# The `_<target>_srcs` lists are defined by including ${EXECUTORCH_SRCS_FILE}.
79+
# The `_<target>_srcs` lists are defined by executorch_load_build_variables.
8080
#
81-
set(EXECUTORCH_SRCS_FILE
82-
"${CMAKE_CURRENT_BINARY_DIR}/../../../executorch_srcs.cmake"
83-
)
84-
85-
extract_sources(${EXECUTORCH_SRCS_FILE})
86-
81+
executorch_load_build_variables()
8782
set(_mps_schema_headers ${CMAKE_BINARY_DIR}/../../../schema/include/)
88-
include(${EXECUTORCH_SRCS_FILE})
8983
target_include_directories(
9084
bundled_program
9185
INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/../../../devtools/include

examples/mediatek/CMakeLists.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,9 @@ set(_common_include_directories
3636
)
3737

3838
#
39-
# The `_<target>_srcs` lists are defined by including ${EXECUTORCH_SRCS_FILE}.
39+
# The `_<target>_srcs` lists are defined by executorch_load_build_variables.
4040
#
41-
set(EXECUTORCH_SRCS_FILE
42-
"${CMAKE_CURRENT_BINARY_DIR}/../../executorch_srcs.cmake"
43-
)
44-
extract_sources(${EXECUTORCH_SRCS_FILE})
45-
include(${EXECUTORCH_SRCS_FILE})
41+
executorch_load_build_variables()
4642

4743
# Find prebuilt libraries. executorch package should contain portable_ops_lib,
4844
# etdump, bundled_program.

examples/portable/custom_ops/CMakeLists.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,9 @@ option(
5959
# ------------------------------- OPTIONS END --------------------------------
6060

6161
#
62-
# The `_<target>_srcs` lists are defined by including ${EXECUTORCH_SRCS_FILE}.
62+
# The `_<target>_srcs` lists are defined by executorch_load_build_variables.
6363
#
64-
set(EXECUTORCH_SRCS_FILE
65-
"${CMAKE_CURRENT_BINARY_DIR}/../../../executorch_srcs.cmake"
66-
)
67-
68-
extract_sources(${EXECUTORCH_SRCS_FILE})
69-
70-
include(${EXECUTORCH_SRCS_FILE})
64+
executorch_load_build_variables()
7165

7266
# Generate C++ bindings to register kernels into both PyTorch (for AOT) and
7367
# Executorch (for runtime).

examples/qualcomm/CMakeLists.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,9 @@ find_package(gflags REQUIRED)
3535
set(_common_compile_options -Wno-deprecated-declarations -fPIC)
3636

3737
#
38-
# The `_<target>_srcs` lists are defined by including ${EXECUTORCH_SRCS_FILE}.
38+
# The `_<target>_srcs` lists are defined by executorch_load_build_variables.
3939
#
40-
set(EXECUTORCH_SRCS_FILE
41-
"${CMAKE_CURRENT_BINARY_DIR}/../../executorch_srcs.cmake"
42-
)
43-
extract_sources(${EXECUTORCH_SRCS_FILE})
44-
include(${EXECUTORCH_SRCS_FILE})
40+
executorch_load_build_variables()
4541

4642
get_filename_component(
4743
EXECUTORCH_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE

examples/selective_build/CMakeLists.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,9 @@ option(EXECUTORCH_DTYPE_SELECTIVE_BUILD "Enable dtype selective build." OFF)
7777
# ------------------------------- OPTIONS END --------------------------------
7878

7979
#
80-
# The `_<target>_srcs` lists are defined by including ${EXECUTORCH_SRCS_FILE}.
80+
# The `_<target>_srcs` lists are defined by executorch_load_build_variables.
8181
#
82-
set(EXECUTORCH_SRCS_FILE
83-
"${CMAKE_CURRENT_BINARY_DIR}/../../executorch_srcs.cmake"
84-
)
85-
86-
extract_sources(${EXECUTORCH_SRCS_FILE})
87-
88-
include(${EXECUTORCH_SRCS_FILE})
82+
executorch_load_build_variables()
8983

9084
#
9185
# select_build_lib: C++ library to register selected ops in custom kernel

extension/llm/custom_ops/CMakeLists.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,9 @@ include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
2525
include(${EXECUTORCH_ROOT}/tools/cmake/Codegen.cmake)
2626

2727
#
28-
# The `_<target>_srcs` lists are defined by including ${EXECUTORCH_SRCS_FILE}.
28+
# The `_<target>_srcs` lists are defined by executorch_load_build_variables.
2929
#
30-
set(EXECUTORCH_SRCS_FILE
31-
"${CMAKE_CURRENT_BINARY_DIR}/../../../executorch_srcs.cmake"
32-
)
33-
34-
extract_sources(${EXECUTORCH_SRCS_FILE})
35-
36-
include(${EXECUTORCH_SRCS_FILE})
30+
executorch_load_build_variables()
3731

3832
set(_common_include_directories
3933
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..,${CMAKE_CURRENT_SOURCE_DIR}/runtime/core/portable_type/c10>

extension/llm/runner/CMakeLists.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,9 @@ include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
2424
include(${EXECUTORCH_ROOT}/tools/cmake/Codegen.cmake)
2525

2626
#
27-
# The `_<target>_srcs` lists are defined by including ${EXECUTORCH_SRCS_FILE}.
27+
# The `_<target>_srcs` lists are defined by executorch_load_build_variables.
2828
#
29-
set(EXECUTORCH_SRCS_FILE
30-
"${CMAKE_CURRENT_BINARY_DIR}/../../../executorch_srcs.cmake"
31-
)
32-
33-
extract_sources(${EXECUTORCH_SRCS_FILE})
34-
35-
include(${EXECUTORCH_SRCS_FILE})
29+
executorch_load_build_variables()
3630

3731
# build llm runner library
3832
list(TRANSFORM _extension_llm_runner__srcs PREPEND "${EXECUTORCH_ROOT}/")

test/CMakeLists.txt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ set(CMAKE_CXX_STANDARD 17)
2323

2424
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/..)
2525

26+
include(${EXECUTORCH_ROOT}/tools/cmake/Codegen.cmake)
2627
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
2728

2829
# Find prebuilt executorch library
@@ -34,13 +35,9 @@ find_package(executorch CONFIG REQUIRED FIND_ROOT_PATH_BOTH)
3435
set(_common_include_directories ${EXECUTORCH_ROOT}/..)
3536

3637
#
37-
# The `_<target>_srcs` lists are defined by including ${EXECUTORCH_SRCS_FILE}.
38+
# The `_<target>_srcs` lists are defined by executorch_load_build_variables.
3839
#
39-
set(EXECUTORCH_SRCS_FILE "${CMAKE_CURRENT_BINARY_DIR}/../executorch_srcs.cmake")
40-
41-
extract_sources(${EXECUTORCH_SRCS_FILE})
42-
43-
include(${EXECUTORCH_SRCS_FILE})
40+
executorch_load_build_variables()
4441

4542
# Since extract_sources.py is not returning absolute values, we need to patch
4643
# the source paths.

tools/cmake/Codegen.cmake

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,13 +349,16 @@ endfunction()
349349
function(executorch_append_filelist name outputvar)
350350
# configure_file adds its input to the list of CMAKE_RERUN dependencies
351351
configure_file(
352-
${PROJECT_SOURCE_DIR}/shim_et/xplat/executorch/build/build_variables.bzl
352+
${EXECUTORCH_ROOT}/shim_et/xplat/executorch/build/build_variables.bzl
353353
${PROJECT_BINARY_DIR}/build_variables.bzl COPYONLY
354354
)
355+
if(NOT PYTHON_EXECUTABLE)
356+
resolve_python_executable()
357+
endif()
355358
execute_process(
356359
COMMAND
357360
"${PYTHON_EXECUTABLE}" -c
358-
"exec(open('${PROJECT_SOURCE_DIR}/shim_et/xplat/executorch/build/build_variables.bzl').read());print(';'.join(${name}))"
361+
"exec(open('${EXECUTORCH_ROOT}/shim_et/xplat/executorch/build/build_variables.bzl').read());print(';'.join(${name}))"
359362
WORKING_DIRECTORY "${_rootdir}"
360363
RESULT_VARIABLE _retval
361364
OUTPUT_VARIABLE _tempvar

0 commit comments

Comments
 (0)