Refactor build_artifacts.sh and makefile
- Move everything to .data, .vendor, .artifacts and .bin in order to cleanly separate build input and output.
- Sprinkle some subshells on build_artifacts.sh to make it fail more gracefully.
- Fix fetch_third_party.sh check.
- GOBUILD make helper.
- Dockerfile with build dependencies.
Test Plan:
Ran `make clean` and build steps described in README.md, it boots:
{P84}
X-Origin-Diff: phab/D195
GitOrigin-RevId: 4106534c7248931b79e93e2a13153482033cd0d8
diff --git a/scripts/build_artifacts.sh b/scripts/build_artifacts.sh
index 9ec4d5c..de1addc 100755
--- a/scripts/build_artifacts.sh
+++ b/scripts/build_artifacts.sh
@@ -1,47 +1,76 @@
#!/usr/bin/env bash
set -eo pipefail
-if [ ! -d "$root/linux" ] ; then
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+ROOT=$(realpath ${DIR}/../.vendor)
+
+echo "Vendor build root: $ROOT"
+
+if [ ! -d "$ROOT/linux" ] ; then
echo "Please first call scripts/fetch_third_party.sh"
+ exit 1
fi
-root=$(git rev-parse --show-toplevel)/third_party
-
-# nasm + Python 3.7 + iasl
-if [ ! -d "$root/edk2" ] ; then
- git clone --recurse-submodules https://github.com/tianocore/edk2 $root/edk2
+if [ ! -d "$ROOT/edk2" ] ; then
+ git clone --single-branch --branch edk2-stable201908 --depth=1 --recurse-submodules https://github.com/tianocore/edk2 $ROOT/edk2
fi
-cd $root/edk2
-git checkout --recurse-submodules edk2-stable201908
-. edksetup.sh
-make -C $root/edk2/BaseTools/Source/C
-build -DTPM2_ENABLE -DSECURE_BOOT_ENABLE -t GCC5 -a X64 -b RELEASE -p $PWD/OvmfPkg/OvmfPkgX64.dsc
-musl_prefix=$root/musl-prefix
+(
+ cd $ROOT/edk2
+ . edksetup.sh
+ make -C BaseTools/Source/C
+ build -DTPM2_ENABLE -DSECURE_BOOT_ENABLE -t GCC5 -a X64 -b RELEASE -p $PWD/OvmfPkg/OvmfPkgX64.dsc
-cd $root/linux
-make headers_install ARCH=x86_64 INSTALL_HDR_PATH=$musl_prefix
+ cp Build/OvmfX64/RELEASE_GCC5/FV/{OVMF_CODE.fd,OVMF_VARS.fd} $ROOT/../.artifacts
+)
-mkdir -p $root/musl
-curl -L https://www.musl-libc.org/releases/musl-1.1.23.tar.gz | tar -xzf - -C $root/musl --strip-components 1
-cd $root/musl
+musl_prefix=$ROOT/musl-prefix
-./configure --prefix=$musl_prefix --syslibdir=$musl_prefix/lib
-make -j8
-make install
+(
+ cd $ROOT/linux
+ make headers_install ARCH=x86_64 INSTALL_HDR_PATH=$musl_prefix
+)
-mkdir -p $root/util-linux
-curl -L https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/snapshot/util-linux-2.34.tar.gz | tar -xzf - -C $root/util-linux --strip-components 1
-cd $root/util-linux
-./autogen.sh
-./configure CC=$musl_prefix/bin/musl-gcc --without-systemd --without-udev --without-btrfs --disable-pylibmount --without-tinfo --prefix=$musl_prefix --disable-makeinstall-chown --disable-makeinstall-setuid --with-bashcompletiondir=$musl_prefix/usr/share/bash-completion
-make -j8
-make install
+mkdir -p $ROOT/musl
+curl -L https://www.musl-libc.org/releases/musl-1.1.23.tar.gz | tar -xzf - -C $ROOT/musl --strip-components 1
-mkdir -p $root/xfsprogs-dev
-curl -L https://git.kernel.org/pub/scm/fs/xfs/xfsprogs-dev.git/snapshot/xfsprogs-dev-5.2.1.tar.gz | tar -xzf - -C $root/xfsprogs-dev --strip-components 1
-cd $root/xfsprogs-dev
-patch -p1 < ../../patches/xfsprogs-dev/*.patch
-./configure CC=$musl_prefix/bin/musl-gcc "CFLAGS=-static -I$musl_prefix/include -L$musl_prefix/lib" "LDFLAGS=-L$musl_prefix/lib"
-make -j8 mkfs
-cp $root/xfsprogs-dev/mkfs/mkfs.xfs
\ No newline at end of file
+(
+ cd $ROOT/musl
+
+ ./configure --prefix=$musl_prefix --syslibdir=$musl_prefix/lib
+ make -j8
+ make install
+)
+
+mkdir -p $ROOT/util-linux
+curl -L https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/snapshot/util-linux-2.34.tar.gz | tar -xzf - -C $ROOT/util-linux --strip-components 1
+
+(
+ cd $ROOT/util-linux
+ ./autogen.sh
+ ./configure \
+ CC=$musl_prefix/bin/musl-gcc \
+ --without-systemd \
+ --without-udev \
+ --without-btrfs \
+ --disable-pylibmount \
+ --without-tinfo \
+ --prefix=$musl_prefix \
+ --disable-makeinstall-chown \
+ --disable-makeinstall-setuid \
+ --with-bashcompletiondir=$musl_prefix/usr/share/bash-completion
+ make -j8
+ make install
+)
+
+mkdir -p $ROOT/xfsprogs-dev
+curl -L https://git.kernel.org/pub/scm/fs/xfs/xfsprogs-dev.git/snapshot/xfsprogs-dev-5.2.1.tar.gz | tar -xzf - -C $ROOT/xfsprogs-dev --strip-components 1
+
+(
+ cd $ROOT/xfsprogs-dev
+ patch -p1 < ../../patches/xfsprogs-dev/*.patch
+ make configure
+ ./configure CC=$musl_prefix/bin/musl-gcc "CFLAGS=-static -I$musl_prefix/include -L$musl_prefix/lib" "LDFLAGS=-L$musl_prefix/lib"
+ make -j8 mkfs
+ cp $ROOT/xfsprogs-dev/mkfs/mkfs.xfs $ROOT/../.artifacts
+)