Skip to content

Commit

Permalink
Merge pull request #99 from sisong/dev
Browse files Browse the repository at this point in the history
support Android 15+ run with 16KB page size
  • Loading branch information
sisong authored Aug 6, 2024
2 parents 9a48a5c + ec0974c commit 35892d4
Show file tree
Hide file tree
Showing 22 changed files with 470 additions and 287 deletions.
2 changes: 1 addition & 1 deletion HDiffPatch
Submodule HDiffPatch updated 38 files
+21 −11 .github/workflows/ci.yml
+18 −1 CHANGELOG.md
+76 −22 Makefile
+21 −9 README.md
+23 −10 README_cn.md
+113 −19 bsdiff_wrapper/bsdiff_wrapper.cpp
+5 −5 bsdiff_wrapper/bsdiff_wrapper.h
+11 −9 bsdiff_wrapper/bspatch_wrapper.c
+3 −3 bsdiff_wrapper/bspatch_wrapper.h
+1 −0 builds/android_ndk_jni_mk/Application.mk
+17 −0 builds/codeblocks/HDiffZ.cbp
+14 −0 builds/codeblocks/HPatchZ.cbp
+12 −0 builds/codeblocks/unitTest.cbp
+20 −2 builds/vc/HDiffPatch.sln
+11 −8 builds/vc/HDiffZ.vcxproj
+11 −8 builds/vc/HPatchZ.vcxproj
+332 −0 builds/vc/libdeflate.vcxproj
+6 −0 builds/xcode/HDiffPatch.xcworkspace/contents.xcworkspacedata
+8 −0 builds/xcode/HDiffPatch.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
+12 −2 builds/xcode/hdiffz.xcodeproj/project.pbxproj
+12 −12 builds/xcode/hpatchz.xcodeproj/project.pbxproj
+286 −0 builds/xcode/libdeflate.xcodeproj/project.pbxproj
+7 −0 builds/xcode/libdeflate.xcodeproj/project.xcworkspace/contents.xcworkspacedata
+0 −2 builds/xcode/lzma.xcodeproj/project.pbxproj
+308 −0 builds/xcode/zlib.xcodeproj/project.pbxproj
+7 −0 builds/xcode/zlib.xcodeproj/project.xcworkspace/contents.xcworkspacedata
+32 −6 builds/xcode_iOS_hpatchz/hpatchz.xcodeproj/project.pbxproj
+6 −3 checksum_plugin_demo.h
+208 −42 compress_plugin_demo.h
+320 −19 decompress_plugin_demo.h
+33 −4 dirDiffPatch/dir_diff/dir_diff.cpp
+1 −0 dirDiffPatch/dir_diff/dir_diff.h
+120 −49 hdiffz.cpp
+50 −26 hpatchz.c
+1 −0 libHDiffPatch/HDiff/diff_types.h
+1 −1 libHDiffPatch/HPatch/patch.c
+2 −2 libHDiffPatch/HPatch/patch_types.h
+8 −2 test/unit_test.cpp
53 changes: 36 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# args
STATIC_CPP := 0
STATIC_C := 0
# used clang?
CL := 0
# build with -m32?
Expand All @@ -21,17 +22,13 @@ ZLIB_OBJ := \
zlib1.3.1/zutil.o

ZIPPATCH_OBJ := \
src/patch/NewStream.o \
src/patch/OldStream.o \
src/patch/Patcher.o \
src/patch/ZipDiffData.o \
src/patch/Zipper.o \
HDiffPatch/libHDiffPatch/HPatch/patch.o \
HDiffPatch/file_for_patch.o \
HDiffPatch/libParallel/parallel_import.o \
HDiffPatch/libParallel/parallel_channel.o \
lzma/C/LzmaDec.o \
lzma/C/Lzma2Dec.o \
$(ZLIB_OBJ)

APKNORM_OBJ := \
Expand All @@ -40,6 +37,12 @@ APKNORM_OBJ := \
src/diff/DiffData.o \
$(ZIPPATCH_OBJ)

ZIPPATCH_OBJ += \
src/patch/NewStream.o \
src/patch/Patcher.o \
lzma/C/LzmaDec.o \
lzma/C/Lzma2Dec.o

ZIPDIFF_OBJ := \
src/zip_diff.o \
src/diff/DiffData.o \
Expand Down Expand Up @@ -68,39 +71,55 @@ ZIPDIFF_OBJ := \
lzma/C/Threads.o \
$(ZIPPATCH_OBJ)

