coreboot-kgpe-d16/util/docker/coreboot.org-status/kconfig2html

108 lines
3.3 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env python
#
# kconfig2wiki - Kconfig to MediaWiki converter for
# https://www.coreboot.org/coreboot_Options
# based on http://landley.net/kdocs/make/menuconfig2html.py
#
util/: Replace GPLv2 boiler plate with SPDX header Used commands: perl -i -p0e 's|\/\*[\s*]*.*is free software[:;][\s*]*you[\s*]*can[\s*]*redistribute[\s*]*it[\s*]*and\/or[\s*]*modify[\s*]*it[\s*]*under[\s*]*the[\s*]*terms[\s*]*of[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*as[\s*]*published[\s*]*by[\s*]*the[\s*]*Free[\s*]*Software[\s*]*Foundation[;,][\s*]*version[\s*]*2[\s*]*of[\s*]*the[\s*]*License.[\s*]*This[\s*]*program[\s*]*is[\s*]*distributed[\s*]*in[\s*]*the[\s*]*hope[\s*]*that[\s*]*it[\s*]*will[\s*]*be[\s*]*useful,[\s*]*but[\s*]*WITHOUT[\s*]*ANY[\s*]*WARRANTY;[\s*]*without[\s*]*even[\s*]*the[\s*]*implied[\s*]*warranty[\s*]*of[\s*]*MERCHANTABILITY[\s*]*or[\s*]*FITNESS[\s*]*FOR[\s*]*A[\s*]*PARTICULAR[\s*]*PURPOSE.[\s*]*See[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*for[\s*]*more[\s*]*details.[\s*]*\*\/|/* SPDX-License-Identifier: GPL-2.0-only */|' $(cat filelist) perl -i -p0e 's|This[\s*]*program[\s*]*is[\s*]*free[\s*]*software[:;][\s*]*you[\s*]*can[\s*]*redistribute[\s*]*it[\s*]*and/or[\s*]*modify[\s*]*it[\s*]*under[\s*]*the[\s*]*terms[\s*]*of[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*as[\s*]*published[\s*]*by[\s*]*the[\s*]*Free[\s*]*Software[\s*]*Foundation[;,][\s*]*either[\s*]*version[\s*]*2[\s*]*of[\s*]*the[\s*]*License,[\s*]*or[\s*]*.at[\s*]*your[\s*]*option.*[\s*]*any[\s*]*later[\s*]*version.[\s*]*This[\s*]*program[\s*]*is[\s*]*distributed[\s*]*in[\s*]*the[\s*]*hope[\s*]*that[\s*]*it[\s*]*will[\s*]*be[\s*]*useful,[\s*]*but[\s*]*WITHOUT[\s*]*ANY[\s*]*WARRANTY;[\s*]*without[\s*]*even[\s*]*the[\s*]*implied[\s*]*warranty[\s*]*of[\s*]*MERCHANTABILITY[\s*]*or[\s*]*FITNESS[\s*]*FOR[\s*]*A[\s*]*PARTICULAR[\s*]*PURPOSE.[\s*]*See[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*for[\s*]*more[\s*]*details.[\s*]*\*\/|/* SPDX-License-Identifier: GPL-2.0-or-later */|' $(cat filelist) perl -i -p0e 's|\/\*[\s*]*.*This[\s*#]*program[\s*#]*is[\s*#]*free[\s*#]*software[;:,][\s*#]*you[\s*#]*can[\s*#]*redistribute[\s*#]*it[\s*#]*and/or[\s*#]*modify[\s*#]*it[\s*#]*under[\s*#]*the[\s*#]*terms[\s*#]*of[\s*#]*the[\s*#]*GNU[\s*#]*General[\s*#]*Public[\s*#]*License[\s*#]*as[\s*#]*published[\s*#]*by[\s*#]*the[\s*#]*Free[\s*#]*Software[\s*#]*Foundation[;:,][\s*#]*either[\s*#]*version[\s*#]*3[\s*#]*of[\s*#]*the[\s*#]*License[;:,][\s*#]*or[\s*#]*.at[\s*#]*your[\s*#]*option.*[\s*#]*any[\s*#]*later[\s*#]*version.[\s*#]*This[\s*#]*program[\s*#]*is[\s*#]*distributed[\s*#]*in[\s*#]*the[\s*#]*hope[\s*#]*that[\s*#]*it[\s*#]*will[\s*#]*be[\s*#]*useful[;:,][\s*#]*but[\s*#]*WITHOUT[\s*#]*ANY[\s*#]*WARRANTY[;:,][\s*#]*without[\s*#]*even[\s*#]*the[\s*#]*implied[\s*#]*warranty[\s*#]*of[\s*#]*MERCHANTABILITY[\s*#]*or[\s*#]*FITNESS[\s*#]*FOR[\s*#]*A[\s*#]*PARTICULAR[\s*#]*PURPOSE.[\s*#]*See[\s*#]*the[\s*#]*GNU[\s*#]*General[\s*#]*Public[\s*#]*License[\s*#]*for[\s*#]*more[\s*#]*details.[\s*]*\*\/|/* SPDX-License-Identifier: GPL-3.0-or-later */|' $(cat filelist) perl -i -p0e 's|(\#\#*)[\w]*.*is free software[:;][\#\s]*you[\#\s]*can[\#\s]*redistribute[\#\s]*it[\#\s]*and\/or[\#\s]*modify[\#\s]*it[\s\#]*under[\s \#]*the[\s\#]*terms[\s\#]*of[\s\#]*the[\s\#]*GNU[\s\#]*General[\s\#]*Public[\s\#]*License[\s\#]*as[\s\#]*published[\s\#]*by[\s\#]*the[\s\#]*Free[\s\#]*Software[\s\#]*Foundation[;,][\s\#]*version[\s\#]*2[\s\#]*of[\s\#]*the[\s\#]*License.*[\s\#]*This[\s\#]*program[\s\#]*is[\s\#]*distributed[\s\#]*in[\s\#]*the[\s\#]*hope[\s\#]*that[\s\#]*it[\s\#]*will[\#\s]*be[\#\s]*useful,[\#\s]*but[\#\s]*WITHOUT[\#\s]*ANY[\#\s]*WARRANTY;[\#\s]*without[\#\s]*even[\#\s]*the[\#\s]*implied[\#\s]*warranty[\#\s]*of[\#\s]*MERCHANTABILITY[\#\s]*or[\#\s]*FITNESS[\#\s]*FOR[\#\s]*A[\#\s]*PARTICULAR[\#\s]*PURPOSE.[\#\s]*See[\#\s]*the[\#\s]*GNU[\#\s]*General[\#\s]*Public[\#\s]*License[\#\s]*for[\#\s]*more[\#\s]*details.\s(#* *\n)*|\1 SPDX-License-Identifier: GPL-2.0-only\n\n|' $(cat filelist) perl -i -p0e 's|(\#\#*)[\w*]*.*is free software[:;][\s*]*you[\s*]*can[\s*]*redistribute[\s*]*it[\s*]*and\/or[\s*]*modify[\s*]*it[\s*]*under[\s*]*the[\s*]*terms[\s*]*of[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*as[\s*]*published[\s*]*by[\s*]*the[\s*]*Free[\s*]*Software[\s*]*Foundation[;,][\s*]*version[\s*]*2[\s*]*of[\s*]*the[\s*]*License.[\s*]*This[\s*]*program[\s*]*is[\s*]*distributed[\s*]*in[\s*]*the[\s*]*hope[\s*]*that[\s*]*it[\s*]*will[\s*]*be[\s*]*useful,[\s*]*but[\s*]*WITHOUT[\s*]*ANY[\s*]*WARRANTY;[\s*]*without[\s*]*even[\s*]*the[\s*]*implied[\s*]*warranty[\s*]*of[\s*]*MERCHANTABILITY[\s*]*or[\s*]*FITNESS[\s*]*FOR[\s*]*A[\s*]*PARTICULAR[\s*]*PURPOSE.[\s*]*See[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*for[\s*]*more[\s*]*details.\s(#* *\n)*|\1 SPDX-License-Identifier: GPL-2.0-only\n\n|' $(cat filelist) Change-Id: I1008a63b804f355a916221ac994701d7584f60ff Signed-off-by: Patrick Georgi <pgeorgi@google.com> Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr> Reviewed-on: https://review.coreboot.org/c/coreboot/+/41177 Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2020-05-08 20:48:04 +02:00
# SPDX-License-Identifier: GPL-2.0-only
import glob
helplen = 0
extra_chapters = 0
##
## Remove quotes from Kconfig string options
##
def zapquotes(str):
if str[0]=='"': str = str[1:str.rfind('"')]
return str
##
## Escape HTML special characters
##
def htmlescape(str):
return str.strip().replace("&","&amp;").replace("<","&lt;").replace(">","&gt;")
##
## Process Kconfig file
##
def readfile(filename):
import sys
global helplen
source=filename.replace("src/","").replace("/Kconfig","").replace("Kconfig","toplevel")
try:
lines = open(filename).read().split("\n")
except IOError:
sys.stderr.write("File %s missing\n" % filename)
return
config = None
description = None
configtype = None
for i in lines:
if helplen:
i = i.expandtabs()
if not len(i) or i[:helplen].isspace():
sys.stdout.write("%s<br />\n" % htmlescape(i))
continue
else:
helplen = 0
sys.stdout.write("</td></tr>\n")
words = i.strip().split(None,1)
if not len(words): continue
if words[0] in ("config", "menuconfig"):
config = words[1]
description = ""
elif words[0] in ("bool", "boolean", "tristate", "string", "hex", "int"):
configtype = htmlescape(zapquotes(words[0]))
if len(words)>1: description = htmlescape(zapquotes(words[1]))
elif words[0]=="prompt":
description = htmlescape(zapquotes(words[1]))
elif words[0] in ("help", "---help---"):
sys.stdout.write("<tr bgcolor=\"#eeeeee\">\n")
sys.stdout.write("<td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>\n" % (config,source,configtype,description) )
helplen = len(i[:i.find(words[0])].expandtabs())
elif words[0] == "comment":
sys.stdout.write("<tr bgcolor=\"#eeeeee\">\n")
sys.stdout.write("<td></td><td>%s</td><td>(comment)</td><td></td><td>%s</td></tr>\n" % (source, htmlescape(zapquotes(words[1]))))
elif words[0]=="menu":
if len(words)>1:
temp = htmlescape(zapquotes(words[1]))
sys.stdout.write("<tr bgcolor=\"#6699dd\">\n")
sys.stdout.write("<td colspan=5>Menu: %s</td></tr>\n" % temp)
elif words[0] == "endmenu":
sys.stdout.write("\n")
elif words[0] == "source":
fn=zapquotes(words[1])
for name in glob.glob(fn):
readfile(name)
elif words[0] in ("default","depends", "select", "if", "endif", "#"): pass
#else: sys.stderr.write("unknown: %s\n" % i)
if helplen: sys.stdout.write("</td></tr>\n")
def main():
import sys, time
if len(sys.argv)!=3:
sys.stderr.write("Usage: kconfig2wiki kconfigfile version\n")
sys.exit(1)
sys.stdout.write("This is an automatically generated list of '''coreboot compile-time options'''.\n")
sys.stdout.write("\nLast update: %s\n" % sys.argv[2])
sys.stdout.write("<table border=\"0\" style=\"font-size: smaller\">\n");
sys.stdout.write("<tr bgcolor=\"#6699dd\">\n")
sys.stdout.write("<td align=\"left\">Option</td>\n")
sys.stdout.write("<td align=\"left\">Source</td>\n")
sys.stdout.write("<td align=\"left\">Format</td>\n")
sys.stdout.write("<td align=\"left\">Short&nbsp;Description</td>\n")
sys.stdout.write("<td align=\"left\">Description</td></tr>\n")
readfile(sys.argv[1])
sys.stdout.write("</table>\n")
if __name__ == "__main__":
main()