[edk2-devel] [PATCH v1 1/3] ArmVirtPkg/PlatformCI: Dyn BaseTools Selection

Joey Vagedes posted 3 patches 3 years, 3 months ago
[edk2-devel] [PATCH v1 1/3] ArmVirtPkg/PlatformCI: Dyn BaseTools Selection
Posted by Joey Vagedes 3 years, 3 months ago
When using pytools to build ArmVirtPkg, add the ability to dynamically
determine which BaseTools to build with. The Pypi BaseTools will be used
if present, otherwise defaulting to the in-tree Basetools.

Reference: https://bugzilla.tianocore.org/show_bug.cgi?id=4085

CC: Ard Biesheuvel <ardb+tianocore@kernel.org>
CC: Leif Lindholm <quic_llindhol@quicinc.com>
CC: Sami Mujawar <sami.mujawar@arm.com>
CC: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>

Signed-off-by: Joey Vagedes <Joeyvagedes@microsoft.com>
---
 ArmVirtPkg/PlatformCI/PlatformBuild.py | 33 ++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

diff --git a/ArmVirtPkg/PlatformCI/PlatformBuild.py b/ArmVirtPkg/PlatformCI/PlatformBuild.py
index dff653e919..7ceca8145c 100644
--- a/ArmVirtPkg/PlatformCI/PlatformBuild.py
+++ b/ArmVirtPkg/PlatformCI/PlatformBuild.py
@@ -7,6 +7,7 @@
 import os
 import logging
 import io
+import importlib
 
 from edk2toolext.environment import shell_environment
 from edk2toolext.environment.uefi_build import UefiBuilder
@@ -40,6 +41,9 @@ class CommonPlatform():
 
 class SettingsManager(UpdateSettingsManager, SetupSettingsManager, PrEvalSettingsManager):
 
+    def __init__(self):
+        self.UseBuiltInBaseTools = None
+
     def GetPackagesSupported(self):
         ''' return iterable of edk2 packages supported by this build.
         These should be edk2 workspace relative paths '''
@@ -105,7 +109,18 @@ class SettingsManager(UpdateSettingsManager, SetupSettingsManager, PrEvalSetting
         scopes = CommonPlatform.Scopes
         ActualToolChainTag = shell_environment.GetBuildVars().GetValue("TOOL_CHAIN_TAG", "")
 
-        if GetHostInfo().os.upper() == "LINUX" and ActualToolChainTag.upper().startswith("GCC"):
+        is_linux = GetHostInfo().os.upper() == "LINUX"
+
+        if self.UseBuiltInBaseTools is None:
+            if importlib.util.find_spec('edk2basetools') is not None:
+                self.UseBuiltInBaseTools = True
+            else:
+                self.UseBuiltInBaseTools = False
+
+        if self.UseBuiltInBaseTools is True:
+            scopes += ('pipbuild-unix',) if is_linux else ('pipbuild-win',)
+
+        if is_linux and ActualToolChainTag.upper().startswith("GCC"):
             if "AARCH64" in self.ActualArchitectures:
                 scopes += ("gcc_aarch64_linux",)
             if "ARM" in self.ActualArchitectures:
@@ -149,6 +164,7 @@ class SettingsManager(UpdateSettingsManager, SetupSettingsManager, PrEvalSetting
 
 class PlatformBuilder(UefiBuilder, BuildSettingsManager):
     def __init__(self):
+        self.UseBuiltInBaseTools = None
         UefiBuilder.__init__(self)
 
     def AddCommandLineOptions(self, parserObj):
@@ -179,7 +195,20 @@ class PlatformBuilder(UefiBuilder, BuildSettingsManager):
         ActualToolChainTag = shell_environment.GetBuildVars().GetValue("TOOL_CHAIN_TAG", "")
         Arch = shell_environment.GetBuildVars().GetValue("TARGET_ARCH", "")
 
-        if GetHostInfo().os.upper() == "LINUX" and ActualToolChainTag.upper().startswith("GCC"):
+        is_linux = GetHostInfo().os.upper() == "LINUX"
+
+        if self.UseBuiltInBaseTools is None:
+            if importlib.util.find_spec('edk2basetools') is not None:
+                self.UseBuiltInBaseTools = True
+                logging.warning("Using Pip Tools based BaseTools")
+            else:
+                self.UseBuiltInBaseTools = False
+                logging.warning("Falling back to using in-tree BaseTools")
+
+        if self.UseBuiltInBaseTools is True:
+            scopes += ('pipbuild-unix',) if is_linux else ('pipbuild-win',)
+
+        if is_linux and ActualToolChainTag.upper().startswith("GCC"):
             if "AARCH64" == Arch:
                 scopes += ("gcc_aarch64_linux",)
             elif "ARM" == Arch:
-- 
2.38.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95299): https://edk2.groups.io/g/devel/message/95299
Mute This Topic: https://groups.io/mt/94399353/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-