ZIPPATCH_OBJ += src/zip_patch.o

DEF_FLAGS := -O3 -DNDEBUG -D_IS_USED_MULTITHREAD=1 -D_IS_USED_CPP11THREAD=1
ifeq ($(MINS),0)
else
DEF_FLAGS += \
-s \
-Wno-error=format-security \
-fvisibility=hidden \
-ffunction-sections -fdata-sections \
-ffat-lto-objects -flto
CXXFLAGS += -fvisibility-inlines-hidden
endif
CFLAGS += $(DEF_FLAGS)
CXXFLAGS += $(DEF_FLAGS) -std=c++11

LINK_LIB := -lpthread # link pthread
DEF_LINK := -lpthread # link pthread
ifeq ($(M32),0)
else
LINK_LIB += -m32
DEF_LINK += -m32
endif
ifeq ($(MINS),0)
else
LINK_LIB += -Wl,--gc-sections,--as-needed
DEF_LINK += -s -Wl,--gc-sections,--as-needed
endif
ifeq ($(STATIC_CPP),0)
DEF_LINK += -lstdc++
else
DEF_LINK += -static-libstdc++
endif
ifeq ($(STATIC_C),0)
else
DEF_LINK += -static
endif
ifeq ($(CL),1)
CXX := clang++
CC := clang
endif
ifeq ($(STATIC_CPP),0)
LINK_LIB += -lstdc++
else
LINK_LIB += -static-libstdc++
endif

.PHONY: all clean

all: ApkNormalized ZipDiff ZipPatch

ApkNormalized: $(APKNORM_OBJ)
$(CXX) $(APKNORM_OBJ) $(LINK_LIB) -o ApkNormalized
$(CXX) $(APKNORM_OBJ) $(DEF_LINK) -o ApkNormalized
ZipDiff: $(ZIPDIFF_OBJ)
$(CXX) $(ZIPDIFF_OBJ) $(LINK_LIB) -o ZipDiff
ZipPatch: src/zip_patch.o $(ZIPPATCH_OBJ)
$(CXX) src/zip_patch.o $(ZIPPATCH_OBJ) $(LINK_LIB) -o ZipPatch
$(CXX) $(ZIPDIFF_OBJ) $(DEF_LINK) -o ZipDiff
ZipPatch: $(ZIPPATCH_OBJ)
$(CXX) $(ZIPPATCH_OBJ) $(DEF_LINK) -o ZipPatch

