llvm-project

Форк
0
/
make_cxx_dr_status 
308 строк · 10.3 Кб
1
#! /usr/bin/env python3
2
import sys, os, re, urllib.request
3

4
latest_release = 18
5

6
clang_www_dir = os.path.dirname(__file__)
7
default_issue_list_path = os.path.join(clang_www_dir, 'cwg_index.html')
8
issue_list_url = "https://raw.githubusercontent.com/cplusplus/CWG/gh-pages/issues/cwg_index.html"
9
output = os.path.join(clang_www_dir, 'cxx_dr_status.html')
10
dr_test_dir = os.path.join(clang_www_dir, '../test/CXX/drs')
11

12
class DR:
13
  def __init__(self, section, issue, url, status, title):
14
    self.section, self.issue, self.url, self.status, self.title = \
15
        section, issue, url, status, title
16
  def __repr__(self):
17
    return '%s (%s): %s' % (self.issue, self.status, self.title)
18

19
def parse(dr):
20
  try:
21
    section, issue_link, status, liaison, title = [
22
        col.split('>', 1)[1].split('</TD>')[0]
23
        for col in dr.split('</TR>', 1)[0].split('<TD')[1:]
24
    ]
25
  except Exception as ex:
26
    print(f"Parse error: {ex}\n{dr}", file=sys.stderr)
27
    sys.exit(1)
28
  _, url, issue = issue_link.split('"', 2)
29
  url = url.strip()
30
  issue = int(issue.split('>', 1)[1].split('<', 1)[0])
31
  title = title.replace('<issue_title>', '').replace('</issue_title>', '').replace('\r\n', '\n').strip()
32
  return DR(section, issue, url, status, title)
33

34
def collect_tests():
35
  status_re = re.compile(r'\bcwg([0-9]+): (.*)')
36
  status_map = {}
37
  for test_cpp in os.listdir(dr_test_dir):
38
    if not test_cpp.endswith('.cpp'):
39
      continue
40
    test_cpp = os.path.join(dr_test_dir, test_cpp)
41
    found_any = False;
42
    for match in re.finditer(status_re, open(test_cpp, 'r').read()):
43
      dr_number = int(match.group(1))
44
      if dr_number in status_map:
45
        print("error: Comment for cwg{} encountered more than once. Duplicate found in {}".format(dr_number, test_cpp))
46
        sys.exit(1)
47
      status_map[dr_number] = match.group(2)
48
      found_any = True
49
    if not found_any:
50
      print("warning:%s: no '// cwg123: foo' comments in this file" % test_cpp, file=sys.stderr)
51
  return status_map
52

53
def get_issues(path):
54
  buffer = None
55
  if not path and os.path.exists(default_issue_list_path):
56
    path = default_issue_list_path
57
  try:
58
    if path is None:
59
      print('Fetching issue list from {}'.format(issue_list_url))
60
      with urllib.request.urlopen(issue_list_url) as f:
61
        buffer = f.read().decode('utf-8')
62
    else:
63
      print('Opening issue list from file {}'.format(path))
64
      with open(path, 'r') as f:
65
        buffer = f.read()
66
  except Exception as ex:
67
     print('Unable to read the core issue list', file=sys.stderr)
68
     print(ex, file=sys.stderr)
69
     sys.exit(1)
70

71
  return sorted((parse(dr) for dr in buffer.split('<TR>')[2:]),
72
                key = lambda dr: dr.issue)
73

74

75
issue_list_path  = None
76
if len(sys.argv) == 1:
77
  pass
78
elif len(sys.argv) == 2:
79
  issue_list_path = sys.argv[1]
80
else:
81
  print('Usage: {} [<path to cwg_index.html>]'.format(sys.argv[0]), file=sys.stderr)
82
  sys.exit(1)
83

