|
31 | 31 | from edk2toollib.utility_functions import RunCmd
|
32 | 32 |
|
33 | 33 | from edk2toolext import edk2_logging
|
| 34 | +from edk2toolext.environment import shell_environment |
34 | 35 | from edk2toolext.invocables.edk2_multipkg_aware_invocable import (
|
35 | 36 | Edk2MultiPkgAwareInvocable,
|
36 | 37 | MultiPkgAwareSettingsInterface,
|
@@ -311,29 +312,46 @@ def get_packages_to_build(self, possible_packages: list) -> dict:
|
311 | 312 | if len(remaining_packages) != 1:
|
312 | 313 | raise Exception("Policy 4 can only be used by builds for a single package")
|
313 | 314 |
|
314 |
| - # files are all the files changed edk2 workspace root relative path |
315 |
| - changed_modules = self._get_unique_module_infs_changed(files) |
316 |
| - changed_modules = [Path(m) for m in changed_modules] |
317 |
| - |
318 |
| - # now check DSC |
319 |
| - dsc = DscParser().SetEdk2Path(self.edk2_path_obj) |
320 |
| - # given that PR eval runs before dependencies are downloaded we must tolerate errors |
321 |
| - dsc.SetNoFailMode() |
322 |
| - dsc.SetInputVars(PlatformDscInfo[1]) |
323 |
| - dsc.ParseFile(PlatformDscInfo[0]) |
324 |
| - allinfs = dsc.OtherMods + dsc.ThreeMods + dsc.SixMods + dsc.Libs # get list of all INF files |
325 |
| - allinfs = [Path(i) for i in allinfs] |
326 |
| - |
327 |
| - # |
328 |
| - # Note: for now we assume that remaining_packages has only 1 package and that it corresponds |
329 |
| - # to the DSC file provided. |
330 |
| - # |
331 |
| - for p in remaining_packages[:]: # slice so we can delete as we go |
332 |
| - for cm in changed_modules: |
333 |
| - if cm in allinfs: # is the changed module listed in the DSC file? |
334 |
| - packages_to_build[p] = f"Policy 4 - Package Dsc depends on {str(cm)}" |
335 |
| - remaining_packages.remove(p) # remove from remaining packages |
336 |
| - break |
| 315 | + if self.requested_target_list is None: |
| 316 | + raise ValueError("Policy 4 requires a target to be set.") |
| 317 | + |
| 318 | + for target in self.requested_target_list: |
| 319 | + if target not in self.PlatformSettings.GetTargetsSupported(): |
| 320 | + raise ValueError(f"Target {target} is not supported by this platform.") |
| 321 | + |
| 322 | + # files are all the files changed edk2 workspace root relative path |
| 323 | + changed_modules = self._get_unique_module_infs_changed(files) |
| 324 | + changed_modules = [Path(m) for m in changed_modules] |
| 325 | + |
| 326 | + # now check the DSC |
| 327 | + dsc = DscParser().SetEdk2Path(self.edk2_path_obj) |
| 328 | + # given that PR eval runs before dependencies are downloaded we must tolerate errors |
| 329 | + dsc.SetNoFailMode() |
| 330 | + |
| 331 | + # start with any default values explicitly passed by the GetPlatformDscAndConfig() implementation |
| 332 | + input_vars = {} |
| 333 | + if PlatformDscInfo[1] is not None: |
| 334 | + input_vars.update(PlatformDscInfo[1]) |
| 335 | + |
| 336 | + # update with build variables resolved against the current target |
| 337 | + input_vars.update(shell_environment.GetBuildVars().GetAllBuildKeyValues(target)) |
| 338 | + |
| 339 | + dsc.SetInputVars(input_vars) |
| 340 | + dsc.ParseFile(PlatformDscInfo[0]) |
| 341 | + |
| 342 | + allinfs = dsc.OtherMods + dsc.ThreeMods + dsc.SixMods + dsc.Libs # get list of all INF files |
| 343 | + allinfs = [Path(i) for i in allinfs] |
| 344 | + |
| 345 | + # |
| 346 | + # Note: for now we assume that remaining_packages has only 1 package and that it corresponds |
| 347 | + # to the DSC file provided. |
| 348 | + # |
| 349 | + for p in remaining_packages[:]: # slice so we can delete as we go |
| 350 | + for cm in changed_modules: |
| 351 | + if cm in allinfs: # is the changed module listed in the DSC file? |
| 352 | + packages_to_build[p] = f"Policy 4 - Package Dsc depends on {str(cm)}" |
| 353 | + remaining_packages.remove(p) # remove from remaining packages |
| 354 | + break |
337 | 355 |
|
338 | 356 | #
|
339 | 357 | # Policy 5: If a file changed is a Library INF file, then build all packages that depend on that Library
|
|
0 commit comments