From 85f42f934e22e1dd570881dfb9c7abe12cffe6b5 Mon Sep 17 00:00:00 2001 From: liulihong Date: Mon, 24 Jul 2023 14:54:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4concurrentqueue=E5=BA=93?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liulihong --- thirdparty/concurrentqueue/HPKBUILD | 78 +++++++++++++++++++ thirdparty/concurrentqueue/SHA512SUM | 2 + .../concurrentqueue_oh_pkg.patch | 54 +++++++++++++ 3 files changed, 134 insertions(+) create mode 100644 thirdparty/concurrentqueue/HPKBUILD create mode 100644 thirdparty/concurrentqueue/SHA512SUM create mode 100644 thirdparty/concurrentqueue/concurrentqueue_oh_pkg.patch diff --git a/thirdparty/concurrentqueue/HPKBUILD b/thirdparty/concurrentqueue/HPKBUILD new file mode 100644 index 00000000..f2480611 --- /dev/null +++ b/thirdparty/concurrentqueue/HPKBUILD @@ -0,0 +1,78 @@ +# Contributor: Jeff Han +# Maintainer: Jeff Han +pkgname=concurrentqueue +pkgver=v1.0.3 +pkgrel=0 +pkgdesc="A fast multi-producer, multi-consumer lock-free concurrent queue for C++11" +url="https://github.com/cameron314/concurrentqueue" +archs=("armeabi-v7a" "arm64-v8a") +license=("BSD Boost Software License") +depends=() +makedepends=() +source="https://github.com/cameron314/$pkgname/archive/refs/tags/$pkgver.tar.gz" + +autounpack=true +downloadpackage=true +patchflag=true +builddir=$pkgname-${pkgver:1} +packagename=$builddir.tar.gz +cxx= +cxxflags= + +prepare() { + if $patchflag + then + cd $builddir + # 由于测试用例的makefile使用的g++无法直接传入值,因此定义变量$(CXX),另外报错error: unknown type name 'MOODYCAMEL_EXPORT',需要去除相关宏定义,因此打补丁 + patch -p1 < `pwd`/../concurrentqueue_oh_pkg.patch + patchflag=false + cd $OLDPWD + fi + + if [ $ARCH == "armeabi-v7a" ] + then + cxx=${OHOS_SDK}/native/llvm/bin/arm-linux-ohos-clang++ + cxxflags="-march=armv7a" + elif [ $ARCH == "arm64-v8a" ] + then + cxx=${OHOS_SDK}/native/llvm/bin/aarch64-linux-ohos-clang++ + cxxflags="" + else + echo "${ARCH} not support" + return -1 + fi + cp -rf $builddir $builddir-$ARCH-build +} + +build() { + cd $builddir-$ARCH-build + ${OHOS_SDK}/native/build-tools/cmake/bin/cmake "$@" -DCMAKE_CXX_FLAGS=$cxxflags -DOHOS_ARCH=$ARCH -S./ -L > `pwd`/build.log 2>&1 + make -j4 >> `pwd`/build.log 2>&1 + ret=$? + cd $OLDPWD + return $ret +} + +package() { + cd $builddir-$ARCH-build + make install >> `pwd`/build.log 2>&1 + ret=$? + cd $OLDPWD + return $ret +} + +check() { + cd $builddir-$ARCH-build/build + make CXX=$cxx CXXFLAGS=$cxxflags tests >> `pwd`/build.log 2>&1 + ret=$? + cd $OLDPWD + unset cxx cxxflags + echo "The test must be on an OpenHarmony device!" + # ./build/bin/unittests + return $ret +} + +# 清理环境 +cleanbuild(){ + rm -rf ${PWD}/$builddir $builddir-arm64-v8a-build #${PWD}/$packagename +} diff --git a/thirdparty/concurrentqueue/SHA512SUM b/thirdparty/concurrentqueue/SHA512SUM new file mode 100644 index 00000000..28e506fc --- /dev/null +++ b/thirdparty/concurrentqueue/SHA512SUM @@ -0,0 +1,2 @@ +a27e458dd39306d0e26f5f053a95d9afddb3cbe68fccc13069eb442dd575e6e682a31f12ea38bbcf08f2984fdb78c6f3de7ccfd683d744c78bb9cbda7895077e concurrentqueue-1.0.3.tar.gz +e6c3907ed899179fd8191b7b17931ea66d1cc5ecaf9e4faa9b8899b3aa4cc52dcfc7d2a5e7cc52b5b9f5a34d78d02686f2af6b0367da4d75975421fcb9a80343 concurrentqueue_oh_pkg.patch diff --git a/thirdparty/concurrentqueue/concurrentqueue_oh_pkg.patch b/thirdparty/concurrentqueue/concurrentqueue_oh_pkg.patch new file mode 100644 index 00000000..e92de6cf --- /dev/null +++ b/thirdparty/concurrentqueue/concurrentqueue_oh_pkg.patch @@ -0,0 +1,54 @@ +diff -Naur concurrentqueue-1.0.3/build/makefile concurrentqueue-1.0.3-patch/build/makefile +--- concurrentqueue-1.0.3/build/makefile 2020-12-09 20:15:23.000000000 +0800 ++++ concurrentqueue-1.0.3-patch/build/makefile 2023-06-27 17:07:10.362583499 +0800 +@@ -31,12 +31,12 @@ + + bin/unittests$(EXT): ../concurrentqueue.h ../blockingconcurrentqueue.h ../lightweightsemaphore.h ../tests/unittests/unittests.cpp ../tests/unittests/mallocmacro.cpp ../tests/common/simplethread.h ../tests/common/simplethread.cpp ../tests/common/systemtime.h ../tests/common/systemtime.cpp ../tests/corealgos.h ../tests/unittests/minitest.h ../c_api/blockingconcurrentqueue.cpp ../c_api/concurrentqueue.cpp makefile + test -d bin || mkdir bin +- g++ -c -std=c++11 -Wall -pedantic-errors -Wpedantic -Wconversion -DMOODYCAMEL_STATIC $(OPTS) -fno-elide-constructors -fno-exceptions ../c_api/blockingconcurrentqueue.cpp ../c_api/concurrentqueue.cpp +- g++ -std=c++11 -Wall -pedantic-errors -Wpedantic -Wconversion -DMOODYCAMEL_STATIC $(OPTS) -fno-elide-constructors ../tests/common/simplethread.cpp ../tests/common/systemtime.cpp ../tests/unittests/unittests.cpp blockingconcurrentqueue.o concurrentqueue.o -o bin/unittests$(EXT) $(LD_OPTS) ++ $(CXX) $(CXXFLAGS) -c -std=c++11 -Wall -pedantic-errors -Wpedantic -Wconversion -DMOODYCAMEL_STATIC $(OPTS) -fno-elide-constructors -fno-exceptions ../c_api/blockingconcurrentqueue.cpp ../c_api/concurrentqueue.cpp ++ $(CXX) $(CXXFLAGS) -std=c++11 -Wall -pedantic-errors -Wpedantic -Wconversion -DMOODYCAMEL_STATIC $(OPTS) -fno-elide-constructors ../tests/common/simplethread.cpp ../tests/common/systemtime.cpp ../tests/unittests/unittests.cpp blockingconcurrentqueue.o concurrentqueue.o -o bin/unittests$(EXT) $(LD_OPTS) + + bin/fuzztests$(EXT): ../concurrentqueue.h ../tests/fuzztests/fuzztests.cpp ../tests/common/simplethread.h ../tests/common/simplethread.cpp ../tests/common/systemtime.h ../tests/common/systemtime.cpp ../tests/corealgos.h makefile + test -d bin || mkdir bin +- g++ -std=c++11 -Wall -pedantic-errors -Wpedantic $(BENCH_OPTS) ../tests/common/simplethread.cpp ../tests/common/systemtime.cpp ../tests/fuzztests/fuzztests.cpp -o bin/fuzztests$(EXT) $(LD_OPTS) ++ $(CXX) $(CXXFLAGS) -std=c++11 -Wall -pedantic-errors -Wpedantic $(BENCH_OPTS) ../tests/common/simplethread.cpp ../tests/common/systemtime.cpp ../tests/fuzztests/fuzztests.cpp -o bin/fuzztests$(EXT) $(LD_OPTS) + + bin/benchmarks$(EXT): bin/libtbb.a ../concurrentqueue.h ../benchmarks/benchmarks.cpp ../benchmarks/cpuid.h ../benchmarks/cpuid.cpp ../benchmarks/lockbasedqueue.h ../benchmarks/simplelockfree.h ../tests/common/simplethread.h ../tests/common/simplethread.cpp ../tests/common/systemtime.h ../tests/common/systemtime.cpp makefile + test -d bin || mkdir bin +diff -Naur concurrentqueue-1.0.3/c_api/concurrentqueue.h concurrentqueue-1.0.3-patch/c_api/concurrentqueue.h +--- concurrentqueue-1.0.3/c_api/concurrentqueue.h 2020-12-09 20:15:23.000000000 +0800 ++++ concurrentqueue-1.0.3-patch/c_api/concurrentqueue.h 2023-06-27 13:16:25.044836391 +0800 +@@ -4,19 +4,19 @@ + extern "C" { + #endif + +-#ifndef MOODYCAMEL_EXPORT +-#ifdef _WIN32 +-#if defined(MOODYCAMEL_STATIC) //preferred way ++//#ifndef MOODYCAMEL_EXPORT ++//#ifdef _WIN32 ++//#if defined(MOODYCAMEL_STATIC) //preferred way ++//#define MOODYCAMEL_EXPORT ++//#elif defined(DLL_EXPORT) ++//#define MOODYCAMEL_EXPORT __declspec(dllexport) ++//#else ++//#define MOODYCAMEL_EXPORT __declspec(dllimport) ++//#endif ++//#endif ++//#else + #define MOODYCAMEL_EXPORT +-#elif defined(DLL_EXPORT) +-#define MOODYCAMEL_EXPORT __declspec(dllexport) +-#else +-#define MOODYCAMEL_EXPORT __declspec(dllimport) +-#endif +-#endif +-#else +-#define MOODYCAMEL_EXPORT +-#endif ++//#endif + + typedef void* MoodycamelCQHandle; + typedef void* MoodycamelBCQHandle; -- Gitee