def Go(self): ret = 0 env = shell_environment.GetBuildVars() env.SetValue("PRODUCT_NAME", self.PlatformSettings.GetName(), "Platform Hardcoded") env.SetValue("BLD_*_BUILDID_STRING", "201905", "Current Version") env.SetValue("BUILDREPORTING", "TRUE", "Platform Hardcoded") env.SetValue("BUILDREPORT_TYPES", 'PCD DEPEX LIBRARY BUILD_FLAGS', "Platform Hardcoded") # make sure python_command is set python_command = sys.executable if " " in python_command: python_command = '"' + python_command + '"' shell_environment.GetEnvironment().set_shell_var( "PYTHON_COMMAND", python_command) # Run pre build hook ret += self.PlatformSettings.PreFirstBuildHook() ws = self.GetWorkspaceRoot() pp = self.PlatformSettings.GetModulePkgsPath() # run each configuration ret = 0 try: for config in self.PlatformSettings.GetConfigurations(): pre_ret = self.PlatformSettings.PreBuildHook( ) # run pre build hook if pre_ret != 0: ret = pre_ret raise RuntimeError("We failed in prebuild hook") edk2_logging.log_progress(f"--Running next configuration--") logging.info(config) shell_environment.CheckpointBuildVars( ) # checkpoint our config env = shell_environment.GetBuildVars() # go through the config and apply to environement for key in config: env.SetValue(key, config[key], "provided by configuration") # make sure to set this after in case the config did env.SetValue("TOOL_CHAIN_TAG", "VS2017", "provided by builder") platformBuilder = UefiBuilder() # create our builder build_ret = platformBuilder.Go(ws, pp, self.helper, self.plugin_manager) # we always want to run the post build hook post_ret = self.PlatformSettings.PostBuildHook(ret) if build_ret != 0: ret = build_ret raise RuntimeError("We failed in build") if post_ret != 0: ret = post_ret raise RuntimeError("We failed in postbuild hook") shell_environment.RevertBuildVars() except RuntimeError: pass finally: # make sure to do our final build hook self.PlatformSettings.PostFinalBuildHook(ret) return ret
def RunBuildPlugin(self, packagename, Edk2pathObj, pkgconfig, environment, PLM, PLMHelper, tc, output_stream=None): self._env = environment # Parse the config for required DscPath element if "DscPath" not in pkgconfig: tc.SetSkipped() tc.LogStdError("DscPath not found in config file. Nothing to compile.") return -1 AP = Edk2pathObj.GetAbsolutePathOnThisSystemFromEdk2RelativePath(packagename) APDSC = os.path.join(AP, pkgconfig["DscPath"].strip()) AP_Path = Edk2pathObj.GetEdk2RelativePathFromAbsolutePath(APDSC) if AP is None or AP_Path is None or not os.path.isfile(APDSC): tc.SetSkipped() tc.LogStdError("Package Dsc not found.") return -1 logging.info("Building {0}".format(AP_Path)) self._env.SetValue("ACTIVE_PLATFORM", AP_Path, "Set in Compiler Plugin") # Parse DSC to check for SUPPORTED_ARCHITECTURES dp = DscParser() dp.SetBaseAbsPath(Edk2pathObj.WorkspacePath) dp.SetPackagePaths(Edk2pathObj.PackagePathList) dp.ParseFile(AP_Path) if "SUPPORTED_ARCHITECTURES" in dp.LocalVars: SUPPORTED_ARCHITECTURES = dp.LocalVars["SUPPORTED_ARCHITECTURES"].split('|') TARGET_ARCHITECTURES = environment.GetValue("TARGET_ARCH").split(' ') # Skip if there is no intersection between SUPPORTED_ARCHITECTURES and TARGET_ARCHITECTURES if len(set(SUPPORTED_ARCHITECTURES) & set(TARGET_ARCHITECTURES)) == 0: tc.SetSkipped() tc.LogStdError("No supported architecutres to build") return -1 uefiBuilder = UefiBuilder() # do all the steps # WorkSpace, PackagesPath, PInHelper, PInManager ret = uefiBuilder.Go(Edk2pathObj.WorkspacePath, os.pathsep.join(Edk2pathObj.PackagePathList), PLMHelper, PLM) if ret != 0: # failure: tc.SetFailed("Compile failed for {0}".format(packagename), "Compile_FAILED") tc.LogStdError("{0} Compile failed with error code {1} ".format(AP_Path, ret)) return 1 else: tc.SetSuccess() return 0
def RunBuildPlugin(self, packagename, Edk2pathObj, pkgconfig, environment, PLM, PLMHelper, tc, output_stream=None): self._env = environment environment.SetValue("CI_BUILD_TYPE", "host_unit_test", "Set in HostUnitTestCompilerPlugin") # Parse the config for required DscPath element if "DscPath" not in pkgconfig: tc.SetSkipped() tc.LogStdError( "DscPath not found in config file. Nothing to compile for HostBasedUnitTests." ) return -1 AP = Edk2pathObj.GetAbsolutePathOnThisSytemFromEdk2RelativePath( packagename) APDSC = os.path.join(AP, pkgconfig["DscPath"].strip()) AP_Path = Edk2pathObj.GetEdk2RelativePathFromAbsolutePath(APDSC) if AP is None or AP_Path is None or not os.path.isfile(APDSC): tc.SetSkipped() tc.LogStdError("Package HostBasedUnitTest Dsc not found.") return -1 logging.info("Building {0}".format(AP_Path)) self._env.SetValue("ACTIVE_PLATFORM", AP_Path, "Set in Compiler Plugin") num, RUNNABLE_ARCHITECTURES = self.__GetHostUnitTestArch(environment) if (num == 0): tc.SetSkipped() tc.LogStdError("No host architecture compatibility") return -1 if not environment.SetValue( "TARGET_ARCH", RUNNABLE_ARCHITECTURES, "Update Target Arch based on Host Support"): #use AllowOverride function since this is a controlled attempt to change environment.AllowOverride("TARGET_ARCH") if not environment.SetValue( "TARGET_ARCH", RUNNABLE_ARCHITECTURES, "Update Target Arch based on Host Support"): raise RuntimeError("Can't Change TARGET_ARCH as required") # Parse DSC to check for SUPPORTED_ARCHITECTURES dp = DscParser() dp.SetBaseAbsPath(Edk2pathObj.WorkspacePath) dp.SetPackagePaths(Edk2pathObj.PackagePathList) dp.ParseFile(AP_Path) if "SUPPORTED_ARCHITECTURES" in dp.LocalVars: SUPPORTED_ARCHITECTURES = dp.LocalVars[ "SUPPORTED_ARCHITECTURES"].split('|') TARGET_ARCHITECTURES = environment.GetValue("TARGET_ARCH").split( ' ') # Skip if there is no intersection between SUPPORTED_ARCHITECTURES and TARGET_ARCHITECTURES if len(set(SUPPORTED_ARCHITECTURES) & set(TARGET_ARCHITECTURES)) == 0: tc.SetSkipped() tc.LogStdError( "No supported architecutres to build for host unit tests") return -1 uefiBuilder = UefiBuilder() # do all the steps # WorkSpace, PackagesPath, PInHelper, PInManager ret = uefiBuilder.Go(Edk2pathObj.WorkspacePath, os.pathsep.join(Edk2pathObj.PackagePathList), PLMHelper, PLM) if ret != 0: # failure: tc.SetFailed("Compile failed for {0}".format(packagename), "Compile_FAILED") tc.LogStdError("{0} Compile failed with error code {1} ".format( AP_Path, ret)) return 1 else: tc.SetSuccess() return 0