This is an automated email from the ASF dual-hosted git repository.

laiyingchun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pegasus.git


The following commit(s) were added to refs/heads/master by this push:
     new 7a1c461fc feat(build): Support to specify THIRDPARTY_ROOT by setting 
the environment variable (#2035)
7a1c461fc is described below

commit 7a1c461fcbf9424a0fc28c8bee3b47506c09ec2b
Author: Yingchun Lai <[email protected]>
AuthorDate: Thu May 30 11:29:41 2024 +0800

    feat(build): Support to specify THIRDPARTY_ROOT by setting the environment 
variable (#2035)
    
    Building Pegasus thirdparty libraries costs long time, it would be 
meaningful
    to reuse a built thirdparty directory when build Pegasus source code in 
different
    directories.
    
    This patch introduces an environment variable `PEGASUS_THIRDPARTY_ROOT` to 
indicate
    the thirdparty directory, if it has been built, it can be skipt to save 
time and
    disk space.
---
 CMakeLists.txt              |  8 ++++++--
 run.sh                      |  3 ++-
 scripts/compile_thrift.py   |  6 +++---
 scripts/pack_client.sh      |  2 +-
 scripts/pack_server.sh      | 12 ++++++------
 scripts/pack_tools.sh       | 12 ++++++------
 scripts/recompile_thrift.sh |  1 -
 src/sample/run.sh           | 22 +++++++++++++++++++++-
 8 files changed, 45 insertions(+), 21 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5cc4c7004..0ee9d6040 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -35,8 +35,12 @@ include(BaseFunctions)
 set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
 
 set(PROJECT_ROOT ${CMAKE_CURRENT_LIST_DIR})
-set(THIRDPARTY_ROOT ${PROJECT_ROOT}/thirdparty)
-set(THIRDPARTY_INSTALL_DIR ${PROJECT_ROOT}/thirdparty/output)
+if ("$ENV{THIRDPARTY_ROOT}" STREQUAL "")
+    set(THIRDPARTY_ROOT ${PROJECT_ROOT}/thirdparty)
+else()
+    set(THIRDPARTY_ROOT $ENV{THIRDPARTY_ROOT})
+endif()
+set(THIRDPARTY_INSTALL_DIR ${THIRDPARTY_ROOT}/output)
 message(STATUS "THIRDPARTY_INSTALL_DIR = ${THIRDPARTY_INSTALL_DIR}")
 
 set(BUILD_DIR ${PROJECT_ROOT}/src/builder)
diff --git a/run.sh b/run.sh
index abfd90d1a..7e1b41321 100755
--- a/run.sh
+++ b/run.sh
@@ -24,7 +24,8 @@ ROOT="$(cd "$(dirname "$0")" && pwd)"
 export BUILD_ROOT_DIR=${ROOT}/build
 export BUILD_LATEST_DIR=${BUILD_ROOT_DIR}/latest
 export REPORT_DIR="$ROOT/test_report"
-export THIRDPARTY_ROOT=$ROOT/thirdparty
+# It's possible to specify THIRDPARTY_ROOT by setting the environment variable 
PEGASUS_THIRDPARTY_ROOT.
+export THIRDPARTY_ROOT=${PEGASUS_THIRDPARTY_ROOT:-"$ROOT/thirdparty"}
 ARCH_TYPE=''
 arch_output=$(arch)
 if [ "$arch_output"x == "x86_64"x ]; then
diff --git a/scripts/compile_thrift.py b/scripts/compile_thrift.py
index 376a3c50c..f6d46a4d2 100755
--- a/scripts/compile_thrift.py
+++ b/scripts/compile_thrift.py
@@ -220,13 +220,13 @@ def add_hook(name, path, func, args):
 
 if __name__ == "__main__":
     root_dir = os.getcwd()
-    thrift_exe = root_dir + "/thirdparty/output/bin/thrift"
+    thrift_exe = os.environ['THIRDPARTY_ROOT'] + "/output/bin/thrift"
     print("thrift_exe = " + thrift_exe)
     print("root_dir = " + root_dir)
 
     if not os.path.isfile(thrift_exe):
-        print("Error: can't find compiler %s\nPlease build thrift in 
thirdparty/" % thrift_exe)
-        sys.exit()
+        print("Error: can't find compiler %s\nPlease build thrift in %s/" % 
(thrift_exe, os.environ['THIRDPARTY_ROOT']))
+        sys.exit(1)
 
     ctor_kv_pair = "  kv_pair(const std::string& _key, const std::string& 
_val): key(_key), value(_val) {\n  }"
     ctor_configuration_proposal_action = "  
configuration_proposal_action(::dsn::rpc_address t, ::dsn::rpc_address n, 
config_type::type tp): target(t), node(n), type(tp) {}"
diff --git a/scripts/pack_client.sh b/scripts/pack_client.sh
index e15212cb9..66021465c 100755
--- a/scripts/pack_client.sh
+++ b/scripts/pack_client.sh
@@ -109,7 +109,7 @@ mkdir -p ${pack}/lib
 copy_file ${BUILD_LATEST_DIR}/output/lib/libpegasus_client_static.a ${pack}/lib
 # TODO(yingchun): make sure shared lib works well too
 # copy_file ${BUILD_LATEST_DIR}/output/lib/libpegasus_client_shared.so 
${pack}/lib
-copy_file ./thirdparty/output/lib/libboost*.so.1.69.0 ${pack}/lib
+copy_file ${THIRDPARTY_ROOT}/output/lib/libboost*.so.1.69.0 ${pack}/lib
 ln -sf `ls ${pack}/lib | grep libboost_system` ${pack}/lib/libboost_system.so
 ln -sf `ls ${pack}/lib | grep libboost_filesystem` 
${pack}/lib/libboost_filesystem.so
 ln -sf `ls ${pack}/lib | grep libboost_regex` ${pack}/lib/libboost_regex.so
diff --git a/scripts/pack_server.sh b/scripts/pack_server.sh
index 2ff6e8446..775002128 100755
--- a/scripts/pack_server.sh
+++ b/scripts/pack_server.sh
@@ -116,15 +116,15 @@ copy_file 
${BUILD_LATEST_DIR}/output/lib/libdsn_replica_server.so ${pack}/bin
 copy_file ${BUILD_LATEST_DIR}/output/lib/libdsn_utils.so ${pack}/bin
 
 if [ "$use_jemalloc" == "on" ]; then
-    copy_file ./thirdparty/output/lib/libjemalloc.so.2 ${pack}/bin
-    copy_file ./thirdparty/output/lib/libprofiler.so.0 ${pack}/bin
+    copy_file ${THIRDPARTY_ROOT}/output/lib/libjemalloc.so.2 ${pack}/bin
+    copy_file ${THIRDPARTY_ROOT}/output/lib/libprofiler.so.0 ${pack}/bin
 else
-    copy_file ./thirdparty/output/lib/libtcmalloc_and_profiler.so.4 ${pack}/bin
+    copy_file ${THIRDPARTY_ROOT}/output/lib/libtcmalloc_and_profiler.so.4 
${pack}/bin
 fi
 
-copy_file ./thirdparty/output/lib/libboost*.so.1.69.0 ${pack}/bin
-copy_file ./thirdparty/output/lib/libhdfs* ${pack}/bin
-copy_file ./thirdparty/output/lib/librocksdb.so.8 ${pack}/bin
+copy_file ${THIRDPARTY_ROOT}/output/lib/libboost*.so.1.69.0 ${pack}/bin
+copy_file ${THIRDPARTY_ROOT}/output/lib/libhdfs* ${pack}/bin
+copy_file ${THIRDPARTY_ROOT}/output/lib/librocksdb.so.8 ${pack}/bin
 copy_file ./scripts/sendmail.sh ${pack}/bin
 copy_file ./src/server/config.ini ${pack}/bin
 copy_file ./src/server/config.min.ini ${pack}/bin
diff --git a/scripts/pack_tools.sh b/scripts/pack_tools.sh
index ce386b3a4..f948f1700 100755
--- a/scripts/pack_tools.sh
+++ b/scripts/pack_tools.sh
@@ -125,15 +125,15 @@ mkdir -p ${pack}/lib
 copy_file ${BUILD_LATEST_DIR}/output/lib/*.so* ${pack}/lib/
 
 if [ "$use_jemalloc" == "on" ]; then
-    copy_file ./thirdparty/output/lib/libjemalloc.so.2 ${pack}/lib/
-    copy_file ./thirdparty/output/lib/libprofiler.so.0 ${pack}/lib/
+    copy_file ${THIRDPARTY_ROOT}/output/lib/libjemalloc.so.2 ${pack}/lib/
+    copy_file ${THIRDPARTY_ROOT}/output/lib/libprofiler.so.0 ${pack}/lib/
 else
-    copy_file ./thirdparty/output/lib/libtcmalloc_and_profiler.so.4 
${pack}/lib/
+    copy_file ${THIRDPARTY_ROOT}/output/lib/libtcmalloc_and_profiler.so.4 
${pack}/lib/
 fi
 
-copy_file ./thirdparty/output/lib/libboost*.so.1.69.0 ${pack}/lib/
-copy_file ./thirdparty/output/lib/libhdfs* ${pack}/lib/
-copy_file ./thirdparty/output/lib/librocksdb.so.8 ${pack}/lib/
+copy_file ${THIRDPARTY_ROOT}/output/lib/libboost*.so.1.69.0 ${pack}/lib/
+copy_file ${THIRDPARTY_ROOT}/output/lib/libhdfs* ${pack}/lib/
+copy_file ${THIRDPARTY_ROOT}/output/lib/librocksdb.so.8 ${pack}/lib/
 copy_file `get_stdcpp_lib $custom_gcc` ${pack}/lib/
 
 pack_tools_lib() {
diff --git a/scripts/recompile_thrift.sh b/scripts/recompile_thrift.sh
index 52e5397be..72135f8aa 100755
--- a/scripts/recompile_thrift.sh
+++ b/scripts/recompile_thrift.sh
@@ -17,7 +17,6 @@
 # under the License.
 
 cd `dirname $0`
-THIRDPARTY_ROOT=../thirdparty
 
 if [ ! -d "$THIRDPARTY_ROOT" ]; then
   echo "ERROR: THIRDPARTY_ROOT not set"
diff --git a/src/sample/run.sh b/src/sample/run.sh
index 646446ef8..5da1a9168 100755
--- a/src/sample/run.sh
+++ b/src/sample/run.sh
@@ -16,5 +16,25 @@
 # specific language governing permissions and limitations
 # under the License.
 
-export 
LD_LIBRARY_PATH=`pwd`/../../../../../thirdparty/output/lib:`pwd`/../../lib:/usr/lib/jvm/java-1.8.0-openjdk/jre/lib/amd64/server
+if [ ! -d "$PEGASUS_THIRDPARTY_ROOT" ]; then
+  echo "ERROR: PEGASUS_THIRDPARTY_ROOT not set"
+  exit 1
+fi
+
+if [ ! -d "$JAVA_HOME" ]; then
+  echo "ERROR: JAVA_HOME not set"
+  exit 1
+fi
+
+ARCH_TYPE=''
+arch_output=$(arch)
+if [ "$arch_output"x == "x86_64"x ]; then
+    ARCH_TYPE="amd64"
+elif [ "$arch_output"x == "aarch64"x ]; then
+    ARCH_TYPE="aarch64"
+else
+    echo "WARNING: unsupported CPU architecture '$arch_output', use 'x86_64' 
as default"
+fi
+export 
LD_LIBRARY_PATH=${JAVA_HOME}/jre/lib/${ARCH_TYPE}:${JAVA_HOME}/jre/lib/${ARCH_TYPE}/server:${PEGASUS_THIRDPARTY_ROOT}/output/lib:$(pwd)/../../lib:${LD_LIBRARY_PATH}
+
 ./sample onebox temp


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to