diff --git a/README.md b/README.md index c385493..37af1c6 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ Currently the following tools are supported: * fastboot * mke2fs.android (required by fastboot) * simg2img, img2simg, append2simg +* lpdump, lpmake, lpadd, lpflash, lpunpack 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/patches/extras/0002-libjsonpbparse-Fix-build-after-protobuf-util-Status-.patch b/patches/extras/0002-libjsonpbparse-Fix-build-after-protobuf-util-Status-.patch new file mode 100644 index 0000000..27efba9 --- /dev/null +++ b/patches/extras/0002-libjsonpbparse-Fix-build-after-protobuf-util-Status-.patch @@ -0,0 +1,38 @@ +From aba6bdbbe26285c5bee14c88a514995e4c0e99d1 Mon Sep 17 00:00:00 2001 +From: MoetaYuko +Date: Fri, 10 Dec 2021 17:36:31 +0800 +Subject: [PATCH] libjsonpbparse: Fix build after protobuf util::Status + refactorization + +--- + libjsonpb/parse/jsonpb.cpp | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/libjsonpb/parse/jsonpb.cpp b/libjsonpb/parse/jsonpb.cpp +index 3a042e7..62d651d 100644 +--- a/libjsonpb/parse/jsonpb.cpp ++++ b/libjsonpb/parse/jsonpb.cpp +@@ -48,7 +48,11 @@ ErrorOr MessageToJsonString(const Message& message) { + &json, options); + + if (!status.ok()) { ++#if GOOGLE_PROTOBUF_VERSION < 3016000 + return MakeError(status.error_message().as_string()); ++#else ++ return MakeError(status.message().as_string()); ++#endif + } + return ErrorOr(std::move(json)); + } +@@ -61,7 +65,11 @@ ErrorOr JsonStringToMessage(const std::string& content, Message* + std::string binary; + auto status = JsonToBinaryString(resolver.get(), GetTypeUrl(*message), content, &binary); + if (!status.ok()) { ++#if GOOGLE_PROTOBUF_VERSION < 3016000 + return MakeError(status.error_message().as_string()); ++#else ++ return MakeError(status.message().as_string()); ++#endif + } + if (!message->ParseFromString(binary)) { + return MakeError("Fail to parse."); diff --git a/patches/extras/0003-lpadd-Add-missing-header-for-strerror.patch b/patches/extras/0003-lpadd-Add-missing-header-for-strerror.patch new file mode 100644 index 0000000..402cc98 --- /dev/null +++ b/patches/extras/0003-lpadd-Add-missing-header-for-strerror.patch @@ -0,0 +1,21 @@ +From 70d3294a12f05aea953cae415810345f516d778d Mon Sep 17 00:00:00 2001 +From: MoetaYuko +Date: Fri, 10 Dec 2021 17:43:17 +0800 +Subject: [PATCH] lpadd: Add missing header for strerror + +--- + partition_tools/lpadd.cc | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/partition_tools/lpadd.cc b/partition_tools/lpadd.cc +index 48cad72..2d19059 100644 +--- a/partition_tools/lpadd.cc ++++ b/partition_tools/lpadd.cc +@@ -16,6 +16,7 @@ + #include + #include + ++#include + #include + #include + diff --git a/vendor/CMakeLists.libbase.txt b/vendor/CMakeLists.libbase.txt index e6a85e4..117dcca 100644 --- a/vendor/CMakeLists.libbase.txt +++ b/vendor/CMakeLists.libbase.txt @@ -16,4 +16,5 @@ add_library(libbase STATIC libbase/threads.cpp) target_include_directories(libbase PUBLIC - libbase/include core/include logging/liblog/include) + libbase/include core/include) +target_link_libraries(libbase PUBLIC fmt::fmt liblog) diff --git a/vendor/CMakeLists.partition.txt b/vendor/CMakeLists.partition.txt new file mode 100644 index 0000000..1ea18d7 --- /dev/null +++ b/vendor/CMakeLists.partition.txt @@ -0,0 +1,55 @@ +add_library(liblp STATIC + core/fs_mgr/liblp/builder.cpp + core/fs_mgr/liblp/images.cpp + core/fs_mgr/liblp/partition_opener.cpp + core/fs_mgr/liblp/property_fetcher.cpp + core/fs_mgr/liblp/reader.cpp + core/fs_mgr/liblp/utility.cpp + core/fs_mgr/liblp/writer.cpp) + +target_link_libraries(liblp PRIVATE + libbase libext4 libsparse crypto z) +target_include_directories(liblp PRIVATE + boringssl/include) +target_include_directories(liblp PUBLIC + core/fs_mgr/liblp/include) + +protobuf_generate_cpp(DYNAMIC_PARTITIONS_DEVICE_INFO_PROTO_SRCS DYNAMIC_PARTITIONS_DEVICE_INFO_PROTO_HDRS + extras/partition_tools/dynamic_partitions_device_info.proto) + +add_library(libjsonpbparse STATIC + extras/libjsonpb/parse/jsonpb.cpp) +target_link_libraries(libjsonpbparse PRIVATE libbase) +target_include_directories(libjsonpbparse PUBLIC + extras/libjsonpb/parse/include) + +add_library(liblpdump STATIC + ${DYNAMIC_PARTITIONS_DEVICE_INFO_PROTO_SRCS} ${DYNAMIC_PARTITIONS_DEVICE_INFO_PROTO_HDRS} + extras/partition_tools/lpdump.cc) +target_link_libraries(liblpdump PRIVATE + libbase libjsonpbparse liblp ${PROTOBUF_LIBRARIES}) + +add_executable(lpdump + extras/partition_tools/lpdump_host.cc) +target_link_libraries(lpdump + libbase liblpdump libsparse) + +add_executable(lpmake + extras/partition_tools/lpmake.cc) +target_link_libraries(lpmake + libbase liblog liblp libsparse) + +add_executable(lpadd + extras/partition_tools/lpadd.cc) +target_link_libraries(lpadd + libbase liblog liblp libsparse) + +add_executable(lpflash + extras/partition_tools/lpflash.cc) +target_link_libraries(lpflash + libbase liblog liblp libsparse) + +add_executable(lpunpack + extras/partition_tools/lpunpack.cc) +target_link_libraries(lpunpack + libbase liblog liblp libsparse) diff --git a/vendor/CMakeLists.sparse.txt b/vendor/CMakeLists.sparse.txt index a90c946..e70a107 100644 --- a/vendor/CMakeLists.sparse.txt +++ b/vendor/CMakeLists.sparse.txt @@ -8,6 +8,7 @@ add_library(libsparse STATIC target_include_directories(libsparse PUBLIC core/libsparse/include libbase/include) +target_link_libraries(libsparse PRIVATE libbase) add_executable(simg2img core/libsparse/simg2img.cpp) diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt index c9ccb3c..8c9ee71 100644 --- a/vendor/CMakeLists.txt +++ b/vendor/CMakeLists.txt @@ -46,6 +46,7 @@ include(CMakeLists.adb.txt) include(CMakeLists.sparse.txt) include(CMakeLists.fastboot.txt) include(CMakeLists.mke2fs.txt) +include(CMakeLists.partition.txt) # Various C++20 features are used across the codebase, e.g. # std::string_view.starts_with. Additionally, GNU extension @@ -65,8 +66,19 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FILE_OFFSET_BITS=64") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FILE_OFFSET_BITS=64") # Targets which should be installed by `make install`. -install(TARGETS adb fastboot "${ANDROID_MKE2FS_NAME}" - simg2img img2simg append2simg DESTINATION bin) +install(TARGETS + "${ANDROID_MKE2FS_NAME}" + adb + append2simg + fastboot + img2simg + lpadd + lpdump + lpflash + lpmake + lpunpack + simg2img + DESTINATION bin) # Install common completion files. install(FILES adb/adb.bash RENAME adb DESTINATION "${COMPLETION_COMMON_DIR}")