From 1534b6228b0932d745bf6ec9fd4cb010800b92f2 Mon Sep 17 00:00:00 2001 From: Matthew Carlson Date: Tue, 9 Feb 2021 08:50:33 +0800 Subject: BaseTools: Use pip module if available, CI uses it by default Use the new edk2-basetools pip module. Includes a helpful message in setup to let users know which has been selected. Cc: Bob Feng Cc: Liming Gao Cc: Yuwei Chen Reviewed-by: Bob Feng Reviewed-by: Yuwei Signed-off-by: Matthew Carlson --- .pytool/CISettings.py | 57 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 15 deletions(-) (limited to '.pytool/CISettings.py') diff --git a/.pytool/CISettings.py b/.pytool/CISettings.py index e6c5ac7..5f71eca 100644 --- a/.pytool/CISettings.py +++ b/.pytool/CISettings.py @@ -22,16 +22,24 @@ class Settings(CiBuildSettingsManager, UpdateSettingsManager, SetupSettingsManag self.ActualTargets = [] self.ActualArchitectures = [] self.ActualToolChainTag = "" + self.UseBuiltInBaseTools = None + self.ActualScopes = None # ####################################################################################### # # Extra CmdLine configuration # # ####################################################################################### # def AddCommandLineOptions(self, parserObj): - pass + group = parserObj.add_mutually_exclusive_group() + group.add_argument("-force_piptools", "--fpt", dest="force_piptools", action="store_true", default=False, help="Force the system to use pip tools") + group.add_argument("-no_piptools", "--npt", dest="no_piptools", action="store_true", default=False, help="Force the system to not use pip tools") def RetrieveCommandLineOptions(self, args): - pass + super().RetrieveCommandLineOptions(args) + if args.force_piptools: + self.UseBuiltInBaseTools = True + if args.no_piptools: + self.UseBuiltInBaseTools = False # ####################################################################################### # # Default Support for this Ci Build # @@ -128,19 +136,38 @@ class Settings(CiBuildSettingsManager, UpdateSettingsManager, SetupSettingsManag def GetActiveScopes(self): ''' return tuple containing scopes that should be active for this process ''' - scopes = ("cibuild", "edk2-build", "host-based-test") - - self.ActualToolChainTag = shell_environment.GetBuildVars().GetValue("TOOL_CHAIN_TAG", "") - - if GetHostInfo().os.upper() == "LINUX" and self.ActualToolChainTag.upper().startswith("GCC"): - if "AARCH64" in self.ActualArchitectures: - scopes += ("gcc_aarch64_linux",) - if "ARM" in self.ActualArchitectures: - scopes += ("gcc_arm_linux",) - if "RISCV64" in self.ActualArchitectures: - scopes += ("gcc_riscv64_unknown",) - - return scopes + if self.ActualScopes is None: + scopes = ("cibuild", "edk2-build", "host-based-test") + + self.ActualToolChainTag = shell_environment.GetBuildVars().GetValue("TOOL_CHAIN_TAG", "") + + is_linux = GetHostInfo().os.upper() == "LINUX" + + if self.UseBuiltInBaseTools is None: + is_linux = GetHostInfo().os.upper() == "LINUX" + # try and import the pip module for basetools + try: + import edk2basetools + self.UseBuiltInBaseTools = True + except ImportError: + self.UseBuiltInBaseTools = False + pass + + if self.UseBuiltInBaseTools == True: + scopes += ('pipbuild-unix',) if is_linux else ('pipbuild-win',) + logging.warning("Using Pip Tools based BaseTools") + else: + logging.warning("Falling back to using in-tree BaseTools") + + if is_linux and self.ActualToolChainTag.upper().startswith("GCC"): + if "AARCH64" in self.ActualArchitectures: + scopes += ("gcc_aarch64_linux",) + if "ARM" in self.ActualArchitectures: + scopes += ("gcc_arm_linux",) + if "RISCV64" in self.ActualArchitectures: + scopes += ("gcc_riscv64_unknown",) + self.ActualScopes = scopes + return self.ActualScopes def GetRequiredSubmodules(self): ''' return iterable containing RequiredSubmodule objects. -- cgit v1.1