merge all scripts to build.sh
authorBigfootACA <bigfoot@classfun.cn>
星期三, 7 Oct 2020 16:09:09 +0000 (00:09 +0800)
committerBigfootACA <bigfoot@classfun.cn>
星期三, 7 Oct 2020 16:09:09 +0000 (00:09 +0800)
README.md
build.sh [new file with mode: 0755]
build_dipper.sh [deleted file]
build_enchilada.sh [deleted file]
build_fajita.sh [deleted file]
build_polaris.sh [deleted file]
firstrun.sh [deleted file]
firstrun_common.sh [deleted file]

index 3ca15b72a60e6e5ca9a1e9aee2cf68037b55cfee..3946861ccc5013cfc0899fd31439dad2caf17c0a 100644 (file)
--- a/README.md
+++ b/README.md
@@ -63,23 +63,19 @@ git clone https://github.com/tianocore/edk2-platforms.git -o cfdc7f907d545b14302
 git clone https://github.com/edk2-porting/edk2-sdm845.git\r
 ```\r
 \r
-3.Initialize environment\r
-\r
+3.Build this project\r
 ```bash\r
-cd edk2-sdm845\r
-bash firstrun.sh\r
+bash build.sh --device DEVICE\r
 ```\r
 \r
-4.Build this project\r
-```bash\r
-bash build_*.sh\r
-```\r
-5.Debug and use\r
+4.Debug and use\r
 \r
 ```bash\r
