blob: 7995fd6ac0394fafb52277c4630a78fa64583c58 [file] [log] [blame]
Kim Kempf531d52d2017-10-02 17:10:54 -07001#
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16#
17# Run from OpenNetworkLinux top directory
18#
19#cd /aux/OpenNetworkLinux
20set -e
Kim Kempf531d52d2017-10-02 17:10:54 -070021ASFVOLT_REPO_NAME=asfvolt16-driver
Kim Kempfe109db72017-10-05 13:12:54 -070022: ${MAKE_JOBS:=4}
Kim Kempf531d52d2017-10-02 17:10:54 -070023
24# override shell variables to match custom local build environment
25: ${ONL_TOPDIR:=`pwd`}
26: ${BALSRC_RELEASE=bal_src_release}
27: ${VOLTHA_TOPDIR:=${HOME}/voltha/incubator/voltha}
28: ${BALSRC_TOPDIR:=${ONL_TOPDIR}/${BALSRC_RELEASE}/bal_release}
29: ${ASFSRC_TOPDIR:=${ONL_TOPDIR}/${ASFVOLT_REPO_NAME}/src}
30: ${DEVSIM_TOPDIR:=${ONL_TOPDIR}/${ASFVOLT_REPO_NAME}/device_simulator}
Kim Kempfe109db72017-10-05 13:12:54 -070031: ${PATCHF_TOPDIR:=${ONL_TOPDIR}/${ASFVOLT_REPO_NAME}/patches}
Kim Kempf531d52d2017-10-02 17:10:54 -070032
33echo ONL_TOPDIR=${ONL_TOPDIR}
Kim Kempfe109db72017-10-05 13:12:54 -070034echo MAKE_JOBS=${MAKE_JOBS}
Kim Kempf531d52d2017-10-02 17:10:54 -070035echo BALSRC_RELEASE=${BALSRC_RELEASE}
36echo VOLTHA_TOPDIR=${VOLTHA_TOPDIR}
37echo BALSRC_TOPDIR=${BALSRC_TOPDIR}
38echo ASFSRC_TOPDIR=${ASFSRC_TOPDIR}
39echo DEVSIM_TOPDIR=${DEVSIM_TOPDIR}
40echo PATCHF_TOPDIR=${PATCHF_TOPDIR}
41
42# archived ZIP files from "https://github.com/opennetworkinglab/asfvolt16-driver/tree/master/third_party"
43GRPC_ARCH=ed7d06af3eef1c27f10328c73b3ae3ab10d72b10
44GRPC_C_ARCH=be82ab1605717f33e2e0d3038996ea46d9efe25e
45PROTOBUF_ARCH=703cd8e11c8d34283d4c8bf869c61866e8211c9d
46PROTOBUF_C_ARCH=6a4f9a9a67c06769aaa9f65e8f89a56483271f5a
47
Kim Kempfe109db72017-10-05 13:12:54 -070048# Note: removes existing directories: grpc, protobuf
Kim Kempf531d52d2017-10-02 17:10:54 -070049rm -rf grpc protobuf grpc-* protobuf-*
50
51#Clone asfvolt16-driver
52# - The guide assumes that the asfvolt16-driver gerrit repo is cloned under the ONL toplevel directory:
53# - git clone ssh://user@gerrit.opencord.org:29418/asfvolt16-driver ${HOME}/OpenNetworkLinux/asfvolt16-driver
54
Kim Kempfe109db72017-10-05 13:12:54 -070055#git clone https://gerrit.opencord.org/${ASFVOLT_REPO_NAME} ${ONL_TOPDIR}/${ASFVOLT_REPO_NAME}
Kim Kempf531d52d2017-10-02 17:10:54 -070056
57#steps to install grpc
58# - Download as zip "grpc", "grpc-c", "protobuf" and "protobuf-c" from "https://github.com/opennetworkinglab/asfvolt16-driver/tree/master/third_party"
59wget https://github.com/grpc/grpc/archive/${GRPC_ARCH}.zip
60wget https://github.com/Juniper/grpc-c/archive/${GRPC_C_ARCH}.zip
61wget https://github.com/google/protobuf/archive/${PROTOBUF_ARCH}.zip
62wget https://github.com/shadansari/protobuf-c/archive/${PROTOBUF_C_ARCH}.zip
63
64# - extract grpc at ${HOME}/OpenNetworkLinux/grpc
65unzip -q ${GRPC_ARCH}.zip; rm ${GRPC_ARCH}.zip
66mv grpc-${GRPC_ARCH} grpc
67
68# - extract grpc-c at ${HOME}/OpenNetworkLinux/grpc-c
69unzip -q ${GRPC_C_ARCH}.zip; rm ${GRPC_C_ARCH}.zip
70mv grpc-c-${GRPC_C_ARCH} grpc-c
71
72# - extract protobuf at ${HOME}/OpenNetworkLinux/grpc/thirdparty/protobuf
73unzip -q ${PROTOBUF_ARCH}.zip; rm ${PROTOBUF_ARCH}.zip
74mkdir -p grpc/thirdparty
75mv protobuf-${PROTOBUF_ARCH} grpc/thirdparty/protobuf
76
77
78# - extract protobuf-c folder at ${HOME}/OpenNetworkLinux/grpc-c/third_party/protobuf-c
79unzip -q ${PROTOBUF_C_ARCH}.zip; rm ${PROTOBUF_C_ARCH}.zip
80(cd protobuf-c-${PROTOBUF_C_ARCH};tar cf - .)|(cd grpc-c/third_party/protobuf-c;tar xf -)
81rm -rf protobuf-c-${PROTOBUF_C_ARCH}
82
83#steps to install grpc-c
84# cd ${HOME}/OpenNetworkLinux/grpc/thirdparty/protobuf
85# - ./autogen.sh
86# - ./configure
87# - make
88# - sudo make install
89cd ${ONL_TOPDIR}/grpc/thirdparty/protobuf
90./autogen.sh
91./configure
92make --jobs=${MAKE_JOBS}
93sudo make install
94
95# cd ${HOME}/OpenNetworkLinux/grpc
96# - export LD_LIBRARY_PATH=/usr/local/lib
97# - make
98# - sudo make install
99
100cd ${ONL_TOPDIR}/grpc
101export LD_LIBRARY_PATH=/usr/local/lib
102make --jobs=${MAKE_JOBS}
103sudo make install
104
105#cd ${HOME}/OpenNetworkLinux/grpc-c/third_party/protobuf-c
106#- ./autogen.sh
107#- ./configure
108#- export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/protobuf
109#- make
110#- sudo make install
111
112cd ${ONL_TOPDIR}/grpc-c/third_party/protobuf-c
113./autogen.sh
114./configure
115export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/protobuf
116make --jobs=${MAKE_JOBS}
117sudo make install
118
119#Apply grpc-c patch
120# - cd ${HOME}/OpenNetworkLinux/grpc-c/
121cd ${ONL_TOPDIR}/grpc-c
122# Patch 1:
123# Apply patch in following link for grpc-c/lib - "https://github.com/Juniper/grpc-c/commit/353b40cd920cd749ed6cf71f8df17f1d5cf2c89d"
124# Note:
125# (This patch is having very few changes in two files(grpc-c/lib/client.c, grpc-c/lib/service.c.
126# Download these two files from above link and replace at grpc-c/lib or merge these changes manually.)
127patch -p1 -i ${PATCHF_TOPDIR}/grpc-c_compile-error.patch
128
129# Patch 2:
130# Apply patch in service.c.patch and client.c.patch
131patch -p1 -i ${PATCHF_TOPDIR}/grpc-c_asfvolt16.patch
132
133#
134# - cd ${HOME}/OpenNetworkLinux
135# - cp asfvolt16-driver/device_simulator/Makefile.am grpc-c/examples/
136# - cp asfvolt16-driver/device_simulator/voltha_bal_driver.c grpc-c/examples/
137# - cp asfvolt16-driver/device_simulator/bal_stub.c grpc-c/examples/
138# - cp asfvolt16-driver/device_simulator/bal_stub.h grpc-c/examples/
139# - Note: Update voltha adaptor IP in bal_stub.c (Is this required? Not clear which variable needs to be updated).
140cd ${ONL_TOPDIR}
141cp ${DEVSIM_TOPDIR}/Makefile.am grpc-c/examples/
142cp ${DEVSIM_TOPDIR}/voltha_bal_driver.c grpc-c/examples/
143cp ${DEVSIM_TOPDIR}/bal_stub.c grpc-c/examples/
144cp ${DEVSIM_TOPDIR}/bal_stub.h grpc-c/examples/
145
146#
147# - cd ${HOME}/OpenNetworkLinux/grpc-c
148# - autoreconf --install
149# - mkdir build && cd build
150# - ../configure
151# - make
152# - sudo make install
153cd ${ONL_TOPDIR}/grpc-c
154autoreconf --install
155mkdir build && cd build
156../configure
157make --jobs=${MAKE_JOBS}
158sudo make install
159
160#To obtain proto files - Have a repo sync of opencord voltha code base:
161# - git clone https://github.com/opencord/voltha.git ${HOME}/voltha
162# - cd ${HOME}/OpenNetworkLinux/grpc-c/
163# - cp ${HOME}/voltha/voltha/adapters/asfvolt16_olt/protos/* examples/
164#
165cd ${ONL_TOPDIR}/grpc-c
166cp ${VOLTHA_TOPDIR}/voltha/adapters/asfvolt16_olt/protos/* examples
167
168#To autogenerate code from proto files:
169# - cd ${HOME}/OpenNetworkLinux/grpc-c/build/examples
170# - make autogen
171cd ${ONL_TOPDIR}/grpc-c/build/examples
172make autogen
173
174#
175#Build voltha_bal_driver:
176# - cd ${HOME}/OpenNetworkLinux/grpc-c/build/examples
177# - Note: Remove "-O2" from Makefile
178# - Note: Set EDGECORE and BRCM_PATH in Makefile
179cd ${ONL_TOPDIR}/grpc-c/build/examples
180sed -i -e 's/-O2/-O0/g' \
181 -e "s:^EDGECORE = /home/asfvolt/shared.*:#&\nEDGECORE = ${ASFSRC_TOPDIR}:" \
182 -e "s:^BRCM_PATH = /home/asfvolt/shared.*:#&\nBRCM_PATH = ${BALSRC_TOPDIR}:" \
183 Makefile
184
185pushd ${ASFSRC_TOPDIR}
186sed -i -e "s:^BRDCM_SRC=/home/asfvolt/shared.*:#&\nBRDCM_SRC = ${BALSRC_TOPDIR}:" \
187 -e "s:^GRPC_C_PATH= /home/asfvolt/shared.*:#&\nGRPC_C_PATH = ${ONL_TOPDIR}/grpc-c:" \
188 Makefile
189popd
190#```
191# EDGECORE = ${HOME}/OpenNetworkLinux/asfvolt16-driver/src/
192# BRCM_PATH = ${HOME}/OpenNetworkLinux/bal_src_release/bal_release
193#```
194# - make clean_all;make
195make clean_all
196make
197#
198#The ultimate executable voltha_bal_driver can be found under ~/grpc-c/build/examples/.libs/
199
200echo "${ASFVOLT_REPO_NAME} build complete"