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

jiashunzhu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git


The following commit(s) were added to refs/heads/master by this push:
     new 9d23af8e add bzlmod support (#2670)
9d23af8e is described below

commit 9d23af8e92f04a6609a5a2bc840b531d0eb22c5c
Author: Kevin Li <oathdr...@live.cn>
AuthorDate: Mon Jul 15 00:11:28 2024 +0800

    add bzlmod support (#2670)
    
    * add bzlmod support
    
    * drop buggy clang-11 which dont suport -fno-access-control correctly
    
    * fix typo in ci-linux.yml
    
    * give up trying to test bazel in clang
---
 .bazelrc                       |  7 ++++--
 .bazelversion                  |  2 +-
 .github/workflows/ci-linux.yml | 52 +++++-------------------------------------
 BUILD.bazel                    |  6 ++---
 MODULE.bazel                   | 26 +++++++++++++++++++++
 WORKSPACE.bzlmod               | 15 ++++++++++++
 test/BUILD.bazel               |  6 ++---
 test/thread_key_unittest.cpp   |  3 ++-
 8 files changed, 60 insertions(+), 57 deletions(-)

diff --git a/.bazelrc b/.bazelrc
index f3d406b0..e9aa52ad 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -16,10 +16,13 @@
 #
 # Default build options. These are applied first and unconditionally.
 #
+common --registry=https://bcr.bazel.build
+common --registry=https://baidu.github.io/babylon/registry
+common --registry=https://raw.githubusercontent.com/bazelboost/registry/main
 
-build --cxxopt="-std=c++11"
+build --cxxopt="-std=c++17"
 # Use gnu11 for asm keyword.
-build --conlyopt="-std=gnu11"
+build --conlyopt="-std=gnu17"
 
 # Enable position independent code (this is the default on macOS and Windows)
 # (Workaround for https://github.com/bazelbuild/rules_foreign_cc/issues/421)
diff --git a/.bazelversion b/.bazelversion
index af8c8ec7..a8a18875 100644
--- a/.bazelversion
+++ b/.bazelversion
@@ -1 +1 @@
-4.2.2
+7.1.2
diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml
index 652631f2..56aacee3 100644
--- a/.github/workflows/ci-linux.yml
+++ b/.github/workflows/ci-linux.yml
@@ -46,26 +46,13 @@ jobs:
     runs-on: ubuntu-20.04
     steps:
     - uses: actions/checkout@v2
-    - name: install dependences
-      run: |
-           sudo apt-get update
-           sudo apt-get install libibverbs-dev
-    - name: compile
-      run: |
-           export CC=gcc && export CXX=g++
-           bazel build -j ${{env.proc_num}} -c opt --copt -DHAVE_ZLIB=1 //...
+    - run: bazel test --verbose_failures -- //... -//example/...
   
   gcc-compile-with-boringssl:
     runs-on: ubuntu-20.04
     steps:
     - uses: actions/checkout@v2
-    - name: install dependences
-      run: |
-           sudo apt-get update
-           sudo apt-get install libibverbs-dev
-    - name: compile-with-boringssl
-      run: |
-          bazel build -j 12 -c opt --define with_mesalink=false --define 
with_glog=true --define with_thrift=true --define BRPC_WITH_BORINGSSL=true 
--copt -DHAVE_ZLIB=1 //...
+    - run: bazel test --verbose_failures --define with_mesalink=false --define 
with_glog=true --define with_thrift=true --define BRPC_WITH_BORINGSSL=true -- 
//... -//example/...
 
   gcc-compile-with-make-all-options:
     runs-on: ubuntu-20.04
@@ -99,14 +86,7 @@ jobs:
     runs-on: ubuntu-20.04
     steps:
     - uses: actions/checkout@v2
-    - name: install dependences
-      run: |
-           sudo apt-get update
-           sudo apt-get install libibverbs-dev
-    - name: compile
-      run: |
-           export CC=gcc && export CXX=g++
-           bazel build -j 12 -c opt --define with_mesalink=false --define 
with_glog=true --define with_thrift=true --copt -DHAVE_ZLIB=1 //...
+    - run: bazel test --verbose_failures --define with_mesalink=false --define 
with_glog=true --define with_thrift=true -- //... -//example/...
 
   clang-compile-with-make:
     runs-on: ubuntu-20.04
@@ -140,26 +120,13 @@ jobs:
     runs-on: ubuntu-20.04
     steps:
     - uses: actions/checkout@v2
-    - name: install dependences
-      run: |
-           sudo apt-get update
-           sudo apt-get install libibverbs-dev
-    - name: compile
-      run: |
-           export CC=clang && export CXX=clang++
-           bazel build -j ${{env.proc_num}} -c opt --copt -DHAVE_ZLIB=1 //...
+    - run: bazel build --verbose_failures --action_env=CC=clang-12 -- //... 
-//example/...
 
   clang-compile-with-boringssl:
     runs-on: ubuntu-20.04
     steps:
     - uses: actions/checkout@v2
-    - name: install dependences
-      run: |
-           sudo apt-get update
-           sudo apt-get install libibverbs-dev
-    - name: compile
-      run: |
-        bazel build -j ${{env.proc_num}} -c opt --define with_mesalink=false 
--define with_glog=true --define with_thrift=true --define 
BRPC_WITH_BORINGSSL=true  --copt -DHAVE_ZLIB=1 //...
+    - run: bazel build --verbose_failures --action_env=CC=clang-12 --define 
with_mesalink=false --define with_glog=true --define with_thrift=true --define 
BRPC_WITH_BORINGSSL=true -- //... -//example/...
 
   clang-compile-with-make-all-options:
     runs-on: ubuntu-20.04
@@ -193,14 +160,7 @@ jobs:
     runs-on: ubuntu-20.04
     steps:
     - uses: actions/checkout@v2
-    - name: install dependences
-      run: |
-           sudo apt-get update
-           sudo apt-get install libibverbs-dev
-    - name: compile
-      run: |
-           export CC=clang && export CXX=clang++
-           bazel build -j ${{env.proc_num}} -c opt --define 
with_mesalink=false --define with_glog=true --define with_thrift=true --copt 
-DHAVE_ZLIB=1 //...
+    - run: bazel build --verbose_failures --action_env=CC=clang-12 --define 
with_mesalink=false --define with_glog=true --define with_thrift=true -- //... 
-//example/...
 
   clang-unittest:
     runs-on: ubuntu-20.04
diff --git a/BUILD.bazel b/BUILD.bazel
index b2a453e0..795e392e 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -51,7 +51,7 @@ LINKOPTS = [
     "-pthread",
     "-ldl",
 ] + select({
-    "@bazel_tools//tools/osx:darwin": [
+    "@bazel_tools//tools/osx:darwin_x86_64": [
         "-framework CoreFoundation",
         "-framework CoreGraphics",
         "-framework CoreData",
@@ -218,7 +218,7 @@ BUTIL_SRCS = [
     "src/butil/recordio.cc",
     "src/butil/popen.cpp",
 ] + select({
-    "@bazel_tools//tools/osx:darwin": [
+    "@bazel_tools//tools/osx:darwin_x86_64": [
         "src/butil/time/time_mac.cc",
         "src/butil/mac/scoped_mach_port.cc",
     ],
@@ -333,7 +333,7 @@ cc_library(
         "//bazel/config:brpc_with_glog": ["@com_github_google_glog//:glog"],
         "//conditions:default": [],
     }) + select({
-        "@bazel_tools//tools/osx:darwin": [":macos_lib"],
+        "@bazel_tools//tools/osx:darwin_x86_64": [":macos_lib"],
         "//conditions:default": [],
     }) + select({
         "//bazel/config:brpc_with_boringssl": ["@boringssl//:ssl", 
"@boringssl//:crypto"],
diff --git a/MODULE.bazel b/MODULE.bazel
new file mode 100644
index 00000000..0190a3d0
--- /dev/null
+++ b/MODULE.bazel
@@ -0,0 +1,26 @@
+module(
+  name = 'brpc',
+  version = '1.9.0',
+  compatibility_level = 1,
+)
+
+# https://bcr.bazel.build
+bazel_dep(name = 'abseil-cpp', version = '20210324.2', repo_name = 
'com_google_absl')
+bazel_dep(name = 'bazel_skylib', version = '1.0.3')
+bazel_dep(name = 'boringssl', version = '0.0.0-20211025-d4f1ab9')
+bazel_dep(name = 'protobuf', version = '3.19.6', repo_name = 
'com_google_protobuf')
+bazel_dep(name = 'gflags', version = '2.2.2', repo_name = 
'com_github_gflags_gflags')
+bazel_dep(name = 'glog', version = '0.5.0', repo_name = 
'com_github_google_glog')
+bazel_dep(name = 'platforms', version = '0.0.4')
+bazel_dep(name = 'rules_cc', version = '0.0.1')
+bazel_dep(name = 'rules_proto', version = '4.0.0')
+bazel_dep(name = 'zlib', version = '1.2.13', repo_name = 
'com_github_madler_zlib')
+
+# https://baidu.github.io/babylon/registry
+# https://raw.githubusercontent.com/bazelboost/registry/main
+bazel_dep(name = 'leveldb', version = '1.23', repo_name = 
'com_github_google_leveldb')
+bazel_dep(name = 'openssl', version = '3.3.1')
+bazel_dep(name = 'thrift', version = '0.20.0', repo_name = 'org_apache_thrift')
+
+# test only
+bazel_dep(name = 'googletest', version = '1.14.0.bcr.1', repo_name = 
'com_google_googletest', dev_dependency = True)
diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod
new file mode 100644
index 00000000..d0f39e7d
--- /dev/null
+++ b/WORKSPACE.bzlmod
@@ -0,0 +1,15 @@
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+
+#
+# Tools Dependencies
+#
+# Hedron's Compile Commands Extractor for Bazel
+# https://github.com/hedronvision/bazel-compile-commands-extractor
+http_archive(
+    name = "hedron_compile_commands",
+    url = 
"https://github.com/hedronvision/bazel-compile-commands-extractor/archive/3dddf205a1f5cde20faf2444c1757abe0564ff4c.tar.gz";,
+    strip_prefix = 
"bazel-compile-commands-extractor-3dddf205a1f5cde20faf2444c1757abe0564ff4c",
+    sha256 = 
"3cd0e49f0f4a6d406c1d74b53b7616f5e24f5fd319eafc1bf8eee6e14124d115",
+)
+load("@hedron_compile_commands//:workspace_setup.bzl", 
"hedron_compile_commands_setup")
+hedron_compile_commands_setup()
diff --git a/test/BUILD.bazel b/test/BUILD.bazel
index 345043fc..d9af2ae7 100644
--- a/test/BUILD.bazel
+++ b/test/BUILD.bazel
@@ -30,9 +30,7 @@ COPTS = [
     "-Wno-unused-parameter",
     "-fno-omit-frame-pointer",
     "-DGFLAGS_NS=google",
-    "-Dprivate=public",
-    "-Dprotected=public",
-    "--include test/sstream_workaround.h",
+    "-fno-access-control",
     "-DBAZEL_TEST=1",
     "-DBVAR_NOT_LINK_DEFAULT_VARIABLES",
     "-DUNIT_TEST",
@@ -142,7 +140,7 @@ TEST_BUTIL_SOURCES = [
     "bounded_queue_unittest.cc",
     "butil_unittest_main.cpp",
 ] + select({
-    "@bazel_tools//tools/osx:darwin": [],
+    "@bazel_tools//tools/osx:darwin_x86_64": [],
     "//conditions:default": [
         "test_file_util_linux.cc",
         "proc_maps_linux_unittest.cc",
diff --git a/test/thread_key_unittest.cpp b/test/thread_key_unittest.cpp
index adbeb024..f254ce41 100644
--- a/test/thread_key_unittest.cpp
+++ b/test/thread_key_unittest.cpp
@@ -178,6 +178,7 @@ void* ThreadLocalForEachFunc(void* arg) {
     auto counter = static_cast<ThreadLocal<butil::atomic<int>>*>(arg);
     auto local_counter = counter->get();
     EXPECT_NE(nullptr, local_counter);
+    local_counter->store(0, butil::memory_order_relaxed);
     while (!g_stopped) {
         local_counter->fetch_add(1, butil::memory_order_relaxed);
         g_counter.fetch_add(1, butil::memory_order_relaxed);
@@ -497,4 +498,4 @@ TEST(ThreadLocalTest, thread_key_performance) {
 }
 
 }
-} // namespace butil
\ No newline at end of file
+} // namespace butil


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org

Reply via email to