2 # Copyright © 2019-2020 Intel Corporation
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:
11 # The above copyright notice and this permission notice shall be included in
12 # all copies or substantial portions of the Software.
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
22 """Generates release notes for a given version of mesa."""
34 from mako
.template
import Template
35 from mako
import exceptions
38 CURRENT_GL_VERSION
= '4.6'
39 CURRENT_VK_VERSION
= '1.2'
41 TEMPLATE
= Template(textwrap
.dedent("""\
45 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
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">
55 <h1>The Mesa 3D Graphics Library</h1>
58 <iframe src="../contents.html"></iframe>
61 <h1>Mesa ${this_version} Release Notes / ${today}</h1>
65 Mesa ${this_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 ${this_version[:-1]}1.
69 Mesa ${this_version} is a bug fix release which fixes bugs found since the ${previous_version} release.
73 Mesa ${this_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.
81 Mesa ${this_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.
86 <h2>SHA256 checksum</h2>
96 <li>${html.escape(f)}</li>
104 <li>${html.escape(b)}</li>
111 %for c, author in changes:
113 <p>${html.escape(c)}</p>
115 <li>${html.escape(c)}</li>
126 async def gather_commits(version
: str) -> str:
127 p
= await asyncio
.create_subprocess_exec(
128 'git', 'log', '--oneline', 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()
135 async def gather_bugs(version
: str) -> typing
.List
[str]:
136 commits
= await gather_commits(version
)
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()
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
))
156 issues
.append(bug
.lstrip('#'))
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
)
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']
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'
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
193 def calculate_next_version(version
: str, is_point
: bool) -> str:
194 """Calculate the version about to be released."""
196 version
= version
.split('-')[0]
198 base
= version
.split('.')
199 base
[2] = str(int(base
[2]) + 1)
200 return '.'.join(base
)
204 def calculate_previous_version(version
: str, is_point
: bool) -> str:
205 """Calculate the previous version to compare to.
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.
213 version
= version
.split('-')[0]
216 base
= version
.split('.')
218 base
[0] = str(int(base
[0]) - 1)
221 base
[1] = str(int(base
[1]) - 1)
222 return '.'.join(base
)
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'
229 print("WARNING: new features being introduced in a point release", file=sys
.stderr
)
230 with p
.open('rt') as f
:
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 this_version
= calculate_next_version(version
, is_point_release
)
247 shortlog
, bugs
= await asyncio
.gather(
248 get_shortlog(previous_version
),
249 gather_bugs(previous_version
),
252 final
= pathlib
.Path(__file__
).parent
.parent
/ 'docs' / 'relnotes' / f
'{this_version}.html'
253 with final
.open('wt') as f
:
255 f
.write(TEMPLATE
.render(
256 bugfix
=is_point_release
,
258 changes
=walk_shortlog(shortlog
),
259 features
=get_features(is_point_release
),
260 gl_version
=CURRENT_GL_VERSION
,
261 this_version
=this_version
,
262 today
=datetime
.date
.today(),
263 previous_version
=previous_version
,
264 vk_version
=CURRENT_VK_VERSION
,
267 print(exceptions
.text_error_template().render())
270 if __name__
== "__main__":
271 loop
= asyncio
.get_event_loop()
272 loop
.run_until_complete(main())