# Copyright (c) 2026 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: <1321018403@qq.com>
# Maintainer: <1321018403@qq.com>
pkgname=libprofiler
pkgver=master
pkgrel=0
pkgdesc="This project aims at dynamically profile Linux applications."
url="https://github.com/bouviervj/libprofiler"
archs=("arm64-v8a" "armeabi-v7a" "x86_64")
license=("Apache-2.0 license")
depends=("ncurses")
makedepends=()
source="https://github.com/bouviervj/$pkgname.git"
downloadpackage=false
autounpack=false
buildtools=cmake
builddir=libprofiler
packagename=$builddir.tar.gz
patchflag=true
cloneflag=true
commitid=bd888d9212412d029c6aae71f3655094fb90bd9c
prepare() {
if [ $cloneflag == true ];then
git clone $source $builddir
if [ $? -ne 0 ]
then
echo "$pkgname git clone $source error."
rm -rf $builddir
return -1
fi
cd $builddir
git checkout $commitid
cd $OLDPWD
cloneflag=false
fi
if [ $patchflag == true ];then
cd $builddir
patch -p1 < ../libprofiler_oh_pkg.patch >> $publicbuildlog 2>&1
# 添加测试demo
patch -p1 < ../libprofiler_oh_test.patch >> $publicbuildlog 2>&1
cd $OLDPWD
patchflag=false
fi
mkdir -p $builddir/$ARCH-build
}
build() {
cd $builddir
${OHOS_SDK}/native/build-tools/cmake/bin/cmake "$@" \
-DCMAKE_CXX_FLAGS="${CXXFLAGS} -I${LYCIUM_ROOT}/usr/ncurses/${ARCH}/include/ncurses -I${LYCIUM_ROOT}/usr/ncurses/${ARCH}/include/" \
-DCMAKE_CXX_FLAGS_RELEASE="-O3" \
-DOHOS_ARCH=$ARCH -B$ARCH-build -S./ -L > $buildlog 2>&1
$MAKE -C $ARCH-build >> $buildlog 2>&1
ret=$?
cd $OLDPWD
return $ret
}
package() {
cd $builddir
mkdir -p $LYCIUM_ROOT/usr/$pkgname/$ARCH/lib/
cp $ARCH-build/${pkgname}.so $LYCIUM_ROOT/usr/$pkgname/$ARCH/lib
cd $OLDPWD
}
check() {
echo "The test must be on an OpenHarmony device!"
}
cleanbuild() {
rm -rf ${PWD}/$builddir #${PWD}/$packagename
}