-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
${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})
--- /dev/null
+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()