v3d: rename vertex shader key (num)_fs_inputs fields
[mesa.git] / bin / gen_release_notes.py
1 #!/usr/bin/env python3
2 # Copyright © 2019 Intel Corporation
3
4 # Permission is hereby granted, free of charge, to any person obtaining a copy
5 # of this software and associated documentation files (the "Software"), to deal
6 # in the Software without restriction, including without limitation the rights
7 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 # copies of the Software, and to permit persons to whom the Software is
9 # furnished to do so, subject to the following conditions:
10
11 # The above copyright notice and this permission notice shall be included in
12 # all copies or substantial portions of the Software.
13
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 # SOFTWARE.
21
22 """Generates release notes for a given version of mesa."""
23
24 import asyncio
25 import datetime
26 import os
27 import pathlib
28 import sys
29 import textwrap
30 import typing
31 import urllib.parse
32
33 import aiohttp
34 from mako.template import Template
35 from mako import exceptions
36
37
38 CURRENT_GL_VERSION = '4.6'
39 CURRENT_VK_VERSION = '1.1'
40
41 TEMPLATE = Template(textwrap.dedent("""\
42 <%!
43 import html
44 %>
45 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
46 <html lang="en">
47 <head>
48 <meta http-equiv="content-type" content="text/html; charset=utf-8">
49 <title>Mesa Release Notes</title>
50 <link rel="stylesheet" type="text/css" href="../mesa.css">
51 </head>
52 <body>
53
54 <div class="header">
55 <h1>The Mesa 3D Graphics Library</h1>
56 </div>
57
58 <iframe src="../contents.html"></iframe>
59 <div class="content">
60
61 <h1>Mesa ${next_version} Release Notes / ${today}</h1>
62
63 <p>
64 %if not bugfix:
65 Mesa ${next_version} is a new development release. People who are concerned
66 with stability and reliability should stick with a previous release or
67 wait for Mesa ${version[:-1]}1.
68 %else:
69 Mesa ${next_version} is a bug fix release which fixes bugs found since the ${version} release.
70 %endif
71 </p>
72 <p>
73 Mesa ${next_version} implements the OpenGL ${gl_version} API, but the version reported by
74 glGetString(GL_VERSION) or glGetIntegerv(GL_MAJOR_VERSION) /
75 glGetIntegerv(GL_MINOR_VERSION) depends on the particular driver being used.
76 Some drivers don't support all the features required in OpenGL ${gl_version}. OpenGL
77 ${gl_version} is <strong>only</strong> available if requested at context creation.
78 Compatibility contexts may report a lower version depending on each driver.
79 </p>
80 <p>
81 Mesa ${next_version} implements the Vulkan ${vk_version} API, but the version reported by
82 the apiVersion property of the VkPhysicalDeviceProperties struct
83 depends on the particular driver being used.
84 </p>
85
86 <h2>SHA256 checksum</h2>
87 <pre>
88 TBD.
89 </pre>
90
91
92 <h2>New features</h2>
93
94 <ul>
95 %for f in features:
96 <li>${html.escape(f)}</li>
97 %endfor
98 </ul>
99
100 <h2>Bug fixes</h2>
101
102 <ul>
103 %for b in bugs:
104 <li>${html.escape(b)}</li>
105 %endfor
106 </ul>
107
108 <h2>Changes</h2>
109
110 <ul>
111 %for c, author in changes:
112 %if author:
113 <p>${html.escape(c)}</p>
114 %else:
115 <li>${html.escape(c)}</li>
116 %endif
117 %endfor
118 </ul>
119
120 </div>
121 </body>
122 </html>
123 """))
124
125
126 async def gather_commits(version: str) -> str:
127 p = await asyncio.create_subprocess_exec(
128 'git', 'log', f'mesa-{version}..', '--grep', r'Closes: \(https\|#\).*',
129 stdout=asyncio.subprocess.PIPE)
130 out, _ = await p.communicate()
131 assert p.returncode == 0, f"git log didn't work: {version}"
132 return out.decode().strip()
133
134
135 async def gather_bugs(version: str) -> typing.List[str]:
136 commits = await gather_commits(version)
137
138 issues: typing.List[str] = []
139 for commit in commits.split('\n'):
140 sha, message = commit.split(maxsplit=1)
141 p = await asyncio.create_subprocess_exec(
142 'git', 'log', '--max-count', '1', r'--format=%b', sha,
143 stdout=asyncio.subprocess.PIPE)
144 _out, _ = await p.communicate()
145 out = _out.decode().split('\n')
146 for line in reversed(out):
147 if line.startswith('Closes:'):
148 bug = line.lstrip('Closes:').strip()
149 break
150 else:
151 raise Exception('No closes found?')
152 if bug.startswith('h'):
153 # This means we have a bug in the form "Closes: https://..."
154 issues.append(os.path.basename(urllib.parse.urlparse(bug).path))
155 else:
156 issues.append(bug.lstrip('#'))
157
158 loop = asyncio.get_event_loop()
159 async with aiohttp.ClientSession(loop=loop) as session:
160 results = await asyncio.gather(*[get_bug(session, i) for i in issues])
161 typing.cast(typing.Tuple[str, ...], results)
162 return list(results)
163
164
165 async def get_bug(session: aiohttp.ClientSession, bug_id: str) -> str:
166 """Query gitlab to get the name of the issue that was closed."""
167 # Mesa's gitlab id is 176,
168 url = 'https://gitlab.freedesktop.org/api/v4/projects/176/issues'
169 params = {'iids[]': bug_id}
170 async with session.get(url, params=params) as response:
171 content = await response.json()
172 return content[0]['title']
173
174
175 async def get_shortlog(version: str) -> str:
176 """Call git shortlog."""
177 p = await asyncio.create_subprocess_exec('git', 'shortlog', f'mesa-{version}..',
178 stdout=asyncio.subprocess.PIPE)
179 out, _ = await p.communicate()
180 assert p.returncode == 0, 'error getting shortlog'
181 assert out is not None, 'just for mypy'
182 return out.decode()
183
184
185 def walk_shortlog(log: str) -> typing.Generator[typing.Tuple[str, bool], None, None]:
186 for l in log.split('\n'):
187 if l.startswith(' '): # this means we have a patch description
188 yield l, False
189 else:
190 yield l, True
191
192
193 def calculate_next_version(version: str, is_point: bool) -> str:
194 """Calculate the version about to be released."""
195 if '-' in version:
196 version = version.split('-')[0]
197 if is_point:
198 base = version.split('.')
199 base[2] = str(int(base[2]) + 1)
200 return '.'.join(base)
201 return version
202
203
204 def calculate_previous_version(version: str, is_point: bool) -> str:
205 """Calculate the previous version to compare to.
206
207 In the case of -rc to final that verison is the previous .0 release,
208 (19.3.0 in the case of 20.0.0, for example). for point releases that is
209 the last point release. This value will be the same as the input value
210 for a point release, but different for a major release.
211 """
212 if '-' in version:
213 version = version.split('-')[0]
214 if is_point:
215 return version
216 base = version.split('.')
217 if base[1] == '0':
218 base[0] = str(int(base[0]) - 1)
219 base[1] = '3'
220 else:
221 base[1] = str(int(base[1]) - 1)
222 return '.'.join(base)
223
224
225 def get_features(is_point_release: bool) -> typing.Generator[str, None, None]:
226 p = pathlib.Path(__file__).parent.parent / 'docs' / 'relnotes' / 'new_features.txt'
227 if p.exists():
228 if is_point_release:
229 print("WARNING: new features being introduced in a point release", file=sys.stderr)
230 with p.open('rt') as f:
231 for line in f:
232 yield line
233 else:
234 yield "None"
235
236
237 async def main() -> None:
238 v = pathlib.Path(__file__).parent.parent / 'VERSION'
239 with v.open('rt') as f:
240 raw_version = f.read().strip()
241 is_point_release = '-rc' not in raw_version
242 assert '-devel' not in raw_version, 'Do not run this script on -devel'
243 version = raw_version.split('-')[0]
244 previous_version = calculate_previous_version(version, is_point_release)
245 next_version = calculate_next_version(version, is_point_release)
246
247 shortlog, bugs = await asyncio.gather(
248 get_shortlog(previous_version),
249 gather_bugs(previous_version),
250 )
251
252 final = pathlib.Path(__file__).parent.parent / 'docs' / 'relnotes' / f'{next_version}.html'
253 with final.open('wt') as f:
254 try:
255 f.write(TEMPLATE.render(
256 bugfix=is_point_release,
257 bugs=bugs,
258 changes=walk_shortlog(shortlog),
259 features=get_features(is_point_release),
260 gl_version=CURRENT_GL_VERSION,
261 next_version=next_version,
262 today=datetime.date.today(),
263 version=previous_version,
264 vk_version=CURRENT_VK_VERSION,
265 ))
266 except:
267 print(exceptions.text_error_template().render())
268
269
270 if __name__ == "__main__":
271 loop = asyncio.get_event_loop()
272 loop.run_until_complete(main())