Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dynamic Partition Tools #51

Merged
merged 1 commit into from Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -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.
Expand Down
@@ -0,0 +1,38 @@
From aba6bdbbe26285c5bee14c88a514995e4c0e99d1 Mon Sep 17 00:00:00 2001
From: MoetaYuko <loli@yuko.moe>
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<std::string> MessageToJsonString(const Message& message) {
&json, options);

if (!status.ok()) {
+#if GOOGLE_PROTOBUF_VERSION < 3016000
return MakeError<std::string>(status.error_message().as_string());
+#else
+ return MakeError<std::string>(status.message().as_string());
MoetaYuko marked this conversation as resolved.
Show resolved Hide resolved
+#endif
}
return ErrorOr<std::string>(std::move(json));
}
@@ -61,7 +65,11 @@ ErrorOr<std::monostate> 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<std::monostate>(status.error_message().as_string());
+#else
+ return MakeError<std::monostate>(status.message().as_string());
+#endif
}
if (!message->ParseFromString(binary)) {
return MakeError<std::monostate>("Fail to parse.");
21 changes: 21 additions & 0 deletions 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 <loli@yuko.moe>
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 <sysexits.h>
#include <unistd.h>

+#include <cstring>
#include <iostream>
#include <optional>

3 changes: 2 additions & 1 deletion vendor/CMakeLists.libbase.txt
Expand Up @@ -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)
55 changes: 55 additions & 0 deletions 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)
1 change: 1 addition & 0 deletions vendor/CMakeLists.sparse.txt
Expand Up @@ -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)
Expand Down
16 changes: 14 additions & 2 deletions vendor/CMakeLists.txt
Expand Up @@ -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
Expand All @@ -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}")
Expand Down