Skip to content

Commit 32d8326

Browse files
cfriedtnashif
authored andcommitted
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 <[email protected]>
1 parent cbd8519 commit 32d8326

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

samples/modules/thrift/hello/README.rst

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,23 @@ Requirements
5757
west update
5858
5959
- QEMU Networking (described in :ref:`networking_with_qemu`)
60-
- Thrift dependencies installed for your host OS e.g. in Ubuntu
60+
- Thrift dependencies installed for your host OS
6161

62-
.. code-block:: console
63-
:caption: Install additional dependencies in Ubuntu
62+
.. tabs::
63+
64+
.. group-tab:: Ubuntu
65+
66+
.. code-block:: bash
67+
:caption: Install thrift dependencies in Ubuntu
68+
69+
sudo apt install -y libboost-all-dev thrift-compiler libthrift-dev
70+
71+
.. group-tab:: macOS
72+
73+
.. code-block:: bash
74+
:caption: Install thrift dependencies in macOS
6475
65-
sudo apt install -y libboost-all-dev thrift-compiler libthrift-dev
76+
brew install boost openssl thrift
6677
6778
Building and Running
6879
********************

samples/modules/thrift/hello/client/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
.PHONY: all clean
55

6+
OS = $(shell uname -s)
7+
68
CXXFLAGS :=
79
CXXFLAGS += -std=c++17
810

@@ -14,6 +16,14 @@ GENOBJ = $(filter-out %.h, $(GENSRC:.cpp=.o))
1416
THRIFT_FLAGS :=
1517
THRIFT_FLAGS += $(shell pkg-config --cflags thrift)
1618
THRIFT_FLAGS += -I$(GEN_DIR)
19+
ifeq ($(OS),Darwin)
20+
# get Homebrew prefix
21+
HOMEBREW_PREFIX := $(shell brew --prefix)
22+
# get boost include path (no pkgconfig file)
23+
BOOST_INCLUDE := $(shell find $(HOMEBREW_PREFIX) -path '*/Cellar/boost/*/include' -type d | head -n 1)
24+
THRIFT_FLAGS += -I$(BOOST_INCLUDE)
25+
THRIFT_FLAGS += $(shell pkg-config --cflags openssl)
26+
endif
1727
THRIFT_LIBS = $(shell pkg-config --libs thrift)
1828

1929
all: hello_client hello_client_compact hello_client_ssl hello_client_py.stamp

samples/modules/thrift/hello/server/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
.PHONY: all clean
55

6+
OS = $(shell uname -s)
7+
68
CXXFLAGS :=
79
CXXFLAGS += -std=c++17
810

@@ -14,6 +16,14 @@ GENOBJ = $(filter-out %.h, $(GENSRC:.cpp=.o))
1416
THRIFT_FLAGS :=
1517
THRIFT_FLAGS += $(shell pkg-config --cflags thrift)
1618
THRIFT_FLAGS += -I$(GEN_DIR)
19+
ifeq ($(OS),Darwin)
20+
# get Homebrew prefix
21+
HOMEBREW_PREFIX := $(shell brew --prefix)
22+
# get boost include path (no pkgconfig file)
23+
BOOST_INCLUDE := $(shell find $(HOMEBREW_PREFIX) -path '*/Cellar/boost/*/include' -type d | head -n 1)
24+
THRIFT_FLAGS += -I$(BOOST_INCLUDE)
25+
THRIFT_FLAGS += $(shell pkg-config --cflags openssl)
26+
endif
1727
THRIFT_LIBS :=
1828
THRIFT_LIBS = $(shell pkg-config --libs thrift)
1929

0 commit comments

Comments
 (0)