Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import os.path as op
- import sys
- import html
- master = []
- actual = {}
- def add(config, arch, mode='n'):
- if config not in master:
- return
- if config not in actual:
- actual[config] = {arch: mode}
- else:
- actual[config][arch] = mode
- mode2class = {
- 'y': 'yes',
- 'n': 'no',
- 'm': 'module'
- }
- mode2str = {
- 'y': '✔',
- 'n': '✗',
- 'm': '✱'
- }
- archs = ('armv7', 'aarch64', 'ppc', 'ppc64', 'ppc64-p8', 'sparc64', 'pmmx', 'x86_64')
- with open('uniconfig', mode='rt') as f:
- lines = f.readlines()
- for line in lines:
- line = line[:-1]
- config, *trash = line.split('=')
- master.append(config)
- for arch in archs:
- with open('config-{}'.format(arch), mode='rt') as f:
- lines = f.readlines()
- for line in lines:
- line = line[:-1]
- if len(line) < 2:
- continue
- mode = '?'
- if line.startswith('#'):
- args = line.split()
- config = args[1]
- mode = 'n'
- if '=' in line:
- config, mode = line.split('=', 2)
- elif mode == '?':
- config = line
- mode = 'y'
- add(config, arch, mode)
- with open('config.html', mode='wt') as f:
- f.write('\n'.join([
- '<!DOCTYPE html>',
- '<html>',
- '\t<head>',
- '\t\t<meta charset="UTF-8">',
- '\t\t<title>Kernel config map</title>',
- '\t\t<link href="style.css" rel="stylesheet">',
- '\t</head>',
- '\t<body>',
- '\t\t<p><b>Notes</b>:</p>',
- '\t\t<ul>',
- '\t\t\t<li>32-bit ARM is ARMv7. No config exists for this platform as of yet.</li>',
- '\t\t\t<li>32-bit x86 is Pentium® with MMX® technology. This platform omits SSE instructions.</li>',
- '\t\t\t<li>SPARC64 config exists, but Adélie support is waiting for a port of the musl libc to this arch.</li>',
- '\t\t\t<li>P8 is POWER8+. This is necessary because <tt>CONFIG_GENERIC=y</tt> produces unsuable images on POWER8+.</li>',
- '\t\t</ul>',
- '\t\t<table>',
- '\t\t\t<thead>'
- '\t\t\t\t<tr class="header"><th rowspan="2">Flag</th><th colspan="2">ARM</th><th colspan="3">PPC</th><th rowspan="2">Sparc64</th><th colspan="2">x86</th></tr>',
- '\t\t\t\t<tr class="header"><th>32</th><th>64</th><th>32</th><th>64</th><th>P8</th><th>32</th><th>64</th></tr>',
- '\t\t\t</thead>',
- '\t\t\t<tbody>',
- ]))
- for config in sorted(actual.keys()):
- arch_conf = actual[config]
- if not op.exists('kconfig/{}.html'.format(config)):
- text = config
- else:
- with open('kconfig/{}.html'.format(config), mode='rt') as g:
- text = ''.join(g.readlines())
- f.write('\t\t\t<tr><th>{}</th>'.format(text))
- for arch in archs:
- if arch in arch_conf:
- mode = arch_conf[arch]
- if mode in 'ynm':
- string = '<td class="{}">{}</td>'.format(
- mode2class[arch_conf[arch]],
- mode2str[arch_conf[arch]]
- )
- else:
- if len(mode) > 8:
- string = '<td title={}>{}</td>'.format(
- '"{}"'.format(mode if not mode.startswith('"') else html.escape(mode)),
- '{}…'.format(mode[:7])
- )
- else:
- string = '<td>{}</td>'.format(mode)
- f.write(string)
- else:
- f.write('<td class="{}">{}</td>'.format(
- mode2class['n'], mode2str['n']
- ))
- f.write('</tr>\n')
- f.write('\n'.join([
- '\t\t\t</tbody>',
- '\t\t</table>',
- '\t</body>',
- '</html>'
- ]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement