v3d: add new flag dirty TMU cache at v3d_compiler
[mesa.git] / bin / post_version.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 """Update the main page, release notes, and calendar."""
23
24 import calendar
25 import datetime
26 import pathlib
27 from lxml import (
28 etree,
29 html,
30 )
31
32
33 def calculate_previous_version(version: str, is_point: bool) -> str:
34 """Calculate the previous version to compare to.
35
36 In the case of -rc to final that verison is the previous .0 release,
37 (19.3.0 in the case of 20.0.0, for example). for point releases that is
38 the last point release. This value will be the same as the input value
39 for a poiont release, but different for a major release.
40 """
41 if '-' in version:
42 version = version.split('-')[0]
43 if is_point:
44 return version
45 base = version.split('.')
46 if base[1] == '0':
47 base[0] = str(int(base[0]) - 1)
48 base[1] = '3'
49 else:
50 base[1] = str(int(base[1]) - 1)
51 return '.'.join(base)
52
53
54 def get_version() -> str:
55 v = pathlib.Path(__file__).parent.parent / 'VERSION'
56 with v.open('rt') as f:
57 raw_version = f.read().strip()
58 return raw_version.split('-')[0]
59
60
61 def is_point_release() -> bool:
62 v = pathlib.Path(__file__).parent.parent / 'VERSION'
63 with v.open('rt') as f:
64 raw_version = f.read().strip()
65 return '-rc' not in raw_version
66
67
68 def update_index(is_point: bool, version: str, previous_version: str) -> None:
69 p = pathlib.Path(__file__).parent.parent / 'docs' / 'index.html'
70 with p.open('rt') as f:
71 tree = html.parse(f)
72
73 news = tree.xpath('.//h1')[0]
74
75 date = datetime.date.today()
76 month = calendar.month_name[date.month]
77 header = etree.Element('h2')
78 header.text=f"{month} {date.day}, {date.year}"
79
80 body = etree.Element('p')
81 a = etree.SubElement(body, 'a', attrib={'href': f'relnotes/{previous_version}'})
82 a.text = f"Mesa {previous_version}"
83 if is_point:
84 a.tail = " is released. This is a bug fix release."
85 else:
86 a.tail = (" is released. This is a new development release. "
87 "See the release notes for mor information about this release.")
88
89 root = news.getparent()
90 index = root.index(news) + 1
91 root.insert(index, body)
92 root.insert(index, header)
93
94 tree.write(p.as_posix(), method='html')
95
96
97 def update_release_notes(previous_version: str) -> None:
98 p = pathlib.Path(__file__).parent.parent / 'docs' / 'relnotes.html'
99 with p.open('rt') as f:
100 tree = html.parse(f)
101
102 li = etree.Element('li')
103 a = etree.SubElement(li, 'a', href=f'relnotes/{previous_version}')
104 a.text = f'{previous_version} release notes'
105
106 ul = tree.xpath('.//ul')[0]
107 ul.insert(0, li)
108
109 tree.write(p.as_posix(), method='html')
110
111
112 def main() -> None:
113 is_point = is_point_release()
114 version = get_version()
115 previous_version = calculate_previous_version(version, is_point)
116
117 update_index(is_point, version, previous_version)
118 update_release_notes(previous_version)
119
120
121 if __name__ == "__main__":
122 main()