mirror of
https://github.com/neovim/neovim.git
synced 2025-10-01 07:28:34 +00:00
Refactor declaration generation
- Call compiler from CMake instead of lua script to generate a preprocessor file - allows for better/early error detection if the compiler fails - Preprocessor files are saved along with the headers as .i files - Accept preprocessor lines with trailing chars after # as is the case in Clang/Windows - The fourth argument to gendeclarations.lua is now the path to the proprocessor output file
This commit is contained in:
@@ -109,13 +109,15 @@ if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
endif()
|
||||
|
||||
get_directory_property(gen_cdefs COMPILE_DEFINITIONS)
|
||||
foreach(gen_cdef ${gen_cdefs})
|
||||
set(gen_cflags "${gen_cflags} -D${gen_cdef}")
|
||||
foreach(gen_cdef ${gen_cdefs} DO_NOT_DEFINE_EMPTY_ATTRIBUTES)
|
||||
if(NOT "${gen_cdef}" MATCHES "INCLUDE_GENERATED_DECLARATIONS")
|
||||
list(APPEND gen_cflags "-D${gen_cdef}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
get_directory_property(gen_includes INCLUDE_DIRECTORIES)
|
||||
foreach(gen_include ${gen_includes})
|
||||
set(gen_cflags "${gen_cflags} -I${gen_include}")
|
||||
list(APPEND gen_cflags "-I${gen_include}")
|
||||
endforeach()
|
||||
string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type)
|
||||
set(gen_cflags "${gen_cflags} ${CMAKE_C_FLAGS_${build_type}} ${CMAKE_C_FLAGS}")
|
||||
@@ -132,11 +134,12 @@ foreach(sfile ${NEOVIM_SOURCES}
|
||||
endif()
|
||||
set(gf1 "${GENERATED_DIR}/${r}.c.generated.h")
|
||||
set(gf2 "${GENERATED_INCLUDES_DIR}/${r}.h.generated.h")
|
||||
set(gf3 "${GENERATED_DIR}/${r}.i")
|
||||
separate_arguments(C_FLAGS_ARRAY UNIX_COMMAND ${CMAKE_C_FLAGS})
|
||||
add_custom_command(
|
||||
OUTPUT "${gf1}" "${gf2}"
|
||||
COMMAND "${LUA_PRG}" "${HEADER_GENERATOR}"
|
||||
"${sfile}" "${gf1}" "${gf2}"
|
||||
"${CMAKE_C_COMPILER} ${gen_cflags} -E"
|
||||
COMMAND ${CMAKE_C_COMPILER} ${sfile} -o ${gf3} ${gen_cflags} -E ${C_FLAGS_ARRAY}
|
||||
COMMAND "${LUA_PRG}" "${HEADER_GENERATOR}" "${sfile}" "${gf1}" "${gf2}" "${gf3}"
|
||||
DEPENDS "${HEADER_GENERATOR}" "${sfile}"
|
||||
)
|
||||
list(APPEND NEOVIM_GENERATED_SOURCES "${gf1}")
|
||||
|
Reference in New Issue
Block a user