diff --git a/.gitignore b/.gitignore index af87e4ac..89950c3c 100644 --- a/.gitignore +++ b/.gitignore @@ -31,4 +31,5 @@ stamp-h1 *.bak CMakeCache.txt CMakeFiles -cmake_install.cmake \ No newline at end of file +cmake_install.cmake +out/ diff --git a/.gitmodules b/.gitmodules index cda52a30..3e111c55 100644 --- a/.gitmodules +++ b/.gitmodules @@ -18,4 +18,4 @@ url = https://android.googlesource.com/platform/system/core.git [submodule "src/selinux"] path = src/selinux - url = https://github.com/SELinuxProject/selinux + url = https://android.googlesource.com/platform/external/selinux diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 036df880..00000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -cmake_minimum_required(VERSION 3.14.2) -project(erofs-utils) - -set(CMAKE_CXX_STANDARD 17) -# set global cflags and cxxflags -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -Wno-ignored-qualifiers -Wno-pointer-arith -Wno-unused-parameter -Wno-unused-function -DHAVE_FALLOCATE -DHAVE_LINUX_TYPES_H -DHAVE_LIBSELINUX -DHAVE_LIBUUID -DLZ4_ENABLED -DLZ4HC_ENABLED -DWITH_ANDROID ") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-ignored-qualifiers -Wno-pointer-arith -Wno-unused-parameter -Wno-unused-function -DHAVE_FALLOCATE -DHAVE_LINUX_TYPES_H -DHAVE_LIBSELINUX -DHAVE_LIBUUID -DLZ4_ENABLED -DLZ4HC_ENABLED -DWITH_ANDROID") - -set(CMAKE_EXE_LINKER_FLAGS "-static") - -set(SRC ${PROJECT_SOURCE_DIR}/src) - -# git clone submodule -execute_process(COMMAND git submodule init) -execute_process(COMMAND git submodule update) - -# thrid part library -add_subdirectory(src/lz4/build/cmake) - -# start building -add_subdirectory(src) -add_subdirectory(erofs-tools) - diff --git a/build/cmake/CMakeLists.txt b/build/cmake/CMakeLists.txt new file mode 100644 index 00000000..64c7f342 --- /dev/null +++ b/build/cmake/CMakeLists.txt @@ -0,0 +1,45 @@ +cmake_minimum_required(VERSION 3.20) +project(erofs-utils) + +set(CMAKE_C_STANDARD 11) +set(CMAKE_CXX_STANDARD 20) + +if(DEFINED EROFS_C_FLAGS) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EROFS_C_FLAGS}") +endif() + +if(DEFINED EROFS_CXX_FLAGS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EROFS_CXX_FLAGS}") +endif() + +if (DEFINED EROFS_LINKER_FLAGS) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EROFS_LINKER_FLAGS}") +else () + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -static -s") +endif() + +set(MODULES_SRC "${PROJECT_SOURCE_DIR}/../../src") +set(PROJECT_SOURCE_DIR "${PROJECT_SOURCE_DIR}/../..") + +# git clone submodule +execute_process(COMMAND git submodule init) +execute_process(COMMAND git submodule update) + +# thrid part library +add_subdirectory("${MODULES_SRC}/lz4/build/cmake" "modules/lz4") + +# header +include_directories( + "${PROJECT_SOURCE_DIR}/lib" + "${PROJECT_SOURCE_DIR}/include" + "${PROJECT_SOURCE_DIR}/src/lz4/lib" + "${MODULES_SRC}/core/libcutils/include" + "${MODULES_SRC}/e2fsprogs/lib" + "${MODULES_SRC}/e2fsprogs/lib/uuid" + "${MODULES_SRC}/selinux/libselinux/include" + "${MODULES_SRC}/logging/liblog/include" +) + +# start building +add_subdirectory(modules) +add_subdirectory(erofs-tools) diff --git a/erofs-tools/CMakeLists.txt b/build/cmake/erofs-tools/CMakeLists.txt similarity index 100% rename from erofs-tools/CMakeLists.txt rename to build/cmake/erofs-tools/CMakeLists.txt diff --git a/build/cmake/erofs-tools/dump.cmake b/build/cmake/erofs-tools/dump.cmake new file mode 100644 index 00000000..e84fe32b --- /dev/null +++ b/build/cmake/erofs-tools/dump.cmake @@ -0,0 +1,9 @@ +set(TARGET dump.erofs) + +file(GLOB DUMP_SRCS "${PROJECT_SOURCE_DIR}/dump/*.c") + +add_executable(${TARGET} ${DUMP_SRCS}) + +target_compile_options(${TARGET} PRIVATE ${EROFS_UTILS_DEFAULTS_CFLAGS}) + +target_link_libraries(${TARGET} erofs) diff --git a/build/cmake/erofs-tools/fsck.cmake b/build/cmake/erofs-tools/fsck.cmake new file mode 100644 index 00000000..72cd5f60 --- /dev/null +++ b/build/cmake/erofs-tools/fsck.cmake @@ -0,0 +1,9 @@ +set(TARGET fsck.erofs) + +file(GLOB FSCK_SRCS "${PROJECT_SOURCE_DIR}/fsck/*.c") + +add_executable(${TARGET} ${FSCK_SRCS}) + +target_compile_options(${TARGET} PRIVATE ${EROFS_UTILS_DEFAULTS_CFLAGS}) + +target_link_libraries(${TARGET} erofs) diff --git a/erofs-tools/fuse.cmake b/build/cmake/erofs-tools/fuse.cmake similarity index 100% rename from erofs-tools/fuse.cmake rename to build/cmake/erofs-tools/fuse.cmake diff --git a/build/cmake/erofs-tools/mkfs.cmake b/build/cmake/erofs-tools/mkfs.cmake new file mode 100644 index 00000000..a94a9aa0 --- /dev/null +++ b/build/cmake/erofs-tools/mkfs.cmake @@ -0,0 +1,9 @@ +set(TARGET mkfs.erofs) + +file(GLOB MKFS_SRCS "${PROJECT_SOURCE_DIR}/mkfs/*.c") + +add_executable(${TARGET} ${MKFS_SRCS}) + +target_compile_options(${TARGET} PRIVATE ${EROFS_UTILS_DEFAULTS_CFLAGS}) + +target_link_libraries(${TARGET} erofs) diff --git a/src/CMakeLists.txt b/build/cmake/modules/CMakeLists.txt similarity index 56% rename from src/CMakeLists.txt rename to build/cmake/modules/CMakeLists.txt index edb870f8..c329b0b1 100644 --- a/src/CMakeLists.txt +++ b/build/cmake/modules/CMakeLists.txt @@ -4,4 +4,8 @@ include(liblog.cmake) include(libcutils.cmake) include(libselinux.cmake) include(liberofs.cmake) -include(libpcre.cmake) \ No newline at end of file +include(libpcre2.cmake) + +if (CMAKE_SYSTEM_NAME MATCHES "Android") + include(libpackagelistparser.cmake) +endif() diff --git a/build/cmake/modules/libbase.cmake b/build/cmake/modules/libbase.cmake new file mode 100644 index 00000000..5035e698 --- /dev/null +++ b/build/cmake/modules/libbase.cmake @@ -0,0 +1,48 @@ +set(TARGET base) + +set(TARGET_SRC_DIR "${MODULES_SRC}/libbase") + +set(TARGET_CFLAGS + "-Wall" + "-Werror" + "-Wextra" + "-Wexit-time-destructors" +) + +set(LIBBASE_SRCS + "${TARGET_SRC_DIR}/abi_compatibility.cpp" + "${TARGET_SRC_DIR}/chrono_utils.cpp" + "${TARGET_SRC_DIR}/cmsg.cpp" + "${TARGET_SRC_DIR}/file.cpp" + "${TARGET_SRC_DIR}/hex.cpp" + "${TARGET_SRC_DIR}/logging.cpp" + "${TARGET_SRC_DIR}/mapped_file.cpp" + "${TARGET_SRC_DIR}/parsebool.cpp" + "${TARGET_SRC_DIR}/parsenetaddress.cpp" + "${TARGET_SRC_DIR}/posix_strerror_r.cpp" + "${TARGET_SRC_DIR}/process.cpp" + "${TARGET_SRC_DIR}/properties.cpp" + "${TARGET_SRC_DIR}/stringprintf.cpp" + "${TARGET_SRC_DIR}/strings.cpp" + "${TARGET_SRC_DIR}/threads.cpp" + "${TARGET_SRC_DIR}/test_utils.cpp" +) + +if (CMAKE_SYSTEM_NAME MATCHES "Linux") + list(APPEND LIBBASE_SRCS "${TARGET_SRC_DIR}/errors_unix.cpp" ) +elseif (CMAKE_SYSTEM_NAME MATCHES "Android") + list(APPEND TARGET_CFLAGS + "-D_FILE_OFFSET_BITS=64" + ) +endif() + +add_library(${TARGET} STATIC ${LIBBASE_SRCS}) + +target_include_directories(${TARGET} PRIVATE + "${TARGET_SRC_DIR}/include" + "${MODULES_SRC}/core/include" +) + +target_compile_options(${TARGET} PRIVATE $<$:${TARGET_CFLAGS}> $<$:${TARGET_CPPFLAGS}>) + +target_link_libraries(${TARGET} log) diff --git a/build/cmake/modules/libcutils.cmake b/build/cmake/modules/libcutils.cmake new file mode 100644 index 00000000..02848a1c --- /dev/null +++ b/build/cmake/modules/libcutils.cmake @@ -0,0 +1,87 @@ +set(TARGET cutils) + +set(TARGET_SRC_DIR "${MODULES_SRC}/core/libcutils") + +set(TARGET_CFLAGS + "-Wno-exit-time-destructors" + "-Wall" + "-Wextra" +) + +set(LIBCUTILS_SRCS + "${TARGET_SRC_DIR}/config_utils.cpp" + "${TARGET_SRC_DIR}/iosched_policy.cpp" + "${TARGET_SRC_DIR}/load_file.cpp" + "${TARGET_SRC_DIR}/native_handle.cpp" + "${TARGET_SRC_DIR}/properties.cpp" + "${TARGET_SRC_DIR}/record_stream.cpp" + "${TARGET_SRC_DIR}/strlcpy.c" + "${TARGET_SRC_DIR}/threads.cpp" +) +set(LIBCUTILS_NONWINDOWS_SRCS + "${TARGET_SRC_DIR}/fs.cpp" + "${TARGET_SRC_DIR}/hashmap.cpp" + "${TARGET_SRC_DIR}/multiuser.cpp" + "${TARGET_SRC_DIR}/str_parms.cpp" +) + +set(LIBCUTILS_SOCKET_SRCS + "${TARGET_SRC_DIR}/sockets.cpp" +) +set(LIBCUTILS_SOCKET_NONWINDOWS_SRCS + "${TARGET_SRC_DIR}/socket_inaddr_any_server_unix.cpp" + "${TARGET_SRC_DIR}/socket_local_client_unix.cpp" + "${TARGET_SRC_DIR}/socket_local_server_unix.cpp" + "${TARGET_SRC_DIR}/socket_network_client_unix.cpp" + "${TARGET_SRC_DIR}/sockets_unix.cpp" +) + +if (CMAKE_SYSTEM_NAME MATCHES "Linux") + list(APPEND LIBCUTILS_SRCS + ${LIBCUTILS_SOCKET_SRCS} + ${LIBCUTILS_NONWINDOWS_SRCS} + ${LIBCUTILS_SOCKET_NONWINDOWS_SRCS} + "${TARGET_SRC_DIR}/ashmem-host.cpp" + "${TARGET_SRC_DIR}/canned_fs_config.cpp" + "${TARGET_SRC_DIR}/fs_config.cpp" + "${TARGET_SRC_DIR}/trace-host.cpp" + ) +elseif (CMAKE_SYSTEM_NAME MATCHES "Android") + list(APPEND LIBCUTILS_SOCKET_SRCS + "${TARGET_SRC_DIR}/android_get_control_file.cpp" + "${TARGET_SRC_DIR}/socket_inaddr_any_server_unix.cpp" + "${TARGET_SRC_DIR}/socket_local_client_unix.cpp" + "${TARGET_SRC_DIR}/socket_local_server_unix.cpp" + "${TARGET_SRC_DIR}/socket_network_client_unix.cpp" + "${TARGET_SRC_DIR}/sockets_unix.cpp" + ) + list(APPEND LIBCUTILS_SRCS + ${LIBCUTILS_SOCKET_SRCS} + ${LIBCUTILS_SOCKET_NONWINDOWS_SRCS} + ${LIBCUTILS_NONWINDOWS_SRCS} + "${TARGET_SRC_DIR}/android_reboot.cpp" + "${TARGET_SRC_DIR}/ashmem-dev.cpp" + "${TARGET_SRC_DIR}/canned_fs_config.cpp" + "${TARGET_SRC_DIR}/fs_config.cpp" + "${TARGET_SRC_DIR}/klog.cpp" + "${TARGET_SRC_DIR}/partition_utils.cpp" + "${TARGET_SRC_DIR}/qtaguid.cpp" + "${TARGET_SRC_DIR}/trace-dev.cpp" + "${TARGET_SRC_DIR}/uevent.cpp" + ) +endif() + +add_library(${TARGET} STATIC ${LIBCUTILS_SRCS}) + +target_include_directories(${TARGET} PRIVATE + "${TARGET_SRC_DIR}/include" + "${MODULES_SRC}/core/libutils/include" + "${MODULES_SRC}/libbase/include" +) + +target_compile_options(${TARGET} PRIVATE ${TARGET_CFLAGS}) + +target_link_libraries(${TARGET} + base + log +) diff --git a/build/cmake/modules/liberofs.cmake b/build/cmake/modules/liberofs.cmake new file mode 100644 index 00000000..f694f696 --- /dev/null +++ b/build/cmake/modules/liberofs.cmake @@ -0,0 +1,57 @@ +set(TARGET erofs) + +set(TARGET_SRC_DIR "${PROJECT_SOURCE_DIR}/lib") + +set(EROFS_UTILS_DEFAULTS_CFLAGS + "-Wall" + "-Wno-ignored-qualifiers" + "-Wno-pointer-arith" + "-Wno-unused-parameter" + "-Wno-unused-function" + "-DHAVE_FALLOCATE" + "-DHAVE_LINUX_TYPES_H" + "-DHAVE_LIBSELINUX" + "-DHAVE_LIBUUID" + "-DLZ4_ENABLED" + "-DLZ4HC_ENABLED" + "-DWITH_ANDROID" + "-DHAVE_MEMRCHR" + CACHE INTERNAL "erofs_utils_defaults_cflags" +) + +set(LIBEROFS_SRCS + "${TARGET_SRC_DIR}/config.c" + "${TARGET_SRC_DIR}/io.c" + "${TARGET_SRC_DIR}/cache.c" + "${TARGET_SRC_DIR}/super.c" + "${TARGET_SRC_DIR}/inode.c" + "${TARGET_SRC_DIR}/xattr.c" + "${TARGET_SRC_DIR}/exclude.c" + "${TARGET_SRC_DIR}/namei.c" + "${TARGET_SRC_DIR}/data.c" + "${TARGET_SRC_DIR}/compress.c" + "${TARGET_SRC_DIR}/compressor.c" + "${TARGET_SRC_DIR}/zmap.c" + "${TARGET_SRC_DIR}/decompress.c" + "${TARGET_SRC_DIR}/compress_hints.c" + "${TARGET_SRC_DIR}/hashmap.c" + "${TARGET_SRC_DIR}/sha256.c" + "${TARGET_SRC_DIR}/blobchunk.c" + "${TARGET_SRC_DIR}/dir.c" + "${TARGET_SRC_DIR}/block_list.c" + "${TARGET_SRC_DIR}/compressor_lz4.c" + "${TARGET_SRC_DIR}/compressor_lz4hc.c" +) + +add_library(${TARGET} STATIC ${LIBEROFS_SRCS}) + +target_compile_options(${TARGET} PRIVATE ${EROFS_UTILS_DEFAULTS_CFLAGS}) + +target_link_libraries(${TARGET} + base + cutils + ext2_uuid + log + lz4_static + selinux +) diff --git a/build/cmake/modules/libext2_uuid.cmake b/build/cmake/modules/libext2_uuid.cmake new file mode 100644 index 00000000..dd934780 --- /dev/null +++ b/build/cmake/modules/libext2_uuid.cmake @@ -0,0 +1,25 @@ +set(TARGET ext2_uuid) + +set(TARGET_SRC_DIR "${MODULES_SRC}/e2fsprogs/lib/uuid") + +set(TARGET_CFLAGS + "-Wno-unused-function" + "-Wno-unused-parameter" +) + +set(LIBEXT2_UUID_SRCS + "${TARGET_SRC_DIR}/clear.c" + "${TARGET_SRC_DIR}/compare.c" + "${TARGET_SRC_DIR}/copy.c" + "${TARGET_SRC_DIR}/gen_uuid.c" + "${TARGET_SRC_DIR}/isnull.c" + "${TARGET_SRC_DIR}/pack.c" + "${TARGET_SRC_DIR}/parse.c" + "${TARGET_SRC_DIR}/unpack.c" + "${TARGET_SRC_DIR}/unparse.c" + "${TARGET_SRC_DIR}/uuid_time.c" +) + +add_library(${TARGET} STATIC ${LIBEXT2_UUID_SRCS}) + +target_compile_options(${TARGET} PRIVATE $<$:${TARGET_CFLAGS}>) diff --git a/build/cmake/modules/liblog.cmake b/build/cmake/modules/liblog.cmake new file mode 100644 index 00000000..6b02b452 --- /dev/null +++ b/build/cmake/modules/liblog.cmake @@ -0,0 +1,44 @@ +set(TARGET log) + +set(TARGET_SRC_DIR "${MODULES_SRC}/logging/liblog") + +set(TARGET_CFLAGS + "-Wall" + "-Wextra" + "-Wexit-time-destructors" + "-DLIBLOG_LOG_TAG=1006" + "-DSNET_EVENT_LOG_TAG=1397638484" +) + +set(LIBLOG_SRCS + "${TARGET_SRC_DIR}/log_event_list.cpp" + "${TARGET_SRC_DIR}/log_event_write.cpp" + "${TARGET_SRC_DIR}/logger_name.cpp" + "${TARGET_SRC_DIR}/logger_read.cpp" + "${TARGET_SRC_DIR}/logger_write.cpp" + "${TARGET_SRC_DIR}/logprint.cpp" + "${TARGET_SRC_DIR}/properties.cpp" +) +set(LIBLOG_TARGET_SRCS + "${TARGET_SRC_DIR}/event_tag_map.cpp" + "${TARGET_SRC_DIR}/log_time.cpp" + "${TARGET_SRC_DIR}/pmsg_reader.cpp" + "${TARGET_SRC_DIR}/pmsg_writer.cpp" + "${TARGET_SRC_DIR}/logd_reader.cpp" + "${TARGET_SRC_DIR}/logd_writer.cpp" +) + +if (CMAKE_SYSTEM_NAME MATCHES "Android") + list(APPEND LIBLOG_SRCS ${LIBLOG_TARGET_SRCS}) +endif() + +add_library(${TARGET} STATIC ${LIBLOG_SRCS}) + +target_include_directories(${TARGET} PRIVATE + "${TARGET_SRC_DIR}/include" + "${MODULES_SRC}/core/include" + "${MODULES_SRC}/core/libcutils/include" + "${MODULES_SRC}/libbase/include" +) + +target_compile_options(${TARGET} PRIVATE ${TARGET_CFLAGS}) diff --git a/build/cmake/modules/libpackagelistparser.cmake b/build/cmake/modules/libpackagelistparser.cmake new file mode 100644 index 00000000..9cbe4298 --- /dev/null +++ b/build/cmake/modules/libpackagelistparser.cmake @@ -0,0 +1,11 @@ +set(TARGET packagelistparser) + +set(TARGET_SRC_DIR "${MODULES_SRC}/core/libpackagelistparser") + +set(LIBPACKAGELISTPARSER_SRCS "${TARGET_SRC_DIR}/packagelistparser.cpp") + +add_library(${TARGET} STATIC ${LIBPACKAGELISTPARSER_SRCS}) + +target_include_directories(${TARGET} PRIVATE "${TARGET_SRC_DIR}/include") + +target_link_libraries(${TARGET} log) diff --git a/build/cmake/modules/libpcre2.cmake b/build/cmake/modules/libpcre2.cmake new file mode 100644 index 00000000..c1d064b0 --- /dev/null +++ b/build/cmake/modules/libpcre2.cmake @@ -0,0 +1,46 @@ +set(TARGET pcre2) + +set(TARGET_SRC_DIR "${MODULES_SRC}/pcre/src") + +set(TARGET_CFLAGS + "-DHAVE_CONFIG_H" + "-Wall" + "-Werror" + "-DPCRE2_CODE_UNIT_WIDTH=8" +) + +set(LIBPCRE2_SOURCES + "${TARGET_SRC_DIR}/pcre2_auto_possess.c" + "${TARGET_SRC_DIR}/pcre2_compile.c" + "${TARGET_SRC_DIR}/pcre2_config.c" + "${TARGET_SRC_DIR}/pcre2_context.c" + "${TARGET_SRC_DIR}/pcre2_convert.c" + "${TARGET_SRC_DIR}/pcre2_dfa_match.c" + "${TARGET_SRC_DIR}/pcre2_error.c" + "${TARGET_SRC_DIR}/pcre2_extuni.c" + "${TARGET_SRC_DIR}/pcre2_find_bracket.c" + "${TARGET_SRC_DIR}/pcre2_maketables.c" + "${TARGET_SRC_DIR}/pcre2_match.c" + "${TARGET_SRC_DIR}/pcre2_match_data.c" + "${TARGET_SRC_DIR}/pcre2_jit_compile.c" + "${TARGET_SRC_DIR}/pcre2_newline.c" + "${TARGET_SRC_DIR}/pcre2_ord2utf.c" + "${TARGET_SRC_DIR}/pcre2_pattern_info.c" + "${TARGET_SRC_DIR}/pcre2_script_run.c" + "${TARGET_SRC_DIR}/pcre2_serialize.c" + "${TARGET_SRC_DIR}/pcre2_string_utils.c" + "${TARGET_SRC_DIR}/pcre2_study.c" + "${TARGET_SRC_DIR}/pcre2_substitute.c" + "${TARGET_SRC_DIR}/pcre2_substring.c" + "${TARGET_SRC_DIR}/pcre2_tables.c" + "${TARGET_SRC_DIR}/pcre2_ucd.c" + "${TARGET_SRC_DIR}/pcre2_valid_utf.c" + "${TARGET_SRC_DIR}/pcre2_xclass.c" + "${TARGET_SRC_DIR}/pcre2_chartables.c" +) + +add_library(${TARGET} STATIC ${LIBPCRE2_SOURCES}) + +target_include_directories(${TARGET} PRIVATE "${MODULES_SRC}/pcre/include") + +target_compile_options(${TARGET} PRIVATE ${TARGET_CFLAGS}) diff --git a/build/cmake/modules/libselinux.cmake b/build/cmake/modules/libselinux.cmake new file mode 100644 index 00000000..9b82e156 --- /dev/null +++ b/build/cmake/modules/libselinux.cmake @@ -0,0 +1,125 @@ +set(TARGET selinux) + +set(TARGET_SRC_DIR "${MODULES_SRC}/selinux/libselinux/src") + +set(TARGET_CFLAGS + "-DNO_PERSISTENTLY_STORED_PATTERNS" + "-DDISABLE_SETRANS" + "-DDISABLE_BOOL" + "-D_GNU_SOURCE" + "-DNO_MEDIA_BACKEND" + "-DNO_X_BACKEND" + "-DNO_DB_BACKEND" + "-Wno-error=missing-noreturn" + "-Wno-error=unused-function" + "-Wno-error=unused-variable" + "-DUSE_PCRE2" +) + +set(LIBSELINUX_DEFAULTS_SRCS + "${TARGET_SRC_DIR}/booleans.c" + "${TARGET_SRC_DIR}/callbacks.c" + "${TARGET_SRC_DIR}/freecon.c" + "${TARGET_SRC_DIR}/label_backends_android.c" + "${TARGET_SRC_DIR}/label.c" + "${TARGET_SRC_DIR}/label_support.c" + "${TARGET_SRC_DIR}/matchpathcon.c" + "${TARGET_SRC_DIR}/setrans_client.c" + "${TARGET_SRC_DIR}/sha1.c" +) + +set(LIBSELINUX_SRCS + "${TARGET_SRC_DIR}/label_file.c" + "${TARGET_SRC_DIR}/regex.c" +) + +if (CMAKE_SYSTEM_NAME MATCHES "Linux") + #linux_glibc + list(APPEND LIBSELINUX_SRCS + ${LIBSELINUX_DEFAULTS_SRCS} + "${TARGET_SRC_DIR}/android/android_host.c" + "${TARGET_SRC_DIR}/avc.c" + "${TARGET_SRC_DIR}/avc_internal.c" + "${TARGET_SRC_DIR}/avc_sidtab.c" + "${TARGET_SRC_DIR}/compute_av.c" + "${TARGET_SRC_DIR}/compute_create.c" + "${TARGET_SRC_DIR}/compute_member.c" + "${TARGET_SRC_DIR}/context.c" + "${TARGET_SRC_DIR}/deny_unknown.c" + "${TARGET_SRC_DIR}/enabled.c" + "${TARGET_SRC_DIR}/fgetfilecon.c" + "${TARGET_SRC_DIR}/getenforce.c" + "${TARGET_SRC_DIR}/getfilecon.c" + "${TARGET_SRC_DIR}/get_initial_context.c" + "${TARGET_SRC_DIR}/init.c" + "${TARGET_SRC_DIR}/lgetfilecon.c" + "${TARGET_SRC_DIR}/load_policy.c" + "${TARGET_SRC_DIR}/lsetfilecon.c" + "${TARGET_SRC_DIR}/mapping.c" + "${TARGET_SRC_DIR}/procattr.c" + "${TARGET_SRC_DIR}/reject_unknown.c" + "${TARGET_SRC_DIR}/sestatus.c" + "${TARGET_SRC_DIR}/setenforce.c" + "${TARGET_SRC_DIR}/setexecfilecon.c" + "${TARGET_SRC_DIR}/setfilecon.c" + "${TARGET_SRC_DIR}/stringrep.c" + ) + list(APPEND TARGET_CFLAGS "-DBUILD_HOST") +elseif (CMAKE_SYSTEM_NAME MATCHES "Android") + list(APPEND LIBSELINUX_SRCS + ${LIBSELINUX_DEFAULTS_SRCS} + "${TARGET_SRC_DIR}/android/android.c" + "${TARGET_SRC_DIR}/avc.c" + "${TARGET_SRC_DIR}/avc_internal.c" + "${TARGET_SRC_DIR}/avc_sidtab.c" + "${TARGET_SRC_DIR}/canonicalize_context.c" + "${TARGET_SRC_DIR}/checkAccess.c" + "${TARGET_SRC_DIR}/check_context.c" + "${TARGET_SRC_DIR}/compute_av.c" + "${TARGET_SRC_DIR}/compute_create.c" + "${TARGET_SRC_DIR}/compute_member.c" + "${TARGET_SRC_DIR}/context.c" + "${TARGET_SRC_DIR}/deny_unknown.c" + "${TARGET_SRC_DIR}/disable.c" + "${TARGET_SRC_DIR}/enabled.c" + "${TARGET_SRC_DIR}/fgetfilecon.c" + "${TARGET_SRC_DIR}/fsetfilecon.c" + "${TARGET_SRC_DIR}/getenforce.c" + "${TARGET_SRC_DIR}/getfilecon.c" + "${TARGET_SRC_DIR}/get_initial_context.c" + "${TARGET_SRC_DIR}/getpeercon.c" + "${TARGET_SRC_DIR}/init.c" + "${TARGET_SRC_DIR}/lgetfilecon.c" + "${TARGET_SRC_DIR}/load_policy.c" + "${TARGET_SRC_DIR}/lsetfilecon.c" + "${TARGET_SRC_DIR}/mapping.c" + "${TARGET_SRC_DIR}/policyvers.c" + "${TARGET_SRC_DIR}/procattr.c" + "${TARGET_SRC_DIR}/reject_unknown.c" + "${TARGET_SRC_DIR}/sestatus.c" + "${TARGET_SRC_DIR}/setenforce.c" + "${TARGET_SRC_DIR}/setfilecon.c" + "${TARGET_SRC_DIR}/stringrep.c" + "${TARGET_SRC_DIR}/android/android_platform.c" + ) + list(APPEND TARGET_CFLAGS "-DAUDITD_LOG_TAG=1003") +endif() + +add_library(${TARGET} STATIC ${LIBSELINUX_SRCS}) + +target_include_directories(${TARGET} PRIVATE + "${MODULES_SRC}/selinux/libselinux/src" + "${MODULES_SRC}/selinux/libsepol/include" + "${MODULES_SRC}/pcre/include" + "${MODULES_SRC}/core/libpackagelistparser/include" +) + +target_compile_options(${TARGET} PRIVATE ${TARGET_CFLAGS}) + +set(TARGET_LINK_LIBS pcre2) + +if (CMAKE_SYSTEM_NAME MATCHES "Android") + list(APPEND TARGET_LINK_LIBS "packagelistparser") +endif() + +target_link_libraries(${TARGET} ${TARGET_LINK_LIBS}) diff --git a/erofs-tools/dump.cmake b/erofs-tools/dump.cmake deleted file mode 100644 index 56e5bf56..00000000 --- a/erofs-tools/dump.cmake +++ /dev/null @@ -1,26 +0,0 @@ -set(TARGET dump.erofs) - -file(GLOB SRCS "${PROJECT_SOURCE_DIR}/dump/*.c") -add_executable(${TARGET} ${SRCS}) -target_link_libraries(${TARGET} - erofs - cutils - ext2_uuid - log - lz4_static - selinux - pcre - base - ) -include_directories( - ${PROJECT_SOURCE_DIR}/lib - ${PROJECT_SOURCE_DIR}/include - ${SRC}/selinux/libselinux/include - ${SRC}/e2fsprogs/lib/uuid - ${SRC}/core/libcutils/include - ) -link_directories( - ${SRC} - ${SRC}/lz4/build/cmake - ${SRC}/pcre -) diff --git a/erofs-tools/fsck.cmake b/erofs-tools/fsck.cmake deleted file mode 100644 index d2668271..00000000 --- a/erofs-tools/fsck.cmake +++ /dev/null @@ -1,26 +0,0 @@ -set(TARGET fsck.erofs) - -file(GLOB SRCS "${PROJECT_SOURCE_DIR}/fsck/*.c") -add_executable(${TARGET} ${SRCS}) -target_link_libraries(${TARGET} - erofs - cutils - ext2_uuid - log - lz4_static - selinux - pcre - base - ) -include_directories( - ${PROJECT_SOURCE_DIR}/lib - ${PROJECT_SOURCE_DIR}/include - ${SRC}/selinux/libselinux/include - ${SRC}/e2fsprogs/lib/uuid - ${SRC}/core/libcutils/include - ) -link_directories( - ${SRC} - ${SRC}/lz4/build/cmake - ${SRC}/pcre -) diff --git a/erofs-tools/mkfs.cmake b/erofs-tools/mkfs.cmake deleted file mode 100644 index 0b743490..00000000 --- a/erofs-tools/mkfs.cmake +++ /dev/null @@ -1,26 +0,0 @@ -set(TARGET mkfs.erofs) - -file(GLOB SRCS "${PROJECT_SOURCE_DIR}/mkfs/*.c") -add_executable(${TARGET} ${SRCS}) -target_link_libraries(${TARGET} - erofs - cutils - ext2_uuid - log - lz4_static - selinux - pcre - base - ) -include_directories( - ${PROJECT_SOURCE_DIR}/lib - ${PROJECT_SOURCE_DIR}/include - ${SRC}/selinux/libselinux/include - ${SRC}/e2fsprogs/lib/uuid - ${SRC}/core/libcutils/include - ) -link_directories( - ${SRC} - ${SRC}/lz4/build/cmake - ${SRC}/pcre -) diff --git a/include/selinux/android.h b/include/selinux/android.h deleted file mode 100644 index 4971ff00..00000000 --- a/include/selinux/android.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef _SELINUX_ANDROID_H_ -#define _SELINUX_ANDROID_H_ - -#include -#include -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -extern struct selabel_handle* selinux_android_file_context_handle(void); - -extern struct selabel_handle* selinux_android_prop_context_handle(void); - -extern struct selabel_handle* selinux_android_service_context_handle(void); - -extern void selinux_android_set_sehandle(const struct selabel_handle *hndl); - -extern int selinux_android_load_policy(void); - -extern int selinux_android_reload_policy(void); - -extern int selinux_android_setcon(const char *con); - -extern int selinux_android_setcontext(uid_t uid, - bool isSystemServer, - const char *seinfo, - const char *name); - -extern int selinux_android_setfilecon(const char *pkgdir, - const char *pkgname, - const char *seinfo, - uid_t uid); - -extern int selinux_log_callback(int type, const char *fmt, ...) - __attribute__ ((format(printf, 2, 3))); - -#define SELINUX_ANDROID_RESTORECON_NOCHANGE 1 -#define SELINUX_ANDROID_RESTORECON_VERBOSE 2 -#define SELINUX_ANDROID_RESTORECON_RECURSE 4 -#define SELINUX_ANDROID_RESTORECON_FORCE 8 -#define SELINUX_ANDROID_RESTORECON_DATADATA 16 -extern int selinux_android_restorecon(const char *file, unsigned int flags); - -extern int selinux_android_restorecon_pkgdir(const char *pkgdir, - const char *seinfo, - uid_t uid, - unsigned int flags); - -extern int selinux_android_seapp_context_reload(void); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/core b/src/core index 848fe8ab..ee0584b2 160000 --- a/src/core +++ b/src/core @@ -1 +1 @@ -Subproject commit 848fe8abeac464f1f57f34c363198f22f3b46a1b +Subproject commit ee0584b2db18d20cebbdd3075c9fc469e889bde1 diff --git a/src/libbase.cmake b/src/libbase.cmake deleted file mode 100644 index 7e784c14..00000000 --- a/src/libbase.cmake +++ /dev/null @@ -1,26 +0,0 @@ -set(TARGET base) - -add_library(${TARGET} STATIC - ${SRC}/libbase/abi_compatibility.cpp - ${SRC}/libbase/chrono_utils.cpp - ${SRC}/libbase/cmsg.cpp - ${SRC}/libbase/errors_unix.cpp - ${SRC}/libbase/file.cpp - ${SRC}/libbase/logging.cpp - ${SRC}/libbase/mapped_file.cpp - ${SRC}/libbase/parsebool.cpp - ${SRC}/libbase/parsenetaddress.cpp - ${SRC}/libbase/process.cpp - ${SRC}/libbase/properties.cpp - ${SRC}/libbase/stringprintf.cpp - ${SRC}/libbase/strings.cpp - ${SRC}/libbase/test_utils.cpp - ${SRC}/libbase/threads.cpp - ${SRC}/libbase/posix_strerror_r.cpp - ) - -target_include_directories(${TARGET} PUBLIC - ${SRC}/libbase/include - ${SRC}/core/include - ${SRC}/logging/liblog/include - ) diff --git a/src/libcutils.cmake b/src/libcutils.cmake deleted file mode 100644 index 9456aba3..00000000 --- a/src/libcutils.cmake +++ /dev/null @@ -1,36 +0,0 @@ -set(TARGET cutils) - -add_library(${TARGET} STATIC - ${SRC}/core/libcutils/android_get_control_file.cpp - ${SRC}/core/libcutils/ashmem-host.cpp - ${SRC}/core/libcutils/canned_fs_config.cpp - ${SRC}/core/libcutils/config_utils.cpp - ${SRC}/core/libcutils/fs.cpp - ${SRC}/core/libcutils/fs_config.cpp - ${SRC}/core/libcutils/hashmap.cpp - ${SRC}/core/libcutils/iosched_policy.cpp - ${SRC}/core/libcutils/load_file.cpp - ${SRC}/core/libcutils/multiuser.cpp - ${SRC}/core/libcutils/native_handle.cpp - ${SRC}/core/libcutils/properties.cpp - ${SRC}/core/libcutils/record_stream.cpp - ${SRC}/core/libcutils/socket_inaddr_any_server_unix.cpp - ${SRC}/core/libcutils/socket_local_client_unix.cpp - ${SRC}/core/libcutils/socket_local_server_unix.cpp - ${SRC}/core/libcutils/socket_network_client_unix.cpp - ${SRC}/core/libcutils/sockets_unix.cpp - ${SRC}/core/libcutils/sockets.cpp - ${SRC}/core/libcutils/str_parms.cpp - ${SRC}/core/libcutils/strlcpy.c - ${SRC}/core/libcutils/trace-host.cpp - ${SRC}/core/libcutils/threads.cpp) - -target_compile_definitions(${TARGET} PRIVATE -D_GNU_SOURCE) - -target_include_directories(${TARGET} PUBLIC - ${SRC}/core/libutils/include - ${SRC}/core/libcutils/include - ${SRC}/logging/liblog/include - ${SRC}/libbase/include - ) - diff --git a/src/liberofs.cmake b/src/liberofs.cmake deleted file mode 100644 index 823b79d7..00000000 --- a/src/liberofs.cmake +++ /dev/null @@ -1,12 +0,0 @@ -set(TARGET erofs) - -file(GLOB SRCS "${PROJECT_SOURCE_DIR}/lib/*.c") - -add_library(${TARGET} STATIC - ${SRCS} - ) - -include_directories( - ${PROJECT_SOURCE_DIR}/lib - ${PROJECT_SOURCE_DIR}/include - ) diff --git a/src/libext2_uuid.cmake b/src/libext2_uuid.cmake deleted file mode 100644 index 45ca8af2..00000000 --- a/src/libext2_uuid.cmake +++ /dev/null @@ -1,24 +0,0 @@ -set(TARGET ext2_uuid) - -add_library(${TARGET} STATIC - ${SRC}/e2fsprogs/lib/uuid/clear.c - ${SRC}/e2fsprogs/lib/uuid/compare.c - ${SRC}/e2fsprogs/lib/uuid/copy.c - ${SRC}/e2fsprogs/lib/uuid/gen_uuid.c - ${SRC}/e2fsprogs/lib/uuid/isnull.c - ${SRC}/e2fsprogs/lib/uuid/pack.c - ${SRC}/e2fsprogs/lib/uuid/parse.c - ${SRC}/e2fsprogs/lib/uuid/unpack.c - ${SRC}/e2fsprogs/lib/uuid/unparse.c - ${SRC}/e2fsprogs/lib/uuid/uuid_time.c - ) - -include_directories( - ${SRC}/e2fsprogs/lib - ${SRC}/core/libsparse/include - ${SRC}/e2fsprogs/lib - ${SRC}/e2fsprogs/misc - ${SRC}/e2fsprogs/lib/ext2fs - ${SRC}/selinux/libselinux/include - ${SRC}/core/libcutils/include - ) diff --git a/src/liblog.cmake b/src/liblog.cmake deleted file mode 100644 index 3cb83b4c..00000000 --- a/src/liblog.cmake +++ /dev/null @@ -1,25 +0,0 @@ -set(TARGET log) - -add_library(${TARGET} STATIC - ${SRC}/logging/liblog/log_event_list.cpp - ${SRC}/logging/liblog/log_event_write.cpp - ${SRC}/logging/liblog/logger_name.cpp - ${SRC}/logging/liblog/logger_read.cpp - ${SRC}/logging/liblog/logger_write.cpp - ${SRC}/logging/liblog/properties.cpp - ${SRC}/logging/liblog/logprint.cpp - ) - -target_compile_definitions(${TARGET} PRIVATE - -DLIBLOG_LOG_TAG=1006 - -D_XOPEN_SOURCE=700 - -DFAKE_LOG_DEVICE=1 - -DSNET_EVENT_LOG_TAG=1397638686 - ) - -target_include_directories(${TARGET} PUBLIC - ${SRC}/core/include - ${SRC}/logging/liblog/include - ${SRC}/core/libcutils/include - ${SRC}/libbase/include - ) \ No newline at end of file diff --git a/src/libpcre.cmake b/src/libpcre.cmake deleted file mode 100644 index cedac10c..00000000 --- a/src/libpcre.cmake +++ /dev/null @@ -1,37 +0,0 @@ -set(TARGET pcre) - -add_library(${TARGET} STATIC - ${SRC}/pcre/src/pcre2_auto_possess.c - ${SRC}/pcre/src/pcre2_compile.c - ${SRC}/pcre/src/pcre2_config.c - ${SRC}/pcre/src/pcre2_context.c - ${SRC}/pcre/src/pcre2_convert.c - ${SRC}/pcre/src/pcre2_dfa_match.c - ${SRC}/pcre/src/pcre2_error.c - ${SRC}/pcre/src/pcre2_extuni.c - ${SRC}/pcre/src/pcre2_find_bracket.c - ${SRC}/pcre/src/pcre2_maketables.c - ${SRC}/pcre/src/pcre2_match.c - ${SRC}/pcre/src/pcre2_match_data.c - ${SRC}/pcre/src/pcre2_jit_compile.c - ${SRC}/pcre/src/pcre2_newline.c - ${SRC}/pcre/src/pcre2_ord2utf.c - ${SRC}/pcre/src/pcre2_pattern_info.c - ${SRC}/pcre/src/pcre2_script_run.c - ${SRC}/pcre/src/pcre2_serialize.c - ${SRC}/pcre/src/pcre2_string_utils.c - ${SRC}/pcre/src/pcre2_study.c - ${SRC}/pcre/src/pcre2_substitute.c - ${SRC}/pcre/src/pcre2_substring.c - ${SRC}/pcre/src/pcre2_tables.c - ${SRC}/pcre/src/pcre2_ucd.c - ${SRC}/pcre/src/pcre2_valid_utf.c - ${SRC}/pcre/src/pcre2_xclass.c - ${SRC}/pcre/src/pcre2_chartables.c) - -target_compile_definitions(${TARGET} PRIVATE -DHAVE_CONFIG_H -DPCRE2_CODE_UNIT_WIDTH=8) - -target_include_directories(${TARGET} PUBLIC - ${SRC}/pcre/include - ) - diff --git a/src/libselinux.cmake b/src/libselinux.cmake deleted file mode 100644 index c2d5be24..00000000 --- a/src/libselinux.cmake +++ /dev/null @@ -1,26 +0,0 @@ -set(TARGET selinux) - -set(SRC_LIST - ${SRC}/selinux/libselinux/src/canonicalize_context.c - ${SRC}/selinux/libselinux/src/selinux_config.c - ${SRC}/selinux/libselinux/src/label_file.c - ${SRC}/selinux/libselinux/src/regex.c - ${SRC}/selinux/libselinux/src/callbacks.c - ${SRC}/selinux/libselinux/src/freecon.c - ${SRC}/selinux/libselinux/src/label_backends_android.c - ${SRC}/selinux/libselinux/src/label.c - ${SRC}/selinux/libselinux/src/label_support.c - ${SRC}/selinux/libselinux/src/matchpathcon.c - ${SRC}/selinux/libselinux/src/setrans_client.c - ${SRC}/selinux/libselinux/src/sha1.c - ${SRC}/selinux/libselinux/src/init.c - ${SRC}/selinux/libselinux/src/lgetfilecon.c - #${SRC}/selinux/libselinux/src/load_policy.c - ${SRC}/selinux/libselinux/src/lsetfilecon.c - ) - -add_library(${TARGET} STATIC ${SRC_LIST}) -target_compile_definitions(${TARGET} PRIVATE -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8 -DBUILD_HOST -DNO_DB_BACKEND -DNO_X_BACKEND -DNO_MEDIA_BACKEND -D_GNU_SOURCE -DDISABLE_BOOL -DNO_PERSISTENTLY_STORED_PATTERNS -DDISABLE_SETRANS -DDISABLE_SETRANS) - -target_include_directories(${TARGET} PRIVATE ${SRC}/selinux/libselinux/include) - diff --git a/src/selinux b/src/selinux index 73850041..0ff24d85 160000 --- a/src/selinux +++ b/src/selinux @@ -1 +1 @@ -Subproject commit 7385004162b22554fa651ae521c8bc67bf4b3524 +Subproject commit 0ff24d85f1ec091c3cdda44e67b8e5d5c14c6d52