pmt: initial 2.8.0 update

This commit is contained in:
2024-09-10 06:17:41 +03:00
parent ec5a2b97b9
commit 595f3b00b3
49 changed files with 2470 additions and 1793 deletions

View File

@@ -16,8 +16,8 @@
function abort()
{
[ -n "${1}" ] \
&& echo -e " - ${RED}${BOLD}Error:${BOLD_RESET}${RESET} ${1}"
[ -n "${@}" ] \
&& echo -e " - ${RED}${BOLD}Error:${BOLD_RESET}${RESET} ${@}"
exit 1
}
@@ -34,4 +34,4 @@ function gen()
touch "${1}" || abort "failed to generate: ${1}"
}
function print() { echo -e "${1}"; }
function print() { echo -e "${@}"; }

View File

@@ -22,13 +22,8 @@
&& echo "Please set NDK_PROJECT_PATH variable!" \
&& exit 1
CC_IS="${NDK_ROOT_DIR}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang"
CC_VERS=$(${CC_IS} --version | head -n 1)
HEADER="${NDK_PROJECT_PATH}/include/pmt/generated/clang-version.h
CXX_IS="${NDK_ROOT_DIR}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang++"
CXX_VERS=$(${CXX_IS} --version | head -n 1)
mkdir -p "${NDK_PROJECT_PATH}/include/pmt/generated"
touch "${HEADER}"
echo "/*" >> "${HEADER}"
cat "${NDK_PROJECT_PATH}/NOTICE" >> "${HEADER}"
echo -e "\n *\n*/" >> "${HEADER}"
echo -e "\n\n#define __NDK_CC_VERSION__ \"${CC_VERS}\"" >> "${HEADER}"
mkdir -p ${NDK_PROJECT_PATH}/include/pmt/generated
echo -e "#define __NDK_CXX_VERSION__ \"${CXX_VERS}\"" > ${NDK_PROJECT_PATH}/include/pmt/generated/clang-version.h

View File

@@ -24,29 +24,43 @@ include env.mk
# #
#########################################
CC = clang
CFLAGS ?= "-O3 -I../include -std=c11 -pedantic -Wall -Wextra -Werror -Wno-nullability-extension -Wno-gnu-zero-variadic-macro-arguments $(PMT_EXTRA_CFLAGS)"
CXX = clang++
AR = ar
CXXFLAGS ?= \
-O3 \
-I../include \
-std=c++20 \
-Wall \
-Wextra \
-Werror \
-Wno-vla-cxx-extension \
-Wno-nullability-completeness \
-Wno-writable-strings \
-Wno-unused-parameter \
-Wno-unused-command-line-argument \
-Wno-nullability-extension \
-Wno-reorder-init-list \
-Wno-gnu-zero-variadic-macro-arguments \
$(PMT_EXTRA_CXXFLAGS)
# set compiler setting (clang-gcc and ar)
ifneq ($(PMT_CC),)
CC ?= $(PMT_CC)
else
CC ?= clang
# set compiler setting (clang and ar)
ifneq ($(PMT_CXX),)
CXX ?= $(PMT_CXX)
endif
ifneq ($(PMT_AR),)
AR ?= $(PMT_AR)
else
AR ?= ar
endif
# compiler flags settings
ifneq ($(PMT_ENABLE_DEBUG),)
CFLAGS += -gdwarf-5 -fsanitize=address
ifeq ($(PMT_ENABLE_DEBUG),true)
CXXFLAGS += \
-gdwarf-5 \
-fsanitize=address
endif
# write current env configuration to oldenv.mk
all:
@ echo "CC := $(CC)" > oldenv.mk
@ echo "CXX := $(CXX)" > oldenv.mk
@ echo "AR := $(AR)" >> oldenv.mk
@ echo "CFLAGS := $(CFLAGS)" >> oldenv.mk
@ echo "CXXFLAGS := $(CXXFLAGS)" >> oldenv.mk

View File

@@ -22,17 +22,17 @@
# #
#########################################
# speficy c compiler (cc)
PMT_CC ?=
# speficy c++ compiler (cxx)
PMT_CXX ?=
# speficy ar
PMT_AR ?=
# addionital compiler flags
PMT_EXTRA_CFLAGS ?=
PMT_EXTRA_CXXFLAGS ?=
# debugging mode (binary). it's enabling address sanitizer and source level debug information with dwarf version 5
PMT_ENABLE_DEBUG ?=
PMT_ENABLE_DEBUG ?= true
#########################################
#########################################

View File

@@ -1,6 +1,6 @@
Source: pmt
Package: pmt
Version: 2.6.0
Version: 2.8.0
Architecture: arm
Description: pmt is for reading, writing and formatting partitions of android devices
Section: misc

View File