84
status_map = collect_tests()
85
drs = get_issues(issue_list_path)
86
out_file = open(output, 'w')
87
out_file.write('''\
88
<!DOCTYPE html>
89
<!-- This file is auto-generated by make_cxx_dr_status. Do not modify. -->
90
<html>
91
<head>
92
  <META http-equiv="Content-Type" content="text/html; charset=utf-8">
93
  <title>Clang - C++ Defect Report Status</title>
94
  <link type="text/css" rel="stylesheet" href="menu.css">
95
  <link type="text/css" rel="stylesheet" href="content.css">
96
  <style type="text/css">
97
    .none { background-color: #FFCCCC }
98
    .none-superseded { background-color: rgba(255, 204, 204, 0.65) }
99
    .unknown { background-color: #EBCAFE }
100
    .unknown-superseded { background-color: rgba(234, 200, 254, 0.65) }
101
    .partial { background-color: #FFE0B0 }
102
    .partial-superseded { background-color: rgba(255, 224, 179, 0.65) }
103
    .unreleased { background-color: #FFFF99 }
104
    .unreleased-superseded { background-color: rgba(255, 255, 153, 0.65) }
105
    .full { background-color: #CCFF99 }
106
    .full-superseded { background-color: rgba(214, 255, 173, 0.65) }
107
    .na { background-color: #DDDDDD }
108
    .na-superseded { background-color: rgba(222, 222, 222, 0.65) }
109
    .open * { color: #AAAAAA }
110
    .open-superseded * { color: rgba(171, 171, 171, 0.65) }
111
    //.open { filter: opacity(0.2) }
112
    tr:target { background-color: #FFFFBB }
113
    th { background-color: #FFDDAA }
114
  </style>
115
</head>
116
<body>
117

118
<!--#include virtual="menu.html.incl"-->
119

120
<div id="content">
121

122
<!--*************************************************************************-->
123
<h1>C++ Defect Report Support in Clang</h1>
124
<!--*************************************************************************-->
125

126
<h2 id="cxxdr">C++ defect report implementation status</h2>
127

128
<p>This page tracks which C++ defect reports are implemented within Clang.</p>
129

130
<table width="689" border="1" cellspacing="0">
131
  <tr>
132
    <th>Number</th>
133
    <th>Status</th>
134
    <th>Issue title</th>
135
    <th>Available in Clang?</th>
136
  </tr>''')
137

138
class AvailabilityError(RuntimeError):
139
  pass
140

141
availability_error_occurred = False
142

143
def availability(issue):
144
  status = status_map.get(issue, 'unknown')
145

146
  unresolved_status = ''
147
  proposed_resolution = ''
148
  unresolved_status_match = re.search(r' (open|drafting|review|tentatively ready)', status)
149
  if unresolved_status_match:
150
    unresolved_status = unresolved_status_match.group(1)
151
    proposed_resolution_match = re.search(r' (open|drafting|review|tentatively ready) (\d{4}-\d{2}(?:-\d{2})?|P\d{4}R\d+)$', status)
152
    if proposed_resolution_match is None:
153
      raise AvailabilityError('Issue {}: \'{}\' status should be followed by a paper number (P1234R5) or proposed resolution in YYYY-MM-DD format'.format(dr.issue, unresolved_status))
154
    proposed_resolution = proposed_resolution_match.group(2)
155
    status = status[:-1-len(proposed_resolution)]
156
    status = status[:-1-len(unresolved_status)]
157

158
  avail_suffix = ''
159
  avail_style = ''
160
  tooltip = ''
161
  if status.endswith(' c++11'):
162
    status = status[:-6]
163
    avail_suffix = ' (C++11 onwards)'
164
  elif status.endswith(' c++14'):
165
    status = status[:-6]
166
    avail_suffix = ' (C++14 onwards)'
167
  elif status.endswith(' c++17'):
168
    status = status[:-6]
169
    avail_suffix = ' (C++17 onwards)'
170
  elif status.endswith(' c++20'):
171
    status = status[:-6]
172
    avail_suffix = ' (C++20 onwards)'
173
  if status == 'unknown':
174
    avail = 'Unknown'
175
    avail_style = 'unknown'
176
  elif re.match(r'^[0-9]+\.?[0-9]*', status):
177
    if not proposed_resolution:
178
      avail = 'Clang %s' % status
179
      if float(status) > latest_release:
180
        avail_style = 'unreleased'
181
      else:
182
        avail_style = 'full'
183
    else: 
184
      avail = 'Not Resolved*'
185
      tooltip = f' title="Clang {status} implements {proposed_resolution} resolution"'
186
  elif status == 'yes':
187
    if not proposed_resolution:
188
      avail = 'Yes'
189
      avail_style = 'full'
190
    else:
191
      avail = 'Not Resolved*'
192
      tooltip = f' title="Clang implements {proposed_resolution} resolution"'
193
  elif status == 'partial':
194
    if not proposed_resolution:
195
      avail = 'Partial'
