From: Vsevolod Stakhov Date: Tue, 15 Dec 2015 00:19:56 +0000 (+0000) Subject: Add lua preprocessing code X-Git-Tag: 1.1.0~299 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=72bdfc30aaf95f5c686bce08623938fd6338367b;p=rspamd.git Add lua preprocessing code --- diff --git a/src/rspamadm/CMakeLists.txt b/src/rspamadm/CMakeLists.txt index 44da69156..80a253c20 100644 --- a/src/rspamadm/CMakeLists.txt +++ b/src/rspamadm/CMakeLists.txt @@ -1,4 +1,11 @@ -SET(RSPAMADMSRC rspamadm.c commands.c pw.c keypair.c configtest.c +SET(RSPAMADMSRC rspamadm.c + commands.c + pw.c + keypair.c + configtest.c + fuzzy_merge.c + configdump.c + control.c ${CMAKE_BINARY_DIR}/src/workers.c ${CMAKE_BINARY_DIR}/src/modules.c ${CMAKE_SOURCE_DIR}/src/controller.c @@ -6,11 +13,18 @@ SET(RSPAMADMSRC rspamadm.c commands.c pw.c keypair.c configtest.c ${CMAKE_SOURCE_DIR}/src/lua_worker.c ${CMAKE_SOURCE_DIR}/src/smtp_proxy.c ${CMAKE_SOURCE_DIR}/src/worker.c - ${CMAKE_SOURCE_DIR}/src/http_proxy.c fuzzy_merge.c configdump.c control.c) + ${CMAKE_SOURCE_DIR}/src/http_proxy.c) +SET(RSPAMADMLUASRC ${CMAKE_CURRENT_SOURCE_DIR}/fuzzy_stat.lua) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) +ADD_CUSTOM_TARGET(rspamadm_lua_preprocess + ${CMAKE_COMMAND} -DRSPAMADMLUASRC=${RSPAMADMLUASRC} + -P ${CMAKE_CURRENT_SOURCE_DIR}/lua_preprocess.cmake + SOURCES ${RSPAMADMLUASRC}) IF (ENABLE_HYPERSCAN MATCHES "ON") LIST(APPEND RSPAMADMSRC "${CMAKE_SOURCE_DIR}/src/hs_helper.c") ENDIF() ADD_EXECUTABLE(rspamadm ${RSPAMADMSRC}) +ADD_DEPENDENCIES(rspamadm rspamadm_lua_preprocess) TARGET_LINK_LIBRARIES(rspamadm rspamd-server) TARGET_LINK_LIBRARIES(rspamadm ${RSPAMD_REQUIRED_LIBRARIES}) diff --git a/src/rspamadm/lua_preprocess.cmake b/src/rspamadm/lua_preprocess.cmake new file mode 100644 index 000000000..13a23487a --- /dev/null +++ b/src/rspamadm/lua_preprocess.cmake @@ -0,0 +1,22 @@ +FOREACH(_LUA_SRC ${RSPAMADMLUASRC}) + GET_FILENAME_COMPONENT(_LUA_BASE ${_LUA_SRC} NAME_WE) + FILE(READ ${_LUA_SRC} _FILE_DATA) + STRING(REPLACE \" \\\" _OUT1 ${_FILE_DATA}) + # Convert into cmake list + STRING(REGEX REPLACE ";" "\\\\;" _OUT2 "${_OUT1}") + STRING(REPLACE "\n" ";" _OUT3 "${_OUT2}") + FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_LUA_BASE}.lua.h" " +#ifndef ${_LUA_BASE}_H +#define ${_LUA_BASE}_H + +static const char rspamadm_script_${_LUA_BASE}[] = \"\" +") + FOREACH(_LINE ${_OUT3}) + STRING(REGEX REPLACE "^(.+)$" "\"\\1\\\\n\"\n" _OUT4 "${_LINE}") + FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/${_LUA_BASE}.lua.h" ${_OUT4}) + ENDFOREACH() + + FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/${_LUA_BASE}.lua.h" "\"\"; +#endif +") +ENDFOREACH()