From 94a865cc0e7ca72347cd3da85eaa3417a4cd33f4 Mon Sep 17 00:00:00 2001 From: Arturo Buzarra Date: Tue, 3 Oct 2023 20:15:08 +0200 Subject: [PATCH] build scripts: sync internal and Github build scripts Signed-off-by: Arturo Buzarra --- sdk/build-github.sh | 52 +++++++++++++++++++++++++++++++++------------ sdk/build.sh | 8 +++++-- 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/sdk/build-github.sh b/sdk/build-github.sh index c505a6166..106e41c8d 100755 --- a/sdk/build-github.sh +++ b/sdk/build-github.sh @@ -14,9 +14,11 @@ # !Description: Yocto autobuild script from Jenkins. # # Parameters set by Jenkins: -# DY_PLATFORMS: Platforms to build -# DY_REVISION: Revision of the manifest repository (for 'repo init') -# DY_TARGET: Target image (the default is platform dependent) +# DY_BUILD_RELEASE: Build for release mode +# DY_BUILD_TCHAIN: Build toolchains for DEY images +# DY_PLATFORMS: Platforms to build +# DY_REVISION: Revision of the manifest repository (for 'repo init') +# DY_TARGET: Target image (the default is platform dependent) # #=============================================================================== @@ -56,10 +58,15 @@ copy_images() { # Copy individual packages only for 'release' builds, not for 'daily'. # For 'daily' builds just copy the firmware images (the buildserver # cannot afford such amount of disk space) - if echo "${JOB_NAME}" | grep -qs 'dey.*release'; then + if [ "${DY_BUILD_RELEASE}" = "true" ]; then cp -r tmp/deploy/* "${1}"/ else cp -r tmp/deploy/images "${1}"/ + if [ "${DY_BUILD_TCHAIN}" = "true" ]; then + if [ -d tmp/deploy/sdk ]; then + cp -r tmp/deploy/sdk "${1}"/ + fi + fi fi # Images directory post-processing @@ -109,9 +116,15 @@ swu_recipe_name() { fi } -# Sanity checks (Jenkins environment) -[ -z "${DY_REVISION}" ] && error "DY_REVISION not specified" -[ -z "${WORKSPACE}" ] && error "WORKSPACE not specified" +# Sanity check (Jenkins environment) +[ -z "${DY_REVISION}" ] && error "DY_REVISION not specified" +[ -z "${WORKSPACE}" ] && error "WORKSPACE not specified" + +# Set default settings if Jenkins does not do it +[ -z "${DY_BUILD_RELEASE}" ] && [[ "${JOB_NAME}" =~ dey-.*-release ]] && DY_BUILD_RELEASE="true" + +# If DY_BUILD_TCHAIN is unset, set it for release jobs +[ -z "${DY_BUILD_TCHAIN}" ] && [ "${DY_BUILD_RELEASE}" = "true" ] && DY_BUILD_TCHAIN="true" # Per-platform data while read -r _pl _tgt; do @@ -139,7 +152,8 @@ _EOF_ DY_PLATFORMS="${DY_PLATFORMS:-${AVAILABLE_PLATFORMS}}" YOCTO_IMGS_DIR="${WORKSPACE}/images" -YOCTO_INST_DIR="${WORKSPACE}/dey.$(echo "${DY_REVISION}" | tr '/' '_')" +YOCTO_INST_DIR="${WORKSPACE}/digi-yocto-sdk-github.$(echo "${DY_REVISION}" | tr '/' '_')" +YOCTO_DOWNLOAD_DIR="${DY_DOWNLOADS:-${WORKSPACE}}/downloads" YOCTO_PROJ_DIR="${WORKSPACE}/projects" # If CPUS is unset, set it with the machine cpus @@ -150,8 +164,8 @@ fi printf "\n[INFO] Build Yocto \"%s\" for \"%s\" (cpus=%s)\n\n" "${DY_REVISION}" "${DY_PLATFORMS}" "${CPUS}" -# Install DEY -rm -rf "${YOCTO_INST_DIR}" && mkdir -p "${YOCTO_INST_DIR}" +# Install/Update Digi's Yocto SDK +mkdir -p "${YOCTO_INST_DIR}" if pushd "${YOCTO_INST_DIR}"; then # Use git ls-remote to check the revision type if [ "${DY_REVISION}" != "master" ]; then @@ -175,13 +189,20 @@ if pushd "${YOCTO_INST_DIR}"; then popd fi -# Create projects and build +# Clean downloads directory +if [ "${DY_RM_DOWNLOADS}" = "true" ]; then + printf "\n[INFO] Removing the downloads folder.\n" + rm -rf "${YOCTO_DOWNLOAD_DIR}" +fi + +# Clean images and projects folders rm -rf "${YOCTO_IMGS_DIR}" "${YOCTO_PROJ_DIR}" + +# Create projects and build for platform in ${DY_PLATFORMS}; do # The variable _tgt got its dashes converted to # underscores, so we must convert also the ones in ${platform}. eval "platform_targets=\"\${${platform//-/_}_tgt}\"" - _this_prj_dir="${YOCTO_PROJ_DIR}/${platform}" _this_img_dir="${YOCTO_IMGS_DIR}/${platform}" mkdir -p "${_this_img_dir}" "${_this_prj_dir}" @@ -193,7 +214,7 @@ for platform in ${DY_PLATFORMS}; do # shellcheck disable=SC1091,SC2086 MKP_PAGER="" . ${YOCTO_INST_DIR}/mkproject.sh -p "${platform}" <<< "y" # Set a common DL_DIR and SSTATE_DIR for all platforms - sed -i -e "/^#DL_DIR ?=/cDL_DIR ?= \"${YOCTO_PROJ_DIR}/downloads\"" \ + sed -i -e "/^#DL_DIR ?=/cDL_DIR ?= \"${YOCTO_DOWNLOAD_DIR}\"" \ -e "/^#SSTATE_DIR ?=/cSSTATE_DIR ?= \"${YOCTO_PROJ_DIR}/sstate-cache\"" \ conf/local.conf { @@ -205,6 +226,11 @@ for platform in ${DY_PLATFORMS}; do printf "\n[INFO] Building the %s target.\n" "${target}" # shellcheck disable=SC2046 time bitbake "${target}" $(swu_recipe_name "${target}") + # Build the toolchain for DEY images + if [ "${DY_BUILD_TCHAIN}" = "true" ] && echo "${target}" | grep -qs '^\(core\|dey\)-image-[^-]\+$'; then + printf "\n[INFO] Building the toolchain for %s.\n" "${target}" + time bitbake -c populate_sdk "${target}" + fi done purge_sstate ) diff --git a/sdk/build.sh b/sdk/build.sh index 61ac6ff1d..311d6f435 100755 --- a/sdk/build.sh +++ b/sdk/build.sh @@ -14,12 +14,13 @@ # !Description: Yocto autobuild script from Jenkins. # # Parameters set by Jenkins: +# DY_BUILD_RELEASE: Build for release mode # DY_BUILD_TCHAIN: Build toolchains for DEY images # DY_DISTRO: Distribution name (the default is 'dey') # DY_PLATFORMS: Platforms to build # DY_REVISION: Revision of the manifest repository (for 'repo init') # DY_RM_WORK: Remove the package working folders to save disk space. -# DY_TARGET: Target image (the default is 'dey-image-qt') +# DY_TARGET: Target image (the default is platform dependent) # DY_USE_MIRROR: Use internal Digi mirror to download packages # DY_CVE_REPORT: Generate Vigiles CVE report # DY_VIGILES_DIR: Path to Vigiles configuration files on the build server @@ -138,7 +139,6 @@ swu_recipe_name() { } # Sanity check (Jenkins environment) -[ -z "${DY_PLATFORMS}" ] && error "DY_PLATFORMS not specified" [ -z "${DY_REVISION}" ] && error "DY_REVISION not specified" [ -z "${DY_RM_WORK}" ] && error "DY_RM_WORK not specified" [ -z "${DY_USE_MIRROR}" ] && error "DY_USE_MIRROR not specified" @@ -164,6 +164,7 @@ fi # Per-platform data while read -r _pl _tgt; do + AVAILABLE_PLATFORMS="${AVAILABLE_PLATFORMS:+${AVAILABLE_PLATFORMS} }${_pl}" # shellcheck disable=SC2015 [ -n "${DY_TARGET}" ] && _tgt="${DY_TARGET}" || true # Dashes are not allowed in variables so let's substitute them on @@ -185,6 +186,9 @@ done<<-_EOF_ ccimx93-dvk dey-image-qt _EOF_ +# Set default values if not provided by Jenkins +DY_PLATFORMS="${DY_PLATFORMS:-${AVAILABLE_PLATFORMS}}" + YOCTO_IMGS_DIR="${WORKSPACE}/images" YOCTO_INST_DIR="${WORKSPACE}/digi-yocto-sdk.$(echo "${DY_REVISION}" | tr '/' '_')" YOCTO_DOWNLOAD_DIR="${DY_DOWNLOADS:-${WORKSPACE}}/downloads"