-fastboot boot boot_*.img\r
+fastboot boot boot_DEVICE.img\r
 ```\r
 \r
+(DEVICE is the codename of your phone.)\r
+\r
 ## Credits\r
 \r
 Special thanks to [fxsheep](https://github.com/fxsheep)\r
diff --git a/build.sh b/build.sh
new file mode 100755 (executable)
index 0000000..b84136c
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,74 @@
+#!/bin/bash
+##### Change this to add device #####
+DEVICES=(
+       dipper
+       enchilada
+       fajita
+       polaris
+)
+#####################################
+function _help(){
+       echo "Usage: build.sh --device DEV"
+       echo
+       echo "Build edk2 for Qualcomm SDM845 platform."
+       echo
+       echo "Options: "
+       echo "  --device DEV, -d DEV: build for DEV. (${DEVICES[*]})"
+       echo "  --help, -h:           show this help."
+       echo
+       echo "MainPage: https://github.com/edk2-porting/edk2-sdm845"
+       exit "${1}"
+}
+cd "$(dirname "$0")"
+if ! [ -f sdm845Pkg/sdm845Pkg.dsc ]
+then   echo "cannot found sdm845Pkg/sdm845Pkg.dsc" >&2
+       exit 1
+fi
+typeset -l DEVICE
+DEVICE=""
+OPTS="$(getopt -o d:h -l device:,help -n 'build.sh' -- "$@")"||exit 1
+eval set -- "${OPTS}"
+while true
+do     case "${1}" in
+               -d|--device)DEVICE="${2}";shift 2;;
+               -h|--help)_help 0;shift;;
+               --)shift;break;;
+               *)_help 1;;
+       esac
+done
+[ -z "${DEVICE}" ]&&_help 1
+HAS=false
+for i in "${DEVICES[@]}"
+do     [ "${i}" == "${DEVICE}" ]||continue
+       HAS=true
+       break
+done
+if [ "${HAS}" != "true" ]
+then   echo "build.sh: unknown build target device ${DEVICE}." >&2
+       exit 1
+fi
+_EDK2="$(realpath "$PWD/../edk2")"
+_EDK2_PLATFORMS="$(realpath "$PWD/../edk2-platforms")"
+if ! [ -d "${_EDK2}" ]
+then   echo "${_EDK2} not found, please see README.md" >&2
+       exit 1
+fi
+if ! [ -d "${_EDK2_PLATFORMS}" ]
+then   echo "${_EDK2_PLATFORMS} not found, please see README.md" >&2
+       exit 1
+fi
+set -e
+export PACKAGES_PATH="$_EDK2:$_EDK2_PLATFORMS:$PWD"
+export WORKSPACE="$PWD/workspace"
+source ../edk2/edksetup.sh
+[ -d "${WORKSPACE}" ]||mkdir "${WORKSPACE}"
+set -x
+make -C ../edk2/BaseTools -j "$(nproc)"
+# based on the instructions from edk2-platform
+rm -f "boot_${DEVICE}.img" uefi_img
+# not actually GCC5, it's GCC7 on Ubuntu 18.04.
+GCC5_AARCH64_PREFIX=aarch64-linux-gnu- build -s -n 0 -a AARCH64 -t GCC5 -p "sdm845Pkg/${DEVICE}.dsc"
+gzip -c < workspace/Build/sdm845Pkg/DEBUG_GCC5/FV/SDM845PKG_UEFI.fd > "uefi-${DEVICE}.img"
+cat "uefi-${DEVICE}.img" "device_specific/${DEVICE}.dtb" >> "uefi-${DEVICE}.img-dtb"
+abootimg --create "boot-${DEVICE}.img" -k "uefi-${DEVICE}.img-dtb" -r ramdisk -f bootimg.cfg
+echo "Build done: boot-${DEVICE}.img"
diff --git a/build_dipper.sh b/build_dipper.sh
deleted file mode 100644 (file)
index 9a5b3d2..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/bash
-# based on the instructions from edk2-platform
-echo cleanning BuidFiles
-rm -rf boot_dipper.img
-echo Done.
-set -e
-. firstrun_common.sh
-# not actually GCC5; it's GCC7 on Ubuntu 18.04.
-GCC5_AARCH64_PREFIX=aarch64-linux-gnu- build -s -n 0 -a AARCH64 -t GCC5 -p sdm845Pkg/dipper.dsc
-gzip -c < workspace/Build/sdm845Pkg/DEBUG_GCC5/FV/SDM845PKG_UEFI.fd >uefi_img
-cat ./device_specific/dipper.dtb >>uefi_img
-abootimg --create boot_dipper.img -k uefi_img -r ramdisk -f bootimg.cfg
-rm -rf ./uefi_img
diff --git a/build_enchilada.sh b/build_enchilada.sh
deleted file mode 100644 (file)
index 9fd488f..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/bash
-# based on the instructions from edk2-platform
-echo cleanning BuidFiles
-rm -rf boot_enchilada.img
-echo Done.
-set -e
-. firstrun_common.sh
-# not actually GCC5; it's GCC7 on Ubuntu 18.04.
-GCC5_AARCH64_PREFIX=aarch64-linux-gnu- build -s -n 0 -a AARCH64 -t GCC5 -p sdm845Pkg/enchilada.dsc
-gzip -c < workspace/Build/sdm845Pkg/DEBUG_GCC5/FV/SDM845PKG_UEFI.fd >uefi_img
-cat ./device_specific/enchilada.dtb >>uefi_img
-abootimg --create boot_enchilada.img -k uefi_img -r ramdisk -f bootimg.cfg
-rm -rf ./uefi_img
diff --git a/build_fajita.sh b/build_fajita.sh
deleted file mode 100644 (file)
index e91efef..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/bash
-# based on the instructions from edk2-platform
-echo cleanning BuidFiles
-rm -rf boot_fajita.img
-echo Done.
-set -e
-. firstrun_common.sh
-# not actually GCC5; it's GCC7 on Ubuntu 18.04.
-GCC5_AARCH64_PREFIX=aarch64-linux-gnu- build -s -n 0 -a AARCH64 -t GCC5 -p sdm845Pkg/fajita.dsc
-gzip -c < workspace/Build/sdm845Pkg/DEBUG_GCC5/FV/SDM845PKG_UEFI.fd >uefi_img
-cat ./device_specific/fajita.dtb >>uefi_img
-abootimg --create boot_fajita.img -k uefi_img -r ramdisk -f bootimg.cfg
-rm -rf ./uefi_img
diff --git a/build_polaris.sh b/build_polaris.sh
deleted file mode 100644 (file)
index d379982..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/bash
-# based on the instructions from edk2-platform
-echo cleanning BuidFiles
-rm -rf boot_polaris.img
-echo Done.
-set -e
-. firstrun_common.sh
-# not actually GCC5; it's GCC7 on Ubuntu 18.04.
-GCC5_AARCH64_PREFIX=aarch64-linux-gnu- build -s -n 0 -a AARCH64 -t GCC5 -p sdm845Pkg/polaris.dsc
-gzip -c < workspace/Build/sdm845Pkg/DEBUG_GCC5/FV/SDM845PKG_UEFI.fd >uefi_img
-cat ./device_specific/polaris.dtb >>uefi_img
-abootimg --create boot_polaris.img -k uefi_img -r ramdisk -f bootimg.cfg
-rm -rf ./uefi_img
diff --git a/firstrun.sh b/firstrun.sh
deleted file mode 100644 (file)
index 3b74743..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-# based on the instructions from edk2-platform
-# do this first:
-# https://github.com/tianocore/tianocore.github.io/wiki/Using-EDK-II-with-Native-GCC#Install_required_software_from_apt
-set -e
-. firstrun_common.sh
-make -C ../edk2/BaseTools
-
diff --git a/firstrun_common.sh b/firstrun_common.sh
deleted file mode 100644 (file)
index 09a5b06..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-export PACKAGES_PATH=$PWD/../edk2:$PWD/../edk2-platforms:$PWD
-export WORKSPACE=$PWD/workspace
-. ../edk2/edksetup.sh