3 # Copyright (C) 2019 Wind River Systems, Inc.
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 # Ensure we fail the job if any steps fail.
20 SUPPORTED_BSP="intel-x86-64 nxp-lx2xxx"
21 WRTEMPLATE_COMMON="feature/oran-host-rt-tune feature/kubernetes feature/self-hosted"
22 WRTEMPLATE_X86="feature/hosts-ia feature/kvm feature/dpdk"
24 SRC_ORAN_BRANCH="master"
25 SRC_WRL_BRANCH="WRLINUX_10_18_BASE"
26 SRC_WRL_URL="git://github.com/WindRiver-Labs/wrlinux-x.git"
28 SCRIPTS_DIR=$(dirname $(readlink -f $0))
33 $(basename $0) <-w WORKSPACE_DIR> [-b BSP] [-n] [-h] [-r]
35 -w WORKSPACE_DIR is the path for the project
36 -b BPS is one of supported BSP: "${SUPPORTED_BSP}"
37 (default is intel-x86-64 if not specified.)
38 -n dry-run only for bitbake
40 -e EXTRA_CONF is the pat for extra config file
41 -r whether to inherit rm_work (default is Yes)
56 echo "CMD: ${RUN_CMD}"
60 echo "Missing options!"
75 echo "Invalid arg for -r option."
84 for b in ${SUPPORTED_BSP}; do
85 if [ "${bsp}" == "${b}" ]; then
90 if [ -z "${BSP_VALID}" ]; then
91 echo_error "${bsp} is not a supported BSP, the supported BSPs are: ${SUPPORTED_BSP}"
102 while getopts "w:b:e:r:nh" OPTION; do
105 WORKSPACE=`readlink -f ${OPTARG}`
108 check_valid_bsp ${OPTARG}
111 EXTRA_CONF=`readlink -f ${OPTARG}`
117 check_yn_rm_work ${OPTARG}
126 if [ -z "${WORKSPACE}" ]; then
127 echo_info "No workspace specified, a directory 'workspace' will be created in current directory as the workspace"
128 WORKSPACE=`readlink -f workspace`
131 if [ -n "${BSP_VALID}" ]; then
135 # iso image is not supported by nxp-lx2xxx yet
136 if [ "${BSP}" == "nxp-lx2xxx" ]; then
140 SRC_WRL_DIR=${WORKSPACE}/src_wrlinux
141 SRC_ORAN_DIR=${WORKSPACE}/src_oran
142 PRJ_BUILD_DIR=${WORKSPACE}/prj_oran-inf
144 mkdir -p ${SRC_WRL_DIR} ${PRJ_BUILD_DIR} ${SRC_ORAN_DIR}
146 echo_info "The following directories are created in your workspace(${WORKSPACE}):"
147 echo_info "For wrlinux source: ${SRC_WRL_DIR}"
148 echo_info "For oran layer source: ${SRC_ORAN_DIR}"
149 echo_info "For build project: ${PRJ_BUILD_DIR}"
151 # Clone the source of WRLinux from github and setup
152 RUN_CMD="git clone --branch ${SRC_WRL_BRANCH} ${SRC_WRL_URL}"
153 echo_cmd "Cloning wrlinux-x source from github:"
157 RUN_CMD="./wrlinux-x/setup.sh --machines ${BSP} --layers meta-cloud-services"
158 echo_cmd "Setup wrlinux build project:"
161 # Clone the oran layer if it's not already cloned
162 # Check if the script is inside the repo
163 if cd ${SCRIPTS_DIR} && git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
164 CLONED_ORAN_REPO=`dirname ${SCRIPTS_DIR}`
165 echo_info "Use the cloned oran repo: ${CLONED_ORAN_REPO}"
166 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
171 echo_info "Cloning oran layer:"
173 RUN_CMD="git clone --branch ${SRC_ORAN_BRANCH} https://gerrit.o-ran-sc.org/r/pti/rtp"
174 echo_cmd "Cloing with:"
178 # Apply meta patches for nxp-lx2xxx
179 if [ "${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
184 # Source the build env
186 . ./environment-setup-x86_64-wrlinuxsdk-linux
188 . ./oe-init-build-env ${PRJ_BUILD_DIR}
190 # Add the meta-oran layer
192 RUN_CMD="bitbake-layers add-layer ${SRC_ORAN_DIR}/rtp/meta-oran"
193 echo_cmd "Add the meta-oran layer into the build project"
196 # Add extra configs into local.conf
197 cat << EOF >> conf/local.conf
198 ########################
199 # Configs for oran-inf #
200 ########################
204 # Work around for CI build
205 IMAGE_INSTALL_remove = "ceph"
207 # For container image
208 WR_APP_CONTAINER_APP = "rt-tests"
210 # Disable multilib fo nxp-lx2xxx
211 MULTILIBS_nxp-lx2xxx = ""
212 DEFAULTTUNE_virtclass-multilib-lib32_nxp-lx2xxx = ""
215 WRTEMPLATE += "${WRTEMPLATE_COMMON}"
216 WRTEMPLATE_prepend_x86-64 += "${WRTEMPLATE_X86}"
219 if [ "${RM_WORK}" == "Yes" ]; then
220 echo "INHERIT += 'rm_work'" >> conf/local.conf
223 if [ "${EXTRA_CONF}" != "" ] && [ -f "${EXTRA_CONF}" ]; then
224 cat ${EXTRA_CONF} >> conf/local.conf
227 # Build the oran-inf-host image
229 TIMESTAMP=`date +"%Y%m%d_%H%M%S"`
230 RUN_CMD="bitbake ${DRYRUN} oran-image-inf-host"
231 echo_cmd "Build the oran-image-inf-host image"
232 bitbake ${DRYRUN} oran-image-inf-host 2>&1|tee logs/bitbake_oran-image-inf-host_${TIMESTAMP}.log
234 RUN_CMD="bitbake ${DRYRUN} wr-app-container"
235 echo_cmd "Build the wr-app-container image"
236 bitbake ${DRYRUN} wr-app-container 2>&1|tee logs/bitbake_wr-app-container_${TIMESTAMP}.log
238 echo_info "Build succeeded, you can get the image in ${PRJ_BUILD_DIR}/tmp-glibc/deploy/images/${BSP}/oran-image-inf-host-${BSP}.${IMAGE_TYPE}"