未验证 提交 212f015f 编写于 作者: A Aganlengzi 提交者: GitHub

generate_unify_header supports excludes (#44761)

上级 f064ead6
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
function(generate_unify_header DIR_NAME) function(generate_unify_header DIR_NAME)
set(options "") set(options "")
set(oneValueArgs HEADER_NAME SKIP_SUFFIX) set(oneValueArgs HEADER_NAME SKIP_SUFFIX)
set(multiValueArgs "") set(multiValueArgs EXCLUDES)
cmake_parse_arguments(generate_unify_header "${options}" "${oneValueArgs}" cmake_parse_arguments(generate_unify_header "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN}) "${multiValueArgs}" ${ARGN})
...@@ -33,6 +33,9 @@ function(generate_unify_header DIR_NAME) ...@@ -33,6 +33,9 @@ function(generate_unify_header DIR_NAME)
set(skip_suffix "${generate_unify_header_SKIP_SUFFIX}") set(skip_suffix "${generate_unify_header_SKIP_SUFFIX}")
endif() endif()
# exclude files
list(LENGTH generate_unify_header_EXCLUDES generate_unify_header_EXCLUDES_len)
# generate target header file # generate target header file
set(header_file ${CMAKE_CURRENT_SOURCE_DIR}/include/${header_name}.h) set(header_file ${CMAKE_CURRENT_SOURCE_DIR}/include/${header_name}.h)
file( file(
...@@ -43,6 +46,13 @@ function(generate_unify_header DIR_NAME) ...@@ -43,6 +46,13 @@ function(generate_unify_header DIR_NAME)
# get all top-level headers and write into header file # get all top-level headers and write into header file
file(GLOB HEADERS "${CMAKE_CURRENT_SOURCE_DIR}\/${DIR_NAME}\/*.h") file(GLOB HEADERS "${CMAKE_CURRENT_SOURCE_DIR}\/${DIR_NAME}\/*.h")
foreach(header ${HEADERS}) foreach(header ${HEADERS})
if(${generate_unify_header_EXCLUDES_len} GREATER 0)
get_filename_component(header_file_name ${header} NAME)
list(FIND generate_unify_header_EXCLUDES ${header_file_name} _index)
if(NOT ${_index} EQUAL -1)
continue()
endif()
endif()
if("${skip_suffix}" STREQUAL "") if("${skip_suffix}" STREQUAL "")
string(REPLACE "${PADDLE_SOURCE_DIR}\/" "" header "${header}") string(REPLACE "${PADDLE_SOURCE_DIR}\/" "" header "${header}")
file(APPEND ${header_file} "#include \"${header}\"\n") file(APPEND ${header_file} "#include \"${header}\"\n")
......
...@@ -58,6 +58,6 @@ file( ...@@ -58,6 +58,6 @@ file(
# generate inner headers include dir for users # generate inner headers include dir for users
generate_unify_header(backends) generate_unify_header(backends)
generate_unify_header(core) generate_unify_header(core EXCLUDES cuda_stream.h)
generate_unify_header(infermeta) generate_unify_header(infermeta)
generate_unify_header(kernels SKIP_SUFFIX grad_kernel) generate_unify_header(kernels SKIP_SUFFIX grad_kernel)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册