Skip to content

Commit

Permalink
Add argument to specify deprecation timelines
Browse files Browse the repository at this point in the history
  • Loading branch information
NishanthSanjeevi committed Apr 14, 2024
1 parent cc0b407 commit 9ffcfaa
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions BaseTools/Plugin/OverrideValidation/OverrideValidation.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#Tuple for (version, entrycount)
OVERRIDE_FORMAT_VERSION_1 = (1, 4) #Version 1: #OVERRIDE : VERSION | PATH_TO_MODULE | HASH | YYYY-MM-DDThh-mm-ss
OVERRIDE_FORMAT_VERSION_2 = (2, 5) #Version 2: #OVERRIDE : VERSION | PATH_TO_MODULE | HASH | YYYY-MM-DDThh-mm-ss | GIT_COMMIT
DEPRECATION_FORMAT_VERSION_1 = (1, 3) # Version 1: # DEPRECATED : VERSION | PATH_TO_NEW_MODULE_TO_USE | YYYY-MM-DDThh-mm-ss
DEPRECATION_FORMAT_VERSION_1 = (1, 4) # Version 1: # DEPRECATED : VERSION | PATH_TO_NEW_MODULE_TO_USE | YYYY-MM-DDThh-mm-ss | DEPRECATION_TIMELINE
FORMAT_VERSIONS = [OVERRIDE_FORMAT_VERSION_1, OVERRIDE_FORMAT_VERSION_2, DEPRECATION_FORMAT_VERSION_1]
TIMESTAMP_FORMAT = "%Y-%m-%dT%H-%M-%S"

Expand Down Expand Up @@ -411,7 +411,8 @@ def deprecation_process_line_with_version1(self, thebuilder, filepath, Deprecati
return self.OverrideResult.DR_ALL_GOOD

# Check if the module has passed the deprecation date
deprecation_dt = datetime.strptime(DeprecationEntry[2].strip(), TIMESTAMP_FORMAT).replace(tzinfo=timezone.utc)
deprecation_timeline = int(DeprecationEntry[3])
deprecation_dt = datetime.strptime(DeprecationEntry[2].strip(), TIMESTAMP_FORMAT).replace(tzinfo=timezone.utc) + timedelta(days=deprecation_timeline)
current_dt = datetime.now(timezone.utc)

# Module has crossed date of deprecation
Expand Down Expand Up @@ -642,13 +643,17 @@ def path_parse():
help = '''Specify the absolute path to an inf with existing overrides to regen by passing r Path/To/Target or --regenpath Path/To/Target.'''
)
group.add_argument (
'-d', '--deprecatepath', dest = 'DeprecatedPath', type=str,
'-d', '--deprecatepath', dest = 'DeprecatedPath', type=str, default=None,
help = '''Specify the absolute path to the file to be deprecated by passing -d DEPRECATED_MODULE_PATH or --deprecatepath DEPRECATED_MODULE_PATH.'''
)
parser.add_argument (
'-dr', '--deprecationreplacementpath', dest = 'DeprecationReplacementPath', type=str,
'-dr', '--deprecationreplacementpath', dest = 'DeprecationReplacementPath', type=str, default=None,
help = '''Specify the relative path from the package to the replacement module by passing -dr Path/To/ReplacementPath or --deprecationreplacementpath Path/To/Target.'''
)
parser.add_argument (
'-dt', '--deprecationtimeline', dest = 'DeprecationTimelineInDays', type=int, default=90,
help = '''Specify the deprecation timeline in days. default is 90 days.'''
)
parser.add_argument (
'-p', '--packagepath', dest = 'RegenPackagePath', nargs="*", default=[],
help = '''Specify the packages path to be used to resolve relative paths when using --regenpath. ignored otherwise. Workspace is always included.'''
Expand Down Expand Up @@ -765,7 +770,7 @@ def path_parse():
pathtool = Edk2Path(Paths.WorkSpace, dummy_list)
if Paths.DeprecatedPath is not None:
# Generate deprecation warning line
# DEPRECATION_FORMAT_VERSION_1 = (1, 4) # Version 1: # DEPRECATED : VERSION | PATH_TO_NEW_MODULE_TO_USE | YYYY-MM-DDThh-mm-ss
# DEPRECATION_FORMAT_VERSION_1 = (1, 4) # Version 1: # DEPRECATED : VERSION | PATH_TO_NEW_MODULE_TO_USE | YYYY-MM-DDThh-mm-ss | DEPRECATION_TIMELINE

if Paths.DeprecationReplacementPath is not None:
pkg_path = pathtool.GetContainingPackage(Paths.DeprecationReplacementPath)
Expand All @@ -780,10 +785,10 @@ def path_parse():
else:
rel_path = "REMOVED_COMPLETELY"

print("The module will be deprecated in 90 days")
print(f"The module will be deprecated in {Paths.DeprecationTimelineInDays} days")
print("Copy and paste the following line(s) to your deprecated inf file(s):\n")
print('#%s : %08d | %s | %s \n' % ('Deprecated', DEPRECATION_FORMAT_VERSION_1[0], rel_path,
(datetime.now(timezone.utc) + timedelta(days=90)).strftime(TIMESTAMP_FORMAT)))
print('#%s : %08d | %s | %s | %s\n' % ('Deprecated', DEPRECATION_FORMAT_VERSION_1[0], rel_path,
datetime.now(timezone.utc).strftime(TIMESTAMP_FORMAT), str(Paths.DeprecationTimelineInDays)))

else:
# Generate override hash
Expand Down

0 comments on commit 9ffcfaa

Please sign in to comment.