@@ -1,6 +1,6 @@
Source: pmt
Package: pmt
Version: 2.6.0
Version: 2.8.0
Architecture: aarch64
Description: pmt is for reading, writing and formatting partitions of android devices
Section: misc

View File

@@ -62,8 +62,8 @@ prepare:
@ mkdir $(TEMP_DIR)/DEBIAN
check_binary:
@ if [ ! -f "$(BINARY_DIR)/pmt" ]; then \
$(E_NS) " - pmt not builded! Please build and retry."; \
@ if [ ! -f "$(BINARY_DIR)/$(TARGET)" ]; then \
$(E_NS) " - $(TARGET) not builded! Please build and retry."; \
exit 1; \
fi
$(E) " - Generating template directory..."

Binary file not shown.

View File

@@ -15,12 +15,25 @@
# limitations under the License.
UPDATE_MAKEFILES = false
CLS_ADTS := rm -f $(BUILD)/bash/additional-vars
CLS_ADTS := "rm -f $(BUILD)/bash/additional-vars"
all:
$(MAKE_HIDE) $(SILENT) -C $(BUILD)/config || exit 1
all: getvars
$(MAKE_HIDE) $(SILENT) -C $(BUILD)/config $$(cat $(BUILD)/goals.txt) || exit 1
@ rm -f $(BUILD)/goals.txt
$(MAKE_HIDE) $(SILENT) -C $(SOURCE_DIRNAME) INC_OLDENV=true || exit 1
getvars:
@ touch $(BUILD)/goals.txt
@ $(foreach var,$(sort $(.VARIABLES)),\
$(if $(filter command line,$(origin $(var))), \
echo "$(var)=$($(var))" >> goals.txt;))
.PHONY: rebuild
rebuild:
$(MAKE_HIDE) $(SILENT) clean
$(E)
$(MAKE_HIDE) $(SILENT)
# cleaner functions
.PHONY: clean
clean:
@@ -31,9 +44,6 @@ clean:
@ if [ -d $(PACKAGE_DIR) ]; then \
$(E_NS) "==> $(OUT_DIRNAME)/`basename $(PACKAGE_DIR)`"; \
fi
@ if [ -d $(STATICLIB_DIR) ]; then \
$(E_NS) "==> $(OUT_DIRNAME)/`basename $(STATICLIB_DIR)`"; \
fi
@ if [ -d $(DEB_DIR) ]; then \
$(E_NS) "==> $(OUT_DIRNAME)/`basename $(DEB_DIR)`"; \
fi
@@ -53,8 +63,10 @@ help:
$(E) " $(MAKE) ==> Build Partition Manager."
$(E) " $(MAKE) deb ==> Generate debian package for termux."
$(E) " $(MAKE) clean ==> Clear builded binary."
$(E) " $(MAKE) rebuild ==> Re-build Partition Manager (clean and make)."
$(E) " $(MAKE) install ==> It installs $(TARGET) into termux."
$(E) " $(MAKE) uninstall ==> It uninstalls $(TARGET) into termux."
$(E) " $(MAKE) reinstall ==> It uninstall and reinstalls $(TARGET)."
$(E) " $(MAKE) gen-makefiles ==> Generate makefiles for build."
$(E) " $(MAKE) gen-ndk-makefiles ==> Generate NDK makefiles for build."
$(E) " $(MAKE) clean-makefiles ==> Cleanup makefiles."
@@ -67,7 +79,7 @@ help:
.PHONY: deb
deb:
$(MAKE_HIDE) $(SILENT) -C $(DEBUTILS_DIR) -f deb.mk FOR_THIS=$(FOR_THIS) || exit 1
$(P) ""
@ $(P) ""
# install pmt in to termux
.PHONY: install
@@ -81,6 +93,11 @@ uninstall:
$(eval PROG := $@)
$(MAKE_HIDE) $(SILENT) -C $(OUT_DIRNAME) uninstall PROG=$(PROG) || exit 1
.PHONY: reinstall
reinstall:
$(MAKE_HIDE) $(SILENT) uninstall
$(MAKE_HIDE) $(SILENT) install
# clean ndk makefiles
.PHONY: gen-ndk-makefiles
gen-ndk-makefiles:

View File

