Skip to content

Commit fd75602

Browse files
authored
Merge pull request #357 from sisong/dev
diffFile created by xdelta3,open-vcdiff, always patch in mem; + xcode iOS's static lib
2 parents 4ab860a + bc1d59a commit fd75602

File tree

18 files changed

+979
-46
lines changed

18 files changed

+979
-46
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ else
274274
endif
275275
ifeq ($(ARM64ASM),0)
276276
else
277-
DEF_FLAGS += -D_LZMA_DEC_OPT
277+
DEF_FLAGS += -DZ7_LZMA_DEC_OPT
278278
endif
279279
endif
280280
ifeq ($(ZSTD),0)

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# [HDiffPatch](https://github.com/sisong/HDiffPatch)
2-
[![release](https://img.shields.io/badge/release-v4.6.5-blue.svg)](https://github.com/sisong/HDiffPatch/releases)
2+
[![release](https://img.shields.io/badge/release-v4.6.6-blue.svg)](https://github.com/sisong/HDiffPatch/releases)
33
[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/sisong/HDiffPatch/blob/master/LICENSE)
44
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-blue.svg)](https://github.com/sisong/HDiffPatch/pulls)
55
[![+issue Welcome](https://img.shields.io/github/issues-raw/sisong/HDiffPatch?color=green&label=%2Bissue%20welcome)](https://github.com/sisong/HDiffPatch/issues)
@@ -27,7 +27,7 @@ NOTE: *This library does not deal with file metadata, such as file last wirte ti
2727
( release files build by projects in path `HDiffPatch/builds` )
2828
use cmdline to create a delta:
2929
`$hdiffz -m-6 -SD -c-zstd-21-24 -d oldPath newPath outDiffFile`
30-
if file'size is very large, try changing `-m-6` to `-s-64`
30+
if file is very large, try changing `-m-6` to `-s-64`
3131
apply the delta:
3232
`$hpatchz oldPath diffFile outNewPath`
3333

@@ -206,10 +206,10 @@ memory options:
206206
requires (cacheSize + 4*decompress buffer size)+O(1) bytes of memory.
207207
if diffFile is single compressed diffData(created by hdiffz -SD-stepSize), then requires
208208
(cacheSize+ stepSize + 1*decompress buffer size)+O(1) bytes of memory;
209-
if diffFile is created by hdiffz -BSD,bsdiff4, hdiffz -VCD,xdelta3,open-vcdiff, then requires
209+
if diffFile is created by hdiffz -BSD,bsdiff4, hdiffz -VCD, then requires
210210
(cacheSize + 3*decompress buffer size)+O(1) bytes of memory;
211-
if diffFile is VCDIFF: if created by hdiffz -VCD, then recommended patch by -s;
212-
if created by xdelta3,open-vcdiff, then recommended patch by -m.
211+
if diffFile is created by xdelta3,open-vcdiff, then requires
212+
(sourceWindowSize+targetWindowSize + 3*decompress buffer size)+O(1) bytes of memory.
213213
-m oldPath all loaded into Memory;
214214
requires (oldFileSize + 4*decompress buffer size)+O(1) bytes of memory.
215215
if diffFile is single compressed diffData(created by hdiffz -SD-stepSize), then requires
@@ -446,11 +446,11 @@ case list:
446446
**sfpatcher -1 zstd** v1.1.1 diff with `-o-1 -c-zstd-21-23 -m-1 -step-3m -lp-512k -p-8 -cache -d {old} {new} {pat}`
447447
**sfpatcher -2 lzma2** diff with `-o-2 -c-lzma2-9-4m -m-1 -step-2m -lp-8m -p-8 -cache -d {old} {new} {pat}`
448448
sfpatcher patch with `-lp -p-8 {old} {pat} {new}`
449-
adding test hpatchz&hsynz&sfpatcher on Android, CPU Kirin 980(2×A76 2.6G + 2×A76 1.92G + 4×A55 1.8G)
449+
adding test hpatchz&hsynz&sfpatcher on Android, CPU Kirin980(2×A76 2.6G + 2×A76 1.92G + 4×A55 1.8G)
450450
( [archive-patcher](https://github.com/google/archive-patcher), [sfpatcher](https://github.com/sisong/sfpatcher) optimized diff&patch between apk files )
451451

452452
**test result average**:
453-
|Program|compress|diff mem|speed|patch mem|max mem|speed|Kirin 980|
453+
|Program|compress|diff mem|speed|patch mem|max mem|speed|arm Kirin980|
454454
|:----|----:|----:|----:|----:|----:|----:|----:|
455455
|zstd --patch-from|53.18%|2199M|3.6MB/s|209M|596M|609MB/s|
456456
|xdelta3|54.51%|422M|3.8MB/s|98M|99M|170MB/s|

builds/android_ndk_jni_mk/Android.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ ifeq ($(LZMA),0)
106106
else
107107
DEF_FLAGS += -D_CompressPlugin_lzma -D_CompressPlugin_lzma2 -DZ7_ST -I$(LZMA_PATH)
108108
ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
109-
DEF_FLAGS += -D_LZMA_DEC_OPT
109+
DEF_FLAGS += -DZ7_LZMA_DEC_OPT
110110
endif
111111
ifeq ($(VCD),0)
112112
else

builds/android_ndk_jni_mk/hpatch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ void bz_internal_error(int errcode){
3131
int hpatchz(const char *oldFileName,const char *diffFileName,
3232
const char *outNewFileName, size_t cacheMemory){
3333
return hpatch(oldFileName,diffFileName,outNewFileName,
34-
hpatch_FALSE,cacheMemory,0,0,1);
34+
hpatch_FALSE,cacheMemory,0,0,1,1);
3535
}

builds/android_ndk_jni_mk/hpatch.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@
77
#ifdef __cplusplus
88
extern "C" {
99
#endif
10-
#define H_PATCH_EXPORT __attribute__((visibility("default")))
11-
10+
#ifndef H_PATCH_EXPORT
11+
# if ( __GNUC__ >= 4 )
12+
#define H_PATCH_EXPORT __attribute__((visibility("default")))
13+
# else
14+
#define H_PATCH_EXPORT
15+
# endif
16+
#endif
17+
1218
// return THPatchResult, 0 is ok
13-
// 'diffFileName' file is create by hdiffz app,or by create_compressed_diff(),create_compressed_diff_stream()
1419
int hpatchz(const char *oldFileName,const char *diffFileName,
1520
const char *outNewFileName, size_t cacheMemory) H_PATCH_EXPORT;
1621

builds/android_ndk_jni_mk/java/com/github/sisong/HPatch.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,17 @@ public class HPatch{
55
// auto load libhpatchz.so ?
66
// static { System.loadLibrary("hpatchz"); }
77

8-
// return THPatchResult, 0 is ok
9-
// different cacheMemory only affects patch speed, if cacheMemory<0 then default 256*1024;
10-
// if diffFile created by hdiffz,hdiffz -SD,hdiffz -VCD,bsdiff4,hdiffz -BSD,
11-
// then cacheMemory recommended 256*1024,1024*1024,...
12-
// if diffFile created by xdelta3(-S,-S lzma),open-vcdiff, and patch very slow,
13-
// then cacheMemory recommended sourceWindowSize+targetWindowSize+256*1024;
14-
// ( window sizes is set when diff, C API getVcDiffInfo() can got values. )
15-
// if diffFile created by bsdiff4, and patch very slow,
16-
// then cacheMemory recommended oldFileSize+256*1024;
17-
public static native int patch(String oldFileName,String diffFileName,
18-
String outNewFileName,long cacheMemory);
19-
20-
public static int patch(String oldFileName,String diffFileName,String outNewFileName){
8+
//patch:
9+
// return THPatchResult, 0 is ok
10+
// cacheMemory:
11+
// cacheMemory is used for file IO, different cacheMemory only affects patch speed;
12+
// recommended 256*1024,1024*1024,... if cacheMemory<0 then default 256*1024;
13+
// NOTE: if diffFile created by $xdelta3(-S,-S lzma),$open-vcdiff, alloc memory+=sourceWindowSize+targetWindowSize;
14+
// ( sourceWindowSize & targetWindowSize is set when diff, C API getVcDiffInfo() can got values from diffFile. )
15+
// if diffFile created by $bsdiff4, and patch very slow,
16+
// then cacheMemory recommended oldFileSize+256*1024;
17+
public static native int patch(String oldFileName,String diffFileName,String outNewFileName,long cacheMemory);
18+
public static final int patch(String oldFileName,String diffFileName,String outNewFileName){
2119
return patch(oldFileName,diffFileName,outNewFileName,-1);
2220
}
2321
}

builds/vc/lzma.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@
273273
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
274274
<ClCompile>
275275
<WarningLevel>Level3</WarningLevel>
276-
<PreprocessorDefinitions>WIN32;_LZMA_DEC_OPT;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
276+
<PreprocessorDefinitions>WIN32;Z7_LZMA_DEC_OPT;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
277277
<PrecompiledHeader>NotUsing</PrecompiledHeader>
278278
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
279279
<PrecompiledHeaderFile>

builds/xcode/hdiffz.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
0D571A64275CEB3B00672D57 /* liblzma.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0D571A63275CEB3B00672D57 /* liblzma.a */; };
10+
0D225ADB2A997B6200DBD5B1 /* liblzma.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0D225ADA2A997B6200DBD5B1 /* liblzma.a */; };
1111
0D571A66275CEB3B00672D57 /* libzstd.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0D571A65275CEB3B00672D57 /* libzstd.a */; };
1212
0D571A69275CF68900672D57 /* match_block.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D571A68275CF68900672D57 /* match_block.cpp */; };
1313
0D571A6F275CF71A00672D57 /* bspatch_wrapper.c in Sources */ = {isa = PBXBuildFile; fileRef = 0D571A6B275CF71A00672D57 /* bspatch_wrapper.c */; };
@@ -57,7 +57,7 @@
5757
/* End PBXCopyFilesBuildPhase section */
5858

5959
/* Begin PBXFileReference section */
60-
0D571A63275CEB3B00672D57 /* liblzma.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = liblzma.a; sourceTree = BUILT_PRODUCTS_DIR; };
60+
0D225ADA2A997B6200DBD5B1 /* liblzma.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = liblzma.a; sourceTree = BUILT_PRODUCTS_DIR; };
6161
0D571A65275CEB3B00672D57 /* libzstd.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libzstd.a; sourceTree = BUILT_PRODUCTS_DIR; };
6262
0D571A68275CF68900672D57 /* match_block.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = match_block.cpp; sourceTree = "<group>"; };
6363
0D571A6B275CF71A00672D57 /* bspatch_wrapper.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = bspatch_wrapper.c; path = ../../bsdiff_wrapper/bspatch_wrapper.c; sourceTree = "<group>"; };
@@ -155,8 +155,8 @@
155155
isa = PBXFrameworksBuildPhase;
156156
buildActionMask = 2147483647;
157157
files = (
158+
0D225ADB2A997B6200DBD5B1 /* liblzma.a in Frameworks */,
158159
0D571A66275CEB3B00672D57 /* libzstd.a in Frameworks */,
159-
0D571A64275CEB3B00672D57 /* liblzma.a in Frameworks */,
160160
D690AEFD1F2097D30089DC57 /* libz.tbd in Frameworks */,
161161
D690AEFB1F2097C90089DC57 /* libbz2.tbd in Frameworks */,
162162
);
@@ -351,7 +351,7 @@
351351
D690ABBD1F20832E0089DC57 /* Frameworks */ = {
352352
isa = PBXGroup;
353353
children = (
354-
0D571A63275CEB3B00672D57 /* liblzma.a */,
354+
0D225ADA2A997B6200DBD5B1 /* liblzma.a */,
355355
0D571A65275CEB3B00672D57 /* libzstd.a */,
356356
D690AEFC1F2097D30089DC57 /* libz.tbd */,
357357
D690AEFA1F2097C90089DC57 /* libbz2.tbd */,

builds/xcode/hpatchz.xcodeproj/project.pbxproj

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
0D225B1A2A99893300DBD5B1 /* liblzma.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0D225B192A99893300DBD5B1 /* liblzma.a */; };
1011
0D571A5C275CE9CE00672D57 /* libzstd.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0D571A5B275CE9CE00672D57 /* libzstd.a */; };
11-
0D571A5D275CE9CE00672D57 /* liblzma.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D64B4BFE2077B9240039C38B /* liblzma.a */; };
1212
0D571A62275CEAE900672D57 /* bspatch_wrapper.c in Sources */ = {isa = PBXBuildFile; fileRef = 0D571A61275CEAE900672D57 /* bspatch_wrapper.c */; };
1313
0DA2A8E52910E70D000E86E1 /* vcpatch_wrapper.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DA2A8E42910E70D000E86E1 /* vcpatch_wrapper.c */; };
1414
D6241AE521DE47EC00E2846A /* new_stream.c in Sources */ = {isa = PBXBuildFile; fileRef = D6241AE321DE47EC00E2846A /* new_stream.c */; };
@@ -38,6 +38,7 @@
3838
/* End PBXCopyFilesBuildPhase section */
3939

4040
/* Begin PBXFileReference section */
41+
0D225B192A99893300DBD5B1 /* liblzma.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = liblzma.a; sourceTree = BUILT_PRODUCTS_DIR; };
4142
0D571A5B275CE9CE00672D57 /* libzstd.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libzstd.a; sourceTree = BUILT_PRODUCTS_DIR; };
4243
0D571A61275CEAE900672D57 /* bspatch_wrapper.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = bspatch_wrapper.c; path = ../../bsdiff_wrapper/bspatch_wrapper.c; sourceTree = "<group>"; };
4344
0DA2A8E42910E70D000E86E1 /* vcpatch_wrapper.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = vcpatch_wrapper.c; path = ../../vcdiff_wrapper/vcpatch_wrapper.c; sourceTree = "<group>"; };
@@ -52,7 +53,6 @@
5253
D64B4BF42077AB550039C38B /* file_for_patch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = file_for_patch.h; path = ../../file_for_patch.h; sourceTree = "<group>"; };
5354
D64B4BF82077B9090039C38B /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
5455
D64B4BFA2077B91A0039C38B /* libbz2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libbz2.tbd; path = usr/lib/libbz2.tbd; sourceTree = SDKROOT; };
55-
D64B4BFE2077B9240039C38B /* liblzma.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = liblzma.a; sourceTree = BUILT_PRODUCTS_DIR; };
5656
D6553CB3165FA1A9009D4C44 /* hpatchz */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = hpatchz; sourceTree = BUILT_PRODUCTS_DIR; };
5757
D67D3BF021D3C5870050632A /* dir_patch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dir_patch.h; sourceTree = "<group>"; };
5858
D67D3BF121D3C5870050632A /* ref_stream.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ref_stream.c; sourceTree = "<group>"; };
@@ -81,7 +81,7 @@
8181
isa = PBXFrameworksBuildPhase;
8282
buildActionMask = 2147483647;
8383
files = (
84-
0D571A5D275CE9CE00672D57 /* liblzma.a in Frameworks */,
84+
0D225B1A2A99893300DBD5B1 /* liblzma.a in Frameworks */,
8585
0D571A5C275CE9CE00672D57 /* libzstd.a in Frameworks */,
8686
D64B4BFB2077B91A0039C38B /* libbz2.tbd in Frameworks */,
8787
D64B4BF92077B9090039C38B /* libz.tbd in Frameworks */,
@@ -94,8 +94,8 @@
9494
D64B4BF72077B9090039C38B /* Frameworks */ = {
9595
isa = PBXGroup;
9696
children = (
97+
0D225B192A99893300DBD5B1 /* liblzma.a */,
9798
0D571A5B275CE9CE00672D57 /* libzstd.a */,
98-
D64B4BFE2077B9240039C38B /* liblzma.a */,
9999
D64B4BFA2077B91A0039C38B /* libbz2.tbd */,
100100
D64B4BF82077B9090039C38B /* libz.tbd */,
101101
);
@@ -203,6 +203,11 @@
203203
attributes = {
204204
LastUpgradeCheck = 1030;
205205
ORGANIZATIONNAME = HouSisong;
206+
TargetAttributes = {
207+
D6553CB2165FA1A9009D4C44 = {
208+
ProvisioningStyle = Automatic;
209+
};
210+
};
206211
};
207212
buildConfigurationList = D6553CAE165FA1A9009D4C44 /* Build configuration list for PBXProject "hpatchz" */;
208213
compatibilityVersion = "Xcode 3.2";
@@ -353,17 +358,25 @@
353358
isa = XCBuildConfiguration;
354359
buildSettings = {
355360
CLANG_ENABLE_OBJC_WEAK = YES;
361+
CODE_SIGN_IDENTITY = "-";
362+
CODE_SIGN_STYLE = Automatic;
363+
DEVELOPMENT_TEAM = "";
356364
MACOSX_DEPLOYMENT_TARGET = 10.9;
357365
PRODUCT_NAME = "$(TARGET_NAME)";
366+
PROVISIONING_PROFILE_SPECIFIER = "";
358367
};
359368
name = Debug;
360369
};
361370
D6553CBE165FA1A9009D4C44 /* Release */ = {
362371
isa = XCBuildConfiguration;
363372
buildSettings = {
364373
CLANG_ENABLE_OBJC_WEAK = YES;
374+
CODE_SIGN_IDENTITY = "-";
375+
CODE_SIGN_STYLE = Automatic;
376+
DEVELOPMENT_TEAM = "";
365377
MACOSX_DEPLOYMENT_TARGET = 10.9;
366378
PRODUCT_NAME = "$(TARGET_NAME)";
379+
PROVISIONING_PROFILE_SPECIFIER = "";
367380
};
368381
name = Release;
369382
};

0 commit comments

Comments
 (0)