From db84fde9f61120d91c12e8ee2eb4169e16dea919 Mon Sep 17 00:00:00 2001 From: lambdadroid Date: Tue, 27 Aug 2019 16:21:24 +0200 Subject: [PATCH] Build Android sparse image (simg) tools libsparse is already built for fastboot, so building the simg tools only requires a few build rules to link the executables. Adds the following tools: simgtoimg, img2simg, and append2simg. --- README.md | 1 + vendor/CMakeLists.fastboot.txt | 11 ----------- vendor/CMakeLists.sparse.txt | 25 +++++++++++++++++++++++++ vendor/CMakeLists.txt | 4 +++- 4 files changed, 29 insertions(+), 12 deletions(-) create mode 100644 vendor/CMakeLists.sparse.txt diff --git a/README.md b/README.md index c72a5db..3d8456b 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ Currently the following tools are supported: * adb * fastboot * mke2fs.android (required by fastboot) +* simg2img, img2simg, append2simg The build system itself works quite well and is already being used for the Alpine Linux [android-tools package][alpine-linux] which I maintain. diff --git a/vendor/CMakeLists.fastboot.txt b/vendor/CMakeLists.fastboot.txt index 0d8bfca..81596ab 100644 --- a/vendor/CMakeLists.fastboot.txt +++ b/vendor/CMakeLists.fastboot.txt @@ -1,14 +1,3 @@ -add_library(libsparse STATIC - core/libsparse/backed_block.cpp - core/libsparse/output_file.cpp - core/libsparse/sparse.cpp - core/libsparse/sparse_crc32.cpp - core/libsparse/sparse_err.cpp - core/libsparse/sparse_read.cpp) - -target_include_directories(libsparse PUBLIC - core/libsparse/include core/base/include) - add_library(libzip STATIC core/libziparchive/zip_archive.cc) diff --git a/vendor/CMakeLists.sparse.txt b/vendor/CMakeLists.sparse.txt new file mode 100644 index 0000000..71bed0e --- /dev/null +++ b/vendor/CMakeLists.sparse.txt @@ -0,0 +1,25 @@ +add_library(libsparse STATIC + core/libsparse/backed_block.cpp + core/libsparse/output_file.cpp + core/libsparse/sparse.cpp + core/libsparse/sparse_crc32.cpp + core/libsparse/sparse_err.cpp + core/libsparse/sparse_read.cpp) + +target_include_directories(libsparse PUBLIC + core/libsparse/include core/base/include) + +add_executable(simg2img + core/libsparse/simg2img.cpp) +target_link_libraries(simg2img + libsparse z libbase) + +add_executable(img2simg + core/libsparse/img2simg.cpp) +target_link_libraries(img2simg + libsparse z libbase) + +add_executable(append2simg + core/libsparse/append2simg.cpp) +target_link_libraries(append2simg + libsparse z libbase) diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt index 6d1cd21..9fd1649 100644 --- a/vendor/CMakeLists.txt +++ b/vendor/CMakeLists.txt @@ -26,6 +26,7 @@ if(EXISTS "${ANDROID_PATCH_DIR}/") endif() include(CMakeLists.adb.txt) +include(CMakeLists.sparse.txt) include(CMakeLists.fastboot.txt) include(CMakeLists.mke2fs.txt) @@ -36,4 +37,5 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11 -Wno-attributes") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++2a -Wno-attributes") # Targets which should be installed by `make install`. -install(TARGETS adb fastboot "${ANDROID_MKE2FS_NAME}" DESTINATION bin) +install(TARGETS adb fastboot "${ANDROID_MKE2FS_NAME}" + simg2img img2simg append2simg DESTINATION bin)