Skip to content

Commit 5fd07ec

Browse files
committed
cmake: initial version of luzer module
The patch add a CMake module that builds a luzer [1], a coverage-guided, native Lua fuzzing engine. Needed for the following commit. 1. https://github.com/ligurio/luzer
1 parent 23204ab commit 5fd07ec

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

cmake/BuildLuzer.cmake

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
set(LUZER_DIR ${PROJECT_BINARY_DIR}/luzer)
2+
set(LUZER_BUILD_DIR ${LUZER_DIR}/build)
3+
set(LUZER_LIBRARY_PATH ${LUZER_BUILD_DIR}/luzer)
4+
list(APPEND LUZER_LIBRARIES
5+
${LUZER_LIBRARY_PATH}/luzer/luzer.so
6+
${LUZER_LIBRARY_PATH}/luzer/libcustom_mutator.so
7+
)
8+
9+
include(ExternalProject)
10+
11+
get_target_property(LUA_LIBRARIES_LOCATION ${LUA_LIBRARIES} LOCATION)
12+
13+
list(APPEND LUZER_CMAKE_FLAGS
14+
"-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}"
15+
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
16+
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
17+
"-DLUA_INCLUDE_DIR=${LUA_INCLUDE_DIR}"
18+
"-DLUA_LIBRARIES=${LUA_LIBRARIES_LOCATION}"
19+
)
20+
if(USE_LUAJIT)
21+
list(APPEND LUZER_CMAKE_FLAGS
22+
"-DLUAJIT_FRIENDLY_MODE=ON"
23+
"-DLUA_HAS_JIT=ON"
24+
)
25+
endif()
26+
27+
ExternalProject_Add(bundled-luzer
28+
GIT_REPOSITORY https://github.com/ligurio/luzer
29+
GIT_TAG 82d41c5f350296ca351e785a24c914165a0e8033
30+
GIT_PROGRESS TRUE
31+
GIT_SHALLOW FALSE
32+
SOURCE_DIR ${LUZER_DIR}/source
33+
BINARY_DIR ${LUZER_BUILD_DIR}
34+
TMP_DIR ${LUZER_DIR}/tmp
35+
STAMP_DIR ${LUZER_DIR}/stamp
36+
CONFIGURE_COMMAND
37+
${CMAKE_COMMAND} -B <BINARY_DIR> -S <SOURCE_DIR>
38+
-G ${CMAKE_GENERATOR} ${LUZER_CMAKE_FLAGS}
39+
BUILD_COMMAND cd <BINARY_DIR> && ${CMAKE_MAKE_PROGRAM}
40+
INSTALL_COMMAND ""
41+
CMAKE_GENERATOR ${CMAKE_GENERATOR}
42+
BUILD_BYPRODUCTS ${LUZER_LIBRARIES}
43+
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
44+
)
45+
46+
add_library(luzer-library STATIC IMPORTED GLOBAL)
47+
set_target_properties(luzer-library PROPERTIES
48+
IMPORTED_LOCATION "${LUZER_LIBRARIES}")
49+
add_dependencies(luzer-library bundled-luzer)
50+
add_dependencies(bundled-luzer bundled-liblua)
51+
52+
set(LUZER_LUA_PATH ${LUZER_DIR}/source/?/init.lua)
53+
set(LUZER_LUA_PATH ${LUZER_LUA_PATH} PARENT_SCOPE)
54+
55+
set(LUZER_LUA_CPATH ${LUZER_LIBRARY_PATH}/?${CMAKE_SHARED_LIBRARY_SUFFIX})
56+
set(LUZER_LUA_CPATH ${LUZER_LUA_CPATH} PARENT_SCOPE)
57+
58+
set(LUZER_LIBRARY luzer-library PARENT_SCOPE)
59+
60+
unset(LUZER_DIR)
61+
unset(LUZER_BUILD_DIR)

0 commit comments

Comments
 (0)