# Copyright (c) 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Contributor: Jeff Han <hanjinfei@foxmail.com> luozhu <1393302983@qq.com>
# Maintainer: Jeff Han <hanjinfei@foxmail.com>
pkgname=zstd
giteepkgname=facebook-$pkgname
pkgver=v1.5.4
pkgrel=0
pkgdesc="Zstandard, or zstd as short version, is a fast lossless compression algorithm, targeting real-time compression scenarios at zlib-level and better compression ratios"
url="https://github.com/facebook/zstd"
archs=("armeabi-v7a" "arm64-v8a" "x86_64")
license=("BSD-3-Clause or GPL-2.0")
depends=()
makedepends=()
# 官方下载地址: https://github.com/facebook/$pkgname/releases/download/$pkgver/$pkgname-1.5.4.tar.gz,因网络原因采用gitee mirrors
source="https://gitee.com/mirrors/$giteepkgname/repository/archive/$pkgver.zip"
autounpack=true
downloadpackage=true
builddir=$giteepkgname-${pkgver}
packagename=$builddir.zip
prepare() {
mkdir -p $builddir/$ARCH-build
}
build() {
local LOCAL_CFLAGS="-O3 -fstack-protector-strong -fPIC"
local LOCAL_CXXFLAGS="-O3 -fstack-protector-strong -fPIC"
local LOCAL_LDFLAGS="-Wl,-z,relro,-z,now -s"
cd "$builddir"
PKG_CONFIG_LIBDIR="${pkgconfigpath}" \
$OHOS_SDK/native/build-tools/cmake/bin/cmake "$@" \
-DZSTD_BUILD_TESTS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_FLAGS="${LOCAL_CFLAGS}" \
-DCMAKE_CXX_FLAGS="${LOCAL_CXXFLAGS}" \
-DCMAKE_SHARED_LINKER_FLAGS="${LOCAL_LDFLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS="${LOCAL_LDFLAGS}" \
-DCMAKE_SKIP_RPATH=TRUE \
-B"$ARCH-build" -S./build/cmake > "$buildlog" 2>&1
$MAKE -C "$ARCH-build" VERBOSE=1 >> "$buildlog" 2>&1
local ret=$?
cd "$OLDPWD"
return $ret
}
package() {
cd $builddir
$MAKE -C $ARCH-build install >> $buildlog 2>&1
cd $OLDPWD
}
check() {
echo "The test must be on an OpenHarmony device!"
# ctest
}
# 清理环境
cleanbuild(){
rm -rf ${PWD}/$builddir #${PWD}/$packagename
}