Skip to content

Commit a4dfa55

Browse files
authored
Merge pull request #83 from sisong/CI
optimize diff speed
2 parents 474cbb8 + 64d01d6 commit a4dfa55

38 files changed

+965
-151
lines changed

.github/workflows/ci.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: ci
2+
on: [push, pull_request]
3+
jobs:
4+
make-build:
5+
strategy:
6+
matrix:
7+
platform: [ubuntu-latest, macos-latest]
8+
runs-on: ${{ matrix.platform }}
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: makeAll
12+
run: |
13+
git submodule update --init --recursive
14+
make -j
15+
16+
clang-build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: installClang
21+
run: |
22+
sudo apt-get install -y llvm clang
23+
- name: makeByClang
24+
run: |
25+
git submodule update --init --recursive
26+
make CL=1 -j
27+
28+
xcode-build:
29+
runs-on: macos-latest
30+
steps:
31+
- uses: actions/checkout@v2
32+
- name: buildByXcode
33+
run: |
34+
git submodule update --init --recursive
35+
xcodebuild -workspace builds/xcode/ApkDiffPatch.xcworkspace -scheme ApkNormalized -configuration Release OBJROOT=$PWD/bin SYMROOT=$PWD/bin
36+
xcodebuild -workspace builds/xcode/ApkDiffPatch.xcworkspace -scheme ZipDiff -configuration Release OBJROOT=$PWD/bin SYMROOT=$PWD/bin
37+
xcodebuild -workspace builds/xcode/ApkDiffPatch.xcworkspace -scheme ZipPatch -configuration Release OBJROOT=$PWD/bin SYMROOT=$PWD/bin
38+
39+
ndk-build:
40+
strategy:
41+
matrix:
42+
platform: [ubuntu-latest, macos-latest, windows-latest]
43+
runs-on: ${{ matrix.platform }}
44+
steps:
45+
- uses: actions/checkout@v2
46+
- uses: nttld/setup-ndk@v1.0.6
47+
with:
48+
ndk-version: r16b
49+
- name: buildByAndroidNDK
50+
run: |
51+
git submodule update --init --recursive
52+
cd ./builds/android_ndk_jni_mk
53+
ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk NDK_APPLICATION_MK=./Application.mk
54+
55+
vc-build:
56+
runs-on: windows-latest
57+
steps:
58+
- uses: actions/checkout@v2
59+
- uses: microsoft/setup-msbuild@v1.1
60+
with:
61+
msbuild-architecture: x64
62+
- name: buildByVC
63+
run: |
64+
git submodule update --init --recursive
65+
msbuild builds/vc2019/ApkDiffPatch.sln -t:rebuild -verbosity:diag -property:Configuration=Release

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ xcshareddata
1414
*.sdf
1515
*.ipch
1616
xcuserdata/
17+
builds/vc2019/Release/
18+
builds/vc2019/x64/

.travis.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

HDiffPatch

Submodule HDiffPatch updated 111 files

Makefile

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# args
2+
STATIC_CPP := 0
3+
# used clang?
4+
CL := 0
5+
# build with -m32?
6+
M32 := 0
7+
# build for out min size
8+
MINS := 0
9+
110
ZLIB_OBJ := \
211
zlib1.2.11/adler32.o \
312
zlib1.2.11/compress.o \
@@ -36,7 +45,9 @@ ZIPDIFF_OBJ := \
3645
src/diff/DiffData.o \
3746
src/diff/Differ.o \
3847
src/diff/OldRef.o \
48+
HDiffPatch/libHDiffPatch/HPatchLite/hpatch_lite.o \
3949
HDiffPatch/libHDiffPatch/HDiff/diff.o \
50+
HDiffPatch/libHDiffPatch/HDiff/match_block.o \
4051
HDiffPatch/libHDiffPatch/HDiff/private_diff/bytes_rle.o \
4152
HDiffPatch/libHDiffPatch/HDiff/private_diff/suffix_string.o \
4253
HDiffPatch/libHDiffPatch/HDiff/private_diff/compress_detect.o \
@@ -49,24 +60,46 @@ ZIPDIFF_OBJ := \
4960
lzma/C/LzmaEnc.o \
5061
lzma/C/LzFind.o \
5162
lzma/C/LzFindMt.o \
63+
lzma/C/LzFindOpt.o \
64+
lzma/C/CpuArch.o \
5265
lzma/C/MtCoder.o \
5366
lzma/C/MtDec.o \
5467
lzma/C/Threads.o \
5568
$(ZIPPATCH_OBJ)
5669

