From c94e95a77b93167156b16ad7a0721116f7a913c3 Mon Sep 17 00:00:00 2001
From: Joakim Bech <joakim.bech@linaro.org>
Date: Sat, 25 Nov 2017 11:06:50 +0100
Subject: [PATCH] edk2: Update QEMU v8 and FVP builds

QEMU v8 and FVP are both now working with upstream edk2 and
edk2-platforms. QEMU v8's dsc file is located in the edk2 folder whilst
the dsc for FVP is in the edk2-platforms folder. Due to this we had to
export the WORKSPACE variable differently otherwise we would get either
compiler errors or we would get the "Build" folder created on the top
level (something that we do not want).

Signed-off-by: Joakim Bech <joakim.bech@linaro.org>
Tested-by: Joakim Bech <joakim.bech@linaro.org> (QEMU v8, FVP)
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
---
 common.mk  | 6 +++---
 fvp.mk     | 8 ++++++--
 qemu_v8.mk | 4 ++++
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/common.mk b/common.mk
index 12bf1a3..690499e 100644
--- a/common.mk
+++ b/common.mk
@@ -209,15 +209,15 @@ linux-cleaner-common: linux-defconfig-clean
 ################################################################################
 .PHONY: edk2-common
 edk2-common:
-	export WORKSPACE=$(ROOT) && \
-	export PACKAGES_PATH=$(EDK2_PATH):$(ROOT)/edk2-platforms && \
+	$(call edk2-env) && \
+	export PACKAGES_PATH=$(EDK2_PATH):$(EDK2_PLATFORMS_PATH) && \
 	source $(EDK2_PATH)/edksetup.sh && \
 	$(MAKE) -j1 -C $(EDK2_PATH)/BaseTools && \
 	$(call edk2-call) all
 
 .PHONY: edk2-clean-common
 edk2-clean-common:
-	export WORKSPACE=$(ROOT) && \
+	$(call edk2-env) && \
 	export PACKAGES_PATH=$(EDK2_PATH):$(ROOT)/edk2-platforms && \
 	source $(EDK2_PATH)/edksetup.sh && \
 	$(MAKE) -j1 -C $(EDK2_PATH)/BaseTools clean && \
diff --git a/fvp.mk b/fvp.mk
index 9b6f2a8..aa12bd7 100644
--- a/fvp.mk
+++ b/fvp.mk
@@ -18,8 +18,8 @@ include common.mk
 ################################################################################
 ARM_TF_PATH		?= $(ROOT)/arm-trusted-firmware
 EDK2_PATH		?= $(ROOT)/edk2
-EDK2_BIN		?= $(ROOT)/Build/ArmVExpress-FVP-AArch64/RELEASE_GCC49/FV/FVP_AARCH64_EFI.fd
 EDK2_PLATFORMS_PATH	?= $(ROOT)/edk2-platforms
+EDK2_BIN		?= $(EDK2_PLATFORMS_PATH)/Build/ArmVExpress-FVP-AArch64/RELEASE_GCC49/FV/FVP_AARCH64_EFI.fd
 FOUNDATION_PATH		?= $(ROOT)/Foundation_Platformpkg
 ifeq ($(wildcard $(FOUNDATION_PATH)),)
 $(error $(FOUNDATION_PATH) does not exist)
@@ -84,10 +84,14 @@ busybox-cleaner: busybox-cleaner-common
 ################################################################################
 # EDK2 / Tianocore
 ################################################################################
+define edk2-env
+	export WORKSPACE=$(EDK2_PLATFORMS_PATH)
+endef
+
 define edk2-call
 	GCC49_AARCH64_PREFIX=$(LEGACY_AARCH64_CROSS_COMPILE) \
 	build -n `getconf _NPROCESSORS_ONLN` -a "AARCH64" \
-		-t "GCC49" -p $(EDK2_PLATFORMS_PATH)/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc -b RELEASE
+		-t "GCC49" -p Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc -b RELEASE
 endef
 
 edk2: edk2-common
diff --git a/qemu_v8.mk b/qemu_v8.mk
index 92ff70a..ea465bc 100644
--- a/qemu_v8.mk
+++ b/qemu_v8.mk
@@ -97,6 +97,10 @@ busybox-cleaner: busybox-cleaner-common
 ################################################################################
 # EDK2 / Tianocore
 ################################################################################
+define edk2-env
+	export WORKSPACE=$(EDK2_PATH)
+endef
+
 define edk2-call
 	GCC49_AARCH64_PREFIX=$(LEGACY_AARCH64_CROSS_COMPILE) \
 		$(MAKE) -j1 -C $(EDK2_PATH) \
-- 
GitLab