Skip to content

Commit 2a692c2

Browse files
authored
switch top-level ExecuTorch build from executorch_srcs.cmake to build_variables.bzl (#13358)
Will remove other uses of EXECUTORCH_SRCS_FILE in follow-up PR; want to demonstrate the build working first. #8268
1 parent ebfdcb9 commit 2a692c2

File tree

2 files changed

+93
-74
lines changed

2 files changed

+93
-74
lines changed

CMakeLists.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,15 @@ set(_common_include_directories
309309
)
310310

311311
#
312-
# The `_<target>_srcs` lists are defined by including ${EXECUTORCH_SRCS_FILE}.
312+
# The `_<target>_srcs` lists are defined by executorch_load_build_variables.
313313
#
314-
314+
if(EXECUTORCH_SRCS_FILE)
315+
message(
316+
WARNING
317+
"EXECUTORCH_SRCS_FILE is no longer necessary and will not affect the build."
318+
)
319+
endif()
320+
executorch_load_build_variables()
315321
if(NOT EXECUTORCH_SRCS_FILE)
316322
# A file wasn't provided. Run a script to extract the source lists from the
317323
# buck2 build system and write them to a file we can include.
@@ -324,10 +330,6 @@ if(NOT EXECUTORCH_SRCS_FILE)
324330
executorch_validate_build_variables()
325331
endif()
326332

327-
# This file defines the `_<target>__srcs` variables used below.
328-
message(STATUS "executorch: Using sources file ${EXECUTORCH_SRCS_FILE}")
329-
include(${EXECUTORCH_SRCS_FILE})
330-
331333
# Detect if an iOS toolchain is set.
332334
if(CMAKE_TOOLCHAIN_FILE MATCHES ".*(iOS|ios\.toolchain)\.cmake$")
333335
set(CMAKE_TOOLCHAIN_IOS ON)

tools/cmake/Codegen.cmake

Lines changed: 85 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,73 @@ function(executorch_append_filelist name outputvar)
375375
)
376376
endfunction()
377377

