| 413 | |
| 414 | |
| 415 | def readme(matrices, file, **kw): |
| 416 | def print_row(cells): |
| 417 | print('|', ' | '.join(cells), '|', file=file) |
| 418 | |
| 419 | # Get All APIs |
| 420 | apis = [] |
| 421 | for matrix in matrices: |
| 422 | for api in matrix.apis: |
| 423 | if api not in apis: |
| 424 | apis.append(api) |
| 425 | apis.sort() |
| 426 | |
| 427 | # Get All NDKs |
| 428 | ndks = set() |
| 429 | for matrix in matrices: |
| 430 | for ndk in matrix.ndks: |
| 431 | ndks |= {ndk} |
| 432 | ndks = sort_ndks(list(ndks)) |
| 433 | |
| 434 | # Print Legend |
| 435 | for matrix in matrices: |
| 436 | name = '`{}`'.format(matrix.name) |
| 437 | if matrix.url is not None: |
| 438 | name = '[{}]({})'.format(name, matrix.url) |
| 439 | print('`{}` = {}'.format(matrix.mark, name), file=file) |
| 440 | |
| 441 | # Print Table Header |
| 442 | print_row([''] + list(map(str, apis))) |
| 443 | print_row(['---'] * (len(apis) + 1)) |
| 444 | # Print Rows |
| 445 | for ndk in ndks: |
| 446 | cells = [ndk] |
| 447 | for api in apis: |
| 448 | marks = [] |
| 449 | for matrix in matrices: |
| 450 | if matrix.has_build_for(ndk, api): |
| 451 | marks.append('`{}`'.format(matrix.mark)) |
| 452 | cells.append(','.join(marks) if marks else '-') |
| 453 | print_row(cells) |
| 454 | |
| 455 | |
| 456 | settings_export = re.compile(r'^(#)?export (\w+)=([^#]*)$') |