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}"
101 while getopts "w:b:e:r:nh" OPTION; do
104 WORKSPACE=`readlink -f ${OPTARG}`
107 check_valid_bsp ${OPTARG}
110 EXTRA_CONF=`readlink -f ${OPTARG}`
116 check_yn_rm_work ${OPTARG}
125 if [ -z "${WORKSPACE}" ]; then
126 echo_info "No workspace specified, a directory 'workspace' will be created in current directory as the workspace"
127 WORKSPACE=`readlink -f workspace`
130 if [ -n "${BSP_VALID}" ]; then
134 SRC_WRL_DIR=${WORKSPACE}/src_wrlinux
135 SRC_ORAN_DIR=${WORKSPACE}/src_oran
136 PRJ_BUILD_DIR=${WORKSPACE}/prj_oran-inf
138 mkdir -p ${SRC_WRL_DIR} ${PRJ_BUILD_DIR} ${SRC_ORAN_DIR}
140 echo_info "The following directories are created in your workspace(${WORKSPACE}):"
141 echo_info "For wrlinux source: ${SRC_WRL_DIR}"
142 echo_info "For oran layer source: ${SRC_ORAN_DIR}"
143 echo_info "For build project: ${PRJ_BUILD_DIR}"
145 # Clone the source of WRLinux from github and setup
146 RUN_CMD="git clone --branch ${SRC_WRL_BRANCH} ${SRC_WRL_URL}"
147 echo_cmd "Cloning wrlinux-x source from github:"
151 RUN_CMD="./wrlinux-x/setup.sh --machines ${BSP} --layers meta-cloud-services"
152 echo_cmd "Setup wrlinux build project:"
155 # Clone the oran layer if it's not already cloned
156 # Check if the script is inside the repo
157 if cd ${SCRIPTS_DIR} && git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
158 CLONED_ORAN_REPO=`dirname ${SCRIPTS_DIR}`
159 echo_info "Use the cloned oran repo: ${CLONED_ORAN_REPO}"
160 mkdir ${SRC_ORAN_DIR}/rtp
161 cd ${SRC_ORAN_DIR}/rtp
162 ln -sf ${CLONED_ORAN_REPO}/meta-oran meta-oran
163 ln -sf ${CLONED_ORAN_REPO}/scripts scripts
165 echo_info "Cloning oran layer:"
167 RUN_CMD="git clone --branch ${SRC_ORAN_BRANCH} https://gerrit.o-ran-sc.org/r/pti/rtp"
168 echo_cmd "Cloing with:"
172 # Apply meta patches for nxp-lx2xxx
173 if [ "${BSP}" == "nxp-lx2xxx" ]; then
174 cd ${SRC_WRL_DIR}/layers/nxp-lx2xxx/
175 git am ${SRC_ORAN_DIR}/rtp/scripts/meta-patches/nxp-lx2xxx/0001-Revert-nxp-lx2xxx-remove-preempt-rt-related-file.patch
178 # Source the build env
180 . ./environment-setup-x86_64-wrlinuxsdk-linux
182 . ./oe-init-build-env ${PRJ_BUILD_DIR}
184 # Add the meta-oran layer
186 RUN_CMD="bitbake-layers add-layer ${SRC_ORAN_DIR}/rtp/meta-oran"
187 echo_cmd "Add the meta-oran layer into the build project"
190 # Add extra configs into local.conf
191 cat << EOF >> conf/local.conf
192 ########################
193 # Configs for oran-inf #
194 ########################
198 # Work around for CI build
199 IMAGE_INSTALL_remove = "ceph"
201 # For container image
202 WR_APP_CONTAINER_APP = "rt-tests"
204 # Disable multilib fo nxp-lx2xxx
205 MULTILIBS_nxp-lx2xxx = ""
206 DEFAULTTUNE_virtclass-multilib-lib32_nxp-lx2xxx = ""
209 WRTEMPLATE += "${WRTEMPLATE_COMMON}"
210 WRTEMPLATE_prepend_x86-64 += "${WRTEMPLATE_X86}"
213 if [ "${RM_WORK}" == "Yes" ]; then
214 echo "INHERIT += 'rm_work'" >> conf/local.conf
217 if [ "${EXTRA_CONF}" != "" ] && [ -f "${EXTRA_CONF}" ]; then
218 cat ${EXTRA_CONF} >> conf/local.conf
221 # Build the oran-inf-host image
223 TIMESTAMP=`date +"%Y%m%d_%H%M%S"`
224 RUN_CMD="bitbake ${DRYRUN} oran-image-inf-host"
225 echo_cmd "Build the oran-image-inf-host image"
226 bitbake ${DRYRUN} oran-image-inf-host 2>&1|tee logs/bitbake_oran-image-inf-host_${TIMESTAMP}.log
228 RUN_CMD="bitbake ${DRYRUN} wr-app-container"
229 echo_cmd "Build the wr-app-container image"
230 bitbake ${DRYRUN} wr-app-container 2>&1|tee logs/bitbake_wr-app-container_${TIMESTAMP}.log
232 echo_info "Build succeeded, you can get the image in ${PRJ_BUILD_DIR}/tmp-glibc/deploy/images/intel-x86-64/oran-image-inf-host-intel-x86-64.iso"