aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/gendeclarations.lua16
-rw-r--r--src/nvim/CMakeLists.txt15
2 files changed, 16 insertions, 15 deletions
diff --git a/scripts/gendeclarations.lua b/scripts/gendeclarations.lua
index bc55b48a0a..9398bbb31c 100755
--- a/scripts/gendeclarations.lua
+++ b/scripts/gendeclarations.lua
@@ -3,9 +3,8 @@
local fname = arg[1]
local static_fname = arg[2]
local non_static_fname = arg[3]
-local cpp = arg[4]
+local preproc_fname = arg[4]
-cpp = cpp:gsub(' %-DINCLUDE_GENERATED_DECLARATIONS ', ' ')
local lpeg = require('lpeg')
@@ -156,15 +155,14 @@ local pattern = concat(
if fname == '--help' then
print'Usage:'
print()
- print' gendeclarations.lua definitions.c static.h non-static.h "cc -E …"'
+ print' gendeclarations.lua definitions.c static.h non-static.h preprocessor.i'
os.exit()
end
-local pipe = io.popen(cpp .. ' -DDO_NOT_DEFINE_EMPTY_ATTRIBUTES ' .. fname, 'r')
-local text = pipe:read('*a')
-if not pipe:close() then
- os.exit(2)
-end
+local preproc_f = io.open(preproc_fname)
+local text = preproc_f:read("*all")
+preproc_f:close()
+
local header = [[
#ifndef DEFINE_FUNC_ATTRIBUTES
@@ -181,7 +179,7 @@ local footer = [[
local non_static = header
local static = header
-local filepattern = '^# %d+ "[^"]-/?([^"/]+)"'
+local filepattern = '^#%a* %d+ "[^"]-/?([^"/]+)"'
local curfile
init = 0
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index 3b05c7329c..69b7440da2 100644
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -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}")