196
      avail_style = 'partial'
197
    else:
198
      avail = 'Not Resolved*'
199
      tooltip = f' title="Clang partially implements {proposed_resolution} resolution"'
200
  elif status == 'no':
201
    if not proposed_resolution:
202
      avail = 'No'
203
      avail_style = 'none'
204
    else:
205
      avail = 'Not Resolved*'
206
      tooltip = f' title="Clang does not implement {proposed_resolution} resolution"'
207
  elif status == 'na':
208
    avail = 'N/A'
209
    avail_style = 'na'
210
  elif status == 'na lib':
211
    avail = 'N/A (Library DR)'
212
    avail_style = 'na'
213
  elif status == 'na abi':
214
    avail = 'N/A (ABI constraint)'
215
    avail_style = 'na'
216
  elif status.startswith('sup '):
217
    dup = status.split(' ', 1)[1]
218
    if dup.startswith('P'):
219
      avail = 'Superseded by <a href="https://wg21.link/%s">%s</a>' % (dup, dup)
220
      avail_style = 'na'
221
    else:
222
      avail = 'Superseded by <a href="#%s">%s</a>' % (dup, dup)
223
      try:
224
        _, avail_style, _, _ = availability(int(dup))
225
        avail_style += '-superseded'
226
      except:
227
        print("issue %s marked as sup %s" % (issue, dup), file=sys.stderr)
228
        avail_style = 'none'
229
  elif status.startswith('dup '):
230
    dup = int(status.split(' ', 1)[1])
231
    avail = 'Duplicate of <a href="#%s">%s</a>' % (dup, dup)
232
    _, avail_style, _, _ = availability(dup)
233
  else:
234
    raise AvailabilityError('Unknown status %s for issue %s' % (status, dr.issue))
235
  return (avail + avail_suffix, avail_style, unresolved_status, tooltip)
236

237
count = {}
238
for dr in drs:
239
  if dr.status in ('concepts',):
240
    # This refers to the old ("C++0x") concepts feature, which was not part
241
    # of any C++ International Standard or Technical Specification.
242
    continue
243

244
  elif dr.status == 'extension':
245
    row_style = ' class="open"'
246
    avail = 'Extension'
247
    avail_style = ''
248

249
  elif dr.status in ('open', 'drafting', 'review', 'tentatively ready'):
250
    row_style = ' class="open"'
251
    try:
252
      avail, avail_style, unresolved_status, tooltip = availability(dr.issue)
253
    except AvailabilityError as e:
254
      availability_error_occurred = True
255
      print(e.args[0])
256
      continue
257
      
258
    if avail == 'Unknown':
259
      avail = 'Not resolved'
260
      avail_style = ''
261
    else:
262
      if unresolved_status != dr.status:
263
        availability_error_occurred = True
264
        print("Issue %s is marked '%s', which differs from CWG index status '%s'" \
265
             % (dr.issue, unresolved_status, dr.status))
266
        continue
267
  else:
268
    row_style = ''
269
    try:
270
      avail, avail_style, unresolved_status, tooltip = availability(dr.issue)
271
    except AvailabilityError as e:
272
      availability_error_occurred = True
273
      print(e.args[0])
274
      continue
275

276
    if unresolved_status:
277
      availability_error_occurred = True
278
      print("Issue %s is marked '%s', even though it is resolved in CWG index" \
279
           % (dr.issue, unresolved_status))
280
      continue
281

282
  if not avail.startswith('Sup') and not avail.startswith('Dup'):
283
    count[avail] = count.get(avail, 0) + 1
284

285
  if avail_style != '':
286
    avail_style = ' class="{}"'.format(avail_style)
287
  out_file.write('''
288
  <tr%s id="%s">
289
    <td><a href="https://cplusplus.github.io/CWG/issues/%s.html">%s</a></td>
290
    <td>%s</td>
291
    <td>%s</td>
292
    <td%s%s align="center">%s</td>
293
  </tr>''' % (row_style, dr.issue, dr.issue, dr.issue, dr.status, dr.title, avail_style, tooltip, avail))
294

295
if availability_error_occurred:
296
  exit(1)
297

298
for status, num in sorted(count.items()):
299
  print("%s: %s" % (status, num), file=sys.stderr)
300

301
out_file.write('''\
302
</table>
303

304
</div>
305
</body>
306
</html>
307
''')
308
out_file.close()
309

310

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.