diff --git a/dash-pipeline/SAI/debian/changelog b/dash-pipeline/SAI/debian/changelog new file mode 100644 index 000000000..3564f1214 --- /dev/null +++ b/dash-pipeline/SAI/debian/changelog @@ -0,0 +1,5 @@ +sonic (1.0.0) stable; urgency=medium + + * Initial release. + + -- Ze Gan Tue, 10 Jan 2023 12:00:00 -0800 \ No newline at end of file diff --git a/dash-pipeline/SAI/debian/compat b/dash-pipeline/SAI/debian/compat new file mode 100644 index 000000000..9a037142a --- /dev/null +++ b/dash-pipeline/SAI/debian/compat @@ -0,0 +1 @@ +10 \ No newline at end of file diff --git a/dash-pipeline/SAI/debian/control b/dash-pipeline/SAI/debian/control new file mode 100644 index 000000000..12b7df6c3 --- /dev/null +++ b/dash-pipeline/SAI/debian/control @@ -0,0 +1,11 @@ +Source: sonic +Maintainer: Ze Gan +Section: net +Priority: optional +Build-Depends: dh-exec (>=0.3), debhelper (>= 9), autotools-dev, cmake, composer, patchelf +Standards-Version: 1.0.0 + +Package: sai-dash +Architecture: any +Depends: ${shlibs:Depends} +Description: This package contains SAI of dash. diff --git a/dash-pipeline/SAI/debian/rules b/dash-pipeline/SAI/debian/rules new file mode 100644 index 000000000..a41d933a3 --- /dev/null +++ b/dash-pipeline/SAI/debian/rules @@ -0,0 +1,34 @@ +#!/usr/bin/make -f +# See debhelper(7) (uncomment to enable) +# output every command that modifies files on the build system. +#export DH_VERBOSE = 1 + +# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/* +DPKG_EXPORT_BUILDFLAGS = 1 +include /usr/share/dpkg/default.mk + +# see FEATURE AREAS in dpkg-buildflags(1) +#export DEB_BUILD_MAINT_OPTIONS = hardening=+all + +# see ENVIRONMENT in dpkg-buildflags(1) +# package maintainers to append CFLAGS +#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic +# package maintainers to append LDFLAGS +#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed + + +# main packaging script based on dh7 syntax +%: + dh $@ + +# dh_make generated override targets +# This is example for Cmake (See https://bugs.debian.org/641051 ) +#override_dh_auto_configure: +# dh_auto_configure -- \ +# -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) + +override_dh_auto_make: + dh_auto_make -- libsai-dash.so + +override_dh_auto_install: + dh_auto_install --destdir=debian/libsai-dash diff --git a/dash-pipeline/SAI/generate_dash_api.sh b/dash-pipeline/SAI/generate_dash_api.sh index d3c73ebe2..553a0a372 100755 --- a/dash-pipeline/SAI/generate_dash_api.sh +++ b/dash-pipeline/SAI/generate_dash_api.sh @@ -3,3 +3,6 @@ /bmv2/dash_pipeline.bmv2/dash_pipeline_p4rt.json \ --ignore-tables=appliance,eni_meter,slb_decap \ dash +cp /bmv2/dash_pipeline.bmv2/dash_pipeline_p4rt.json ./lib +cp /bmv2/dash_pipeline.bmv2/dash_pipeline_p4rt.txt ./lib +cp -r debian/ ./lib diff --git a/dash-pipeline/SAI/templates/Makefile.j2 b/dash-pipeline/SAI/templates/Makefile.j2 index 89417578a..aa11089cc 100644 --- a/dash-pipeline/SAI/templates/Makefile.j2 +++ b/dash-pipeline/SAI/templates/Makefile.j2 @@ -2,6 +2,10 @@ # THIS MAKEFILE IS AUTO-GENERATED FROM templates/Makefile.j2 # DO NOT MODIFY +.ONESHELL: +SHELL = /bin/bash +.SHELLFLAGS += -e + # Sources from OCP SAI Repo: SAI_DIR=../SAI/meta/ SAI_SRCS=saimetadatautils.c \ @@ -49,3 +53,86 @@ libsai.so: $(DASH_FIXED_SAI_SRCS) $(DASH_GEN_SAI_SRCS) $(DASH_FIXED_SAI_OBJ) \ $(DASH_GEN_SAI_OBJ) \ $(SAI_OBJS) + +libprotobuf: + git clone --depth=1 -b v3.18.1 https://github.com/google/protobuf.git + pushd ./protobuf + ./autogen.sh + ./configure + make -j + sudo make install + sudo ldconfig + popd + +libgrpc: + git clone --depth=1 -b v1.43.2 https://github.com/google/grpc.git + pushd ./grpc + git submodule update --init --recursive + mkdir -p cmake/build + pushd ./cmake/build + cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=ON ../.. + make -j + sudo make install + sudo ldconfig + popd + popd + +libbm: + git clone https://github.com/p4lang/behavioral-model.git + pushd ./behavioral-model + git checkout 9417f2d742cc9325c09e4a222a9b0702d0ce656a + apt install -y composer + bash ci/install-thrift.sh + bash ci/install-nanomsg.sh + sudo ldconfig + ./autogen.sh + ./configure + make -j + sudo make install + popd + +libpi: libprotobuf libgrpc libbm + git clone https://github.com/p4lang/PI.git + pushd ./PI + git checkout 21592d61b314ba0c44a7409a733dbf9e46da6556 + git submodule update --init --recursive + ./autogen.sh + ./configure --with-proto --with-bmv2 + make -j + make check + sudo make install + popd + +libsai-dash.so: libpi libgrpc $(DASH_FIXED_SAI_SRCS) $(DASH_GEN_SAI_SRCS) + g++ \ + -fpermissive \ + -c \ + -I ../SAI/meta/ \ + -I ../SAI/inc/ \ + -I ../SAI/experimental/ \ + -fPIC \ + -g \ + $(GXX_FLAGS) \ + $(DASH_FIXED_SAI_SRCS) \ + $(DASH_GEN_SAI_SRCS) + + g++ \ + -shared \ + -g \ + -o libsai-dash.so \ + -lpiprotogrpc \ + -lgrpc++ \ + $(DASH_FIXED_SAI_OBJ) \ + $(DASH_GEN_SAI_OBJ) + +INSTALL_DIR:=/usr/lib/libsai-dash +CONF_DIR:=/etc/dash + +install: + sudo mkdir -p $(DESTDIR)/$(INSTALL_DIR) + sudo cp libsai-dash.so $(DESTDIR)/$(INSTALL_DIR) + cp $(shell ldd libsai-dash.so | awk '{print $$3}' | grep /usr/local) $(DESTDIR)/$(INSTALL_DIR) + find $(DESTDIR)/$(INSTALL_DIR) -name '*.so*' -exec patchelf --set-rpath $(INSTALL_DIR) {} \; + sudo mkdir -p $(DESTDIR)/$(CONF_DIR) + sudo cp dash_pipeline_p4rt.txt $(DESTDIR)/$(CONF_DIR) + sudo cp dash_pipeline_p4rt.json $(DESTDIR)$(CONF_DIR)