blob: a8ac7781216d80faf7793a1c09a6c9d582b26919 [file] [log] [blame]
Jackie Huangb5105bb2019-10-16 14:53:59 +08001#!/bin/bash
Jackie Huang54049b42019-11-13 14:43:04 +08002#
3# Copyright (C) 2019 Wind River Systems, Inc.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
Jackie Huang90b87ff2019-09-30 13:36:48 +080016
Jackie Huangab45ef32019-11-07 11:49:57 +080017# Ensure we fail the job if any steps fail.
Jackie Huangba8ab242019-11-07 16:31:10 +080018set -e -o pipefail
Jackie Huangab45ef32019-11-07 11:49:57 +080019
Jackie Huangaa94cc12020-03-02 19:29:01 +080020SUPPORTED_BSP="intel-x86-64 nxp-lx2xxx"
21WRTEMPLATE_COMMON="feature/oran-host-rt-tune feature/kubernetes feature/self-hosted"
22WRTEMPLATE_X86="feature/hosts-ia feature/kvm feature/dpdk"
23
24SRC_ORAN_BRANCH="master"
25SRC_WRL_BRANCH="WRLINUX_10_18_BASE"
26SRC_WRL_URL="git://github.com/WindRiver-Labs/wrlinux-x.git"
27
28SCRIPTS_DIR=$(dirname $(readlink -f $0))
29
Jackie Huang90b87ff2019-09-30 13:36:48 +080030help_info () {
31cat << ENDHELP
32Usage:
Jackie Huangaa94cc12020-03-02 19:29:01 +080033$(basename $0) <-w WORKSPACE_DIR> [-b BSP] [-n] [-h] [-r]
Jackie Huang90b87ff2019-09-30 13:36:48 +080034where:
Jackie Huangbe9f4e22019-10-16 10:02:00 +080035 -w WORKSPACE_DIR is the path for the project
Jackie Huangaa94cc12020-03-02 19:29:01 +080036 -b BPS is one of supported BSP: "${SUPPORTED_BSP}"
37 (default is intel-x86-64 if not specified.)
Jackie Huangbe9f4e22019-10-16 10:02:00 +080038 -n dry-run only for bitbake
39 -h this help info
Jackie Huang6d582c52019-11-01 15:28:47 +080040 -e EXTRA_CONF is the pat for extra config file
Jackie Huang45c76112019-12-09 17:39:02 +080041 -r whether to inherit rm_work (default is Yes)
Jackie Huang90b87ff2019-09-30 13:36:48 +080042ENDHELP
43}
44
45echo_info () {
46 echo "INFO: $1"
47}
48
49echo_error () {
50 echo "ERROR: $1"
51}
52
53echo_cmd () {
54 echo
Jackie Huang6d582c52019-11-01 15:28:47 +080055 echo_info "$1"
Jackie Huang90b87ff2019-09-30 13:36:48 +080056 echo "CMD: ${RUN_CMD}"
57}
58
59if [ $# -eq 0 ]; then
Jackie Huangbe9f4e22019-10-16 10:02:00 +080060 echo "Missing options!"
Jackie Huang90b87ff2019-09-30 13:36:48 +080061 help_info
62 exit
63fi
64
Jackie Huang45c76112019-12-09 17:39:02 +080065check_yn_rm_work () {
66 yn="$1"
67 case ${yn} in
68 [Yy]|[Yy]es)
69 RM_WORK="Yes"
70 ;;
71 [Nn]|[Nn]o)
72 RM_WORK="No"
73 ;;
74 *)
75 echo "Invalid arg for -r option."
76 help_info
77 exit 1
78 ;;
79 esac
80}
81
Jackie Huangaa94cc12020-03-02 19:29:01 +080082check_valid_bsp () {
83 bsp="$1"
84 for b in ${SUPPORTED_BSP}; do
85 if [ "${bsp}" == "${b}" ]; then
86 BSP_VALID="${bsp}"
87 break
88 fi
89 done
90 if [ -z "${BSP_VALID}" ]; then
91 echo_error "${bsp} is not a supported BSP, the supported BSPs are: ${SUPPORTED_BSP}"
92 exit 1
93 fi
94}
95
Jackie Huangbe9f4e22019-10-16 10:02:00 +080096DRYRUN=""
Jackie Huang6d582c52019-11-01 15:28:47 +080097EXTRA_CONF=""
Jackie Huang45c76112019-12-09 17:39:02 +080098RM_WORK="Yes"
Jackie Huangaa94cc12020-03-02 19:29:01 +080099BSP="intel-x86-64"
Jackie Huang9e0c38e2020-06-10 16:49:17 +0800100IMAGE_TYPE="iso"
Jackie Huangbe9f4e22019-10-16 10:02:00 +0800101
Jackie Huangaa94cc12020-03-02 19:29:01 +0800102while getopts "w:b:e:r:nh" OPTION; do
Jackie Huangbe9f4e22019-10-16 10:02:00 +0800103 case ${OPTION} in
104 w)
105 WORKSPACE=`readlink -f ${OPTARG}`
106 ;;
Jackie Huangaa94cc12020-03-02 19:29:01 +0800107 b)
108 check_valid_bsp ${OPTARG}
109 ;;
Jackie Huang6d582c52019-11-01 15:28:47 +0800110 e)
111 EXTRA_CONF=`readlink -f ${OPTARG}`
Jackie Huang45c76112019-12-09 17:39:02 +0800112 ;;
Jackie Huangbe9f4e22019-10-16 10:02:00 +0800113 n)
114 DRYRUN="-n"
115 ;;
Jackie Huang45c76112019-12-09 17:39:02 +0800116 r)
117 check_yn_rm_work ${OPTARG}
118 ;;
Jackie Huangbe9f4e22019-10-16 10:02:00 +0800119 h)
120 help_info
121 exit
122 ;;
123 esac
124done
125
Jackie Huangaa94cc12020-03-02 19:29:01 +0800126if [ -z "${WORKSPACE}" ]; then
Jackie Huangbe9f4e22019-10-16 10:02:00 +0800127 echo_info "No workspace specified, a directory 'workspace' will be created in current directory as the workspace"
128 WORKSPACE=`readlink -f workspace`
129fi
Jackie Huang90b87ff2019-09-30 13:36:48 +0800130
Jackie Huangaa94cc12020-03-02 19:29:01 +0800131if [ -n "${BSP_VALID}" ]; then
132 BSP="${BSP_VALID}"
133fi
134
Jackie Huang9e0c38e2020-06-10 16:49:17 +0800135# iso image is not supported by nxp-lx2xxx yet
136if [ "${BSP}" == "nxp-lx2xxx" ]; then
137 IMAGE_TYPE="tar.bz2"
138fi
139
Jackie Huangaa94cc12020-03-02 19:29:01 +0800140SRC_WRL_DIR=${WORKSPACE}/src_wrlinux
Jackie Huang90b87ff2019-09-30 13:36:48 +0800141SRC_ORAN_DIR=${WORKSPACE}/src_oran
142PRJ_BUILD_DIR=${WORKSPACE}/prj_oran-inf
143
144mkdir -p ${SRC_WRL_DIR} ${PRJ_BUILD_DIR} ${SRC_ORAN_DIR}
145
146echo_info "The following directories are created in your workspace(${WORKSPACE}):"
Jackie Huangaa94cc12020-03-02 19:29:01 +0800147echo_info "For wrlinux source: ${SRC_WRL_DIR}"
Jackie Huang90b87ff2019-09-30 13:36:48 +0800148echo_info "For oran layer source: ${SRC_ORAN_DIR}"
149echo_info "For build project: ${PRJ_BUILD_DIR}"
150
Jackie Huangaa94cc12020-03-02 19:29:01 +0800151# Clone the source of WRLinux from github and setup
152RUN_CMD="git clone --branch ${SRC_WRL_BRANCH} ${SRC_WRL_URL}"
153echo_cmd "Cloning wrlinux-x source from github:"
Jackie Huang90b87ff2019-09-30 13:36:48 +0800154cd ${SRC_WRL_DIR}
155${RUN_CMD}
156
Jackie Huangaa94cc12020-03-02 19:29:01 +0800157RUN_CMD="./wrlinux-x/setup.sh --machines ${BSP} --layers meta-cloud-services"
Jackie Huang90b87ff2019-09-30 13:36:48 +0800158echo_cmd "Setup wrlinux build project:"
159${RUN_CMD}
160
Jackie Huang6d582c52019-11-01 15:28:47 +0800161# Clone the oran layer if it's not already cloned
Jackie Huang6d582c52019-11-01 15:28:47 +0800162# Check if the script is inside the repo
Jackie Huang1135be22019-11-05 15:39:00 +0800163if cd ${SCRIPTS_DIR} && git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
Jackie Huang6d582c52019-11-01 15:28:47 +0800164 CLONED_ORAN_REPO=`dirname ${SCRIPTS_DIR}`
165 echo_info "Use the cloned oran repo: ${CLONED_ORAN_REPO}"
Jackie Huangb6503892019-12-07 23:39:51 +0800166 mkdir ${SRC_ORAN_DIR}/rtp
167 cd ${SRC_ORAN_DIR}/rtp
168 ln -sf ${CLONED_ORAN_REPO}/meta-oran meta-oran
169 ln -sf ${CLONED_ORAN_REPO}/scripts scripts
Jackie Huang6d582c52019-11-01 15:28:47 +0800170else
171 echo_info "Cloning oran layer:"
Jackie Huang1135be22019-11-05 15:39:00 +0800172 cd ${SRC_ORAN_DIR}
Jackie Huangaa94cc12020-03-02 19:29:01 +0800173 RUN_CMD="git clone --branch ${SRC_ORAN_BRANCH} https://gerrit.o-ran-sc.org/r/pti/rtp"
Jackie Huang6d582c52019-11-01 15:28:47 +0800174 echo_cmd "Cloing with:"
175 ${RUN_CMD}
176fi
Jackie Huang90b87ff2019-09-30 13:36:48 +0800177
Jackie Huangaa94cc12020-03-02 19:29:01 +0800178# Apply meta patches for nxp-lx2xxx
179if [ "${BSP}" == "nxp-lx2xxx" ]; then
180 cd ${SRC_WRL_DIR}/layers/nxp-lx2xxx/
181 git am ${SRC_ORAN_DIR}/rtp/scripts/meta-patches/nxp-lx2xxx/0001-Revert-nxp-lx2xxx-remove-preempt-rt-related-file.patch
182fi
183
Jackie Huang90b87ff2019-09-30 13:36:48 +0800184# Source the build env
185cd ${SRC_WRL_DIR}
186. ./environment-setup-x86_64-wrlinuxsdk-linux
187set ${PRJ_BUILD_DIR}
188. ./oe-init-build-env ${PRJ_BUILD_DIR}
189
Jackie Huang6d582c52019-11-01 15:28:47 +0800190# Add the meta-oran layer
Jackie Huang90b87ff2019-09-30 13:36:48 +0800191cd ${PRJ_BUILD_DIR}
Jackie Huang6d582c52019-11-01 15:28:47 +0800192RUN_CMD="bitbake-layers add-layer ${SRC_ORAN_DIR}/rtp/meta-oran"
193echo_cmd "Add the meta-oran layer into the build project"
194${RUN_CMD}
Jackie Huang90b87ff2019-09-30 13:36:48 +0800195
196# Add extra configs into local.conf
197cat << EOF >> conf/local.conf
198########################
199# Configs for oran-inf #
200########################
201DISTRO = "oran-inf"
202BB_NO_NETWORK = '0'
Jackie Huangb06a9772019-12-03 17:13:24 +0800203
204# Work around for CI build
205IMAGE_INSTALL_remove = "ceph"
Jackie Huangaa94cc12020-03-02 19:29:01 +0800206
207# For container image
208WR_APP_CONTAINER_APP = "rt-tests"
209
210# Disable multilib fo nxp-lx2xxx
211MULTILIBS_nxp-lx2xxx = ""
212DEFAULTTUNE_virtclass-multilib-lib32_nxp-lx2xxx = ""
213
214# Add templates
215WRTEMPLATE += "${WRTEMPLATE_COMMON}"
216WRTEMPLATE_prepend_x86-64 += "${WRTEMPLATE_X86}"
Jackie Huang90b87ff2019-09-30 13:36:48 +0800217EOF
218
Jackie Huang45c76112019-12-09 17:39:02 +0800219if [ "${RM_WORK}" == "Yes" ]; then
220 echo "INHERIT += 'rm_work'" >> conf/local.conf
221fi
222
Jackie Huang6d582c52019-11-01 15:28:47 +0800223if [ "${EXTRA_CONF}" != "" ] && [ -f "${EXTRA_CONF}" ]; then
224 cat ${EXTRA_CONF} >> conf/local.conf
225fi
226
Jackie Huang90b87ff2019-09-30 13:36:48 +0800227# Build the oran-inf-host image
228mkdir -p logs
229TIMESTAMP=`date +"%Y%m%d_%H%M%S"`
Jackie Huang6d582c52019-11-01 15:28:47 +0800230RUN_CMD="bitbake ${DRYRUN} oran-image-inf-host"
231echo_cmd "Build the oran-image-inf-host image"
Jackie Huangbe9f4e22019-10-16 10:02:00 +0800232bitbake ${DRYRUN} oran-image-inf-host 2>&1|tee logs/bitbake_oran-image-inf-host_${TIMESTAMP}.log
Jackie Huang6d582c52019-11-01 15:28:47 +0800233
Jackie Huangaa94cc12020-03-02 19:29:01 +0800234RUN_CMD="bitbake ${DRYRUN} wr-app-container"
235echo_cmd "Build the wr-app-container image"
236bitbake ${DRYRUN} wr-app-container 2>&1|tee logs/bitbake_wr-app-container_${TIMESTAMP}.log
237
Jackie Huang9e0c38e2020-06-10 16:49:17 +0800238echo_info "Build succeeded, you can get the image in ${PRJ_BUILD_DIR}/tmp-glibc/deploy/images/${BSP}/oran-image-inf-host-${BSP}.${IMAGE_TYPE}"