diff options
author | Rui Abreu Ferreira <raf-ep@gmx.com> | 2014-06-20 23:38:19 +0100 |
---|---|---|
committer | Rui Abreu Ferreira <raf-ep@gmx.com> | 2014-11-29 23:39:52 +0000 |
commit | 05d72e98265b260f645835701a0183596b674c97 (patch) | |
tree | 98523b677a53cc20fd232f34299c3645ce1d9636 /scripts/gendeclarations.lua | |
parent | 75524dbf9ac0013305fa4357066c36f41784a87c (diff) | |
download | rneovim-05d72e98265b260f645835701a0183596b674c97.tar.gz rneovim-05d72e98265b260f645835701a0183596b674c97.tar.bz2 rneovim-05d72e98265b260f645835701a0183596b674c97.zip |
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
Diffstat (limited to 'scripts/gendeclarations.lua')
-rwxr-xr-x | scripts/gendeclarations.lua | 16 |
1 files changed, 7 insertions, 9 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 |