From 3482d3185982b3c687ab33faa71e904e0e28c9bc Mon Sep 17 00:00:00 2001 From: Chris Friedt Date: Wed, 19 Jun 2024 13:59:56 -0400 Subject: [PATCH] modules: thrift: update doc and cmake to build with macos Added tabs to the thrift doc so that building works for macos and is consistent with the rest of the documentation in terms of one tab per os. Updated client and server makefiles to discover include paths for boost and openssl. Signed-off-by: Chris Friedt --- samples/modules/thrift/hello/README.rst | 19 +++++++++++++++---- samples/modules/thrift/hello/client/Makefile | 10 ++++++++++ samples/modules/thrift/hello/server/Makefile | 10 ++++++++++ 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/samples/modules/thrift/hello/README.rst b/samples/modules/thrift/hello/README.rst index a773bc547b56d..53b400a4c0bfa 100644 --- a/samples/modules/thrift/hello/README.rst +++ b/samples/modules/thrift/hello/README.rst @@ -57,12 +57,23 @@ Requirements west update - QEMU Networking (described in :ref:`networking_with_qemu`) -- Thrift dependencies installed for your host OS e.g. in Ubuntu +- Thrift dependencies installed for your host OS -.. code-block:: console - :caption: Install additional dependencies in Ubuntu +.. tabs:: + + .. group-tab:: Ubuntu + + .. code-block:: bash + :caption: Install thrift dependencies in Ubuntu + + sudo apt install -y libboost-all-dev thrift-compiler libthrift-dev + + .. group-tab:: macOS + + .. code-block:: bash + :caption: Install thrift dependencies in macOS - sudo apt install -y libboost-all-dev thrift-compiler libthrift-dev + brew install boost openssl thrift Building and Running ******************** diff --git a/samples/modules/thrift/hello/client/Makefile b/samples/modules/thrift/hello/client/Makefile index dabdf64c0ca74..218fd0928e9ed 100644 --- a/samples/modules/thrift/hello/client/Makefile +++ b/samples/modules/thrift/hello/client/Makefile @@ -3,6 +3,8 @@ .PHONY: all clean +OS = $(shell uname -s) + CXXFLAGS := CXXFLAGS += -std=c++17 @@ -14,6 +16,14 @@ GENOBJ = $(filter-out %.h, $(GENSRC:.cpp=.o)) THRIFT_FLAGS := THRIFT_FLAGS += $(shell pkg-config --cflags thrift) THRIFT_FLAGS += -I$(GEN_DIR) +ifeq ($(OS),Darwin) +# get Homebrew prefix +HOMEBREW_PREFIX := $(shell brew --prefix) +# get boost include path (no pkgconfig file) +BOOST_INCLUDE := $(shell find $(HOMEBREW_PREFIX) -path '*/Cellar/boost/*/include' -type d | head -n 1) +THRIFT_FLAGS += -I$(BOOST_INCLUDE) +THRIFT_FLAGS += $(shell pkg-config --cflags openssl) +endif THRIFT_LIBS = $(shell pkg-config --libs thrift) all: hello_client hello_client_compact hello_client_ssl hello_client_py.stamp diff --git a/samples/modules/thrift/hello/server/Makefile b/samples/modules/thrift/hello/server/Makefile index 20fc9bf625c3d..7f98ded3fef43 100644 --- a/samples/modules/thrift/hello/server/Makefile +++ b/samples/modules/thrift/hello/server/Makefile @@ -3,6 +3,8 @@ .PHONY: all clean +OS = $(shell uname -s) + CXXFLAGS := CXXFLAGS += -std=c++17 @@ -14,6 +16,14 @@ GENOBJ = $(filter-out %.h, $(GENSRC:.cpp=.o)) THRIFT_FLAGS := THRIFT_FLAGS += $(shell pkg-config --cflags thrift) THRIFT_FLAGS += -I$(GEN_DIR) +ifeq ($(OS),Darwin) +# get Homebrew prefix +HOMEBREW_PREFIX := $(shell brew --prefix) +# get boost include path (no pkgconfig file) +BOOST_INCLUDE := $(shell find $(HOMEBREW_PREFIX) -path '*/Cellar/boost/*/include' -type d | head -n 1) +THRIFT_FLAGS += -I$(BOOST_INCLUDE) +THRIFT_FLAGS += $(shell pkg-config --cflags openssl) +endif THRIFT_LIBS := THRIFT_LIBS = $(shell pkg-config --libs thrift)