Browse Source

Link MesaLink in bazel if enabled

Yiming Jing 4 years ago
parent
commit
862be4e112
4 changed files with 25 additions and 9 deletions
  1. 4 4
      .travis.yml
  2. 17 3
      BUILD
  3. 2 0
      CMakeLists.txt
  4. 2 2
      build_in_travis_ci.sh

+ 4 - 4
.travis.yml

@@ -11,10 +11,10 @@ env:
 - PURPOSE=unittest
 - PURPOSE=compile-with-cmake
 - PURPOSE=compile-with-bazel
-- PURPOSE=compile USE_MESALINK=yes
-- PURPOSE=unittest USE_MESALINK=yes
-- PURPOSE=compile-with-cmake USE_MESALINK=yes
-- PURPOSE=compile-with-bazel USE_MESALINK=yes
+- PURPOSE=compile USE_MESALINK=true
+- PURPOSE=unittest USE_MESALINK=true
+- PURPOSE=compile-with-cmake USE_MESALINK=true
+- PURPOSE=compile-with-bazel USE_MESALINK=true
 
 before_script:
 - ulimit -c unlimited -S       # enable core dumps

+ 17 - 3
BUILD

@@ -10,6 +10,12 @@ config_setting(
     visibility = ["//visibility:public"],
 )
 
+config_setting(
+    name = "with_mesalink",
+    define_values = {"with_mesalink": "true"},
+    visibility = ["//visibility:public"],
+)
+
 config_setting(
     name = "with_thrift",
     define_values = {"with_thrift": "true"},
@@ -46,6 +52,9 @@ COPTS = [
 ] + select({
     ":with_glog": ["-DBRPC_WITH_GLOG=1"],
     "//conditions:default": ["-DBRPC_WITH_GLOG=0"],
+}) + select({
+    ":with_mesalink": ["-DUSE_MESALINK"],
+    "//conditions:default": [""],
 }) + select({
     ":with_thrift": ["-DENABLE_THRIFT_FRAMED_PROTOCOL=1"],
     "//conditions:default": [""],
@@ -54,7 +63,7 @@ COPTS = [
 LINKOPTS = [
     "-lpthread",
     "-ldl",
-    "-lz", 
+    "-lz",
     "-lssl",
     "-lcrypto",
 ] + select({
@@ -73,6 +82,11 @@ LINKOPTS = [
     "//conditions:default": [
       "-lrt",
     ],
+}) + select({
+    ":with_mesalink": [
+        "-lmesalink",
+    ],
+    "//conditions:default": [],
 }) + select({
     ":with_thrift": [
         "-lthriftnb",
@@ -236,7 +250,7 @@ objc_library(
         "src/butil/atomicops.h",
         "src/butil/atomicops_internals_atomicword_compat.h",
         "src/butil/atomicops_internals_mac.h",
-        "src/butil/base_export.h",        
+        "src/butil/base_export.h",
         "src/butil/basictypes.h",
         "src/butil/build_config.h",
         "src/butil/compat.h",
@@ -270,7 +284,7 @@ objc_library(
         "src/butil/strings/sys_string_conversions.h",
         "src/butil/synchronization/lock.h",
         "src/butil/time/time.h",
-        "src/butil/time.h",        
+        "src/butil/time.h",
         "src/butil/third_party/dynamic_annotations/dynamic_annotations.h",
         "src/butil/threading/platform_thread.h",
         "src/butil/threading/thread_restrictions.h",

+ 2 - 0
CMakeLists.txt

@@ -146,6 +146,8 @@ if(WITH_MESALINK)
     find_library(MESALINK_LIB NAMES mesalink)
     if((NOT MESALINK_INCLUDE_PATH) OR (NOT MESALINK_LIB))
         message(FATAL_ERROR "Fail to find MesaLink")
+    else()
+        message(STATUS "Found MesaLink: ${MESALINK_LIB}")
     endif()
     include_directories(${MESALINK_INCLUDE_PATH})
 endif()

+ 2 - 2
build_in_travis_ci.sh

@@ -23,7 +23,7 @@ echo "build combination: PURPOSE=$PURPOSE CXX=$CXX CC=$CC"
 
 init_make_config() {
 EXTRA_BUILD_OPTS=""
-if [ "$USE_MESALINK" = "yes" ]; then
+if [ "$USE_MESALINK" = "true" ]; then
     EXTRA_BUILD_OPTS="$EXTRA_BUILD_OPTS --with-mesalink"
 fi
 
@@ -42,7 +42,7 @@ elif [ "$PURPOSE" = "unittest" ]; then
 elif [ "$PURPOSE" = "compile-with-cmake" ]; then
     rm -rf bld && mkdir bld && cd bld && cmake -DWITH_MESALINK="$USE_MESALINK" .. && make -j4
 elif [ "$PURPOSE" = "compile-with-bazel" ]; then
-    bazel build -j 12 -c opt --copt -DHAVE_ZLIB=1 //...
+    bazel build -j 12 -c opt --define with_mesalink="$USE_MESALINK" --copt -DHAVE_ZLIB=1 //...
 else
     echo "Unknown purpose=\"$PURPOSE\""
 fi