From 4aefdf611dd28804e1afcbdef5b2de72e5a39453 Mon Sep 17 00:00:00 2001 From: Andy Fiddaman Date: Wed, 6 Dec 2017 12:55:33 +0000 Subject: [PATCH] bhyve-fw: build non-CSM variants too --- build/bhyve-fw/build.sh | 109 ++++++++++++++++++++++++++------------- build/bhyve-fw/local.mog | 1 + 2 files changed, 73 insertions(+), 37 deletions(-) diff --git a/build/bhyve-fw/build.sh b/build/bhyve-fw/build.sh index 8c24891b28..c4e73259cf 100755 --- a/build/bhyve-fw/build.sh +++ b/build/bhyve-fw/build.sh @@ -35,10 +35,25 @@ DESC="$SUMMARY" : ${PKG_SOURCE_BRANCH:=bhyve/UDK2014.SP1} # Extend VER so that the temporary build directory is branch specific. -# Branches can include '/' so remove them. +# Branch names can include '/' so remove them. VER+="-${PKG_SOURCE_BRANCH//\//_}" -clone_source(){ +export GCCPATH=/opt/gcc-4.4.4 + +MAKE_ARGS=" + AS=/usr/bin/gas + AR=/usr/bin/gar + LD=/usr/bin/gld + OBJCOPY=/usr/bin/gobjcopy + CC=${GCCPATH}/bin/gcc + CXX=${GCCPATH}/bin/g++ +" + +export OOGCC_BIN=$GCCPATH/bin/ +export IASL_PREFIX=/usr/sbin/ +export NASM_PREFIX=/usr/bin/i386/ + +clone_source() { logmsg "$PROG -> $TMPDIR/$BUILDDIR/$PROG" logcmd mkdir -p $TMPDIR/$BUILDDIR pushd $TMPDIR/$BUILDDIR > /dev/null @@ -58,72 +73,92 @@ clone_source(){ popd > /dev/null } -build() { - pushd $TMPDIR/$BUILDDIR/$PROG >/dev/null || logerr "--- chdir failed" - - export GCCPATH=/opt/gcc-4.4.4 - - MAKE_ARGS=" - AS=/usr/bin/gas - AR=/usr/bin/gar - LD=/usr/bin/gld - OBJCOPY=/usr/bin/gobjcopy - CC=${GCCPATH}/bin/gcc - CXX=${GCCPATH}/bin/g++ - " +edksetup() { + pushd $TMPDIR/$BUILDDIR/$PROG > /dev/null || logerr "--- chdir failed" + source edksetup.sh + popd > /dev/null +} +cleanup() { logmsg "-- Cleaning source tree" + pushd $TMPDIR/$BUILDDIR/$PROG > /dev/null || logerr "--- chdir failed" + logcmd gmake $MAKE_ARGS ARCH=X64 -C BaseTools clean - rm -f Build Conf/{target,build_rule,tools_def}.txt Conf/.cache 2>/dev/null + rm -rf Build Conf/{target,build_rule,tools_def}.txt Conf/.cache 2>/dev/null + popd > /dev/null +} + +build_tools() { logmsg "-- Building tools" - # First build the tools. The code isn't able to detect the build - # architecture - it doesn't expect `uname -m` to return `i86pc` + pushd $TMPDIR/$BUILDDIR/$PROG > /dev/null || logerr "--- chdir failed" + + # The code isn't able to detect the build architecture - it doesn't + # expect `uname -m` to return `i86pc` logcmd gmake $MAKE_ARGS ARCH=X64 -C BaseTools \ || logerr "--- BaseTools build failed" - BUILD_ARGS="-DDEBUG_ON_SERIAL_PORT=TRUE -DFD_SIZE_2MB -DCSM_ENABLE=TRUE" + popd > /dev/null +} + +build() { + pushd $TMPDIR/$BUILDDIR/$PROG > /dev/null || logerr "--- chdir failed" - ( - export OOGCC_BIN=$GCCPATH/bin/ - export IASL_PREFIX=/usr/sbin/ - export NASM_PREFIX=/usr/bin/i386/ - source edksetup.sh + [ "$1" = "-csm" ] && csm=1 || csm=0 + BUILD_ARGS="-DDEBUG_ON_SERIAL_PORT=TRUE -DFD_SIZE_2MB" + [ $csm -eq 1 ] && BUILD_ARGS+=" -DCSM_ENABLE=TRUE" + export BUILD_ARGS + + if [ $csm -eq 1 ]; then logmsg "-- Building compatibility support module (CSM)" logcmd gmake $MAKE_ARGS -C BhyvePkg/Csm/BhyveCsm16/ \ || logerr "--- CSM build failed" + fi - for mode in RELEASE DEBUG; do - logmsg "-- Building $mode firmware" - logcmd `which build` \ - -t OOGCC -a X64 -b $mode \ - -p BhyvePkg/BhyvePkgX64.dsc \ - $BUILD_ARGS || logerr "--- $mode build failed" - done - ) || logerr "--- Build failed" + for mode in RELEASE DEBUG; do + logmsg "-- Building $mode firmware" + logcmd `which build` \ + -t OOGCC -a X64 -b $mode \ + -p BhyvePkg/BhyvePkgX64.dsc \ + $BUILD_ARGS || logerr "--- $mode build failed" + done - popd >/dev/null + popd > /dev/null } install() { - pushd $TMPDIR/$BUILDDIR/$PROG >/dev/null || logerr "--- chdir failed" + suffix="$1" + pushd $TMPDIR/$BUILDDIR/$PROG > /dev/null || logerr "--- chdir failed" logcmd mkdir -p $DESTDIR/usr/share/bhyve/firmware - cp OvmfPkg/License.txt $DESTDIR/LICENCE + [ -f $DESTDIR/LICENCE ] || cp OvmfPkg/License.txt $DESTDIR/LICENCE for mode in RELEASE DEBUG; do logcmd cp Build/BhyveX64/${mode}_OOGCC/FV/BHYVE.fd \ - $DESTDIR/usr/share/bhyve/firmware/BHYVE_$mode.fd + $DESTDIR/usr/share/bhyve/firmware/BHYVE_$mode$suffix.fd done - popd >/dev/null + popd > /dev/null } init prep_build clone_source + +cleanup +build_tools +edksetup + +# Build UEFI firmware +note "UEFI Firmware" build install + +# Build UEFI+CSM firmware +note "UEFI+CSM Firmware" +build -csm +install _CSM + # Reset version for package creation VER=$VERHUMAN make_package diff --git a/build/bhyve-fw/local.mog b/build/bhyve-fw/local.mog index 4a3e6c3b37..024031b4f6 100644 --- a/build/bhyve-fw/local.mog +++ b/build/bhyve-fw/local.mog @@ -14,4 +14,5 @@ license LICENCE license=Intel set mode 0755> link path=usr/share/bhyve/firmware/BHYVE.fd target=BHYVE_RELEASE.fd +link path=usr/share/bhyve/firmware/BHYVE_CSM.fd target=BHYVE_RELEASE_CSM.fd