public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Joey Vagedes <joey.vagedes@gmail.com>
To: devel@edk2.groups.io
Cc: Andrew Fish <afish@apple.com>, Ray Ni <ray.ni@intel.com>
Subject: [PATCH v1 3/3] EmulatorPkg/PlatformCI: Dyn BaseTools Selection
Date: Mon, 17 Oct 2022 11:06:35 -0700	[thread overview]
Message-ID: <20221017180635.488-4-joey.vagedes@gmail.com> (raw)
In-Reply-To: <20221017180635.488-1-joey.vagedes@gmail.com>

When using pytools to build EmulatorPkg, 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: Andrew Fish <afish@apple.com>
Cc: Ray Ni <ray.ni@intel.com>

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

diff --git a/EmulatorPkg/PlatformCI/PlatformBuild.py b/EmulatorPkg/PlatformCI/PlatformBuild.py
index 6defbf6ef1..d6d37f6053 100644
--- a/EmulatorPkg/PlatformCI/PlatformBuild.py
+++ b/EmulatorPkg/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 '''
@@ -100,7 +104,20 @@ class SettingsManager(UpdateSettingsManager, SetupSettingsManager, PrEvalSetting
 
     def GetActiveScopes(self):
         ''' return tuple containing scopes that should be active for this process '''
-        return CommonPlatform.Scopes
+        scopes = CommonPlatform.Scopes
+
+        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',)
+
+        return scopes
 
     def FilterPackagesToTest(self, changedFilesList: list, potentialPackagesList: list) -> list:
         ''' Filter other cases that this package should be built
@@ -135,6 +152,7 @@ class SettingsManager(UpdateSettingsManager, SetupSettingsManager, PrEvalSetting
 
 class PlatformBuilder(UefiBuilder, BuildSettingsManager):
     def __init__(self):
+        self.UseBuiltInBaseTools = None
         UefiBuilder.__init__(self)
 
     def AddCommandLineOptions(self, parserObj):
@@ -161,7 +179,22 @@ class PlatformBuilder(UefiBuilder, BuildSettingsManager):
 
     def GetActiveScopes(self):
         ''' return tuple containing scopes that should be active for this process '''
-        return CommonPlatform.Scopes
+        scopes = CommonPlatform.Scopes
+
+        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',)
+
+        return scopes
 
     def GetName(self):
         ''' Get the name of the repo, platform, or product being build '''
-- 
2.38.0.windows.1


      parent reply	other threads:[~2022-10-17 18:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-17 18:06 [PATCH v1 0/3] Dynamic BaseTools Selection Joey Vagedes
2022-10-17 18:06 ` [PATCH v1 1/3] ArmVirtPkg/PlatformCI: Dyn " Joey Vagedes
2022-10-17 18:06 ` [PATCH v1 2/3] OvmfPkg/PlatformCI: " Joey Vagedes
2022-10-17 18:06 ` Joey Vagedes [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221017180635.488-4-joey.vagedes@gmail.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox