You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by li...@apache.org on 2022/09/20 14:17:42 UTC
[rocketmq-clients] branch cmake_package created (now a8ed15f)
This is an automated email from the ASF dual-hosted git repository.
lizhanhui pushed a change to branch cmake_package
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git
at a8ed15f Prepare to build binary package
This branch includes the following new commits:
new a8ed15f Prepare to build binary package
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[rocketmq-clients] 01/01: Prepare to build binary package
Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
lizhanhui pushed a commit to branch cmake_package
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git
commit a8ed15fc35d75b5dc7c1f9565c8db1f5a66cd305
Author: lizhanhui <li...@gmail.com>
AuthorDate: Tue Sep 20 22:17:10 2022 +0800
Prepare to build binary package
---
cpp/examples/Makefile | 16 ++++++++++++++++
cpp/source/CMakeLists.txt | 11 +++++++++--
cpp/source/rocketmq/rocketmq.lds | 9 +++++++++
cpp/tools/package.sh | 36 ++++++++++++++++++++++++++++++++++++
4 files changed, 70 insertions(+), 2 deletions(-)
diff --git a/cpp/examples/Makefile b/cpp/examples/Makefile
new file mode 100644
index 0000000..31773fb
--- /dev/null
+++ b/cpp/examples/Makefile
@@ -0,0 +1,16 @@
+all: $(wildcard *.cpp)
+ c++ -std=c++11 -I../include -L../lib ExampleProducer.cpp -o example_producer -lrocketmq -Wl,-rpath,../lib
+ c++ -std=c++11 -I../include -L../lib ExamplePushConsumer.cpp -o example_push_consumer -lrocketmq -Wl,-rpath,../lib
+ c++ -std=c++11 -I../include -L../lib ExampleProducerWithAsync.cpp -o example_producer_with_async -lrocketmq -Wl,-rpath,../lib
+ c++ -std=c++11 -I../include -L../lib ExampleProducerWithFifoMessage.cpp -o example_producer_with_fifo_message -lrocketmq -Wl,-rpath,../lib
+ c++ -std=c++11 -I../include -L../lib ExampleProducerWithTimedMessage.cpp -o example_producer_with_timed_message -lrocketmq -Wl,-rpath,../lib
+ c++ -std=c++11 -I../include -L../lib ExampleProducerWithTransactionalMessage.cpp.cpp -o example_producer_with_transactinoal_message -lrocketmq -Wl,-rpath,../lib
+ c++ -std=c++11 -I../include -L../lib ExampleSimpleConsumer.cpp -o example_simple_consumer -lrocketmq -Wl,-rpath,../lib
+clean:
+ rm -fr example_producer
+ rm -fr example_push_consumer
+ rm -fr example_producer_with_async
+ rm -fr example_producer_with_fifo_message
+ rm -fr example_producer_with_timed_message
+ rm -fr example_producer_with_transactinoal_message
+ rm -fr example_simple_consumer
\ No newline at end of file
diff --git a/cpp/source/CMakeLists.txt b/cpp/source/CMakeLists.txt
index d42c6a1..32e7466 100644
--- a/cpp/source/CMakeLists.txt
+++ b/cpp/source/CMakeLists.txt
@@ -29,7 +29,9 @@ target_link_libraries(rocketmq
opencensus::stats
opencensus_proto
spdlog)
-set_target_properties(rocketmq PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
+set_target_properties(rocketmq
+ PROPERTIES
+ ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
add_library(rocketmq_shared SHARED
@@ -53,7 +55,12 @@ target_link_libraries(rocketmq_shared
opencensus::stats
opencensus_proto
spdlog)
+target_link_options(rocketmq_shared
+ PRIVATE
+ $<$<PLATFORM_ID:Linux>:-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/rocketmq/rocketmq.lds>)
set_target_properties(rocketmq_shared
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
- LIBRARY_OUTPUT_NAME rocketmq)
\ No newline at end of file
+ LIBRARY_OUTPUT_NAME rocketmq
+ VERSION 5.0.0
+ SOVERSION 5)
\ No newline at end of file
diff --git a/cpp/source/rocketmq/rocketmq.lds b/cpp/source/rocketmq/rocketmq.lds
new file mode 100644
index 0000000..80ff8dc
--- /dev/null
+++ b/cpp/source/rocketmq/rocketmq.lds
@@ -0,0 +1,9 @@
+VERSION_5.0.0 {
+ global:
+ *rocketmq::*;
+ extern "C++" {
+ *rocketmq::*;
+ };
+ local:
+ *;
+};
\ No newline at end of file
diff --git a/cpp/tools/package.sh b/cpp/tools/package.sh
new file mode 100644
index 0000000..640d9ec
--- /dev/null
+++ b/cpp/tools/package.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+TOOLS_DIR=$(dirname "$0")
+WORKSPACE=$(cd -- "$TOOLS_DIR/.." && pwd)
+BUILD_DIR=$WORKSPACE/_build
+if [ -d $BUILD_DIR ]; then
+ rm -fr $BUILD_DIR
+fi
+
+mkdir -p "$BUILD_DIR"
+
+cd $BUILD_DIR
+cmake -DCMAKE_BUILD_TYPE=Release ..
+make -j $(nproc)
+VERSION="rocketmq-client-5.0.0"
+DIST_DIR="$WORKSPACE/$VERSION/"
+if [ -d "$DIST_DIR" ]; then
+ rm -fr $DIST_DIR
+fi
+
+mkdir -p "$DIST_DIR/include"
+mkdir -p "$DIST_DIR/lib"
+mkdir -p "$DIST_DIR/examples"
+
+cp -r $WORKSPACE/include/rocketmq $DIST_DIR/include/
+cp $WORKSPACE/examples/*.cpp $DIST_DIR/examples/
+cp $WORKSPACE/examples/Makefile $DIST_DIR/examples/
+
+if [[ "$OSTYPE" == "linux-gnu"* ]]; then
+ cp $BUILD_DIR/librocketmq.so $DIST_DIR/lib/
+elif [[ "$OSTYPE" == "darwin"* ]]; then
+ cp $BUILD_DIR/librocketmq.dylib $DIST_DIR/lib/
+fi
+
+echo "Create Package"
+cd "$WORKSPACE"
+tar -czvf "$VERSION.tar.gz" "$VERSION"