2020-10-08 00:09:09 +08:00
|
|
|
#!/bin/bash
|
2021-03-19 12:01:52 +08:00
|
|
|
|
2020-10-08 00:09:09 +08:00
|
|
|
##### Change this to add device #####
|
|
|
|
DEVICES=(
|
|
|
|
dipper
|
|
|
|
enchilada
|
2021-08-22 16:37:19 +08:00
|
|
|
enchilada-8g
|
2020-10-08 00:09:09 +08:00
|
|
|
fajita
|
2021-08-22 13:26:05 +08:00
|
|
|
fajita-8g
|
2021-08-22 06:34:19 +08:00
|
|
|
polaris
|
2021-08-22 13:26:05 +08:00
|
|
|
polaris-8g
|
2021-01-12 22:23:58 +08:00
|
|
|
beryllium
|
2021-01-15 23:16:35 +08:00
|
|
|
perseus
|
2021-03-07 10:02:01 +08:00
|
|
|
nx616j
|
2021-03-09 15:25:32 +08:00
|
|
|
m1882
|
2021-07-03 22:30:58 +08:00
|
|
|
m1892
|
2021-03-15 10:56:35 +08:00
|
|
|
skr-a0
|
2021-03-15 12:01:03 +08:00
|
|
|
judyln
|
2021-03-18 10:18:56 +08:00
|
|
|
star2qltechn
|
2021-03-21 19:13:28 +08:00
|
|
|
dipper-old
|
2021-03-22 16:14:00 +08:00
|
|
|
pafm00
|
2021-03-28 21:08:22 +08:00
|
|
|
trident
|
2021-04-13 13:28:19 +08:00
|
|
|
olympic
|
2021-06-30 23:50:42 +08:00
|
|
|
draco
|
2021-07-13 13:25:28 +08:00
|
|
|
pd1821
|
2021-08-26 21:14:57 +08:00
|
|
|
ayn-odin
|
2020-10-08 00:09:09 +08:00
|
|
|
)
|
|
|
|
#####################################
|
2021-03-19 12:01:52 +08:00
|
|
|
|
2020-10-08 00:09:09 +08:00
|
|
|
function _help(){
|
|
|
|
echo "Usage: build.sh --device DEV"
|
|
|
|
echo
|
|
|
|
echo "Build edk2 for Qualcomm SDM845 platform."
|
|
|
|
echo
|
|
|
|
echo "Options: "
|
2021-08-16 18:32:46 +08:00
|
|
|
echo " --device DEV, -d DEV: build for DEV. (${DEVICES[*]})"
|
|
|
|
echo " --all, -a: build all devices."
|
|
|
|
echo " --chinese, -c: use Fastgit for submodule cloning."
|
|
|
|
echo " --release MODE, -r MODE: Release mode for building, default is 'RELEASE', 'DEBUG' alternatively."
|
|
|
|
echo " --acpi, -A: compile acpi. (not implemented yet)"
|
|
|
|
echo " --clean, -C: clean workspace and output."
|
|
|
|
echo " --distclean, -D: clean up all files that are not in repo."
|
|
|
|
echo " --outputdir, -O: output folder."
|
|
|
|
echo " --help, -h: show this help."
|
2020-10-08 00:09:09 +08:00
|
|
|
echo
|
|
|
|
echo "MainPage: https://github.com/edk2-porting/edk2-sdm845"
|
|
|
|
exit "${1}"
|
|
|
|
}
|
2021-03-19 12:01:52 +08:00
|
|
|
|
2021-01-16 03:32:50 +08:00
|
|
|
function _error(){ echo "${@}" >&2;exit 1; }
|
2021-03-19 12:01:52 +08:00
|
|
|
|
2021-01-16 03:32:50 +08:00
|
|
|
function _build(){
|
|
|
|
local DEVICE="${1}"
|
|
|
|
shift
|
|
|
|
source "${_EDK2}/edksetup.sh"
|
|
|
|
[ -d "${WORKSPACE}" ]||mkdir "${WORKSPACE}"
|
|
|
|
set -x
|
2021-07-19 02:36:14 +08:00
|
|
|
make -C "${_EDK2}/BaseTools"||exit "$?"
|
2021-03-04 22:44:07 +08:00
|
|
|
if "${GEN_ACPI}" && ! iasl -ve "sdm845Pkg/AcpiTables/${DEVICE}/Dsdt.asl"
|
|
|
|
then echo "iasl failed with ${?}" >&2;return 1
|
|
|
|
fi
|
2021-01-16 03:32:50 +08:00
|
|
|
# based on the instructions from edk2-platform
|
2021-03-27 23:37:49 +08:00
|
|
|
rm -f "${OUTDIR}/boot-${DEVICE}.img" uefi_img "uefi-${DEVICE}.img.gz" "uefi-${DEVICE}.img.gz-dtb"
|
2021-08-16 18:32:46 +08:00
|
|
|
if [ "$MODE" != "RELEASE" ]
|
|
|
|
then
|
|
|
|
build -s -n 0 -a AARCH64 -t GCC5 -p "sdm845Pkg/Devices/${DEVICE}.dsc" -b DEBUG||return "$?"
|
|
|
|
gzip -c < workspace/Build/sdm845Pkg/DEBUG_GCC5/FV/SDM845PKG_UEFI.fd > "workspace/uefi-${DEVICE}.img.gz"||return "$?"
|
|
|
|
else
|
|
|
|
build -s -n 0 -a AARCH64 -t GCC5 -p "sdm845Pkg/Devices/${DEVICE}.dsc" -b RELEASE||return "$?"
|
|
|
|
gzip -c < workspace/Build/sdm845Pkg/RELEASE_GCC5/FV/SDM845PKG_UEFI.fd > "workspace/uefi-${DEVICE}.img.gz"||return "$?"
|
|
|
|
fi
|
2021-03-04 22:47:27 +08:00
|
|
|
cat "workspace/uefi-${DEVICE}.img.gz" "device_specific/${DEVICE}.dtb" > "workspace/uefi-${DEVICE}.img.gz-dtb"||return "$?"
|
2021-03-27 23:37:49 +08:00
|
|
|
abootimg --create "${OUTDIR}/boot-${DEVICE}.img" -k "workspace/uefi-${DEVICE}.img.gz-dtb" -r ramdisk||return "$?"
|
|
|
|
echo "Build done: ${OUTDIR}/boot-${DEVICE}.img"
|
2021-01-16 03:32:50 +08:00
|
|
|
set +x
|
|
|
|
}
|
2021-03-19 12:01:52 +08:00
|
|
|
|
2021-03-07 09:59:01 +08:00
|
|
|
function _clean(){ rm --one-file-system --recursive --force ./workspace boot-*.img uefi-*.img*; }
|
2021-03-19 12:01:52 +08:00
|
|
|
|
2021-03-07 09:59:01 +08:00
|
|
|
function _distclean(){ if [ -d .git ];then git clean -xdf;else _clean;fi; }
|
2021-03-19 12:01:52 +08:00
|
|
|
|
2021-01-16 03:32:50 +08:00
|
|
|
cd "$(dirname "$0")"||exit 1
|
|
|
|
[ -f sdm845Pkg/sdm845Pkg.dsc ]||_error "cannot find sdm845Pkg/sdm845Pkg.dsc"
|
2020-10-08 00:09:09 +08:00
|
|
|
typeset -l DEVICE
|
2021-08-16 18:32:46 +08:00
|
|
|
typeset -u MODE
|
2020-10-08 00:09:09 +08:00
|
|
|
DEVICE=""
|
2021-08-16 18:32:46 +08:00
|
|
|
MODE=RELEASE
|
2021-01-18 01:14:33 +08:00
|
|
|
CHINESE=false
|
2021-03-07 09:59:01 +08:00
|
|
|
CLEAN=false
|
|
|
|
DISTCLEAN=false
|
2021-03-27 23:37:49 +08:00
|
|
|
export OUTDIR="${PWD}"
|
2021-03-04 22:44:07 +08:00
|
|
|
export GEN_ACPI=false
|
2021-08-16 18:32:46 +08:00
|
|
|
OPTS="$(getopt -o d:hacACDO:r: -l device:,help,all,chinese,acpi,clean,distclean,outputdir:,release: -n 'build.sh' -- "$@")"||exit 1
|
2020-10-08 00:09:09 +08:00
|
|
|
eval set -- "${OPTS}"
|
|
|
|
while true
|
|
|
|
do case "${1}" in
|
|
|
|
-d|--device)DEVICE="${2}";shift 2;;
|
2021-01-18 01:14:33 +08:00
|
|
|
-a|--all)DEVICE=all;shift;;
|
|
|
|
-c|--chinese)CHINESE=true;shift;;
|
2021-03-04 22:44:07 +08:00
|
|
|
-A|--acpi)GEN_ACPI=true;shift;;
|
2021-03-07 09:59:01 +08:00
|
|
|
-C|--clean)CLEAN=true;shift;;
|
|
|
|
-D|--distclean)DISTCLEAN=true;shift;;
|
2021-03-27 23:37:49 +08:00
|
|
|
-O|--outputdir)OUTDIR="${2}";shift 2;;
|
2021-08-16 18:32:46 +08:00
|
|
|
-r|--release)MODE="${2}";shift 2;;
|
2020-10-08 00:09:09 +08:00
|
|
|
-h|--help)_help 0;shift;;
|
|
|
|
--)shift;break;;
|
|
|
|
*)_help 1;;
|
|
|
|
esac
|
|
|
|
done
|
2021-03-07 09:59:01 +08:00
|
|
|
if "${DISTCLEAN}";then _distclean;exit "$?";fi
|
|
|
|
if "${CLEAN}";then _clean;exit "$?";fi
|
2021-01-19 15:12:18 +08:00
|
|
|
[ -z "${DEVICE}" ]&&_help 1
|
2021-01-17 23:19:03 +08:00
|
|
|
if ! [ -f edk2/edksetup.sh ] || ! [ -f ../edk2/edksetup.sh ]
|
|
|
|
then set -e
|
|
|
|
echo "Updating submodules"
|
2021-08-30 23:34:22 +08:00
|
|
|
git clone https://git.renegade-project.org/edk2-sdm845-acpi.git sdm845Pkg/AcpiTables
|
2021-01-18 01:14:33 +08:00
|
|
|
if "${CHINESE}"
|
2021-01-22 22:09:35 +08:00
|
|
|
then git submodule set-url edk2 https://hub.fastgit.org/tianocore/edk2.git
|
|
|
|
git submodule set-url edk2-platforms https://hub.fastgit.org/tianocore/edk2-platforms.git
|
2021-01-18 01:14:33 +08:00
|
|
|
git submodule init;git submodule update --depth 1
|
|
|
|
pushd edk2
|
2021-03-27 23:39:06 +08:00
|
|
|
|
2021-08-16 15:05:58 +08:00
|
|
|
git submodule set-url ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3 https://hub.fastgit.org/ucb-bar/berkeley-softfloat-3.git
|
2021-01-22 22:09:35 +08:00
|
|
|
git submodule set-url CryptoPkg/Library/OpensslLib/openssl https://hub.fastgit.org/openssl/openssl.git
|
|
|
|
git submodule set-url BaseTools/Source/C/BrotliCompress/brotli https://hub.fastgit.org/google/brotli.git
|
|
|
|
git submodule set-url UnitTestFrameworkPkg/Library/CmockaLib/cmocka https://git.cryptomilk.org/projects/cmocka.git
|
|
|
|
git submodule set-url ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3 https://hub.fastgit.org/ucb-bar/berkeley-softfloat-3.git
|
|
|
|
git submodule set-url MdeModulePkg/Library/BrotliCustomDecompressLib/brotli https://hub.fastgit.org/google/brotli.git
|
|
|
|
git submodule set-url MdeModulePkg/Universal/RegularExpressionDxe/oniguruma https://hub.fastgit.org/kkos/oniguruma.git
|
2021-08-08 18:35:45 +08:00
|
|
|
git submodule set-url RedfishPkg/Library/JsonLib/jansson https://hub.fastgit.org/akheron/jansson.git
|
2021-01-18 01:14:33 +08:00
|
|
|
git submodule init;git submodule update
|
|
|
|
git checkout .gitmodules
|
|
|
|
popd
|
|
|
|
git checkout .gitmodules
|
|
|
|
else git submodule init;git submodule update --depth 1
|
|
|
|
pushd edk2
|
|
|
|
git submodule init;git submodule update
|
|
|
|
popd
|
|
|
|
fi
|
2021-01-17 23:19:03 +08:00
|
|
|
set +e
|
2020-10-08 00:09:09 +08:00
|
|
|
fi
|
2021-01-16 03:32:50 +08:00
|
|
|
for i in "${EDK2}" ./edk2 ../edk2
|
|
|
|
do if [ -n "${i}" ]&&[ -f "${i}/edksetup.sh" ]
|
|
|
|
then _EDK2="$(realpath "${i}")"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
for i in "${EDK2_PLATFORMS}" ./edk2-platforms ../edk2-platforms
|
|
|
|
do if [ -n "${i}" ]&&[ -d "${i}/Platform" ]
|
|
|
|
then _EDK2_PLATFORMS="$(realpath "${i}")"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
[ -n "${_EDK2}" ]||_error "EDK2 not found, please see README.md"
|
|
|
|
[ -n "${_EDK2_PLATFORMS}" ]||_error "EDK2 Platforms not found, please see README.md"
|
|
|
|
echo "EDK2 Path: ${_EDK2}"
|
|
|
|
echo "EDK2_PLATFORMS Path: ${_EDK2_PLATFORMS}"
|
|
|
|
export GCC5_AARCH64_PREFIX="${CROSS_COMPILE:-aarch64-linux-gnu-}"
|
|
|
|
export PACKAGES_PATH="$_EDK2:$_EDK2_PLATFORMS:$PWD"
|
|
|
|
export WORKSPACE="${PWD}/workspace"
|
2021-03-27 23:40:22 +08:00
|
|
|
GITCOMMIT="$(git describe --tags --always)"||GITCOMMIT="unknown"
|
|
|
|
export GITCOMMIT
|
2020-10-09 12:24:21 +08:00
|
|
|
echo > ramdisk
|
2021-01-16 03:32:50 +08:00
|
|
|
set -e
|
2021-03-22 13:00:39 +08:00
|
|
|
python3 assets/generate-logo.py "${GITCOMMIT}"
|
2021-01-19 15:12:18 +08:00
|
|
|
if [ "${DEVICE}" == "all" ]
|
2021-01-16 03:32:50 +08:00
|
|
|
then E=0
|
|
|
|
for i in "${DEVICES[@]}"
|
|
|
|
do echo "Building ${i}"
|
|
|
|
rm --recursive --force --one-file-system ./workspace||true
|
|
|
|
_build "${i}"||E="$?"
|
|
|
|
done
|
|
|
|
exit "${E}"
|
|
|
|
else HAS=false
|
|
|
|
for i in "${DEVICES[@]}"
|
|
|
|
do [ "${i}" == "${DEVICE}" ]||continue
|
|
|
|
HAS=true
|
|
|
|
break
|
|
|
|
done
|
|
|
|
[ "${HAS}" == "true" ]||_error "build.sh: unknown build target device ${DEVICE}."
|
|
|
|
_build "${DEVICE}"
|
|
|
|
fi
|