@@ -15,84 +15,50 @@
# limitations under the License.
########
# 2.7.0
# 2.8.0
########
LOCAL_PATH := $(call my-dir)
include $(LOCAL_PATH)/../build/config/env.mk
PMT_CFLAGS = \
PMT_CXXFLAGS = \
-O3 \
-std=c11 \
-pedantic \
-std=c++20 \
-Wall \
-Wextra \
-Werror \
-Wno-vla-cxx-extension \
-Wno-nullability-completeness \
-Wno-writable-strings \
-Wno-unused-parameter \
-Wno-unused-command-line-argument \
-Wno-nullability-extension \
-Wno-reorder-init-list \
-Wno-gnu-zero-variadic-macro-arguments \
-D__NDK_BUILD \
$(EXTRA_COMPILER_FLAGS)
$(PMT_EXTRA_CXXFLAGS)
ifneq ($(PMT_ENABLE_DEBUG),)
PMT_CFLAGS += -gdwarf-5 -fsanitize=address -fsanitize=undefined
PMT_CXXFLAGS += -gdwarf-5 -fsanitize=address
endif
include $(CLEAR_VARS)
LOCAL_MODULE := libpmt_root
LOCAL_SRC_FILES := root.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include
LOCAL_CFLAGS := $(PMT_CFLAGS)
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libpmt_debug
LOCAL_SRC_FILES := debug.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include
LOCAL_CFLAGS := $(PMT_CFLAGS)
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libpmt_partitiontool
LOCAL_SRC_FILES := partitiontool.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include
LOCAL_CFLAGS := $(PMT_CFLAGS)
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libpmt_list
LOCAL_SRC_FILES := listpart.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include
LOCAL_CFLAGS := $(PMT_CFLAGS)
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := pmt
LOCAL_SRC_FILES := \
pmt.c \
version.c \
get_stat.c \
tools.c \
lang_tools.c \
languages.c \
help.c
Debug.cpp \
Root.cpp \
PartitionManager.cpp \
PartitionTool.cpp \
ListPartitions.cpp \
Version.cpp \
GetState.cpp \
Tools.cpp \
LanguageTools.cpp \
Languages.cpp \
Help.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include
LOCAL_STATIC_LIBRARIES := \
libpmt_root \
libpmt_debug \
libpmt_partitiontool \
libpmt_list
LOCAL_CFLAGS := $(PMT_CFLAGS)
LOCAL_CFLAGS := $(PMT_CXXFLAGS)
include $(BUILD_EXECUTABLE)
# end

View File

@@ -15,7 +15,7 @@
# limitations under the License.
########
# 2.7.0
# 2.8.0
########
# architecture

View File

@@ -68,7 +68,8 @@ install_binary:
fi; \
$(P) " - Success.\n\n"; \
$(E_NS) "INSTALL_SUCCESS := true" > $(BUILD)/config/INS_STAT.mk; \
$(E_NS) "UNINSTALLED_SUCCESS := " > $(BUILD)/config/UNINS_STAT.mk; \
$(E_NS) "UNINSTALLED_SUCCESS := " > $(BUILD)/config/UNINS_STAT.mk
@ exit 0
uninstall_$(TARGET):
if [ -f $(TERMUX_USR)/share/man/man8/$(TARGET).8.gz ]; then \

View File