clean:
-rm -f ApkNormalized ZipDiff ZipPatch src/zip_patch.o $(ZIPDIFF_OBJ) $(APKNORM_OBJ)
-rm -f ApkNormalized ZipDiff ZipPatch $(ZIPDIFF_OBJ) $(ZIPPATCH_OBJ) $(APKNORM_OBJ)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# [ApkDiffPatch]
[![release](https://img.shields.io/badge/release-v1.7.2-blue.svg)](https://github.com/sisong/ApkDiffPatch/releases)
[![release](https://img.shields.io/badge/release-v1.8.0-blue.svg)](https://github.com/sisong/ApkDiffPatch/releases)
[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/sisong/ApkDiffPatch/blob/master/LICENSE)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-blue.svg)](https://github.com/sisong/ApkDiffPatch/pulls)
[![+issue Welcome](https://img.shields.io/github/issues-raw/sisong/ApkDiffPatch?color=green&label=%2Bissue%20welcome)](https://github.com/sisong/ApkDiffPatch/issues)
Expand Down
43 changes: 2 additions & 41 deletions builds/android_ndk_jni_mk/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,9 @@ include $(CLEAR_VARS)

LOCAL_MODULE := apkpatch

Lzma_Files := $(LOCAL_PATH)/../../lzma/C/LzmaDec.c \
$(LOCAL_PATH)/../../lzma/C/Lzma2Dec.c
ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
Lzma_Files += $(LOCAL_PATH)/../../lzma/Asm/arm64/LzmaDecOpt.S
endif
include $(LOCAL_PATH)/Android_i.mk

ZLIB_PATH := $(LOCAL_PATH)/../../zlib1.3.1
Zlib_Files := $(ZLIB_PATH)/crc32.c \
$(ZLIB_PATH)/deflate.c \
$(ZLIB_PATH)/inflate.c \
$(ZLIB_PATH)/zutil.c \
$(ZLIB_PATH)/adler32.c \
$(ZLIB_PATH)/trees.c \
$(ZLIB_PATH)/inftrees.c \
$(ZLIB_PATH)/inffast.c

HDP_PATH := $(LOCAL_PATH)/../../HDiffPatch
Hdp_Files := $(HDP_PATH)/file_for_patch.c \
$(HDP_PATH)/libHDiffPatch/HPatch/patch.c \
$(HDP_PATH)/libParallel/parallel_import.cpp \
$(HDP_PATH)/libParallel/parallel_channel.cpp

ADP_PATH := $(LOCAL_PATH)/../../src/patch
Adp_Files := $(ADP_PATH)/NewStream.cpp \
$(ADP_PATH)/OldStream.cpp \
$(ADP_PATH)/Patcher.cpp \
$(ADP_PATH)/ZipDiffData.cpp \
$(ADP_PATH)/Zipper.cpp

Src_Files := $(LOCAL_PATH)/apk_patch_jni.cpp \
$(LOCAL_PATH)/apk_patch.cpp

LOCAL_SRC_FILES := $(Src_Files) $(Lzma_Files) $(Zlib_Files) $(Hdp_Files) $(Adp_Files)

LOCAL_LDLIBS := -llog
LOCAL_CFLAGS := -Os -DANDROID_NDK -DNDEBUG -D_IS_USED_MULTITHREAD=1 -D_IS_USED_PTHREAD=1 -D_IS_NEED_CACHE_OLD_BY_COVERS=0
ifneq ($(TARGET_ARCH_ABI),armeabi)
LOCAL_CFLAGS += -DUNALIGNED_OK
endif
ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
LOCAL_CFLAGS += -DZ7_LZMA_DEC_OPT
endif
LOCAL_CFLAGS += -DNDEBUG

include $(BUILD_SHARED_LIBRARY)

49 changes: 2 additions & 47 deletions builds/android_ndk_jni_mk/Android_DEBUG.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,9 @@ include $(CLEAR_VARS)
LOCAL_MODULE := apkpatch
LOCAL_ARM_MODE := arm

Lzma_Files := $(LOCAL_PATH)/../../lzma/C/LzmaDec.c \
$(LOCAL_PATH)/../../lzma/C/Lzma2Dec.c
ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
Lzma_Files += $(LOCAL_PATH)/../../lzma/Asm/arm64/LzmaDecOpt.S
endif

ZLIB_PATH := $(LOCAL_PATH)/../../zlib1.3.1
Zlib_Files := $(ZLIB_PATH)/crc32.c \
$(ZLIB_PATH)/deflate.c \
$(ZLIB_PATH)/inflate.c \
$(ZLIB_PATH)/zutil.c \
$(ZLIB_PATH)/adler32.c \
$(ZLIB_PATH)/trees.c \
$(ZLIB_PATH)/inftrees.c \
$(ZLIB_PATH)/inffast.c

HDP_PATH := $(LOCAL_PATH)/../../HDiffPatch
Hdp_Files := $(HDP_PATH)/file_for_patch.c \
$(HDP_PATH)/libHDiffPatch/HPatch/patch.c \
$(HDP_PATH)/libParallel/parallel_import.cpp \
$(HDP_PATH)/libParallel/parallel_channel.cpp

ADP_PATH := $(LOCAL_PATH)/../../src/patch
Adp_Files := $(ADP_PATH)/NewStream.cpp \
$(ADP_PATH)/OldStream.cpp \
$(ADP_PATH)/Patcher.cpp \
$(ADP_PATH)/ZipDiffData.cpp \
$(ADP_PATH)/Zipper.cpp

Src_Files := $(LOCAL_PATH)/apk_patch_jni.cpp \
$(LOCAL_PATH)/apk_patch.cpp

LOCAL_SRC_FILES := $(Src_Files) $(Lzma_Files) $(Zlib_Files) $(Hdp_Files) $(Adp_Files)

DEF_FLAGS := -O1 -DZ7_ST -D_IS_USED_MULTITHREAD=1 -D_IS_USED_PTHREAD=1
ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
DEF_FLAGS += -DZ7_LZMA_DEC_OPT
endif

LOCAL_LDLIBS := -llog
LOCAL_CFLAGS := -Os -DANDROID_NDK -DNDEBUG -D_IS_USED_MULTITHREAD=1 -D_IS_USED_PTHREAD=1 -D_IS_NEED_CACHE_OLD_BY_COVERS=0
ifneq ($(TARGET_ARCH_ABI),armeabi)
LOCAL_CFLAGS += -DUNALIGNED_OK
endif
ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
LOCAL_CFLAGS += -DZ7_LZMA_DEC_OPT
endif
include $(LOCAL_PATH)/Android_i.mk

LOCAL_CFLAGS += -DDEBUG=1
LOCAL_SANITIZE := address
include $(BUILD_SHARED_LIBRARY)

44 changes: 44 additions & 0 deletions builds/android_ndk_jni_mk/Android_i.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

Lzma_Files := $(LOCAL_PATH)/../../lzma/C/LzmaDec.c \
$(LOCAL_PATH)/../../lzma/C/Lzma2Dec.c
ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
Lzma_Files += $(LOCAL_PATH)/../../lzma/Asm/arm64/LzmaDecOpt.S
endif

ZLIB_PATH := $(LOCAL_PATH)/../../zlib1.3.1
Zlib_Files := $(ZLIB_PATH)/crc32.c \
$(ZLIB_PATH)/deflate.c \
$(ZLIB_PATH)/inflate.c \
$(ZLIB_PATH)/zutil.c \
$(ZLIB_PATH)/adler32.c \
$(ZLIB_PATH)/trees.c \
$(ZLIB_PATH)/inftrees.c \
$(ZLIB_PATH)/inffast.c

HDP_PATH := $(LOCAL_PATH)/../../HDiffPatch
Hdp_Files := $(HDP_PATH)/file_for_patch.c \
$(HDP_PATH)/libHDiffPatch/HPatch/patch.c \
$(HDP_PATH)/libParallel/parallel_import.cpp \
$(HDP_PATH)/libParallel/parallel_channel.cpp

ADP_PATH := $(LOCAL_PATH)/../../src/patch
Adp_Files := $(ADP_PATH)/NewStream.cpp \
$(ADP_PATH)/OldStream.cpp \
$(ADP_PATH)/Patcher.cpp \
$(ADP_PATH)/ZipDiffData.cpp \
$(ADP_PATH)/Zipper.cpp

Src_Files := $(LOCAL_PATH)/apk_patch_jni.cpp \
$(LOCAL_PATH)/apk_patch.cpp

LOCAL_SRC_FILES := $(Src_Files) $(Lzma_Files) $(Zlib_Files) $(Hdp_Files) $(Adp_Files)

LOCAL_LDLIBS := -llog
LOCAL_CFLAGS := -Os -DANDROID_NDK -D_IS_USED_MULTITHREAD=1 -D_IS_USED_PTHREAD=1 -D_IS_NEED_CACHE_OLD_BY_COVERS=0
ifneq ($(TARGET_ARCH_ABI),armeabi)
LOCAL_CFLAGS += -DUNALIGNED_OK
endif
ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
LOCAL_CFLAGS += -DZ7_LZMA_DEC_OPT
endif

3 changes: 2 additions & 1 deletion builds/android_ndk_jni_mk/Application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ APP_PLATFORM := android-14
APP_CFLAGS += -Wno-error=format-security
APP_CFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
APP_CFLAGS += -ffunction-sections -fdata-sections
APP_CPPFLAGS += -fexceptions
APP_LDFLAGS += -Wl,--gc-sections
APP_LDFLAGS += -Wl,-z,max-page-size=16384
APP_STL := stlport_static
APP_CPPFLAGS := -fexceptions
APP_BUILD_SCRIPT := Android.mk
APP_ABI := armeabi-v7a arm64-v8a x86 x86_64
5 changes: 3 additions & 2 deletions builds/android_ndk_jni_mk/Application_DEBUG.mk
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
APP_PLATFORM := android-27
APP_STL := c++_shared
APP_CFLAGS := -fsanitize=address -fno-omit-frame-pointer
APP_LDFLAGS := -fsanitize=address
APP_CPPFLAGS := -fexceptions
APP_LDFLAGS := -fsanitize=address
APP_LDFLAGS += -Wl,-z,max-page-size=16384
APP_STL := c++_shared
APP_BUILD_SCRIPT := Android_DEBUG.mk
APP_OPTIM := debug
NDK_DEBUG := 1
Expand Down
2 changes: 1 addition & 1 deletion lzma
Submodule lzma updated 259 files
Loading

0 comments on commit 35892d4

Please sign in to comment.