57f73ee1bd540833f434341df54e94c250a31934
2 # Copyright © 2019 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."""
33 from mako
.template
import Template
34 from mako
import exceptions
37 CURRENT_GL_VERSION
= '4.6'
38 CURRENT_VK_VERSION
= '1.1'
40 TEMPLATE
= Template(textwrap
.dedent("""\
44 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
47 <meta http-equiv="content-type" content="text/html; charset=utf-8">
48 <title>Mesa Release Notes</title>
49 <link rel="stylesheet" type="text/css" href="../mesa.css">
54 <h1>The Mesa 3D Graphics Library</h1>
57 <iframe src="../contents.html"></iframe>
60 <h1>Mesa ${next_version} Release Notes / ${today}</h1>
64 Mesa ${next_version} is a new development release. People who are concerned
65 with stability and reliability should stick with a previous release or
66 wait for Mesa ${version[:-1]}1.
68 Mesa ${next_version} is a bug fix release which fixes bugs found since the ${version} release.
72 Mesa ${next_version} implements the OpenGL ${gl_version} API, but the version reported by
73 glGetString(GL_VERSION) or glGetIntegerv(GL_MAJOR_VERSION) /
74 glGetIntegerv(GL_MINOR_VERSION) depends on the particular driver being used.
75 Some drivers don't support all the features required in OpenGL ${gl_version}. OpenGL
76 ${gl_version} is <strong>only</strong> available if requested at context creation.
77 Compatibility contexts may report a lower version depending on each driver.
80 Mesa ${next_version} implements the Vulkan ${vk_version} API, but the version reported by
81 the apiVersion property of the VkPhysicalDeviceProperties struct
82 depends on the particular driver being used.
85 <h2>SHA256 checksum</h2>
95 <li>${html.escape(f)}</li>
103 <li>${html.escape(b)}</li>
110 %for c, author in changes:
112 <p>${html.escape(c)}</p>
114 <li>${html.escape(c)}</li>
125 async def gather_commits(version
: str) -> str:
126 p
= await asyncio
.create_subprocess_exec(
127 'git', 'log', f
'mesa-{version}..', '--grep', r
'Closes: \(https\|#\).*',
128 stdout
=asyncio
.subprocess
.PIPE
)
129 out
, _
= await p
.communicate()
130 assert p
.returncode
== 0, f
"git log didn't work: {version}"
131 return out
.decode().strip()
134 async def gather_bugs(version
: str) -> typing
.List
[str]:
135 commits
= await gather_commits(version
)
137 issues
: typing
.List
[str] = []
138 for commit
in commits
.split('\n'):
139 sha
, message
= commit
.split(maxsplit
=1)
140 p
= await asyncio
.create_subprocess_exec(
141 'git', 'log', '--max-count', '1', r
'--format=%b', sha
,
142 stdout
=asyncio
.subprocess
.PIPE
)
143 _out
, _
= await p
.communicate()
144 out
= _out
.decode().split('\n')
145 for line
in reversed(out
):
146 if line
.startswith('Closes:'):
147 bug
= line
.lstrip('Closes:').strip()
150 raise Exception('No closes found?')
151 if bug
.startswith('h'):
152 # This means we have a bug in the form "Closes: https://..."
153 issues
.append(os
.path
.basename(urllib
.parse
.urlparse(bug
).path
))
155 issues
.append(bug
.lstrip('#'))
157 loop
= asyncio
.get_event_loop()
158 async with aiohttp
.ClientSession(loop
=loop
) as session
:
159 results
= await asyncio
.gather(*[get_bug(session
, i
) for i
in issues
])
160 typing
.cast(typing
.Tuple
[str, ...], results
)
164 async def get_bug(session
: aiohttp
.ClientSession
, bug_id
: str) -> str:
165 """Query gitlab to get the name of the issue that was closed."""
166 # Mesa's gitlab id is 176,
167 url
= 'https://gitlab.freedesktop.org/api/v4/projects/176/issues'
168 params
= {'iids[]': bug_id
}
169 async with session
.get(url
, params
=params
) as response
:
170 content
= await response
.json()
171 return content
[0]['title']
174 async def get_shortlog(version
: str) -> str:
175 """Call git shortlog."""
176 p
= await asyncio
.create_subprocess_exec('git', 'shortlog', f
'mesa-{version}..',
177 stdout
=asyncio
.subprocess
.PIPE
)
178 out
, _
= await p
.communicate()
179 assert p
.returncode
== 0, 'error getting shortlog'
180 assert out
is not None, 'just for mypy'
184 def walk_shortlog(log
: str) -> typing
.Generator
[typing
.Tuple
[str, bool], None, None]:
185 for l
in log
.split('\n'):
186 if l
.startswith(' '): # this means we have a patch description
192 def calculate_next_version(version
: str, is_point
: bool) -> str:
193 """Calculate the version about to be released."""
195 version
= version
.split('-')[0]
197 base
= version
.split('.')
198 base
[2] = str(int(base
[2]) + 1)
199 return '.'.join(base
)
203 def calculate_previous_version(version
: str, is_point
: bool) -> str:
204 """Calculate the previous version to compare to.
206 In the case of -rc to final that verison is the previous .0 release,
207 (19.3.0 in the case of 20.0.0, for example). for point releases that is
208 the last point release. This value will be the same as the input value
209 for a point release, but different for a major release.
212 version
= version
.split('-')[0]
215 base
= version
.split('.')
217 base
[0] = str(int(base
[0]) - 1)
220 base
[1] = str(int(base
[1]) - 1)
221 return '.'.join(base
)
224 def get_features() -> typing
.Generator
[str, None, None]:
225 p
= pathlib
.Path(__file__
).parent
.parent
/ 'docs' / 'relnotes' / 'new_features.txt'
227 with p
.open('rt') as f
:
234 async def main() -> None:
235 v
= pathlib
.Path(__file__
).parent
.parent
/ 'VERSION'
236 with v
.open('rt') as f
:
237 raw_version
= f
.read().strip()
238 is_point_release
= '-rc' not in raw_version
239 assert '-devel' not in raw_version
, 'Do not run this script on -devel'
240 version
= raw_version
.split('-')[0]
241 previous_version
= calculate_previous_version(version
, is_point_release
)
242 next_version
= calculate_next_version(version
, is_point_release
)
244 shortlog
, bugs
= await asyncio
.gather(
245 get_shortlog(previous_version
),
246 gather_bugs(previous_version
),
249 final
= pathlib
.Path(__file__
).parent
.parent
/ 'docs' / 'relnotes' / f
'{next_version}.html'
250 with final
.open('wt') as f
:
252 f
.write(TEMPLATE
.render(
253 bugfix
=is_point_release
,
255 changes
=walk_shortlog(shortlog
),
256 features
=get_features(),
257 gl_version
=CURRENT_GL_VERSION
,
258 next_version
=next_version
,
259 today
=datetime
.date
.today(),
260 version
=previous_version
,
261 vk_version
=CURRENT_VK_VERSION
,
264 print(exceptions
.text_error_template().render())
267 if __name__
== "__main__":
268 loop
= asyncio
.get_event_loop()
269 loop
.run_until_complete(main())