@@ -31,34 +31,33 @@ PMT_INCDIR := $(INCLUDE_DIR)/pmt
# the presence of all source files that are on this list will be checked
SRCS_REQ := \
place-holder/debug.c \
place-holder/help.c \
place-holder/get_stat.c \
place-holder/lang_tools.c \
place-holder/languages.c \
place-holder/partitiontool.c \
place-holder/pmt.c \
place-holder/root.c \
place-holder/tools.c \
place-holder/version.c
place-holder/Debug.cpp \
place-holder/Help.cpp \
place-holder/GetState.cpp \
place-holder/LanguageTools.cpp \
place-holder/Languages.cpp \
place-holder/PartitionTool.cpp \
place-holder/PartitionManager.cpp \
place-holder/Root.cpp \
place-holder/Tools.cpp \
place-holder/Version.cpp
# objects to be used when executable file is created
OBJS_EXEC := \
$(SOURCE_DIR)/$(TARGET).o \
$(SOURCE_DIR)/help.o \
$(SOURCE_DIR)/version.o \
$(SOURCE_DIR)/get_stat.o \
$(SOURCE_DIR)/tools.o \
$(SOURCE_DIR)/lang_tools.o \
$(SOURCE_DIR)/languages.o
$(SOURCE_DIR)/PartitionManager.o \
$(SOURCE_DIR)/Help.o \
$(SOURCE_DIR)/Version.o \
$(SOURCE_DIR)/GetState.o \
$(SOURCE_DIR)/Tools.o \
$(SOURCE_DIR)/Languages.o \
$(SOURCE_DIR)/LanguageTools.o
HEADERS_REQ := \
$(PMT_INCDIR)/pmt/ExternC.h \
$(PMT_INCDIR)/pmt/Deprecates.h \
$(PMT_INCDIR)/pmt/HelpMessages.h \
$(PMT_INCDIR)/pmt/pmt.h \
$(PMT_INCDIR)/pmt/StringKeys.h \
$(PMT_INCDIR)/pmt/VersionVars.h
$(PMT_INCDIR)/PartitionManager/Deprecates.h \
$(PMT_INCDIR)/PartitionManager/HelpFn.h \
$(PMT_INCDIR)/PartitionManager/PartitionManager.h \
$(PMT_INCDIR)/PartitionManager/StringKeys.h \
$(PMT_INCDIR)/PartitionManager/VersionFnVars.h
PROGRESS_LIST := \
welcome \
@@ -74,12 +73,6 @@ PROGRESS_LIST := \
wait \
end_progress
define check_hf
@ [ ! -f "$1" ] \
&& $(E_NS) " ==> Couldn't found required header file: include/pmt/`basename $1`" \
&& exit 1
endef
# all target for building
all: $(PROGRESS_LIST)
@@ -92,11 +85,6 @@ welcome:
&& $(E_NS)
$(E) " -------------------------------- " \
&& $(E_NS)
@ if [ -f $(SOURCE_DIR)/debug.o ]; then \
$(E_NS) " - Please clean up before you build it." && echo; \
$(E_NS) " ----------------------------------- "; \
exit 1; \
fi
$(E) " - Checking required source files..."
pr_obj:
@@ -110,11 +98,11 @@ wait:
make_outdirs:
@ rm -rf $(IN_OUT_DIR)
@ mkdir $(BINARY_DIR)
@ mkdir $(PACKAGE_DIR)
@ mkdir $(STATICLIB_DIR)
@ mkdir -p $(BINARY_DIR)
@ mkdir -p $(PACKAGE_DIR)
@ mkdir -p $(STATICLIB_DIR)
place-holder/%.c:
place-holder/%.cpp:
$(E) " CHK $(SOURCE_DIRNAME)/`basename $@`"
@ if [ ! -f "$(SOURCE_DIR)/`basename $@`" ]; then \
$(E_NS) " ==> Couldn't found required source file: $(SOURCE_DIRNAME)/`basename $@`"; \
@@ -122,24 +110,36 @@ place-holder/%.c:
fi
$(PMT_INCDIR)/%.h:
$(E) " CHK include/pmt/`basename $@`"
@ if [ ! -f "$(INCLUDE_DIR)/pmt/`basename $@`" ]; then \
$(E_NS) " ==> Couldn't found required header file: include/pmt/`basename $@`"; \
$(E) " CHK include/PartitionManager/`basename $@`"
@ if [ ! -f "$(INCLUDE_DIR)/PartitionManager/`basename $@`" ]; then \
$(E_NS) " ==> Couldn't found required header file: include/PartitionManager/`basename $@`"; \
exit 1; \
fi
$(SOURCE_DIR)/%.o: $(SOURCE_DIR)/%.c
$(E) " CC $(SOURCE_DIRNAME)/`basename $@`"
@ $(CC) $(CFLAGS) -c "$<" || exit 1
$(SOURCE_DIR)/%.o: $(SOURCE_DIR)/%.cpp
$(E) " CXX $(SOURCE_DIRNAME)/`basename $@`"
@ $(CXX) -x c++ $(CXXFLAGS) -c "$<" || exit 1
$(TARGET)_%:
pmt_root:
$(E) " AR lib$@.a"
@ $(AR) rcs "lib$@.a" "$(SOURCE_DIR)/$$(echo "$@" | cut -d'_' -f2).o"
@ $(AR) rcs "lib$@.a" "$(SOURCE_DIR)/Root.o"
pmt_debug:
$(E) " AR lib$@.a"
@ $(AR) rcs "lib$@.a" "$(SOURCE_DIR)/Debug.o"
pmt_listpartitions:
$(E) " AR lib$@.a"
@ $(AR) rcs "lib$@.a" "$(SOURCE_DIR)/ListPartitions.o"
pmt_partitiontool:
$(E) " AR lib$@.a"
@ $(AR) rcs "lib$@.a" "$(SOURCE_DIR)/PartitionTool.o"
make_executable:
$(E) " - Making executable file..."
$(E) " LD $(TARGET)"
@ $(CC) $(CFLAGS) -L$(SOURCE_DIR) $(foreach st,$(STATIC_LIBS),$(shell echo -n -l$(st) )) -o $(TARGET) $(OBJS_EXEC) || exit 1
@ $(CXX) $(CXXFLAGS) -L$(SOURCE_DIR) $(foreach st,$(STATIC_LIBS),$(shell echo -n -l$(st) )) -o $(TARGET) $(OBJS_EXEC) || exit 1
end_progress:
@ abort_build() { \

View File

@@ -1,5 +1,3 @@
export PMT_VERSION="2.7.0"
export PMT_VERSION_CODE=270
export NDK_LINK="https://dl.google.com/android/repository/android-ndk-r27-linux.zip"
export NDK_VERSION="r27"
export NDK_IS="android-ndk"
export PMT_VERSION="2.8.0"
export PMT_VERSION_CODE=280
export NDK_VERSION="r27"