diff options
-rw-r--r-- | util/optionlist/Makefile | 20 | ||||
-rw-r--r-- | util/optionlist/Options-wiki.xsl | 47 | ||||
-rw-r--r-- | util/optionlist/Options.xsl | 73 | ||||
-rw-r--r-- | util/optionlist/README | 47 | ||||
-rwxr-xr-x | util/optionlist/kconfig2wiki | 133 | ||||
-rwxr-xr-x | util/optionlist/mkOptionList.py | 141 |
6 files changed, 141 insertions, 320 deletions
diff --git a/util/optionlist/Makefile b/util/optionlist/Makefile index f61409476b..3fb69232ec 100644 --- a/util/optionlist/Makefile +++ b/util/optionlist/Makefile @@ -1,10 +1,9 @@ # -# Copyright (C) 2005 Stefan Reinauer <stepan@coresystems.de> +# Copyright (C) 2010 coresystems GmbH # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# the Free Software Foundation; version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -16,17 +15,12 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # -all: html wiki -html: - ./mkOptionList.py - @#saxon Options.xml Options.xsl > Options.html - xsltproc Options.xsl Options.xml > Options.html - -wiki: - ./mkOptionList.py - xsltproc Options-wiki.xsl Options.xml > Options.wiki +SVNVERSION := $(shell LC_ALL=C svnversion -cn ../.. | sed -e "s/.*://" -e "s/\([0-9]*\).*/\1/" | grep "[0-9]" || LC_ALL=C svn info . | grep ^Revision | sed "s/.*[[:blank:]]\+\([0-9]*\)[^0-9]*/\1/" | grep "[0-9]" || echo unknown) + +all: + cd ../..; util/optionlist/kconfig2wiki src/Kconfig $(SVNVERSION) > util/optionlist/Options.wiki clean: - rm -rf Options.xml Options.html Options.wiki + rm -rf Options.wiki diff --git a/util/optionlist/Options-wiki.xsl b/util/optionlist/Options-wiki.xsl deleted file mode 100644 index fca0427c2b..0000000000 --- a/util/optionlist/Options-wiki.xsl +++ /dev/null @@ -1,47 +0,0 @@ -<?xml version="1.0"?> -<!-- - Copyright (C) 2006 Stefan Reinauer <stepan@coresystems.de> - Copyright (C) 2006 Uwe Hermann <uwe@hermann-uwe.de> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ---> - -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> - -<xsl:output method="text" - encoding="utf-8" - indent="yes" /> - -<xsl:template match="/"> -This is an automatically generated list of '''coreboot v2 compile-time options'''. - -Last update: <xsl:value-of select="//creationdate"/>. - -{| border="0" style="font-size: smaller" -|- bgcolor="#6699dd" -! align="left" | Option -! align="left" | Comment -! align="left" | Default -! align="left" | Export -! align="left" | Format -<xsl:for-each select="options/option"> -|- bgcolor="#eeeeee" -| <xsl:value-of select="@name"/> || <xsl:value-of select="comment"/> || <xsl:value-of select="default"/> || <xsl:value-of select="export"/> || <xsl:value-of select="format"/> -</xsl:for-each> - -|} - -</xsl:template> -</xsl:stylesheet> diff --git a/util/optionlist/Options.xsl b/util/optionlist/Options.xsl deleted file mode 100644 index 5709ba83f0..0000000000 --- a/util/optionlist/Options.xsl +++ /dev/null @@ -1,73 +0,0 @@ -<?xml version="1.0"?> -<!-- - Copyright (C) 2005 Florian Zeitz <florian-zeitz@lycos.de> - Copyright (C) 2005 Stefan Reinauer <stepan@coresystems.de> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ---> - -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> - -<!--<xsl:choose> -<xsl:when test="system-property('xsl:vendor')='Transformiix'"> ---> -<xsl:output method="xml" - doctype-public="PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN" - doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" - encoding="utf-8" - indent="yes" /> -<!-- -</xsl:when> -<xsl:otherwise> -<xsl:output method="xhtml" - doctype-public="PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN" - doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" - encoding="utf-8" - indent="yes" /> -</xsl:otherwise> -</xsl:choose> ---> - -<xsl:template match="/"> -<html> -<head> -<title>Coreboot Options</title> -</head> -<body> -<h2>Coreboot Options</h2> -<p>This is an automatically generated list of coreboot compile time -options. Created at <xsl:value-of select="//creationdate"/>.</p> -<table border="1"> -<tr bgcolor="#0975a7"> -<th align="left">Option</th> -<th align="left">Comment</th> -<th align="left">Default</th> -<th align="left">Export</th> -<th align="left">Format</th> -</tr> -<xsl:for-each select="options/option"> -<tr> -<td><xsl:value-of select="@name"/></td> -<td><xsl:value-of select="comment"/></td> -<td><xsl:value-of select="default"/></td> -<td><xsl:value-of select="export"/></td> -<td><xsl:value-of select="format"/></td> -</tr> -</xsl:for-each> -</table> -</body> -</html> -</xsl:template> -</xsl:stylesheet> diff --git a/util/optionlist/README b/util/optionlist/README index a61678e0b4..616633aed5 100644 --- a/util/optionlist/README +++ b/util/optionlist/README @@ -1,46 +1 @@ -I would like to contribute the following to the coreboot wiki in case -it's useable: - -1. I have written a rather small Python script to convert the Options.lb - into an XML file which is much more useable for the web in most cases. - -2. I have written a XSLT to convert the XML file to (X)HTML to be able - to present it as a table. - -Florob (Florian Zeitz <florian-zeitz@lycos.de>) - - -ChangeLog ---------- - -* 2005-03-19 stepan - - fix xml stylesheet to work with xsltproc and saxon - - add Makefile - - make script a bit more verbose - -* 2005-03-15 florob - - Initial version - - -License -------- - -Copyright (C) 2005 Florian Zeitz <florian-zeitz@lycos.de> -Copyright (C) 2005-2006 Stefan Reinauer <stepan@coresystems.de> -Copyright (C) 2006 Uwe Hermann <uwe@hermann-uwe.de> - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - +This script creates the page http://www.coreboot.org/Coreboot_Options diff --git a/util/optionlist/kconfig2wiki b/util/optionlist/kconfig2wiki new file mode 100755 index 0000000000..0a2b0aaf86 --- /dev/null +++ b/util/optionlist/kconfig2wiki @@ -0,0 +1,133 @@ +#!/usr/bin/python +# +# kconfig2wiki - Kconfig to MediaWiki converter for +# http://www.coreboot.org/Coreboot_Options +# +# Copyright (C) 2010 coresystems GmbH +# based on http://landley.net/kdocs/make/menuconfig2html.py +# Copyright (C) by Rob Landley +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +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("&","&").replace("<","<").replace(">",">") + +## +## 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\n" % htmlescape(i)) + continue + else: + helplen = 0 + sys.stdout.write("||\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("|- bgcolor=\"#eeeeee\"\n") + sys.stdout.write("| %s || %s || %s || %s || \n" % (config,source,configtype,description) ) + helplen = len(i[:i.find(words[0])].expandtabs()) + elif words[0] == "comment": + sys.stdout.write("|- bgcolor=\"#eeeeee\"\n") + sys.stdout.write("| || || (comment) || || %s ||\n" % htmlescape(zapquotes(words[1]))) + elif words[0]=="menu": + if len(words)>1: + temp = htmlescape(zapquotes(words[1])) + if extra_chapters: + sys.stdout.write("== Menu: %s ==\n" % temp) + sys.stdout.write("{| border=\"0\" style=\"font-size: smaller\"\n"); + sys.stdout.write("|- bgcolor=\"#6699dd\"\n") + sys.stdout.write("! align=\"left\" | Option\n") + sys.stdout.write("! align=\"left\" | Source\n") + sys.stdout.write("! align=\"left\" | Format\n") + sys.stdout.write("! align=\"left\" | Short Description\n") + sys.stdout.write("! align=\"left\" | Description\n") + else: + # Don't start an extra chapter for a + # new menu + sys.stdout.write("|- bgcolor=\"#6699dd\"\n") + sys.stdout.write("! align=\"left\" | Menu: %s || || || ||\n" % temp) + elif words[0] == "endmenu": + if extra_chapters: + sys.stdout.write("|}\n") + sys.stdout.write("\n") + elif words[0] == "source": + fn=zapquotes(words[1]) + readfile(fn) + elif words[0] in ("default","depends", "select", "if", "endif", "#"): pass + #else: sys.stderr.write("unknown: %s\n" % i) + if helplen: sys.stdout.write("||\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. (r%s)\n" % (time.strftime('%Y/%m/%d %H:%M:%S'),sys.argv[2])) + sys.stdout.write("{| border=\"0\" style=\"font-size: smaller\"\n"); + sys.stdout.write("|- bgcolor=\"#6699dd\"\n") + sys.stdout.write("! align=\"left\" | Option\n") + sys.stdout.write("! align=\"left\" | Source\n") + sys.stdout.write("! align=\"left\" | Format\n") + sys.stdout.write("! align=\"left\" | Short Description\n") + sys.stdout.write("! align=\"left\" | Description\n") + readfile(sys.argv[1]) + sys.stdout.write("|}\n") + +if __name__ == "__main__": + main() diff --git a/util/optionlist/mkOptionList.py b/util/optionlist/mkOptionList.py deleted file mode 100755 index f5b5ab57e9..0000000000 --- a/util/optionlist/mkOptionList.py +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/python -# -# Copyright (C) 2005 Florian Zeitz <florian-zeitz@lycos.de> -# Copyright (C) 2005 Stefan Reinauer <stepan@coresystems.de> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# - -def xmlString(string): - for i in range(len(string)-1): - if string[i] == "&": - string = string[:i] + "&" + string[i+1:] - if string[i] == "<": - string = string[:i] + "<" + string[i+1:] - if string[i] == ">": - string = string[:i] + ">" + string[i+1:] - return string - -def openInfile(filename): - "getting the input from the inputfile (e.g. Options.lb)" - infile = open(filename, "r") - infile.seek(0) - input = infile.readlines() - infile.close() - return input - -def prepInput(input): - "preparing the input for parsing (not really neccessary, but makes things simpler and doesnt take too long)" - i = -1 - while True: - i += 1 - if i >= len(input): break - if input[i] == ("" or "\n"): - input.pop(i) - if input[i][0:1] == "\t": - input[i] = input[i][1:] - i = -1 - return input - -def parseInput(input): - "parse the output" - output = "" - for line in input: - line = xmlString(line) - if line[:6] == "define": - output = output + '<option name="' + line[7:-1] + '">' + "\n" - elif line[:3] == "end": - output = output + '</option>' + "\n\n" - elif line[:7] == "default": - output = output + '<default>' + line[8:-1] + '</default>' + "\n" - elif line[:6] == "format": - output = output + '<format>' + line[7:-1] + '</format>' + "\n" - elif line[:6] == "export": - output = output + '<export>' + line[7:-1] + '</export>' + "\n" - elif line[:7] == "comment": - output = output + '<comment>' + line[8:-1] + '</comment>' + "\n" - - return output - -def parseArgv(): - "parse the given arguments" - import sys - - In = Out = False - - if len(sys.argv) >= 2: - if sys.argv[1] == ("-h" or "--help"): - print "Syntax: mkOptionList.py [infile] [outfile]" - else: - In = True - inFilename = sys.argv[1] - if len(sys.argv) >= 3: - if sys.argv[2] == ("-h" or "--help"): - print "Syntax: mkOptionList.py [infile] [outfile]" - else: - Out = True - outFilename = sys.argv[2] - - if In and not Out: - return inFilename - elif In and Out: - return inFilename, outFilename - - -def main(): - import time - if not parseArgv(): - inFilename = "../../src/config/Options.lb" - outFilename = "Options.xml" - else: - inFilename, outFilename = parseArgv() - - input = openInfile(inFilename) - input = prepInput(input) - output = parseInput(input) - - print "mkOptionList.py: coreboot option list generator" - print " input file : ", inFilename - print " output file: ", outFilename - - #opening the output file - outfile = open(outFilename, "w", 0) - - #write the beginning of the XML to the output file - outfile.write('<?xml version="1.0"?>') - outfile.write("\n") - outfile.write('<?xml-stylesheet type="text/xsl" href="Options.xsl"?>') - outfile.write("\n") - outfile.write('<options>') - outfile.write("\n") - outfile.write('<creationdate>') - outfile.write(time.strftime('%Y/%m/%d %H:%M:%S')) - outfile.write('</creationdate>') - outfile.write("\n") - - - #write the parsed file to the output file - outfile.write(output) - - #write closing tags to the output file and close it - outfile.write('</options>') - outfile.write("\n") - outfile.flush() - outfile.close() - - print "Done!" - -if __name__ == "__main__": - main() |