-
Notifications
You must be signed in to change notification settings - Fork 628
create and validate build_variables.bzl #8326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 26 commits
07adf1a
bc3fd39
00ce927
6440d3d
e62191a
630bdd0
098432f
773ff37
87513d8
b61319b
d4aaa36
15bc325
6b9b4cc
ca4c14e
a0e9eb9
4878a6b
da6fd97
e9d552e
8ed9894
3f80407
8016e33
a947148
e3ae7b5
a826c40
6601683
7a8397f
f7c1205
4b35d1e
fe6b9c7
ff128f7
f06ee2f
a1b9a76
59355b9
95cfe7d
cb0234b
0d53925
3b24ef4
9d8e434
3a2d555
b8f2a5b
719b63d
f02844b
1b47bf0
61f045d
4eb72d3
9c7b3d1
25a26e2
aafa130
71ef8af
b52f223
8df2f1d
7f5cfd3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -220,3 +220,113 @@ function(merge_yaml) | |
WORKING_DIRECTORY ${EXECUTORCH_ROOT} | ||
) | ||
endfunction() | ||
|
||
function(append_filelist name outputvar) | ||
# configure_file adds its input to the list of CMAKE_RERUN dependencies | ||
configure_file( | ||
${PROJECT_SOURCE_DIR}/build/build_variables.bzl | ||
${PROJECT_BINARY_DIR}/build_variables.bzl COPYONLY | ||
) | ||
execute_process( | ||
COMMAND | ||
"${PYTHON_EXECUTABLE}" -c | ||
"exec(open('${PROJECT_SOURCE_DIR}/build/build_variables.bzl').read());print(';'.join(${name}))" | ||
WORKING_DIRECTORY "${_rootdir}" | ||
RESULT_VARIABLE _retval | ||
OUTPUT_VARIABLE _tempvar | ||
ERROR_VARIABLE _stderr | ||
) | ||
if(NOT _retval EQUAL 0) | ||
message( | ||
FATAL_ERROR | ||
"Failed to fetch filelist ${name} from build_variables.bzl with output ${_tempvar} and stderr ${_stderr}" | ||
) | ||
endif() | ||
string(REPLACE "\n" "" _tempvar "${_tempvar}") | ||
list(APPEND ${outputvar} ${_tempvar}) | ||
set(${outputvar} | ||
"${${outputvar}}" | ||
PARENT_SCOPE | ||
) | ||
endfunction() | ||
|
||
function(validate_build_variables) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a comment on this explaining what it does, and to help future authors understand when they need to add/remove elements in these lists. |
||
include(${EXECUTORCH_SRCS_FILE}) | ||
set(BUILD_VARIABLES_FILELISTS | ||
EXECUTORCH_SRCS | ||
EXECUTORCH_CORE_SRCS | ||
PORTABLE_KERNELS_SRCS | ||
OPTIMIZED_KERNELS_SRCS | ||
QUANTIZED_KERNELS_SRCS | ||
PROGRAM_SCHEMA_SRCS | ||
OPTIMIZED_CPUBLAS_SRCS | ||
OPTIMIZED_NATIVE_CPU_OPS_OSS_SRCS | ||
EXTENSION_DATA_LOADER_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(BUILD_VARIABLES_VARNAMES | ||
_executorch__srcs | ||
_executorch_core__srcs | ||
_portable_kernels__srcs | ||
_optimized_kernels__srcs | ||
_quantized_kernels__srcs | ||
_program_schema__srcs | ||
_optimized_cpublas__srcs | ||
_optimized_native_cpu_ops_oss__srcs | ||
_extension_data_loader__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 BUILD_VARIABLES_FILELISTS | ||
BUILD_VARIABLES_VARNAMES | ||
) | ||
append_filelist( | ||
${filelist_and_varname_0} | ||
"${filelist_and_varname_1}_from_build_variables" | ||
) | ||
if(NOT ${filelist_and_varname_1} STREQUAL | ||
${filelist_and_varname_1}_from_build_variables | ||
) | ||
message( | ||
FATAL_ERROR | ||
"Buck-generated ${filelist_and_varname_1} does not match hardcoded \ | ||
${filelist_and_varname_0} in build_variables.bzl. Left: \ | ||
${${filelist_and_varname_1}}\n \ | ||
Right: ${${filelist_and_varname_1}_from_build_variables}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok as is, but you could skip the backslashes and provide multiple strings; |
||
) | ||
endif() | ||
endforeach() | ||
endfunction() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment explaining what this does and what it expects for (and will do to)
outputvar