-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from sisong/dev
add hpatchi NDK demo & fix bug
- Loading branch information
Showing
15 changed files
with
172 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,22 @@ jobs: | |
xcodebuild -workspace builds/xcode/HPatchLite.xcworkspace -scheme hpatchi -configuration Release OBJROOT=$PWD/bin SYMROOT=$PWD/bin | ||
xcodebuild -workspace builds/xcode/HPatchLite.xcworkspace -scheme hdiffi -configuration Release OBJROOT=$PWD/bin SYMROOT=$PWD/bin | ||
ndk-build: | ||
strategy: | ||
matrix: | ||
platform: [ubuntu-latest, macos-latest, windows-latest] | ||
runs-on: ${{ matrix.platform }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: nttld/[email protected] | ||
with: | ||
ndk-version: r16b | ||
- name: buildByAndroidNDK | ||
run: | | ||
git submodule update --init --recursive | ||
cd ./builds/android_ndk_jni_mk | ||
ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk NDK_APPLICATION_MK=./Application.mk | ||
vc-build: | ||
runs-on: windows-latest | ||
steps: | ||
|
Submodule HDiffPatch
updated
4 files
+1 −1 | README.md | |
+1 −1 | libHDiffPatch/HPatch/patch_types.h | |
+1 −1 | libHDiffPatch/HPatchLite/hpatch_lite.c | |
+1 −1 | libHDiffPatch/HPatchLite/hpatch_lite.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
LOCAL_PATH := $(call my-dir) | ||
include $(CLEAR_VARS) | ||
|
||
LOCAL_MODULE := hpatchi | ||
|
||
# args | ||
LZMA := 0 | ||
TUZ := 1 | ||
ZLIB := 1 # -lz dynamic link unsafe for inflate_state | ||
|
||
ifeq ($(LZMA),0) | ||
Lzma_Files := | ||
else | ||
# https://github.com/sisong/lzma | ||
LZMA_PATH := $(LOCAL_PATH)/../../lzma/C/ | ||
Lzma_Files := $(LZMA_PATH)/LzmaDec.c \ | ||
$(LZMA_PATH)/Lzma2Dec.c | ||
ifeq ($(TARGET_ARCH_ABI),arm64-v8a) | ||
Lzma_Files += $(LZMA_PATH)/../Asm/arm64/LzmaDecOpt.S | ||
endif | ||
endif | ||
ifeq ($(TUZ),0) | ||
Tuz_Files := | ||
else | ||
# https://github.com/sisong/tinyuz | ||
TUZ_PATH := $(LOCAL_PATH)/../../tinyuz/decompress/ | ||
Tuz_Files := $(TUZ_PATH)/tuz_dec.c | ||
endif | ||
ifeq ($(ZLIB),0) | ||
else | ||
# http://zlib.net/ https://github.com/madler/zlib | ||
ZLIB_PATH := $(LOCAL_PATH)/../../zlib/ | ||
endif | ||
|
||
HDP_PATH := $(LOCAL_PATH)/../../HDiffPatch | ||
Hdp_Files := $(HDP_PATH)/file_for_patch.c \ | ||
$(HDP_PATH)/libHDiffPatch/HPatchLite/hpatch_lite.c | ||
|
||
Src_Files := $(LOCAL_PATH)/hpatchi_jni.c \ | ||
$(LOCAL_PATH)/hpatchi.c | ||
|
||
DEF_FLAGS := -Os -D_IS_NEED_DEFAULT_CompressPlugin=0 | ||
ifeq ($(LZMA),0) | ||
else | ||
DEF_FLAGS += -D_CompressPlugin_lzma -D_CompressPlugin_lzma2 -D_7ZIP_ST -I$(LZMA_PATH) | ||
ifeq ($(TARGET_ARCH_ABI),arm64-v8a) | ||
DEF_FLAGS += -D_LZMA_DEC_OPT | ||
endif | ||
endif | ||
ifeq ($(TUZ),0) | ||
else | ||
DEF_FLAGS += -D_CompressPlugin_tuz -I$(TUZ_PATH) | ||
endif | ||
ifeq ($(ZLIB),0) | ||
else | ||
DEF_FLAGS += -D_CompressPlugin_zlib -I$(ZLIB_PATH) | ||
endif | ||
|
||
LOCAL_SRC_FILES := $(Src_Files) $(Lzma_Files) $(Tuz_Files) $(Hdp_Files) | ||
LOCAL_LDLIBS := -llog | ||
ifeq ($(ZLIB),0) | ||
else | ||
LOCAL_LDLIBS += -lz | ||
endif | ||
LOCAL_CFLAGS := -DANDROID_NDK -DNDEBUG $(DEF_FLAGS) | ||
include $(BUILD_SHARED_LIBRARY) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
APP_PLATFORM := android-14 | ||
APP_CFLAGS += -Wno-error=format-security | ||
APP_CFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden | ||
APP_CFLAGS += -ffunction-sections -fdata-sections | ||
APP_LDFLAGS += -Wl,--gc-sections | ||
APP_BUILD_SCRIPT := Android.mk | ||
APP_ABI := armeabi armeabi-v7a arm64-v8a x86 x86_64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk NDK_APPLICATION_MK=Application.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk NDK_APPLICATION_MK=Application.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// hpatchi.c | ||
// Created by sisong on 2022-08-19. | ||
#include "hpatchi.h" | ||
|
||
#ifndef _IS_USED_MULTITHREAD | ||
#define _IS_USED_MULTITHREAD 0 | ||
#endif | ||
#define _IS_NEED_MAIN 0 | ||
#define _IS_NEED_ALL_CompressPlugin 0 | ||
#include "../../hpatchi.c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// hpatchi.h | ||
// Created by sisong on 2022-08-19. | ||
#ifndef hpatchi_h | ||
#define hpatchi_h | ||
#include <assert.h> | ||
#include <string.h> | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
#define H_PATCH_EXPORT __attribute__((visibility("default"))) | ||
|
||
// return THPatchiResult, 0 is ok | ||
// 'diffFileName' file is create by hdiffi app,or by create_lite_diff() | ||
int hpatchi(const char *oldFileName,const char *diffFileName, | ||
const char *outNewFileName, size_t cacheMemory) H_PATCH_EXPORT; | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif // hpatchi_h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// hpatch_jni.c | ||
// Created by sisong on 2022-08-19. | ||
#include <jni.h> | ||
#include "hpatchi.h" | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
JNIEXPORT int | ||
Java_com_github_sisong_hpatchi_patch(JNIEnv* jenv,jobject jobj, | ||
jstring oldFileName,jstring diffFileName, | ||
jstring outNewFileName,jlong cacheMemory){ | ||
const char* cOldFileName = (*jenv)->GetStringUTFChars(jenv,oldFileName, NULL); | ||
const char* cDiffFileName = (*jenv)->GetStringUTFChars(jenv,diffFileName, NULL); | ||
const char* cOutNewFileName = (*jenv)->GetStringUTFChars(jenv,outNewFileName, NULL); | ||
size_t cCacheMemory=(size_t)cacheMemory; | ||
assert((jlong)cCacheMemory==cacheMemory); | ||
int result=hpatchi(cOldFileName,cDiffFileName,cOutNewFileName,cCacheMemory); | ||
(*jenv)->ReleaseStringUTFChars(jenv,outNewFileName,cOutNewFileName); | ||
(*jenv)->ReleaseStringUTFChars(jenv,diffFileName,cDiffFileName); | ||
(*jenv)->ReleaseStringUTFChars(jenv,oldFileName,cOldFileName); | ||
return result; | ||
} | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
9 changes: 9 additions & 0 deletions
9
builds/android_ndk_jni_mk/java/com/github/sisong/hpatchi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.github.sisong; | ||
|
||
public class hpatchi{ | ||
// return THPatchiResult, 0 is ok | ||
// 'diffFileName' file is create by hdiffi app,or by create_lite_diff() | ||
// cacheMemory recommended 32*2024 256*1024 ... | ||
public static native int patch(String oldFileName,String diffFileName, | ||
String outNewFileName,long cacheMemory); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule tinyuz
updated
6 files
+1 −1 | README.md | |
+2 −2 | README_cn.md | |
+4 −2 | compress/tuz_enc.cpp | |
+13 −9 | compress/tuz_enc_private/tuz_enc_clip.cpp | |
+2 −1 | compress/tuz_enc_private/tuz_enc_clip.h | |
+1 −1 | decompress/tuz_types.h |