aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-01-22 04:34:26 +0300
committerZyX <kp-pav@yandex.ru>2017-03-27 00:12:23 +0300
commit6b4a51f7ea49a6ef8305831e8d96b2a7cc4ba5f3 (patch)
tree500ceccf8f07be8a21a00168ce512fcd9802e1cb
parent8fec4d53d0f6db0847050bf2a608141bbd98e768 (diff)
downloadrneovim-6b4a51f7ea49a6ef8305831e8d96b2a7cc4ba5f3.tar.gz
rneovim-6b4a51f7ea49a6ef8305831e8d96b2a7cc4ba5f3.tar.bz2
rneovim-6b4a51f7ea49a6ef8305831e8d96b2a7cc4ba5f3.zip
scripts: Make generate_vim_module more generic
-rw-r--r--scripts/gencharblob.lua (renamed from scripts/generate_vim_module.lua)24
-rw-r--r--src/nvim/CMakeLists.txt8
2 files changed, 21 insertions, 11 deletions
diff --git a/scripts/generate_vim_module.lua b/scripts/gencharblob.lua
index 954f1c38be..d860375e26 100644
--- a/scripts/generate_vim_module.lua
+++ b/scripts/gencharblob.lua
@@ -1,13 +1,23 @@
-assert(#arg == 2)
+if arg[1] == '--help' then
+ print('Usage:')
+ print(' gencharblob.lua source target varname')
+ print('')
+ print('Generates C file with big uint8_t blob.')
+ print('Blob will be stored in a static const array named varname.')
+ os.exit()
+end
+
+assert(#arg == 3)
-module_file = arg[1]
-target_file = arg[2]
+local source_file = arg[1]
+local target_file = arg[2]
+local varname = arg[3]
-module = io.open(module_file, 'r')
+source = io.open(source_file, 'r')
target = io.open(target_file, 'w')
target:write('#include <stdint.h>\n\n')
-target:write('static const uint8_t vim_module[] = {\n')
+target:write(('static const uint8_t %s[] = {\n'):format(varname))
num_bytes = 0
MAX_NUM_BYTES = 15 -- 78 / 5: maximum number of bytes on one line
@@ -21,7 +31,7 @@ increase_num_bytes = function()
end
end
-for line in module:lines() do
+for line in source:lines() do
for i = 1,string.len(line) do
byte = string.byte(line, i)
assert(byte ~= 0)
@@ -34,5 +44,5 @@ end
target:write(' 0};\n')
-module:close()
+source:close()
target:close()
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index 7a7dbbcce6..21a39b950f 100644
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -39,7 +39,7 @@ set(UNICODE_DIR ${PROJECT_SOURCE_DIR}/unicode)
set(GENERATED_UNICODE_TABLES ${GENERATED_DIR}/unicode_tables.generated.h)
set(VIM_MODULE_FILE ${GENERATED_DIR}/viml/executor/vim_module.generated.h)
set(VIM_MODULE_SOURCE ${PROJECT_SOURCE_DIR}/src/nvim/viml/executor/vim.lua)
-set(VIM_MODULE_GENERATOR ${PROJECT_SOURCE_DIR}/scripts/generate_vim_module.lua)
+set(CHAR_BLOB_GENERATOR ${PROJECT_SOURCE_DIR}/scripts/gencharblob.lua)
file(GLOB API_HEADERS api/*.h)
file(GLOB MSGPACK_RPC_HEADERS msgpack_rpc/*.h)
@@ -222,10 +222,10 @@ add_custom_command(
add_custom_command(
OUTPUT ${VIM_MODULE_FILE}
- COMMAND ${LUA_PRG} ${VIM_MODULE_GENERATOR} ${VIM_MODULE_SOURCE}
- ${VIM_MODULE_FILE}
+ COMMAND ${LUA_PRG} ${CHAR_BLOB_GENERATOR} ${VIM_MODULE_SOURCE}
+ ${VIM_MODULE_FILE} vim_module
DEPENDS
- ${VIM_MODULE_GENERATOR}
+ ${CHAR_BLOB_GENERATOR}
${VIM_MODULE_SOURCE}
)