57-
CFLAGS += -O2 -DNDEBUG -D_IS_USED_PTHREAD=1
58-
CXXFLAGS += -O2 -DNDEBUG -D_IS_USED_PTHREAD=1
70+
DEF_FLAGS := -O3 -DNDEBUG -D_IS_USED_MULTITHREAD=1 -D_IS_USED_PTHREAD=1
71+
CFLAGS += $(DEF_FLAGS)
72+
CXXFLAGS += $(DEF_FLAGS) -std=c++11
73+
74+
LINK_LIB := -lpthread # link pthread
75+
ifeq ($(M32),0)
76+
else
77+
LINK_LIB += -m32
78+
endif
79+
ifeq ($(MINS),0)
80+
else
81+
LINK_LIB += -Wl,--gc-sections,--as-needed
82+
endif
83+
ifeq ($(CL),1)
84+
CXX := clang++
85+
CC := clang
86+
endif
87+
ifeq ($(STATIC_CPP),0)
88+
LINK_LIB += -lstdc++
89+
else
90+
LINK_LIB += -static-libstdc++
91+
endif
5992

6093
.PHONY: all clean
6194

6295
all: ApkNormalized ZipDiff ZipPatch
6396

6497
ApkNormalized: $(APKNORM_OBJ)
65-
$(CXX) $(APKNORM_OBJ) -lpthread -o ApkNormalized
98+
$(CXX) $(APKNORM_OBJ) $(LINK_LIB) -o ApkNormalized
6699
ZipDiff: $(ZIPDIFF_OBJ)
67-
$(CXX) $(ZIPDIFF_OBJ) -lpthread -o ZipDiff
100+
$(CXX) $(ZIPDIFF_OBJ) $(LINK_LIB) -o ZipDiff
68101
ZipPatch: src/zip_patch.o $(ZIPPATCH_OBJ)
69-
$(CXX) src/zip_patch.o $(ZIPPATCH_OBJ) -lpthread -o ZipPatch
102+
$(CXX) src/zip_patch.o $(ZIPPATCH_OBJ) $(LINK_LIB) -o ZipPatch
70103

