Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update generated version text for extension APIs and enums #1108

Merged
merged 1 commit into from
Mar 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 33 additions & 24 deletions scripts/gen_version_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,37 @@ def GetFooter():
return """
"""

def FullNote(name, added_in, deprecated_by):
# Four patterns: (1) always present in OpenCL, (2) added after 1.0, (3) in
# 1.0 but now deprecated, and (4) added after 1.0 but now deprecated.
if added_in == "1.0" and deprecated_by == None:
return "\n// Intentionally empty, %s has always been present." % name
if added_in != "1.0" and deprecated_by == None:
return "\nIMPORTANT: {%s} is {missing_before} version %s." % (name, added_in)
if added_in == "1.0" and deprecated_by != None:
return "\nIMPORTANT: {%s} is {deprecated_by} version %s." % (name, deprecated_by)
if added_in != "1.0" and deprecated_by != None:
return "\nIMPORTANT: {%s} is {missing_before} version %s and {deprecated_by} version %s." % (name, added_in, deprecated_by)

def ShortNote(name, added_in, deprecated_by):
# Four patterns: (1) always present in OpenCL, (2) added after 1.0, (3) in
# 1.0 but now deprecated, and (4) added after 1.0 but now deprecated.
if added_in == "1.0" and deprecated_by == None:
return "// Intentionally empty, %s has always been present." % name
if added_in != "1.0" and deprecated_by == None:
return "{missing_before} version %s." % added_in
if added_in == "1.0" and deprecated_by != None:
return "{deprecated_by} version %s." % deprecated_by
if added_in != "1.0" and deprecated_by != None:
return "{missing_before} version %s and {deprecated_by} version %s." % (added_in, deprecated_by)
def FullNote(name, is_extension, added_in, deprecated_by):
if is_extension:
assert deprecated_by == None
return "\nIMPORTANT: {%s} is provided by the `%s` extension." % (name, added_in)
else:
# Four patterns: (1) always present in OpenCL, (2) added after 1.0, (3) in
# 1.0 but now deprecated, and (4) added after 1.0 but now deprecated.
if added_in == "1.0" and deprecated_by == None:
return "\n// Intentionally empty, %s has always been present." % name
if added_in != "1.0" and deprecated_by == None:
return "\nIMPORTANT: {%s} is {missing_before} version %s." % (name, added_in)
if added_in == "1.0" and deprecated_by != None:
return "\nIMPORTANT: {%s} is {deprecated_by} version %s." % (name, deprecated_by)
if added_in != "1.0" and deprecated_by != None:
return "\nIMPORTANT: {%s} is {missing_before} version %s and {deprecated_by} version %s." % (name, added_in, deprecated_by)

def ShortNote(name, is_extension, added_in, deprecated_by):
if is_extension:
assert deprecated_by == None
return "provided by the `%s` extension." % added_in
else:
# Four patterns: (1) always present in OpenCL, (2) added after 1.0, (3) in
# 1.0 but now deprecated, and (4) added after 1.0 but now deprecated.
if added_in == "1.0" and deprecated_by == None:
return "// Intentionally empty, %s has always been present." % name
if added_in != "1.0" and deprecated_by == None:
return "{missing_before} version %s." % added_in
if added_in == "1.0" and deprecated_by != None:
return "{deprecated_by} version %s." % deprecated_by
if added_in != "1.0" and deprecated_by != None:
return "{missing_before} version %s and {deprecated_by} version %s." % (added_in, deprecated_by)

# Find feature or extension groups that are parents of a <feature> or
# <extension> <require> <${entry_type}> tag, and then find all the
Expand All @@ -74,6 +82,7 @@ def process_xml(spec, entry_type, note_printer):
for feature in spec.findall(f'.//{feature_type}/require/{entry_type}/../..'):
for entry in feature.findall(f'.//{entry_type}'):
name = entry.get('name')
is_extension = feature_type != 'feature'
deprecated_by = None

numberOfEntries += 1
Expand Down Expand Up @@ -104,7 +113,7 @@ def process_xml(spec, entry_type, note_printer):
versionFileName = os.path.join(args.directory, name + ".asciidoc")
with open(versionFileName, 'w') as versionFile:
versionFile.write(GetHeader())
versionFile.write(note_printer(name, added_in, deprecated_by))
versionFile.write(note_printer(name, is_extension, added_in, deprecated_by))
versionFile.write(GetFooter())

numberOfNewEntries += 0 if added_in == "1.0" else 1
Expand Down