From 28df1b8ad5d22adc74ccb10455d5eae4590d2da5 Mon Sep 17 00:00:00 2001 From: lisimin Date: Thu, 24 Feb 2022 20:41:43 +0800 Subject: [PATCH] add script to compile openeuler show you how to compile openeuler source oe-init-build-env set PATH to get host command add automake- to HOSTTOOLS set TEMPLATECONF to find local.conf and bblayer.conf add meta-raspberrypi when build raspberrypi Signed-off-by: lisimin --- scripts/compile.sh | 69 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 scripts/compile.sh diff --git a/scripts/compile.sh b/scripts/compile.sh new file mode 100644 index 00000000000..57c45333a7a --- /dev/null +++ b/scripts/compile.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +usage() +{ + echo "Tip: . $(basename "${BASH_SOURCE[0]}") [BUILD_DIR]" + echo " Support machine:" + echo " qemu-aarch64" + echo " qemu-arm" + echo " raspberrypi4-64" +} + +get_build_info() +{ + MACHINE="$1" + BUILD_DIR="$2" + + if [ -n "$BASH_SOURCE" ]; then + THIS_SCRIPT="$BASH_SOURCE" + elif [ -n "$ZSH_NAME" ]; then + THIS_SCRIPT="$0" + else + THIS_SCRIPT="$(pwd)/compile.sh" + if [ ! -e "$THIS_SCRIPT" ]; then + echo "Error: $THIS_SCRIPT doesn't exist!" + exit 1 + fi + fi + + if [ -z "$ZSH_NAME" ] && [ "$0" = "$THIS_SCRIPT" ]; then + echo "Error: This script needs to be sourced. Please run as '. $THIS_SCRIPT'" >&2 + usage + exit 1 + fi + + SRC_DIR="$(cd $(dirname "${BASH_SOURCE[0]}")/../../;pwd)" + [[ -z "${BUILD_DIR}" ]] && BUILD_DIR="${SRC_DIR}/build" + + if [[ -z "${MACHINE}" ]];then + usage + fi +} + +set_env() +{ + export PATH="/opt/buildtools/ninja-1.10.1/bin/:/usr/sbin/:$PATH" + + TEMPLATECONF="${SRC_DIR}/yocto-meta-openeuler/meta-openeuler/conf" + mkdir -p "${BUILD_DIR}" + source "${SRC_DIR}"/yocto-poky/oe-init-build-env "${BUILD_DIR}" + set +x + sed -i "s|^MACHINE.*|MACHINE = \"${MACHINE}\"|g" conf/local.conf + + echo "$MACHINE" | grep -q "^raspberrypi" + if [ $? -eq 0 ];then + grep "meta-raspberrypi" conf/bblayers.conf |grep -qv "^[[:space:]]*#" || sed -i "/\/meta-openeuler /a \ "${SRC_DIR}"/yocto-meta-openeuler/bsp/meta-raspberrypi \\\\" conf/bblayers.conf + fi + + AUTOMAKE_V=$(ls /usr/bin/automake-1.* |awk -F "/" '{print $4}') + grep -q "HOSTTOOLS .*$AUTOMAKE_V" conf/local.conf || echo "HOSTTOOLS += \"$AUTOMAKE_V\"" >> conf/local.conf +} + +main() +{ + get_build_info $@ + set_env + echo -e "Tip: You can now run 'bitbake openeuler-image'.\n" +} + +main $@ -- Gitee