change to submodule, add build all devices
authorBigfootACA <bigfoot@classfun.cn>
星期五, 15 Jan 2021 19:32:50 +0000 (03:32 +0800)
committerBigfootACA <bigfoot@classfun.cn>
星期五, 2 Jul 2021 08:29:18 +0000 (16:29 +0800)
.github/workflows/main.yml
.gitignore
.gitmodules [new file with mode: 0644]
README.md
build.sh
edk2 [new submodule]
edk2-platforms [new submodule]

index 9ddbd2eb7285c38ef8921cecb46c5eed35394b82..a064a3a2ccbea120a4ca03646a60b0e9302e5770 100644 (file)
@@ -23,11 +23,5 @@ jobs:
       - uses: actions/checkout@v2
 
       # Runs a single command using the runners shell
-      - name: Run a one-line script
-        run: echo Hello, world!
-
-      # Runs a set of commands using the runners shell
-      - name: Run a multi-line script
-        run: |
-          echo Add other actions to build,
-          echo test, and deploy your project.
+      - name: Build all devices
+        run: ./build.sh -a
index 845cdefda25bd688c29290803810fed6f36f676d..7a46a2cbf2946308a5b41f98b6799d8a0f596395 100644 (file)
@@ -1,6 +1,8 @@
 boot-*.img
 uefi-*.img
 uefi-*.img-dtb
+uefi-*.img.gz
+uefi-*.img.gz-dtb
 workspace
 *.dll
 ramdisk
diff --git a/.gitmodules b/.gitmodules
new file mode 100644 (file)
index 0000000..d2a7fd5
--- /dev/null
@@ -0,0 +1,6 @@
+[submodule "edk2"]
+       path = edk2
+       url = https://github.com/tianocore/edk2.git
+[submodule "edk2-platforms"]
+       path = edk2-platforms
+       url = https://github.com/tianocore/edk2-platforms.git
index 9c30b57ff2576696a55d04a464911a072768d28e..7cec569773c4d556aa9ff890cedbe32e8cd48aac 100644 (file)
--- a/README.md
+++ b/README.md
@@ -28,38 +28,19 @@ Ubuntu 20.04 is also proved to be fine.
 \r
 ## Building\r
 \r
-1.Clone edk2 and edk2-platforms (Place three directories side by side.)\r
-\r
-edk2:\r
-```\r
-commit:3a3713e62cfad00d78bb938b0d9fb1eedaeff314\r
-```\r
-\r
-edk2-platforms:\r
-```\r
-commit:cfdc7f907d545b14302295b819ea078bc36c6a40\r
-```\r
-\r
-```bash\r
-mkdir workspace-edk2\r
-cd workspace-edk2\r
-git clone https://github.com/tianocore/edk2.git -o 3a3713e62cfad00d78bb938b0d9fb1eedaeff314 --recursive --depth=1\r
-git clone https://github.com/tianocore/edk2-platforms.git -o cfdc7f907d545b14302295b819ea078bc36c6a40 --recursive --depth=1\r
-```\r
-\r
-2.Clone this project\r
+1.Clone this project\r
 \r
 ```bash\r
-git clone https://github.com/edk2-porting/edk2-sdm845.git\r
+git clone https://github.com/edk2-porting/edk2-sdm845.git --recursive\r
 ```\r
 \r
-3.Build this project\r
+2.Build this project\r
 \r
 ```bash\r
 bash build.sh --device DEVICE\r
 ```\r
 \r
-4.Boot the image\r
+3.Boot the image\r
 \r
 ```bash\r
 fastboot boot boot_DEVICE.img\r
index c21a5b21dc7cc46eef085a7ea9d2f2c2ff6bd916..ec861d3b6132cd1868e3a4c562c26a5d7d45a200 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -17,62 +17,88 @@ function _help(){
        echo
        echo "Options: "
        echo "  --device DEV, -d DEV: build for DEV. (${DEVICES[*]})"
+       echo "  --all, -a:            build all 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 find sdm845Pkg/sdm845Pkg.dsc" >&2
-       exit 1
-fi
+function _error(){ echo "${@}" >&2;exit 1; }
+function _build(){
+       local DEVICE="${1}"
+       shift
+       source "${_EDK2}/edksetup.sh"
+       [ -d "${WORKSPACE}" ]||mkdir "${WORKSPACE}"
+       set -x
+       make -C "${_EDK2}/BaseTools" -j "$(nproc)"||exit "$?"
+       # based on the instructions from edk2-platform
+       rm -f "boot_${DEVICE}.img" uefi_img "uefi-${DEVICE}.img.gz" "uefi-${DEVICE}.img.gz-dtb"
+       build -s -n 0 -a AARCH64 -t GCC5 -p "sdm845Pkg/${DEVICE}.dsc"||return "$?"
+       gzip -c < workspace/Build/sdm845Pkg/DEBUG_GCC5/FV/SDM845PKG_UEFI.fd > "uefi-${DEVICE}.img.gz"||return "$?"
+       cat "uefi-${DEVICE}.img.gz" "device_specific/${DEVICE}.dtb" > "uefi-${DEVICE}.img.gz-dtb"||return "$?"
+       abootimg --create "boot-${DEVICE}.img" -k "uefi-${DEVICE}.img.gz-dtb" -r ramdisk||return "$?"
+       echo "Build done: boot-${DEVICE}.img"
+       set +x
+}
+cd "$(dirname "$0")"||exit 1
+[ -f sdm845Pkg/sdm845Pkg.dsc ]||_error "cannot find sdm845Pkg/sdm845Pkg.dsc"
 typeset -l DEVICE
 DEVICE=""
-OPTS="$(getopt -o d:h -l device:,help -n 'build.sh' -- "$@")"||exit 1
+OPTS="$(getopt -o d:ha -l device:,help,all -n 'build.sh' -- "$@")"||exit 1
 eval set -- "${OPTS}"
 while true
 do     case "${1}" in
                -d|--device)DEVICE="${2}";shift 2;;
+               -a|--all)DEVICE="all";shift;;
                -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
+if ! [ -d ../edk2 ]
+then   echo "Updating submodules"
+       git submodule init&&git submodule update
+       pushd edk2&&git submodule init&&git submodule update&&popd
+       pushd edk2-platforms&&git submodule init&&git submodule update&&popd
 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
+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}"
 # 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"
+export GCC5_AARCH64_PREFIX="${CROSS_COMPILE:-aarch64-linux-gnu-}"
+export PACKAGES_PATH="$_EDK2:$_EDK2_PLATFORMS:$PWD"
+export WORKSPACE="${PWD}/workspace"
 echo > ramdisk
-abootimg --create "boot-${DEVICE}.img" -k "uefi-${DEVICE}.img-dtb" -r ramdisk
-echo "Build done: boot-${DEVICE}.img"
+set -e
+if [ -z "${DEVICE}" ]
+then _help 1
+elif [ "${DEVICE}" == "all" ]
+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
diff --git a/edk2 b/edk2
new file mode 160000 (submodule)
index 0000000..3a3713e
--- /dev/null
+++ b/edk2
@@ -0,0 +1 @@
+Subproject commit 3a3713e62cfad00d78bb938b0d9fb1eedaeff314
diff --git a/edk2-platforms b/edk2-platforms
new file mode 160000 (submodule)
index 0000000..cfdc7f9
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit cfdc7f907d545b14302295b819ea078bc36c6a40