remove windows CR from LF's from several files
This commit is contained in:
parent
a773c947d7
commit
e83b57b10a
4 changed files with 133 additions and 133 deletions
|
@ -1,28 +1,28 @@
|
|||
include("${CMAKE_SOURCE_DIR}/config/scripts_to_embed.cmake")
|
||||
|
||||
set(SCRIPT_SOURCES_C)
|
||||
|
||||
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/generated)
|
||||
|
||||
foreach(script_source ${SCRIPT_SOURCES})
|
||||
get_filename_component(GEN_BASE_NAME ${script_source} NAME_WLE)
|
||||
set(file_c "script_${GEN_BASE_NAME}.c")
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_BINARY_DIR}/generated/${file_c}
|
||||
COMMAND ${LUA_BINARY} ${CMAKE_SOURCE_DIR}/src/lua2c.lua ${script_source} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR}/generated
|
||||
VERBATIM
|
||||
COMMENT "Generating: ${CMAKE_BINARY_DIR}/generated/${file_c}"
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${script_source}
|
||||
)
|
||||
list(APPEND SCRIPT_BASE_NAMES ${GEN_BASE_NAME})
|
||||
list(APPEND SCRIPT_SOURCES_C ${CMAKE_BINARY_DIR}/generated/${file_c})
|
||||
endforeach()
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_BINARY_DIR}/generated/generated_scripts.c
|
||||
COMMAND ${LUA_BINARY} ${CMAKE_SOURCE_DIR}/src/embedded_generate.lua ${CMAKE_BINARY_DIR}/generated ${SCRIPT_BASE_NAMES}
|
||||
COMMENT "Generating: ${CMAKE_BINARY_DIR}/generated/generated_scripts.c"
|
||||
DEPENDS ${SCRIPT_SOURCES_C} ${CMAKE_SOURCE_DIR}/src/embedded_generate.lua
|
||||
)
|
||||
|
||||
add_custom_target(generate_scripts DEPENDS ${CMAKE_BINARY_DIR}/generated/generated_scripts.c)
|
||||
include("${CMAKE_SOURCE_DIR}/config/scripts_to_embed.cmake")
|
||||
|
||||
set(SCRIPT_SOURCES_C)
|
||||
|
||||
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/generated)
|
||||
|
||||
foreach(script_source ${SCRIPT_SOURCES})
|
||||
get_filename_component(GEN_BASE_NAME ${script_source} NAME_WLE)
|
||||
set(file_c "script_${GEN_BASE_NAME}.c")
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_BINARY_DIR}/generated/${file_c}
|
||||
COMMAND ${LUA_BINARY} ${CMAKE_SOURCE_DIR}/src/lua2c.lua ${script_source} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR}/generated
|
||||
VERBATIM
|
||||
COMMENT "Generating: ${CMAKE_BINARY_DIR}/generated/${file_c}"
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${script_source}
|
||||
)
|
||||
list(APPEND SCRIPT_BASE_NAMES ${GEN_BASE_NAME})
|
||||
list(APPEND SCRIPT_SOURCES_C ${CMAKE_BINARY_DIR}/generated/${file_c})
|
||||
endforeach()
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_BINARY_DIR}/generated/generated_scripts.c
|
||||
COMMAND ${LUA_BINARY} ${CMAKE_SOURCE_DIR}/src/embedded_generate.lua ${CMAKE_BINARY_DIR}/generated ${SCRIPT_BASE_NAMES}
|
||||
COMMENT "Generating: ${CMAKE_BINARY_DIR}/generated/generated_scripts.c"
|
||||
DEPENDS ${SCRIPT_SOURCES_C} ${CMAKE_SOURCE_DIR}/src/embedded_generate.lua
|
||||
)
|
||||
|
||||
add_custom_target(generate_scripts DEPENDS ${CMAKE_BINARY_DIR}/generated/generated_scripts.c)
|
||||
|
|
|
@ -1,38 +1,38 @@
|
|||
include_directories(BEFORE ${LUA_INCLUDE})
|
||||
# Required for ${CMAKE_BINARY_DIR}/generated/generated_scripts.c to find generated_scripts.h
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
include_directories(${CMAKE_BINARY_DIR}/generated)
|
||||
|
||||
if(LUA_TARGET_VERSION EQUAL 504)
|
||||
set(LESI_INTERPRETER_SRC lua54.c)
|
||||
elseif(LUA_TARGET_VERSION EQUAL 503)
|
||||
set(LESI_INTERPRETER_SRC lua53.c)
|
||||
elseif(LUA_TARGET_VERSION EQUAL 502)
|
||||
set(LESI_INTERPRETER_SRC lua52.c)
|
||||
elseif(LUA_TARGET_VERSION EQUAL 501)
|
||||
set(LESI_INTERPRETER_SRC lua51.c)
|
||||
else()
|
||||
error("Unknown LUA_TARGET_VERSION: ${LUA_TARGET_VERSION}")
|
||||
endif()
|
||||
|
||||
set(PLATFORM_LIBS)
|
||||
|
||||
set(SRC embedded_script.c ${LESI_INTERPRETER_SRC} ${CMAKE_BINARY_DIR}/generated/generated_scripts.c ${CMAKE_BINARY_DIR}/generated/generated_modules.c)
|
||||
if (WIN32)
|
||||
list(APPEND SRC iscygpty.c)
|
||||
endif()
|
||||
|
||||
add_executable(lesi ${SRC})
|
||||
if (WIN32)
|
||||
set(PLATFORM_LIBS "")
|
||||
add_executable(wlesi wmain.c ${SRC})
|
||||
set_target_properties(wlesi PROPERTIES WIN32_EXECUTABLE $<CONFIG:Release>)
|
||||
set_target_properties(wlesi PROPERTIES WIN32_EXECUTABLE $<CONFIG:Debug>)
|
||||
add_dependencies(wlesi generate_scripts)
|
||||
target_link_libraries(wlesi ${LUA_LIBRARY} ${EMBEDDED_CMODULE_LIST})
|
||||
install(TARGETS wlesi RUNTIME DESTINATION ${CMAKE_BINARY_DIR} LIBRARY DESTINATION ${CMAKE_BINARY_DIR})
|
||||
else()
|
||||
set(PLATFORM_LIBS m dl)
|
||||
endif()
|
||||
add_dependencies(lesi generate_scripts generate_modules)
|
||||
target_link_libraries(lesi ${LUA_LIBRARY} ${EMBEDDED_CMODULE_LIST} ${PLATFORM_LIBS})
|
||||
include_directories(BEFORE ${LUA_INCLUDE})
|
||||
# Required for ${CMAKE_BINARY_DIR}/generated/generated_scripts.c to find generated_scripts.h
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
include_directories(${CMAKE_BINARY_DIR}/generated)
|
||||
|
||||
if(LUA_TARGET_VERSION EQUAL 504)
|
||||
set(LESI_INTERPRETER_SRC lua54.c)
|
||||
elseif(LUA_TARGET_VERSION EQUAL 503)
|
||||
set(LESI_INTERPRETER_SRC lua53.c)
|
||||
elseif(LUA_TARGET_VERSION EQUAL 502)
|
||||
set(LESI_INTERPRETER_SRC lua52.c)
|
||||
elseif(LUA_TARGET_VERSION EQUAL 501)
|
||||
set(LESI_INTERPRETER_SRC lua51.c)
|
||||
else()
|
||||
error("Unknown LUA_TARGET_VERSION: ${LUA_TARGET_VERSION}")
|
||||
endif()
|
||||
|
||||
set(PLATFORM_LIBS)
|
||||
|
||||
set(SRC embedded_script.c ${LESI_INTERPRETER_SRC} ${CMAKE_BINARY_DIR}/generated/generated_scripts.c ${CMAKE_BINARY_DIR}/generated/generated_modules.c)
|
||||
if (WIN32)
|
||||
list(APPEND SRC iscygpty.c)
|
||||
endif()
|
||||
|
||||
add_executable(lesi ${SRC})
|
||||
if (WIN32)
|
||||
set(PLATFORM_LIBS "")
|
||||
add_executable(wlesi wmain.c ${SRC})
|
||||
set_target_properties(wlesi PROPERTIES WIN32_EXECUTABLE $<CONFIG:Release>)
|
||||
set_target_properties(wlesi PROPERTIES WIN32_EXECUTABLE $<CONFIG:Debug>)
|
||||
add_dependencies(wlesi generate_scripts)
|
||||
target_link_libraries(wlesi ${LUA_LIBRARY} ${EMBEDDED_CMODULE_LIST})
|
||||
install(TARGETS wlesi RUNTIME DESTINATION ${CMAKE_BINARY_DIR} LIBRARY DESTINATION ${CMAKE_BINARY_DIR})
|
||||
else()
|
||||
set(PLATFORM_LIBS m dl)
|
||||
endif()
|
||||
add_dependencies(lesi generate_scripts generate_modules)
|
||||
target_link_libraries(lesi ${LUA_LIBRARY} ${EMBEDDED_CMODULE_LIST} ${PLATFORM_LIBS})
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
#ifndef GENERATED_SCRIPTS_H
|
||||
#define GENERATED_SCRIPTS_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
struct generated_script
|
||||
{
|
||||
const char *name;
|
||||
const char *data;
|
||||
const size_t data_size;
|
||||
};
|
||||
|
||||
extern const char script_main[];
|
||||
extern const size_t script_main_size;
|
||||
|
||||
extern struct generated_script generated_scripts[];
|
||||
|
||||
#endif // GENERATED_SCRIPTS_H
|
||||
#ifndef GENERATED_SCRIPTS_H
|
||||
#define GENERATED_SCRIPTS_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
struct generated_script
|
||||
{
|
||||
const char *name;
|
||||
const char *data;
|
||||
const size_t data_size;
|
||||
};
|
||||
|
||||
extern const char script_main[];
|
||||
extern const size_t script_main_size;
|
||||
|
||||
extern struct generated_script generated_scripts[];
|
||||
|
||||
#endif // GENERATED_SCRIPTS_H
|
||||
|
|
|
@ -1,49 +1,49 @@
|
|||
function lua2c(base_name, destination_file, file_contents)
|
||||
local result
|
||||
local fd = io.open(destination_file, "w")
|
||||
if fd then
|
||||
fd:write(string.format("#define SCRIPT_%s_SZ %u\n", base_name:upper(), #file_contents))
|
||||
fd:write(string.format("const size_t script_%s_size = %u;\n", base_name, #file_contents))
|
||||
fd:write(string.format("const char script_%s[%u] = {\n", base_name, #file_contents))
|
||||
fd:write("\t")
|
||||
|
||||
for i = 1, #file_contents do
|
||||
fd:write(string.format("0x%02x", string.byte(file_contents, i)))
|
||||
if i ~= #file_contents then fd:write(", ") end
|
||||
if math.fmod(i, 16) == 0 then fd:write("\n\t") end
|
||||
end
|
||||
|
||||
fd:write("\n};")
|
||||
fd:close()
|
||||
result = true
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
function get_file_contents(filename)
|
||||
local file_contents
|
||||
|
||||
local fd = io.open(filename, "r")
|
||||
if fd then
|
||||
file_contents = fd:read("*a")
|
||||
fd:close()
|
||||
end
|
||||
|
||||
return file_contents
|
||||
end
|
||||
|
||||
function main(filename, source, destination)
|
||||
local exit_code = 1
|
||||
|
||||
local base_name = filename:gsub("%.lua$", "")
|
||||
local destination_file = string.format("%s/script_%s.c", destination, base_name)
|
||||
local file_contents = get_file_contents(string.format("%s/%s", source, filename))
|
||||
|
||||
if file_contents and lua2c(base_name, destination_file, file_contents) then
|
||||
exit_code = 0
|
||||
end
|
||||
end
|
||||
|
||||
local filename, source, destination = assert(select(1, ...))
|
||||
os.exit(main(filename, source, destination))
|
||||
function lua2c(base_name, destination_file, file_contents)
|
||||
local result
|
||||
local fd = io.open(destination_file, "w")
|
||||
if fd then
|
||||
fd:write(string.format("#define SCRIPT_%s_SZ %u\n", base_name:upper(), #file_contents))
|
||||
fd:write(string.format("const size_t script_%s_size = %u;\n", base_name, #file_contents))
|
||||
fd:write(string.format("const char script_%s[%u] = {\n", base_name, #file_contents))
|
||||
fd:write("\t")
|
||||
|
||||
for i = 1, #file_contents do
|
||||
fd:write(string.format("0x%02x", string.byte(file_contents, i)))
|
||||
if i ~= #file_contents then fd:write(", ") end
|
||||
if math.fmod(i, 16) == 0 then fd:write("\n\t") end
|
||||
end
|
||||
|
||||
fd:write("\n};")
|
||||
fd:close()
|
||||
result = true
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
function get_file_contents(filename)
|
||||
local file_contents
|
||||
|
||||
local fd = io.open(filename, "r")
|
||||
if fd then
|
||||
file_contents = fd:read("*a")
|
||||
fd:close()
|
||||
end
|
||||
|
||||
return file_contents
|
||||
end
|
||||
|
||||
function main(filename, source, destination)
|
||||
local exit_code = 1
|
||||
|
||||
local base_name = filename:gsub("%.lua$", "")
|
||||
local destination_file = string.format("%s/script_%s.c", destination, base_name)
|
||||
local file_contents = get_file_contents(string.format("%s/%s", source, filename))
|
||||
|
||||
if file_contents and lua2c(base_name, destination_file, file_contents) then
|
||||
exit_code = 0
|
||||
end
|
||||
end
|
||||
|
||||
local filename, source, destination = assert(select(1, ...))
|
||||
os.exit(main(filename, source, destination))
|
||||
|
|
Loading…
Reference in a new issue