Skip to content

Commit ad673a3

Browse files
committed
add cmake build
1 parent 8bf5ded commit ad673a3

File tree

11 files changed

+237
-0
lines changed

11 files changed

+237
-0
lines changed

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
cmake_minimum_required(VERSION 3.14.2)
2+
3+
project(make_ext4fs_tools)
4+
5+
set(SRC ${CMAKE_SOURCE_DIR}/src)
6+
set(BIN ${CMAKE_SOURCE_DIR}/bin)
7+
8+
set(common_include
9+
${SRC}/core/include
10+
${SRC}/core/libsparse
11+
${SRC}/core/libsparse/include
12+
${SRC}/libselinux/include
13+
)
14+
15+
add_subdirectory(cmake)

cmake/CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
cmake_minimum_required(VERSION 3.14.2)
2+
3+
project(cmake)
4+
5+
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
6+
7+
set(GLOBAL_C_FLAGS " \
8+
-fPIC \
9+
-Wall \
10+
-Wno-unused \
11+
-Wno-unused-parameter \
12+
-fcolor-diagnostics \
13+
")
14+
15+
add_subdirectory(lib)
16+
17+
add_subdirectory(make_ext4fs_tools)
18+

cmake/lib/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cmake_minimum_required(VERSION 3.14.2)
2+
3+
project(lib)
4+
5+
add_subdirectory(libselinux)
6+
add_subdirectory(libsparse)
7+
add_subdirectory(libzlib)
8+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
cmake_minimum_required(VERSION 3.14.2)
2+
3+
project(libselinux)
4+
5+
set(LIBSELINUX ${SRC}/libselinux/src)
6+
7+
set(LIBSELINUX_SRC_FILES
8+
${LIBSELINUX}/callbacks.c
9+
${LIBSELINUX}/check_context.c
10+
${LIBSELINUX}/freecon.c
11+
${LIBSELINUX}/init.c
12+
${LIBSELINUX}/label.c
13+
${LIBSELINUX}/label_android_property.c
14+
${LIBSELINUX}/label_file.c
15+
)
16+
17+
set(CMAKE_C_FLAGS " \
18+
-std=gnu89 -DBUILD_HOST \
19+
")
20+
21+
include_directories(
22+
${common_include}
23+
)
24+
25+
add_library(selinux STATIC ${LIBSELINUX_SRC_FILES})
26+
target_link_libraries(selinux)

cmake/lib/libsparse/CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
cmake_minimum_required(VERSION 3.14.2)
2+
3+
project(libsparse)
4+
5+
set(LIBSPARSE ${SRC}/core/libsparse)
6+
7+
set(LIBSPARSE_SRC_FILES
8+
${LIBSPARSE}/backed_block.c
9+
${LIBSPARSE}/img2simg.c
10+
${LIBSPARSE}/output_file.c
11+
${LIBSPARSE}/simg2img.c
12+
${LIBSPARSE}/simg2simg.c
13+
${LIBSPARSE}/sparse.c
14+
${LIBSPARSE}/sparse_crc32.c
15+
${LIBSPARSE}/sparse_err.c
16+
${LIBSPARSE}/sparse_read.c
17+
)
18+
19+
include_directories(
20+
${common_include}
21+
)
22+
23+
add_library(sparse STATIC ${LIBSPARSE_SRC_FILES})
24+
target_link_libraries(sparse)

cmake/lib/libzlib/CMakeLists.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
cmake_minimum_required(VERSION 3.14.2)
2+
3+
project(libzlib)
4+
5+
set(LIBZLIB ${SRC}/zlib/src)
6+
7+
set(LIBZLIB_SRC_FILES
8+
${LIBZLIB}/adler32.c
9+
${LIBZLIB}/compress.c
10+
${LIBZLIB}/crc32.c
11+
${LIBZLIB}/deflate.c
12+
${LIBZLIB}/gzclose.c
13+
${LIBZLIB}/gzlib.c
14+
${LIBZLIB}/gzread.c
15+
${LIBZLIB}/gzwrite.c
16+
${LIBZLIB}/infback.c
17+
${LIBZLIB}/inffast.c
18+
${LIBZLIB}/inflate.c
19+
${LIBZLIB}/inftrees.c
20+
${LIBZLIB}/trees.c
21+
${LIBZLIB}/uncompr.c
22+
${LIBZLIB}/zutil.c
23+
)
24+
25+
set(CMAKE_C_FLAGS " \
26+
-DUSE_MMAP \
27+
-D_FILE_OFFSET_BITS=64 \
28+
-D_LARGEFILE64_SOURCE=1 \
29+
-DZLIB_CONST \
30+
")
31+
32+
include_directories(
33+
${common_include}
34+
)
35+
36+
add_library(zlib STATIC ${LIBZLIB_SRC_FILES})
37+
target_link_libraries(zlib)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cmake_minimum_required(VERSION 3.14.2)
2+
3+
project(make_ext4fs_tools)
4+
5+
add_subdirectory(make_ext4fs)
6+
add_subdirectory(img2simg)
7+
add_subdirectory(simg2img)
8+
add_subdirectory(sefcontext_decompile)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
cmake_minimum_required(VERSION 3.14.2)
2+
3+
project(img2simg)
4+
5+
set(IMG2SIMG ${SRC}/core/libsparse)
6+
7+
set(IMG2SIMG_SRC_FILES
8+
${IMG2SIMG}/img2simg.c
9+
)
10+
11+
include_directories(
12+
${common_include}
13+
)
14+
15+
add_executable(img2simg ${IMG2SIMG_SRC_FILES})
16+
target_link_libraries(img2simg
17+
sparse
18+
zlib)
19+
20+
install(TARGETS img2simg DESTINATION ${BIN})
21+
22+
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
cmake_minimum_required(VERSION 3.14.2)
2+
3+
project(make_ext4fs)
4+
5+
set(MAKE_EXT4FS ${SRC}/extras/ext4_utils)
6+
7+
set(MAKE_EXT4FS_SRC_FILES
8+
${MAKE_EXT4FS}/allocate.c
9+
${MAKE_EXT4FS}/canned_fs_config.c
10+
${MAKE_EXT4FS}/contents.c
11+
${MAKE_EXT4FS}/crc16.c
12+
${MAKE_EXT4FS}/ext4_sb.c
13+
${MAKE_EXT4FS}/ext4_utils.c
14+
${MAKE_EXT4FS}/ext4fixup.c
15+
${MAKE_EXT4FS}/extent.c
16+
${MAKE_EXT4FS}/indirect.c
17+
${MAKE_EXT4FS}/make_ext4fs.c
18+
${MAKE_EXT4FS}/make_ext4fs_main.c
19+
${MAKE_EXT4FS}/sha1.c
20+
${MAKE_EXT4FS}/uuid.c
21+
${MAKE_EXT4FS}/wipe.c
22+
)
23+
24+
set(CMAKE_C_FLAGS " \
25+
-D_GNU_SOURCE \
26+
-DANDROID \
27+
-DHOST \
28+
")
29+
30+
include_directories(
31+
${common_include}
32+
${MAKE_EXT4FS_SRC_FILES}
33+
)
34+
35+
add_executable(make_ext4fs ${MAKE_EXT4FS_SRC_FILES})
36+
target_link_libraries(make_ext4fs
37+
selinux
38+
sparse
39+
zlib)
40+
41+
install(TARGETS make_ext4fs DESTINATION ${BIN})
42+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
cmake_minimum_required(VERSION 3.14.2)
2+
3+
project(sefcontext_decompile)
4+
5+
set(SEFCONTEXT_DECOMPILE ${SRC}/sefcontext_decompile)
6+
7+
set(SEFCONTEXT_DECOMPILE_SRC_FILES
8+
${SEFCONTEXT_DECOMPILE}/sefcontext_decompile.cpp
9+
)
10+
11+
add_executable(sefcontext_decompile ${SEFCONTEXT_DECOMPILE_SRC_FILES})
12+
target_link_libraries(sefcontext_decompile)
13+
14+
install(TARGETS sefcontext_decompile DESTINATION ${BIN})
15+

0 commit comments

Comments
 (0)