diff --git a/CMakeLists.txt b/CMakeLists.txt index cfae0f8b74b..32a737cfb02 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -318,17 +318,6 @@ if(EXECUTORCH_SRCS_FILE) ) endif() executorch_load_build_variables() -if(NOT EXECUTORCH_SRCS_FILE) - # A file wasn't provided. Run a script to extract the source lists from the - # buck2 build system and write them to a file we can include. - # - # NOTE: This will only happen once during cmake setup, so it will not re-run - # if the buck2 targets change. - message(STATUS "executorch: Generating source lists") - set(EXECUTORCH_SRCS_FILE "${CMAKE_CURRENT_BINARY_DIR}/executorch_srcs.cmake") - extract_sources(${EXECUTORCH_SRCS_FILE}) - executorch_validate_build_variables() -endif() # Detect if an iOS toolchain is set. if(CMAKE_TOOLCHAIN_FILE MATCHES ".*(iOS|ios\.toolchain)\.cmake$") diff --git a/tools/cmake/Codegen.cmake b/tools/cmake/Codegen.cmake index 93ba0f890a8..aa9c2133851 100644 --- a/tools/cmake/Codegen.cmake +++ b/tools/cmake/Codegen.cmake @@ -378,139 +378,73 @@ function(executorch_append_filelist name outputvar) ) endfunction() -set(EXECUTORCH_BUILD_VARIABLES_FILELISTS - EXECUTORCH_SRCS - EXECUTORCH_CORE_SRCS - PORTABLE_KERNELS_SRCS - KERNELS_UTIL_ALL_DEPS_SRCS - OPTIMIZED_KERNELS_SRCS - QUANTIZED_KERNELS_SRCS - PROGRAM_SCHEMA_SRCS - OPTIMIZED_CPUBLAS_SRCS - OPTIMIZED_NATIVE_CPU_OPS_SRCS - TEST_BACKEND_COMPILER_LIB_SRCS - EXTENSION_DATA_LOADER_SRCS - EXTENSION_EVALUE_UTIL_SRCS - EXTENSION_FLAT_TENSOR_SRCS - EXTENSION_MODULE_SRCS - EXTENSION_RUNNER_UTIL_SRCS - EXTENSION_LLM_RUNNER_SRCS - EXTENSION_TENSOR_SRCS - EXTENSION_THREADPOOL_SRCS - EXTENSION_TRAINING_SRCS - TRAIN_XOR_SRCS - EXECUTOR_RUNNER_SRCS - SIZE_TEST_SRCS - MPS_EXECUTOR_RUNNER_SRCS - MPS_BACKEND_SRCS - MPS_SCHEMA_SRCS - XNN_EXECUTOR_RUNNER_SRCS - XNNPACK_BACKEND_SRCS - XNNPACK_SCHEMA_SRCS - VULKAN_SCHEMA_SRCS - CUSTOM_OPS_SRCS - LLAMA_RUNNER_SRCS -) -set(EXECUTORCH_BUILD_VARIABLES_VARNAMES - _executorch__srcs - _executorch_core__srcs - _portable_kernels__srcs - _kernels_util_all_deps__srcs - _optimized_kernels__srcs - _quantized_kernels__srcs - _program_schema__srcs - _optimized_cpublas__srcs - _optimized_native_cpu_ops__srcs - _test_backend_compiler_lib__srcs - _extension_data_loader__srcs - _extension_evalue_util__srcs - _extension_flat_tensor__srcs - _extension_module__srcs - _extension_runner_util__srcs - _extension_llm_runner__srcs - _extension_tensor__srcs - _extension_threadpool__srcs - _extension_training__srcs - _train_xor__srcs - _executor_runner__srcs - _size_test__srcs - _mps_executor_runner__srcs - _mps_backend__srcs - _mps_schema__srcs - _xnn_executor_runner__srcs - _xnnpack_backend__srcs - _xnnpack_schema__srcs - _vulkan_schema__srcs - _custom_ops__srcs - _llama_runner__srcs -) - -# Fail the build if the src lists in build_variables.bzl do not match the src -# lists extracted from Buck and placed into EXECUTORCH_SRCS_FILE. This is -# intended to be a safety mechanism while we are in the process of removing Buck -# from the CMake build and replacing it with build_variables.bzl; if you are -# seeing failures after you have intentionally changed Buck srcs, then simply -# update build_variables.bzl. If you are seeing failures after changing -# something about the build system, make sure your changes will work both before -# and after we finish replacing Buck with build_variables.bzl, which should -# involve getting these lists to match! -function(executorch_validate_build_variables) - include(${EXECUTORCH_SRCS_FILE}) - foreach(filelist_and_varname IN - ZIP_LISTS EXECUTORCH_BUILD_VARIABLES_FILELISTS - EXECUTORCH_BUILD_VARIABLES_VARNAMES - ) - executorch_append_filelist( - ${filelist_and_varname_0} - "${filelist_and_varname_1}_from_build_variables" - ) - # The Buck and CMake mechanisms for getting the default PAL set up are - # different. Prevent the Buck choice from flowing into CMake and causing - # validation to fail, just like we do in our CMakeLists.txt. - if("${filelist_and_varname_1}" STREQUAL "_executorch_core__srcs") - list(FILTER ${filelist_and_varname_1} EXCLUDE REGEX - "runtime/platform/default/[^/]*.cpp$" - ) - endif() - if(NOT ${filelist_and_varname_1} STREQUAL - ${filelist_and_varname_1}_from_build_variables - ) - set(generated_items_not_in_build_variables ${${filelist_and_varname_1}}) - list(REMOVE_ITEM generated_items_not_in_build_variables - ${${filelist_and_varname_1}_from_build_variables} - ) - - set(build_variables_items_not_in_generated - ${${filelist_and_varname_1}_from_build_variables} - ) - list(REMOVE_ITEM build_variables_items_not_in_generated - ${${filelist_and_varname_1}} - ) - - list(JOIN generated_items_not_in_build_variables "\n" - pretty_generated_items_not_in_build_variables - ) - list(JOIN build_variables_items_not_in_generated "\n" - pretty_build_variables_items_not_in_generated - ) - if(NOT pretty_generated_items_not_in_build_variables) - set(pretty_generated_items_not_in_build_variables "") - endif() - if(NOT pretty_build_variables_items_not_in_generated) - set(pretty_build_variables_items_not_in_generated "") - endif() - message( - FATAL_ERROR - "Buck-generated ${filelist_and_varname_1} does not match hardcoded " - "${filelist_and_varname_0} in build_variables.bzl. Buck-generated items not in build_variables.bzl: " - "${pretty_generated_items_not_in_build_variables}\n " - "build_variables.bzl items not in buck-generated list: ${pretty_build_variables_items_not_in_generated}" - ) - endif() - endforeach() -endfunction() - function(executorch_load_build_variables) + set(EXECUTORCH_BUILD_VARIABLES_FILELISTS + EXECUTORCH_SRCS + EXECUTORCH_CORE_SRCS + PORTABLE_KERNELS_SRCS + KERNELS_UTIL_ALL_DEPS_SRCS + OPTIMIZED_KERNELS_SRCS + QUANTIZED_KERNELS_SRCS + PROGRAM_SCHEMA_SRCS + OPTIMIZED_CPUBLAS_SRCS + OPTIMIZED_NATIVE_CPU_OPS_SRCS + TEST_BACKEND_COMPILER_LIB_SRCS + EXTENSION_DATA_LOADER_SRCS + EXTENSION_EVALUE_UTIL_SRCS + EXTENSION_FLAT_TENSOR_SRCS + EXTENSION_MODULE_SRCS + EXTENSION_RUNNER_UTIL_SRCS + EXTENSION_LLM_RUNNER_SRCS + EXTENSION_TENSOR_SRCS + EXTENSION_THREADPOOL_SRCS + EXTENSION_TRAINING_SRCS + TRAIN_XOR_SRCS + EXECUTOR_RUNNER_SRCS + SIZE_TEST_SRCS + MPS_EXECUTOR_RUNNER_SRCS + MPS_BACKEND_SRCS + MPS_SCHEMA_SRCS + XNN_EXECUTOR_RUNNER_SRCS + XNNPACK_BACKEND_SRCS + XNNPACK_SCHEMA_SRCS + VULKAN_SCHEMA_SRCS + CUSTOM_OPS_SRCS + LLAMA_RUNNER_SRCS + ) + set(EXECUTORCH_BUILD_VARIABLES_VARNAMES + _executorch__srcs + _executorch_core__srcs + _portable_kernels__srcs + _kernels_util_all_deps__srcs + _optimized_kernels__srcs + _quantized_kernels__srcs + _program_schema__srcs + _optimized_cpublas__srcs + _optimized_native_cpu_ops__srcs + _test_backend_compiler_lib__srcs + _extension_data_loader__srcs + _extension_evalue_util__srcs + _extension_flat_tensor__srcs + _extension_module__srcs + _extension_runner_util__srcs + _extension_llm_runner__srcs + _extension_tensor__srcs + _extension_threadpool__srcs + _extension_training__srcs + _train_xor__srcs + _executor_runner__srcs + _size_test__srcs + _mps_executor_runner__srcs + _mps_backend__srcs + _mps_schema__srcs + _xnn_executor_runner__srcs + _xnnpack_backend__srcs + _xnnpack_schema__srcs + _vulkan_schema__srcs + _custom_ops__srcs + _llama_runner__srcs + ) foreach(filelist_and_varname IN ZIP_LISTS EXECUTORCH_BUILD_VARIABLES_FILELISTS EXECUTORCH_BUILD_VARIABLES_VARNAMES