Skip to content

Commit 4709e4c

Browse files
vincent-xsVincent Legrand
authored andcommitted
allow vendor specific lib for saithrift server compile (#234)
* allow vendor specific lib for saithrift server compile modify dashpipeline to guarantee PWD is the makefile location * update saithrift server build documentation * spellcheck Co-authored-by: Vincent Legrand <vincentl@xsl-bos1>
1 parent e25b13d commit 4709e4c

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

.wordlist.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,9 @@ Keysight
281281
KVM
282282
kvm
283283
lang
284+
LIBS
284285
libsai
286+
libprotobuf
285287
linux
286288
liveness
287289
LLDP
@@ -441,6 +443,7 @@ rx
441443
SAI
442444
sai
443445
sairedis
446+
SAIRPC
444447
saiserver
445448
saithrift
446449
sata

dash-pipeline/Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
SHELL = /bin/bash
22

3+
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
4+
mkfile_dir := $(dir $(mkfile_path))
5+
36
# "All" type targets for convenience
47
all:p4 sai saithrift-server docker-saithrift-client test
58

@@ -13,7 +16,7 @@ clean: kill-all p4-clean sai-clean test-clean network-clean saithrift-server-cle
1316

1417
kill-all: kill-saithrift-server kill-switch undeploy-ixiac
1518

16-
PWD := $(shell pwd)
19+
PWD := $(realpath $(mkfile_dir))
1720
DASH_USER ?=dashuser
1821
DASH_GROUP ?=dashusers
1922
DASH_UID ?=4321
@@ -102,14 +105,15 @@ $(P4_ARTIFACTS): $(P4_SRC)
102105
# DASH SAI HEADER & libsai.so TARGETS
103106
######################################
104107

105-
108+
SAIRPC_VENDOR_EXTRA_LIBS?=""
106109
# Note we have to mount main DASH dir to allow container to "see" the parent Git repo for the SAI submodule
107110
DOCKER_RUN_SAITHRIFT_BLDR =\
108111
docker run \
109112
$(DOCKER_FLAGS) \
110113
--rm \
111114
--name dash-saithrift-bldr-$(USER) \
112115
-v $(PWD)/..:/dash -w /dash/dash-pipeline/SAI/saithrift \
116+
-e SAIRPC_VENDOR_EXTRA_LIBS=$(SAIRPC_VENDOR_EXTRA_LIBS) \
113117
$(DOCKER_SAITHRIFT_BLDR_IMG) \
114118

115119
# TODO - create separate rules for headers, libsai.so

dash-pipeline/README-dash-workflows.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,23 @@ This builds a saithrift-server daemon, which is linked to the `libsai` library a
247247
```
248248
make saithrift-server
249249
```
250+
In the case a vendor integrates its own `libsai` library into the saithrift server, the libsai might have new external dependencies (such as google protocol buffer) thus requiring for vendor specific libraries or linker options to be passed down to the saiserver linker.
251+
An environment variable (SAIRPC_VENDOR_EXTRA_LIBS) can be specified when invoking the saithrift server build command to provide path to new libraries and/or new linker options.
252+
Its value will be added to the baseline SAIRPC_EXTRA_LIBS as defined in the saithrift makefile.
253+
254+
Since the saithrift server is built within a docker container (and the parent repository is mounted as /dash), any of the extra libraries needed will need to be copied over under the parent repository, and the paths to those libraries will need to be relative to the docker mount point.
255+
256+
In the example below, libprotobuf.a is a new external dependency to the vendor specific libsai.so and has been copied over under the parent repository (in our case, dash-pipeline/SAI/lib).
257+
We use the provided Makefile.3rdpty as an entry point into the DASH makefiles.
258+
259+
```
260+
SAIRPC_VENDOR_EXTRA_LIBS="/dash/dash-pipeline/SAI/lib/libprotobuf.a"
261+
thirdparty-saithrift-server: thirdparty-libsai
262+
@echo "Build third-party saithrift-server"
263+
@echo " Expects libsai.so under $(DASHDIR)/dash-pipeline/SAI/lib"
264+
SAIRPC_VENDOR_EXTRA_LIBS=$(SAIRPC_VENDOR_EXTRA_LIBS) $(MAKE) -C $(DASHDIR)/dash-pipeline saithrift-server
265+
```
266+
250267
## Build libsai C++ client test program(s)
251268
This compiles simple libsai client program(s) to verify the libsai-to-p4runtime-to-bmv2 stack. It performs table access(es).
252269

dash-pipeline/SAI/saithrift/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ RPC_INST_DIR=$(shell pwd)/../rpc
77

88
META=../SAI/meta
99

10-
SAIRPC_EXTRA_LIBS="\
10+
SAIRPC_VENDOR_EXTRA_LIBS?=
11+
SAIRPC_EXTRA_LIBS= "$(SAIRPC_VENDOR_EXTRA_LIBS) \
1112
-L/lib/x86_64-linux-gnu -Wl,-rpath=/lib/x86_64-linux-gnu -lm \
1213
-L/usr/local/lib/ -Wl,-rpath=/usr/local/lib \
1314
-lpthread \

0 commit comments

Comments
 (0)