pmt: switch builder to ninja. And some extra improvements
This commit is contained in:
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@@ -23,7 +23,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt upgrade -y
|
sudo apt upgrade -y
|
||||||
sudo apt install make cmake extra-cmake-modules zip -y
|
sudo apt install make ninja cmake extra-cmake-modules zip -y
|
||||||
|
|
||||||
- name: Setup Android NDK
|
- name: Setup Android NDK
|
||||||
id: setup-ndk
|
id: setup-ndk
|
||||||
|
|||||||
@@ -82,14 +82,14 @@ cc_defaults {
|
|||||||
shared_libs: ["libbase"],
|
shared_libs: ["libbase"],
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build libhelper library
|
// libhelper library target
|
||||||
cc_library_shared {
|
cc_library_shared {
|
||||||
name: "libhelper",
|
name: "libhelper",
|
||||||
defaults: ["pmt_defaults"],
|
defaults: ["pmt_defaults"],
|
||||||
srcs: [":libhelper_srcs"],
|
srcs: [":libhelper_srcs"],
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build libpartition_map library
|
// libpartition_map library target
|
||||||
cc_library_shared {
|
cc_library_shared {
|
||||||
name: "libpartition_map",
|
name: "libpartition_map",
|
||||||
defaults: ["pmt_defaults"],
|
defaults: ["pmt_defaults"],
|
||||||
@@ -98,7 +98,7 @@ cc_library_shared {
|
|||||||
static_libs: ["libc++fs"],
|
static_libs: ["libc++fs"],
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build pmt
|
// pmt executable target
|
||||||
cc_binary {
|
cc_binary {
|
||||||
name: "pmt",
|
name: "pmt",
|
||||||
defaults: ["pmt_defaults"],
|
defaults: ["pmt_defaults"],
|
||||||
|
|||||||
8
build.sh
8
build.sh
@@ -29,6 +29,10 @@ checks() {
|
|||||||
echo "Please verify your CMake installation."
|
echo "Please verify your CMake installation."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
if ! which ninja &>/dev/null; then
|
||||||
|
echo "Please verify your Ninja installation."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
clean() {
|
clean() {
|
||||||
@@ -50,7 +54,7 @@ build() {
|
|||||||
for a in ${TARGET_ABI_LIST[@]}; do
|
for a in ${TARGET_ABI_LIST[@]}; do
|
||||||
echo "Configuring for $a..."
|
echo "Configuring for $a..."
|
||||||
mkdir -p build_$a
|
mkdir -p build_$a
|
||||||
cmake -B build_$a -S . $1 \
|
cmake -B build_$a -G Ninja -S . $1 \
|
||||||
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
|
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
|
||||||
-DANDROID_ABI=$a \
|
-DANDROID_ABI=$a \
|
||||||
-DANDROID_PLATFORM=$ANDROID_PLATFORM \
|
-DANDROID_PLATFORM=$ANDROID_PLATFORM \
|
||||||
@@ -59,7 +63,7 @@ build() {
|
|||||||
|
|
||||||
for a in ${TARGET_ABI_LIST[@]}; do
|
for a in ${TARGET_ABI_LIST[@]}; do
|
||||||
echo "Building $a artifacts..."
|
echo "Building $a artifacts..."
|
||||||
cmake --build build_$a
|
cmake --build build_$a -j$(nproc)
|
||||||
echo "$a build complete, artifacts: $PWD/build_$a"
|
echo "$a build complete, artifacts: $PWD/build_$a"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,15 +56,10 @@ INIT(infoFunction) {
|
|||||||
|
|
||||||
RUN(infoFunction) {
|
RUN(infoFunction) {
|
||||||
if (partitions.back() == "get-all" || partitions.back() == "getvar-all") {
|
if (partitions.back() == "get-all" || partitions.back() == "getvar-all") {
|
||||||
partitions.clear();
|
if (!Variables->PartMap->copyPartitionsToVector(partitions))
|
||||||
const auto parts = Variables->PartMap->getPartitionList();
|
|
||||||
if (!parts)
|
|
||||||
throw Error("Cannot get list of all partitions! See logs for more "
|
throw Error("Cannot get list of all partitions! See logs for more "
|
||||||
"information (%s)",
|
"information (%s)",
|
||||||
Helper::LoggingProperties::FILE.data());
|
Helper::LoggingProperties::FILE.data());
|
||||||
|
|
||||||
for (const auto &name : *parts)
|
|
||||||
partitions.push_back(name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<PartitionMap::Partition_t> jParts;
|
std::vector<PartitionMap::Partition_t> jParts;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ Copyright 2025 Yağız Zengin
|
|||||||
|
|
||||||
#define SFUN "partitionSizeFunction"
|
#define SFUN "partitionSizeFunction"
|
||||||
|
|
||||||
std::string convertTo(const uint64_t size, const std::string &multiple) {
|
static std::string convertTo(const uint64_t size, const std::string &multiple) {
|
||||||
if (multiple == "KB") return std::to_string(TO_KB(size));
|
if (multiple == "KB") return std::to_string(TO_KB(size));
|
||||||
if (multiple == "MB") return std::to_string(TO_MB(size));
|
if (multiple == "MB") return std::to_string(TO_MB(size));
|
||||||
if (multiple == "GB") return std::to_string(TO_GB(size));
|
if (multiple == "GB") return std::to_string(TO_GB(size));
|
||||||
@@ -31,7 +31,10 @@ INIT(partitionSizeFunction) {
|
|||||||
LOGN(SFUN, INFO)
|
LOGN(SFUN, INFO)
|
||||||
<< "Initializing variables of partition size getter function."
|
<< "Initializing variables of partition size getter function."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
cmd = _app.add_subcommand("sizeof", "Tell size(s) of input partition list");
|
cmd = _app.add_subcommand("sizeof", "Tell size(s) of input partition list")
|
||||||
|
->footer("Use get-all or getvar-all as partition name for getting "
|
||||||
|
"sizes of all "
|
||||||
|
"partitions.");
|
||||||
cmd->add_option("partition(s)", partitions, "Partition name(s).")
|
cmd->add_option("partition(s)", partitions, "Partition name(s).")
|
||||||
->required()
|
->required()
|
||||||
->delimiter(',');
|
->delimiter(',');
|
||||||
@@ -55,6 +58,13 @@ INIT(partitionSizeFunction) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RUN(partitionSizeFunction) {
|
RUN(partitionSizeFunction) {
|
||||||
|
if (partitions.back() == "get-all" || partitions.back() == "getvar-all") {
|
||||||
|
if (!Variables->PartMap->copyPartitionsToVector(partitions))
|
||||||
|
throw Error("Cannot get list of all partitions! See logs for more "
|
||||||
|
"information (%s)",
|
||||||
|
Helper::LoggingProperties::FILE.data());
|
||||||
|
}
|
||||||
|
|
||||||
for (const auto &partition : partitions) {
|
for (const auto &partition : partitions) {
|
||||||
if (!Variables->PartMap->hasPartition(partition))
|
if (!Variables->PartMap->hasPartition(partition))
|
||||||
throw Error("Couldn't find partition: %s", partition.data());
|
throw Error("Couldn't find partition: %s", partition.data());
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ std::string getLibVersion();
|
|||||||
#define MKVERSION(name) \
|
#define MKVERSION(name) \
|
||||||
char vinfo[512]; \
|
char vinfo[512]; \
|
||||||
sprintf(vinfo, \
|
sprintf(vinfo, \
|
||||||
"%s 1.2.0 [XXXX-XX-XX XX.XX.XX]\nBuildType: Release\nCompiler: clang\n" \
|
"%s 1.2.0\nBuildType: Release\nCompiler: clang\n" \
|
||||||
"BuildFlags: -Wall;-Werror;-Wno-deprecated-declarations;-Os", name); \
|
"BuildFlags: -Wall;-Werror;-Wno-deprecated-declarations;-Os", name); \
|
||||||
return std::string(vinfo)
|
return std::string(vinfo)
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -221,6 +221,21 @@ public:
|
|||||||
*/
|
*/
|
||||||
[[nodiscard]] bool isLogical(std::string_view name) const;
|
[[nodiscard]] bool isLogical(std::string_view name) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy partition list to vec, current vec contents are cleaned
|
||||||
|
*/
|
||||||
|
bool copyPartitionsToVector(std::vector<std::string> &vec) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy logical partition list to vec, current vec contents are cleaned
|
||||||
|
*/
|
||||||
|
bool copyLogicalPartitionsToVector(std::vector<std::string> &vec) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy physical partition list to vec, current vec contents are cleaned
|
||||||
|
*/
|
||||||
|
bool copyPhysicalPartitionsToVector(std::vector<std::string> &vec) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The created list and the current search index name are cleared.
|
* The created list and the current search index name are cleared.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -218,6 +218,49 @@ bool basic_partition_map_builder::readDefaultDirectories() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool basic_partition_map_builder::copyPartitionsToVector(std::vector<std::string> &vec) const {
|
||||||
|
if (_current_map.empty()) {
|
||||||
|
LOGN(MAP, ERROR) << "Current map is empty.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
vec.clear();
|
||||||
|
for (const auto &[name, props] : _current_map)
|
||||||
|
vec.push_back(name);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool basic_partition_map_builder::copyLogicalPartitionsToVector(std::vector<std::string> &vec) const {
|
||||||
|
if (_current_map.empty()) {
|
||||||
|
LOGN(MAP, ERROR) << "Current map is empty.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
std::vector<std::string> vec2;
|
||||||
|
for (const auto &[name, props] : _current_map)
|
||||||
|
if (props.isLogical) vec2.push_back(name);
|
||||||
|
|
||||||
|
if (vec2.empty()) {
|
||||||
|
LOGN(MAP, ERROR) << "Cannot find logical partitions in current map.";
|
||||||
|
return false;
|
||||||
|
} else vec = vec2;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool basic_partition_map_builder::copyPhysicalPartitionsToVector(std::vector<std::string> &vec) const {
|
||||||
|
if (_current_map.empty()) {
|
||||||
|
LOGN(MAP, ERROR) << "Current map is empty.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
std::vector<std::string> vec2;
|
||||||
|
for (const auto &[name, props] : _current_map)
|
||||||
|
if (!props.isLogical) vec2.push_back(name);
|
||||||
|
|
||||||
|
if (vec2.empty()) {
|
||||||
|
LOGN(MAP, ERROR) << "Cannot find physical partitions in current map.";
|
||||||
|
return false;
|
||||||
|
} else vec = vec2;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool basic_partition_map_builder::empty() const {
|
bool basic_partition_map_builder::empty() const {
|
||||||
_map_build_check();
|
_map_build_check();
|
||||||
return _current_map.empty();
|
return _current_map.empty();
|
||||||
|
|||||||
Reference in New Issue
Block a user