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

guangmingchen 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 33c4396d Make unit tests runnable on macOS (#3018)
33c4396d is described below

commit 33c4396de7d644414534d8da83870854c0aaf18e
Author: Chen Chuanle <60637740+git...@users.noreply.github.com>
AuthorDate: Sun Jul 6 23:27:14 2025 +0800

    Make unit tests runnable on macOS (#3018)
---
 test/Makefile | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/test/Makefile b/test/Makefile
index 0f1534b7..30e196bb 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -21,6 +21,11 @@ include ../config.mk
 CPPFLAGS+=-DBTHREAD_USE_FAST_PTHREAD_MUTEX -D_GNU_SOURCE -DUSE_SYMBOLIZE 
-DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-D__STDC_CONSTANT_MACROS -DUNIT_TEST -Dprivate=public -Dprotected=public 
-DBVAR_NOT_LINK_DEFAULT_VARIABLES --include sstream_workaround.h
 CXXFLAGS+=$(CPPFLAGS) -pipe -Wall -W -fPIC -fstrict-aliasing 
-Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer -std=c++0x
 
+# On Darwin, only gtest library is needed, other libraries have been linked in 
`brpc.dbg.dylib`
+ifeq ($(SYSTEM),Darwin)
+  GTEST_STATIC_LINKINGS := $(filter %libgtest.a 
%libgtest_main.a,$(STATIC_LINKINGS))
+endif
+
 #required by butil/crc32.cc to boost performance for 10x
 ifeq ($(shell test $(GCC_VERSION) -ge 40400; echo $$?),0)
   ifeq ($(shell uname -p),i386)  #note: i386 is processor family type, not the 
32-bit x86 arch
@@ -210,7 +215,7 @@ test_butil:$(TEST_BUTIL_OBJS) | libbrpc.dbg.$(SOEXT)
 ifeq ($(SYSTEM),Linux)
        $(CXX) -o $@ $(LIBPATHS) $(SOPATHS) -Xlinker "-(" $^ -Xlinker "-)" 
$(STATIC_LINKINGS) $(UT_DYNAMIC_LINKINGS)
 else ifeq ($(SYSTEM),Darwin)
-       $(CXX) -o $@ $(LIBPATHS) $(SOPATHS) $^ $(STATIC_LINKINGS) 
$(UT_DYNAMIC_LINKINGS)
+       $(CXX) -o $@ $(LIBPATHS) $(SOPATHS) $^ $(GTEST_STATIC_LINKINGS) 
$(UT_DYNAMIC_LINKINGS)
 endif
 
 test_bvar:libbvar.dbg.a $(TEST_BVAR_OBJS)
@@ -226,7 +231,7 @@ bthread%unittest:bthread%unittest.o | libbrpc.dbg.$(SOEXT)
 ifeq ($(SYSTEM),Linux)
        $(CXX) -o $@ $(LIBPATHS) $(SOPATHS) -Xlinker "-(" $^ -Xlinker "-)" 
$(STATIC_LINKINGS) $(UT_DYNAMIC_LINKINGS)
 else ifeq ($(SYSTEM),Darwin)
-       $(CXX) -o $@ $(LIBPATHS) $(SOPATHS) $^ $(STATIC_LINKINGS) 
$(UT_DYNAMIC_LINKINGS)
+       $(CXX) -o $@ $(LIBPATHS) $(SOPATHS) $^ $(GTEST_STATIC_LINKINGS) 
$(UT_DYNAMIC_LINKINGS)
 endif
 
 brpc_%_unittest:$(TEST_PROTO_OBJS) brpc_%_unittest.o | libbrpc.dbg.$(SOEXT)
@@ -234,7 +239,7 @@ brpc_%_unittest:$(TEST_PROTO_OBJS) brpc_%_unittest.o | 
libbrpc.dbg.$(SOEXT)
 ifeq ($(SYSTEM),Linux)
        $(CXX) -o $@ $(LIBPATHS) $(SOPATHS) -Xlinker "-(" $^ -Xlinker "-)" 
$(STATIC_LINKINGS) $(UT_DYNAMIC_LINKINGS)
 else ifeq ($(SYSTEM),Darwin)
-       $(CXX) -o $@ $(LIBPATHS) $(SOPATHS) $^ $(STATIC_LINKINGS) 
$(UT_DYNAMIC_LINKINGS)
+       $(CXX) -o $@ $(LIBPATHS) $(SOPATHS) $^ $(GTEST_STATIC_LINKINGS) 
$(UT_DYNAMIC_LINKINGS)
 endif
 
 %.pb.cc %.pb.h:%.proto


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

Reply via email to