378+
set(EXECUTORCH_BUILD_VARIABLES_FILELISTS
379+
EXECUTORCH_SRCS
380+
EXECUTORCH_CORE_SRCS
381+
PORTABLE_KERNELS_SRCS
382+
KERNELS_UTIL_ALL_DEPS_SRCS
383+
OPTIMIZED_KERNELS_SRCS
384+
QUANTIZED_KERNELS_SRCS
385+
PROGRAM_SCHEMA_SRCS
386+
OPTIMIZED_CPUBLAS_SRCS
387+
OPTIMIZED_NATIVE_CPU_OPS_SRCS
388+
TEST_BACKEND_COMPILER_LIB_SRCS
389+
EXTENSION_DATA_LOADER_SRCS
390+
EXTENSION_EVALUE_UTIL_SRCS
391+
EXTENSION_FLAT_TENSOR_SRCS
392+
EXTENSION_MODULE_SRCS
393+
EXTENSION_RUNNER_UTIL_SRCS
394+
EXTENSION_LLM_RUNNER_SRCS
395+
EXTENSION_TENSOR_SRCS
396+
EXTENSION_THREADPOOL_SRCS
397+
EXTENSION_TRAINING_SRCS
398+
TRAIN_XOR_SRCS
399+
EXECUTOR_RUNNER_SRCS
400+
SIZE_TEST_SRCS
401+
MPS_EXECUTOR_RUNNER_SRCS
402+
MPS_BACKEND_SRCS
403+
MPS_SCHEMA_SRCS
404+
XNN_EXECUTOR_RUNNER_SRCS
405+
XNNPACK_BACKEND_SRCS
406+
XNNPACK_SCHEMA_SRCS
407+
VULKAN_SCHEMA_SRCS
408+
CUSTOM_OPS_SRCS
409+
LLAMA_RUNNER_SRCS
410+
)
411+
set(EXECUTORCH_BUILD_VARIABLES_VARNAMES
412+
_executorch__srcs
413+
_executorch_core__srcs
414+
_portable_kernels__srcs
415+
_kernels_util_all_deps__srcs
416+
_optimized_kernels__srcs
417+
_quantized_kernels__srcs
418+
_program_schema__srcs
419+
_optimized_cpublas__srcs
420+
_optimized_native_cpu_ops__srcs
421+
_test_backend_compiler_lib__srcs
422+
_extension_data_loader__srcs
423+
_extension_evalue_util__srcs
424+
_extension_flat_tensor__srcs
425+
_extension_module__srcs
426+
_extension_runner_util__srcs
427+
_extension_llm_runner__srcs
428+
_extension_tensor__srcs
429+
_extension_threadpool__srcs
430+
_extension_training__srcs
431+
_train_xor__srcs
432+
_executor_runner__srcs
433+
_size_test__srcs
434+
_mps_executor_runner__srcs
435+
_mps_backend__srcs
436+
_mps_schema__srcs
437+
_xnn_executor_runner__srcs
438+
_xnnpack_backend__srcs
439+
_xnnpack_schema__srcs
440+
_vulkan_schema__srcs
441+
_custom_ops__srcs
442+
_llama_runner__srcs
443+
)
444+
378445
# Fail the build if the src lists in build_variables.bzl do not match the src
379446
# lists extracted from Buck and placed into EXECUTORCH_SRCS_FILE. This is
380447
# intended to be a safety mechanism while we are in the process of removing Buck
@@ -386,74 +453,9 @@ endfunction()
386453
# involve getting these lists to match!
387454
function(executorch_validate_build_variables)
388455
include(${EXECUTORCH_SRCS_FILE})
389-
set(BUILD_VARIABLES_FILELISTS
390-
EXECUTORCH_SRCS
391-
EXECUTORCH_CORE_SRCS
392-
PORTABLE_KERNELS_SRCS
393-
KERNELS_UTIL_ALL_DEPS_SRCS
394-
OPTIMIZED_KERNELS_SRCS
395-
QUANTIZED_KERNELS_SRCS
396-
PROGRAM_SCHEMA_SRCS
397-
OPTIMIZED_CPUBLAS_SRCS
398-
OPTIMIZED_NATIVE_CPU_OPS_SRCS
399-
TEST_BACKEND_COMPILER_LIB_SRCS
400-
EXTENSION_DATA_LOADER_SRCS
401-
EXTENSION_EVALUE_UTIL_SRCS
402-
EXTENSION_FLAT_TENSOR_SRCS
403-
EXTENSION_MODULE_SRCS
404-
EXTENSION_RUNNER_UTIL_SRCS
405-
EXTENSION_LLM_RUNNER_SRCS
406-
EXTENSION_TENSOR_SRCS
407-
EXTENSION_THREADPOOL_SRCS
408-
EXTENSION_TRAINING_SRCS
409-
TRAIN_XOR_SRCS
410-
EXECUTOR_RUNNER_SRCS
411-
SIZE_TEST_SRCS
412-
MPS_EXECUTOR_RUNNER_SRCS
413-
MPS_BACKEND_SRCS
414-
MPS_SCHEMA_SRCS
415-
XNN_EXECUTOR_RUNNER_SRCS
416-
XNNPACK_BACKEND_SRCS
417-
XNNPACK_SCHEMA_SRCS
418-
VULKAN_SCHEMA_SRCS
419-
CUSTOM_OPS_SRCS
420-
LLAMA_RUNNER_SRCS
421-
)
422-
set(BUILD_VARIABLES_VARNAMES
423-
_executorch__srcs
424-
_executorch_core__srcs
425-
_portable_kernels__srcs
426-
_kernels_util_all_deps__srcs
427-
_optimized_kernels__srcs
428-
_quantized_kernels__srcs
429-
_program_schema__srcs
430-
_optimized_cpublas__srcs
431-
_optimized_native_cpu_ops__srcs
432-
_test_backend_compiler_lib__srcs
433-
_extension_data_loader__srcs
434-
_extension_evalue_util__srcs
435-
_extension_flat_tensor__srcs
436-
_extension_module__srcs
437-
_extension_runner_util__srcs
438-
_extension_llm_runner__srcs
439-
_extension_tensor__srcs
440-
_extension_threadpool__srcs
441-
_extension_training__srcs
442-
_train_xor__srcs
443-
_executor_runner__srcs
444-
_size_test__srcs
445-
_mps_executor_runner__srcs
446-
_mps_backend__srcs
447-
_mps_schema__srcs
448-
_xnn_executor_runner__srcs
449-
_xnnpack_backend__srcs
450-
_xnnpack_schema__srcs
451-
_vulkan_schema__srcs
452-
_custom_ops__srcs
453-
_llama_runner__srcs
454-
)
455-
foreach(filelist_and_varname IN ZIP_LISTS BUILD_VARIABLES_FILELISTS
456-
BUILD_VARIABLES_VARNAMES
456+
foreach(filelist_and_varname IN
457+
ZIP_LISTS EXECUTORCH_BUILD_VARIABLES_FILELISTS
458+
EXECUTORCH_BUILD_VARIABLES_VARNAMES
457459
)
458460
executorch_append_filelist(
459461
${filelist_and_varname_0}
@@ -504,3 +506,18 @@ function(executorch_validate_build_variables)
504506
endif()
505507
endforeach()
506508
endfunction()
509+
510+
function(executorch_load_build_variables)
511+
foreach(filelist_and_varname IN
512+
ZIP_LISTS EXECUTORCH_BUILD_VARIABLES_FILELISTS
513+
EXECUTORCH_BUILD_VARIABLES_VARNAMES
514+
)
515+
executorch_append_filelist(
516+
${filelist_and_varname_0} "${filelist_and_varname_1}"
517+
)
518+
set(${filelist_and_varname_1}
519+
"${${filelist_and_varname_1}}"
520+
PARENT_SCOPE
521+
)
522+
endforeach()
523+
endfunction()

0 commit comments

Comments
 (0)