diff --git a/thirdparty/HDiffPatch/HDiffPatch_oh_pkg.patch b/thirdparty/HDiffPatch/HDiffPatch_oh_pkg.patch new file mode 100644 index 0000000000000000000000000000000000000000..2a7d2cbd13c84a198d2cb6d6b827555c75da0d0b --- /dev/null +++ b/thirdparty/HDiffPatch/HDiffPatch_oh_pkg.patch @@ -0,0 +1,90 @@ +diff -Naur HDiffPatch-4.6.3_old/libParallel/parallel_import.cpp HDiffPatch-4.6.3/libParallel/parallel_import.cpp +--- HDiffPatch-4.6.3_old/libParallel/parallel_import.cpp 2023-07-22 11:10:42.804788922 +0800 ++++ HDiffPatch-4.6.3/libParallel/parallel_import.cpp 2023-07-22 11:13:27.139807279 +0800 +@@ -34,7 +34,7 @@ + # //define PTW32_STATIC_LIB //for static pthread lib + # endif + # include +-# ifdef __ANDROID__ ++# if defined(__ANDROID__) || defined(__OHOS__) + # include // sched_yield() + # endif + #endif +@@ -141,7 +141,7 @@ + # ifdef WIN32 + Sleep(0); + # else +-# ifdef __ANDROID__ ++# if defined(__ANDROID__) || defined(__OHOS__) + sched_yield(); + # else + pthread_yield(); +diff -Naur HDiffPatch-4.6.3_old/Makefile HDiffPatch-4.6.3/Makefile +--- HDiffPatch-4.6.3_old/Makefile 2023-07-22 15:37:29.261756730 +0800 ++++ HDiffPatch-4.6.3/Makefile 2023-07-22 15:37:46.722039873 +0800 +@@ -2,8 +2,8 @@ + DIR_DIFF := 1 + MT := 1 + # 0: not need zlib; 1: compile zlib source code; 2: used -lz to link zlib lib; +-ZLIB := 2 +-LZMA := 1 ++ZLIB := 1 ++LZMA := 0 + ARM64ASM := 0 + # 0: not need zstd; 1: compile zstd source code; 2: used -lzstd to link zstd lib; + ZSTD := 1 +@@ -24,7 +24,7 @@ + BZIP2 := 1 + else + # 0: not need bzip2 (must BSD=0); 1: compile bzip2 source code; 2: used -lbz2 to link bzip2 lib; +- BZIP2 := 2 ++ BZIP2 := 1 + endif + ifeq ($(BZIP2),0) + ifeq ($(BSD),0) +@@ -203,6 +203,16 @@ + compress_parallel.o + endif + ++HDIFF_SYNC_OBJ := \ ++ libhsync/sync_client/dir_sync_client.o \ ++ libhsync/sync_client/match_in_old.o \ ++ libhsync/sync_client/sync_client.o \ ++ libhsync/sync_client/sync_diff_data.o \ ++ libhsync/sync_client/sync_info_client.o \ ++ libhsync/sync_make/dir_sync_make.o \ ++ libhsync/sync_make/match_in_new.o \ ++ libhsync/sync_make/sync_info_make.o \ ++ libhsync/sync_make/sync_make.o + + DEF_FLAGS := \ + -O3 -DNDEBUG -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \ +@@ -334,7 +344,7 @@ + + .PHONY: all install clean + +-all: libhdiffpatch.a hpatchz hdiffz mostlyclean ++all: libhdiffpatch.a hpatchz hdiffz unit_test mostlyclean + + libhdiffpatch.a: $(HDIFF_OBJ) + $(AR) rcs $@ $^ +@@ -343,6 +353,8 @@ + $(CC) hpatchz.c $(HPATCH_OBJ) $(CFLAGS) $(PATCH_LINK) -o hpatchz + hdiffz: libhdiffpatch.a + $(CXX) hdiffz.cpp libhdiffpatch.a $(CXXFLAGS) $(DIFF_LINK) -o hdiffz ++unit_test: libhdiffpatch.a $(HDIFF_SYNC_OBJ) ++ $(CXX) ./test/unit_test.cpp libhdiffpatch.a $(HDIFF_SYNC_OBJ) $(DIFF_LINK) -o unit_test + + ifeq ($(OS),Windows_NT) # mingw? + RM := del /Q /F +@@ -352,8 +364,8 @@ + DEL_HDIFF_OBJ := $(HDIFF_OBJ) + endif + INSTALL_X := install -m 0755 +-INSTALL_BIN := $(DESTDIR)/usr/local/bin +- ++#INSTALL_BIN := $(DESTDIR)/usr/local/bin ++INSTALL_BIN := $(DESTDIR) + mostlyclean: hpatchz hdiffz + $(RM) $(DEL_HDIFF_OBJ) + clean: diff --git a/thirdparty/HDiffPatch/HPKBUILD b/thirdparty/HDiffPatch/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..ed6f1bb99f238ca0ea7d79c3b263871d1bdec115 --- /dev/null +++ b/thirdparty/HDiffPatch/HPKBUILD @@ -0,0 +1,114 @@ +# Contributor: shann +# Maintainer: shann +pkgname=HDiffPatch +pkgver=v4.6.3 +pkgrel=0 +pkgdesc="HDiffPatch is a C++ library for comparing and merging text differences. It provides an efficient way to calculate the differences between two texts and apply these differences to a target text to produce a new merged text. HDiffPatch can be used in various applications, such as version control systems, text editors, automation build tools, etc.." +url="https://github.com/sisong/HDiffPatch" +archs=("armeabi-v7a" "arm64-v8a") + +license=("MIT") +depends=() +makedepends=() + +source="https://github.com/sisong/$pkgname/archive/refs/tags/$pkgver.tar.gz" + +autounpack=true +downloadpackage=true + +builddir=$pkgname-${pkgver:1} +packagename=$builddir.tar.gz +dependsname="bzip2 libmd5 zlib zstd" +buildtools="make" + +source envset.sh +c_cxxflag="" + +firstflag=true + +prepare() { + if $firstflag + then + git clone https://github.com/sisong/libmd5.git + if [ $ret -ne 0 ]; then + echo "fail: git clone libmd5 $ret" + return $ret + fi + git clone -b bzip2-1.0.8 https://github.com/sisong/bzip2.git + if [ $ret -ne 0 ]; then + echo "fail: git clone bzip2 $ret" + return $ret + fi + git clone -b v1.5.5 https://github.com/sisong/zstd.git + if [ $ret -ne 0 ]; then + echo "fail: git clone zstd $ret" + return $ret + fi + git clone -b v1.2.11 https://github.com/sisong/zlib.git + if [ $ret -ne 0 ]; then + echo "fail: git clone zlib $ret" + return $ret + fi + cd $builddir + # patch只需要打一次,关闭打patch + patch -p1 < ../HDiffPatch_oh_pkg.patch + cd $OLDPWD + firstflag=false + fi + mkdir $pkgname_$ARCH-build/ + cp -r $builddir/ $pkgname_$ARCH-build/$builddir/ + cp -r $dependsname $pkgname_$ARCH-build/ + + if [ $ARCH == "armeabi-v7a" ]; then + setarm32ENV + c_cxxflag="-mfloat-abi=softfp -I../bzip2/ -D_IS_NEED_DEFAULT_CompressPlugin=0" + elif [ $ARCH == "arm64-v8a" ]; then + setarm64ENV + c_cxxflag="-I../bzip2/ -D_IS_NEED_DEFAULT_CompressPlugin=0" + else + echo "${ARCH} not support" + return -1 + fi +} + +build() { + cd $pkgname_$ARCH-build/$builddir/ + make CC=$CC CXX=$CXX CFLAGS="$CFLAGS $c_cxxflag" CXXFLAGS="$CXXFLAGS $c_cxxflag" \ + DESTDIR=$LYCIUM_ROOT/usr/$pkgname LZMA=0 ZSTD=1 MD5=1 > `pwd`/build.log 2>&1 + ret=$? + cd $OLDPWD + return $ret +} + +package() { + cd $pkgname_$ARCH-build/$builddir/ + mkdir -p $LYCIUM_ROOT/usr/$pkgname/$ARCH/bin + mkdir -p $LYCIUM_ROOT/usr/$pkgname/$ARCH/lib + mkdir -p $LYCIUM_ROOT/usr/$pkgname/$ARCH/include + make install INSTALL_BIN=$LYCIUM_ROOT/usr/$pkgname/$ARCH/bin >> `pwd`/build.log 2>&1 + cp *.a $LYCIUM_ROOT/usr/$pkgname/$ARCH/lib + cp *.h $LYCIUM_ROOT/usr/$pkgname/$ARCH/include + cd $OLDPWD +} + +check() { + if [ $ARCH == "armeabi-v7a" ]; then + # 拷贝shared库到测试程序运行目录 + cp $OHOS_SDK/native/llvm/lib/arm-linux-ohos/libc++_shared.so $pkgname_$ARCH-build/$builddir/ + unsetarm32ENV + elif [ $ARCH == "arm64-v8a" ]; then + # 拷贝shared库到测试程序运行目录 + cp $OHOS_SDK/native/llvm/lib/aarch64-linux-ohos/libc++_shared.so $pkgname_$ARCH-build/$builddir/ + unsetarm64ENV + else + echo "${ARCH} not support" + return -1 + fi + echo "The test must be on an OpenHarmony device!" + # 编译生成目录$pkgname_$ARCH-build/$builddir/下执行./unit_test +} + +# 清理环境 +cleanbuild() { + rm -rf ${PWD}/arm64-v8a-build ${PWD}/armeabi-v7a-build ${PWD}/$dependsname +} diff --git a/thirdparty/HDiffPatch/HPKCHECK b/thirdparty/HDiffPatch/HPKCHECK new file mode 100644 index 0000000000000000000000000000000000000000..661bfebec026fb7247695bb17ae7e0d9a9a5d831 --- /dev/null +++ b/thirdparty/HDiffPatch/HPKCHECK @@ -0,0 +1,17 @@ +# Contributor: shann +# Maintainer: shann + +source HPKBUILD > /dev/null 2>&1 +logfile=${LYCIUM_THIRDPARTY_ROOT}/${pkgname}/${pkgname}_${ARCH}_${OHOS_SDK_VER}_test.log + +openharmonycheck() { + res=0 + cd $pkgname_$ARCH-build/$builddir/ + # 没有其他依赖环境,直接添加当前环境 + export LD_LIBRARY_PATH=`pwd` + ./unit_test > ${logfile} 2>&1 + res=$? + cd $OLDPWD + + return $res +} \ No newline at end of file diff --git a/thirdparty/HDiffPatch/OAT.xml b/thirdparty/HDiffPatch/OAT.xml new file mode 100644 index 0000000000000000000000000000000000000000..961b45b01d5b014c234b0b14f579c52d4a55564b --- /dev/null +++ b/thirdparty/HDiffPatch/OAT.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/thirdparty/HDiffPatch/README.OpenSource b/thirdparty/HDiffPatch/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..ed8a427e0b07ca1037cb0becc95a5c1f3063c874 --- /dev/null +++ b/thirdparty/HDiffPatch/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "HDiffPatch", + "License": "MIT", + "License File": "https://github.com/sisong/HDiffPatch/blob/master/LICENSE", + "Version Number": "v4.6.3", + "Owner": "swkec@isoftstone.com", + "Upstream URL": "https://github.com/sisong/HDiffPatch/archive/refs/tags/v4.6.3.tar.gz", + "Description": "HDiffPatch is a C++ library for comparing and merging text differences. It provides an efficient way to calculate the differences between two texts and apply these differences to a target text to produce a new merged text. HDiffPatch can be used in various applications, such as version control systems, text editors, automation build tools, etc.." + } +] diff --git a/thirdparty/HDiffPatch/README_zh.md b/thirdparty/HDiffPatch/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..f454cb0801ef75258764ffb2e9310e5ad8c61c4f --- /dev/null +++ b/thirdparty/HDiffPatch/README_zh.md @@ -0,0 +1,11 @@ +# HDiffPatch三方库说明 +## 功能简介 +HDiffPatch是一个用于比较和合并文本差异的C++库。它提供了一种高效的方法来计算两个文本之间的差异,并将这些差异应用于目标文本以产生新的合并文本。HDiffPatch库可用于各种应用程序,如版本控制系统、文本编辑器、自动化构建工具等。 +## 使用约束 +- IDE版本:DevEco Studio 3.1 Beta2 +- SDK版本:ohos_sdk_public 3.2.11.9 (API Version 9 Release) +- 三方库版本:v4.6.3 +- 当前适配的功能:实现了计算两个文本之间的差异,并将这些差异应用于目标文本以产生新的合并文本. + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/HDiffPatch/SHA512SUM b/thirdparty/HDiffPatch/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..9eef56abc29cd9b337500162aa5011073e43a4c0 --- /dev/null +++ b/thirdparty/HDiffPatch/SHA512SUM @@ -0,0 +1 @@ +1cef5b50b5203d0c1a93698ee2eae818cd25967fc48a473272db616e9197c74710d32a8fedadbfe60adbd37b853e6edc50e797c97c3cd634e294257b40ce11b5 HDiffPatch-4.6.3.tar.gz diff --git a/thirdparty/HDiffPatch/docs/hap_integrate.md b/thirdparty/HDiffPatch/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..4df584784a28a988fe30f8fca5f37eaf9fda40c7 --- /dev/null +++ b/thirdparty/HDiffPatch/docs/hap_integrate.md @@ -0,0 +1,73 @@ +# HDiffPatch集成到应用hap +本库是在RK3568开发板上基于OpenHarmony3.2 Release版本的镜像验证的,如果是从未使用过RK3568,可以先查看[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 +## 开发环境 +- ubuntu20.04 +- [OpenHarmony3.2Release镜像](https://gitee.com/link?target=https%3A%2F%2Frepo.huaweicloud.com%2Fopenharmony%2Fos%2F3.2-Release%2Fdayu200_standard_arm32.tar.gz) +- [ohos_sdk_public 4.0.8.1 (API Version 10 Release)](http://download.ci.openharmony.cn/version/Master_Version/OpenHarmony_4.0.8.1/20230608_091016/version-Master_Version-OpenHarmony_4.0.8.1-20230608_091016-ohos-sdk-full.tar.gz) +- [DevEco Studio 3.1 Release](https://contentcenter-vali-drcn.dbankcdn.cn/pvt_2/DeveloperAlliance_package_901_9/81/v3/tgRUB84wR72nTfE8Ir_xMw/devecostudio-windows-3.1.0.501.zip?HW-CC-KV=V1&HW-CC-Date=20230621T074329Z&HW-CC-Expire=315360000&HW-CC-Sign=22F6787DF6093ECB4D4E08F9379B114280E1F65DA710599E48EA38CB24F3DBF2) +- [准备三方库构建环境](../../../lycium/README.md#1编译环境准备) +- [准备三方库测试环境](../../../lycium/README.md#3ci环境准备) +## 编译三方库 +- 下载本仓库 + ``` + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` +- 三方库目录结构 + ``` + tpc_c_cplusplus/thirdparty/HDiffPatch #三方库HDiffPatch的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── HPKCHECK #自动化测试脚本 + ├── OAT.xml #OAT开源审查文本 + ├── HDiffPatch_oh_pkg.patch #patch脚本 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md #三方库说明文档 + └── SHA512SUM #校验文档 + ``` + +- 进入lycium目录下 + ``` + cd tpc_c_cplusplus/lycium + ``` +- 在lycium目录下编译三方库 + HDiffPatch库依赖库会在本仓自动编译,所以在build时只需要编译HDiffPatch库 + 编译环境的搭建参考[准备三方库构建环境](../../../lycium/README.md#1编译环境准备) + ``` + ./build.sh HDiffPatch + ``` +- 三方库头文件及生成的库 + 在lycium目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + ``` + HDiffPatch/arm64-v8a HDiffPatch/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 + + ![thirdparty_install_dir](pic/HDiffPatch_install_dir.jpg) + +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + ``` + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/HDiffPatch/${OHOS_ARCH}/lib/libhdiffpatch.a) + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/HDiffPatch/${OHOS_ARCH}/include) + ``` + +## 测试三方库 +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../lycium/README.md#3ci环境准备) + +- 将编译生成的可执行文件及生成的动态库准备好 + +- 将准备好的文件推送到开发板,进入到构建的目录arm64-v8a-build/HDiffPatch-4.6.3(32位在armeabi-v7a-build//HDiffPatch-4.6.3)下执行./unit_test + + ![HDiffPatch_test](pic/HDiffPatch_test.jpg) + +## 参考资料 +- [润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld) +- [OpenHarmony三方库地址](https://gitee.com/openharmony-tpc) +- [OpenHarmony知识体系](https://gitee.com/openharmony-sig/knowledge) +- [通过DevEco Studio开发一个NAPI工程](https://gitee.com/openharmony-sig/knowledge_demo_temp/blob/master/docs/napi_study/docs/hello_napi.md) diff --git a/thirdparty/HDiffPatch/docs/pic/HDiffPatch_install_dir.jpg b/thirdparty/HDiffPatch/docs/pic/HDiffPatch_install_dir.jpg new file mode 100644 index 0000000000000000000000000000000000000000..18af4ed9e99677a7eeddf728069f2450f1916943 Binary files /dev/null and b/thirdparty/HDiffPatch/docs/pic/HDiffPatch_install_dir.jpg differ diff --git a/thirdparty/HDiffPatch/docs/pic/HDiffPatch_test.jpg b/thirdparty/HDiffPatch/docs/pic/HDiffPatch_test.jpg new file mode 100644 index 0000000000000000000000000000000000000000..2da918ab7a4a6dbd7ad8ced28b268bea24cf8bbe Binary files /dev/null and b/thirdparty/HDiffPatch/docs/pic/HDiffPatch_test.jpg differ