71104
clean:
72105
-rm -f ApkNormalized ZipDiff ZipPatch src/zip_patch.o $(ZIPDIFF_OBJ) $(APKNORM_OBJ)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# [ApkDiffPatch]
2-
[![release](https://img.shields.io/badge/release-v1.4.1-blue.svg)](https://github.com/sisong/ApkDiffPatch/releases)
2+
[![release](https://img.shields.io/badge/release-v1.5.0-blue.svg)](https://github.com/sisong/ApkDiffPatch/releases)
33
[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/sisong/ApkDiffPatch/blob/master/LICENSE)
44
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-blue.svg)](https://github.com/sisong/ApkDiffPatch/pulls)
55
[![+issue Welcome](https://img.shields.io/github/issues-raw/sisong/ApkDiffPatch?color=green&label=%2Bissue%20welcome)](https://github.com/sisong/ApkDiffPatch/issues)
66

7-
[![Build Status](https://travis-ci.org/sisong/ApkDiffPatch.svg?branch=master)](https://travis-ci.org/sisong/ApkDiffPatch)
7+
[![Build Status](https://github.com/sisong/ApkDiffPatch/workflows/ci/badge.svg?branch=master)](https://github.com/sisong/ApkDiffPatch/actions?query=workflow%3Aci+branch%3Amaster)
88
[![Build status](https://ci.appveyor.com/api/projects/status/u5tbrqwl72875r6h/branch/master?svg=true)](https://ci.appveyor.com/project/sisong/apkdiffpatch/branch/master)
99

1010
a C++ library and command-line tools for Zip(Jar,Apk) file Diff & Patch; create minimal delta/differential; support [Jar sign](Apk v1 sign) & [Apk v2 sign] & [Apk v3 sign] .

builds/android_ndk_jni_mk/Android.mk

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ Src_Files := $(LOCAL_PATH)/apk_patch_jni.cpp \
3737

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

40-
DEF_FLAGS := -O2 -D_7ZIP_ST -D_IS_USED_MULTITHREAD=1 -D_IS_USED_PTHREAD=1
40+
LOCAL_LDLIBS := -llog
41+
LOCAL_CFLAGS := -Os -DANDROID_NDK -DNDEBUG -D_IS_USED_MULTITHREAD=1 -D_IS_USED_PTHREAD=1 -D_IS_NEED_CACHE_OLD_BY_COVERS=0
42+
ifneq ($(TARGET_ARCH_ABI),armeabi)
43+
LOCAL_CFLAGS += -DUNALIGNED_OK
44+
endif
4145
ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
42-
DEF_FLAGS += -D_LZMA_DEC_OPT
46+
LOCAL_CFLAGS += -D_LZMA_DEC_OPT
4347
endif
4448

45-
LOCAL_LDLIBS := -llog -landroid
46-
LOCAL_CFLAGS := -DANDROID_NDK $(DEF_FLAGS)
4749
include $(BUILD_SHARED_LIBRARY)
4850

builds/android_ndk_jni_mk/Android_DEBUG.mk

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,15 @@ ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
4343
DEF_FLAGS += -D_LZMA_DEC_OPT
4444
endif
4545

46-
LOCAL_LDLIBS := -llog -landroid
47-
LOCAL_CFLAGS := -DANDROID_NDK $(DEF_FLAGS)
46+
LOCAL_LDLIBS := -llog
47+
LOCAL_CFLAGS := -Os -DANDROID_NDK -DNDEBUG -D_IS_USED_MULTITHREAD=1 -D_IS_USED_PTHREAD=1 -D_IS_NEED_CACHE_OLD_BY_COVERS=0
48+
ifneq ($(TARGET_ARCH_ABI),armeabi)
49+
LOCAL_CFLAGS += -DUNALIGNED_OK
50+
endif
51+
ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
52+
LOCAL_CFLAGS += -D_LZMA_DEC_OPT
53+
endif
54+
4855
LOCAL_SANITIZE := address
4956
include $(BUILD_SHARED_LIBRARY)
5057

builds/android_ndk_jni_mk/Application_symbol.mk

Lines changed: 0 additions & 8 deletions
This file was deleted.

builds/codeblocks/ZipDiff.cbp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,11 @@
5555
<Option compilerVar="CC" />
5656
</Unit>
5757
<Unit filename="../../HDiffPatch/libHDiffPatch/HDiff/diff.cpp" />
58+
<Unit filename="../../HDiffPatch/libHDiffPatch/HDiff/match_block.cpp" />
5859
<Unit filename="../../HDiffPatch/libHDiffPatch/HDiff/private_diff/bytes_rle.cpp" />
5960
<Unit filename="../../HDiffPatch/libHDiffPatch/HDiff/private_diff/compress_detect.cpp" />
60-
<Unit filename="../../HDiffPatch/libHDiffPatch/HDiff/private_diff/libdivsufsort/divsufsort.c">
61-
<Option compilerVar="CC" />
62-
</Unit>
63-
<Unit filename="../../HDiffPatch/libHDiffPatch/HDiff/private_diff/libdivsufsort/divsufsort64.c">
64-
<Option compilerVar="CC" />
65-
</Unit>
61+
<Unit filename="../../HDiffPatch/libHDiffPatch/HDiff/private_diff/libdivsufsort/divsufsort.cpp" />
62+
<Unit filename="../../HDiffPatch/libHDiffPatch/HDiff/private_diff/libdivsufsort/divsufsort64.cpp" />
6663
<Unit filename="../../HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/adler_roll.c">
6764
<Option compilerVar="CC" />
6865
</Unit>
@@ -72,17 +69,26 @@
7269
<Unit filename="../../HDiffPatch/libHDiffPatch/HPatch/patch.c">
7370
<Option compilerVar="CC" />
7471
</Unit>
72+
<Unit filename="../../HDiffPatch/libHDiffPatch/HPatchLite/hpatch_lite.c">
73+
<Option compilerVar="CC" />
74+
</Unit>
7575
<Unit filename="../../HDiffPatch/libParallel/parallel_channel.cpp" />
7676
<Unit filename="../../HDiffPatch/libParallel/parallel_import.cpp" />
7777
<Unit filename="../../lzma/C/Alloc.c">
7878
<Option compilerVar="CC" />
7979
</Unit>
80+
<Unit filename="../../lzma/C/CpuArch.c">
81+
<Option compilerVar="CC" />
82+
</Unit>
8083
<Unit filename="../../lzma/C/LzFind.c">
8184
<Option compilerVar="CC" />
8285
</Unit>
8386
<Unit filename="../../lzma/C/LzFindMt.c">
8487
<Option compilerVar="CC" />
8588
</Unit>
89+
<Unit filename="../../lzma/C/LzFindOpt.c">
90+
<Option compilerVar="CC" />
91+
</Unit>
8692
<Unit filename="../../lzma/C/Lzma2Dec.c">
8793
<Option compilerVar="CC" />
8894
</Unit>

0 commit comments

Comments
 (0)