Skip to content

Commit

Permalink
Stubs for the full reports.
Browse files Browse the repository at this point in the history
  • Loading branch information
zackw committed Jul 4, 2015
1 parent 7a76f10 commit 94c1c3f
Show file tree
Hide file tree
Showing 7 changed files with 242 additions and 56 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
*.pyc
*.pyo
*.o
/doc/headers/
/doc/headers.rst
/doc/opsys/
/doc/opsys.rst
/web/
__pycache__/
66 changes: 38 additions & 28 deletions config/compilers.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
## mode, and how to interpret certain things in its output.
## There is one section for each compiler, plus some defaults.
##
## Each section must declare at least these three properties:
## Each section must declare at least these four properties:
##
## .. prop:: name
##
## Official marketing name or other human-recognizable name for this
## compiler.
##
## .. prop:: id_macro
##
Expand Down Expand Up @@ -162,18 +167,18 @@ errloc_re = ^(?P<file>[^:]+) :(?P<line>\d+) :(?:\d+:)?\ (?:error|warning):
dump_macros =

[gcc]
imitated = yes
id_macro = __GNUC__
name = GCC
imitated = yes
id_macro = __GNUC__

# Under some conditions the string "gcc" does not appear anywhere in
# gcc's --version output, so look instead for the "Copyright YYYY
# Free Software Foundation" blurb.
id_regexp =
^\S+\s+
(?:\((?P<details1>[^)]+)\))?\s+
(?P<version>[0-9.]+)\s*
(?:\(?(?P<details2>.+?)\)?)?
\nCopyright\ .+?\ Free\ Software\ Foundation\b
id_regexp = ^\S+\s+
(?:\((?P<details1>[^)]+)\))?\s+
(?P<version>[0-9.]+)\s*
(?:\(?(?P<details2>.+?)\)?)?
\nCopyright\ .+?\ Free\ Software\ Foundation\b

# Note: nearly the same as clang
version = --version
Expand All @@ -187,11 +192,12 @@ threads = -pthread
dump_macros = -dM

[clang]
id_macro = __clang__
id_regexp = (?:\bclang\ version\ (?P<version1>[0-9.-]+)|
\bbased\ on\ LLVM\ (?P<version2>[0-9.-]+))
.*?
\bTarget:\s+(?P<details>[a-zA-Z0-9_-]+)
name = Clang
id_macro = __clang__
id_regexp = (?:\bclang\ version\ (?P<version1>[0-9.-]+)|
\bbased\ on\ LLVM\ (?P<version2>[0-9.-]+))
.*?
\bTarget:\s+(?P<details>[a-zA-Z0-9_-]+)
notfound_re = file\ not\ found

# Note: nearly the same as GCC
Expand All @@ -206,6 +212,7 @@ threads = -pthread
dump_macros = -dM

[hp_acc]
name = HP aCC
id_macro = __HP_cc
id_regexp = ^\S+:\ HP\ C/aC\+\+\ (?P<details>[A-Z0-9]+)
\ (?P<version>[A-Z0-9.]+)
Expand All @@ -230,6 +237,7 @@ threads = -mt
dump_macros = -dM

[mipspro]
name = MIPSpro
id_macro = _SGI_COMPILER_VERSION
id_regexp = ^MIPSpro\ Compilers:\ Version\ (?P<version>[0-9.]+)$
version = -version
Expand All @@ -249,31 +257,33 @@ conform = -ansi -ansiE
c1999 = -c99

[sunpro]
name = SUNpro
id_macro = __SUNPRO_C
id_regexp = ^\S+:\ Sun\ C\ (?P<version>[0-9.]+)\s*(?P<details>.+)?$
notfound_re = cannot\ find\ include\ file
errloc_re = ^"(?P<file> .+? )",\ line\ (?P<line> \d+ ):

version = -V
version = -V
# E_OLD_STYLE_FUNC_DECL triggers on e.g. any use of SIG_DFL.
# It would be nice to label that "incorrect", but we can't
# practically distinguish "incorrect" from "missing" for constants,
# and "missing" would give the wrong impression.
compile = -xe -v
-errfmt=error -errwarn=%all -errtags=yes
-erroff=E_OLD_STYLE_FUNC_DECL
-erroff=E_UNRECOGNIZED_PRAGMA_IGNORED
compile_out =
conform = -Xc -fd -features=no%extensions -features=no%typeof
c1989 = -xc99=none
c1999 = -xc99=all
threads = -mt=yes
dump_macros = -E -xdumpmacros=defs,undefs,sys
compile = -xe -v
-errfmt=error -errwarn=%all -errtags=yes
-erroff=E_OLD_STYLE_FUNC_DECL
-erroff=E_UNRECOGNIZED_PRAGMA_IGNORED
compile_out =
conform = -Xc -fd -features=no%extensions -features=no%typeof
c1989 = -xc99=none
c1999 = -xc99=all
threads = -mt=yes
dump_macros = -E -xdumpmacros=defs,undefs,sys

[msvc]
id_macro = _MSC_VER
id_regexp = ^Microsoft .* Compiler\ Version\ (?P<version>\d+\.\d+)
errloc_re = ^(?P<file> [^(]+)\((?P<line> \d+)\)\ :
name = MS Visual C
id_macro = _MSC_VER
id_regexp = ^Microsoft .* Compiler\ Version\ (?P<version>\d+\.\d+)
errloc_re = ^(?P<file> [^(]+)\((?P<line> \d+)\)\ :

preproc = /nologo /P
preproc_out = $.i
Expand Down
17 changes: 7 additions & 10 deletions config/headers.ini
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,8 @@
## potentially invalidate *all* existing inventories.

# Note that because :command:`survey-scan` needs to be
# backward-compatible all the way to Python 2.0, we cannot take
# advantage of RawConfigParser's allow_no_value option (which would
# eliminate the need for all the colons on the header file names) nor
# can we rely on the parser preserving the order of keys within the
# file.
# backward-compatible all the way to Python 2.0, we cannot rely on the
# parser preserving the order of keys within the file.

[standards]
c1989: 01. ISO C1990
Expand Down Expand Up @@ -300,11 +297,11 @@ DESC:
another header (that *is* intended for user space consumption)
compile without error. They should not otherwise be used.

netinet/in_systm.h: Kernel-internal network-related declarations
sys/queue.h: Kernel data structure utility macros (BSD)
sys/socketvar.h: Kernel-internal socket structures (?)
sys/ucred.h: Kernel-internal user credential structures
sys/user.h: Kernel-internal process structures
netinet/in_systm.h: Networking data type declarations
sys/queue.h: Data structure utility macros (BSD)
sys/socketvar.h: Socket structures (?)
sys/ucred.h: User credential structures
sys/user.h: Process structures

[obsolete]
DESC:
Expand Down
4 changes: 3 additions & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ Contents
.. toctree::
:maxdepth: 2

results
headers
opsys
survey
config-ref
content-tests
known-errors

.. Indices and tables
.. ==================
Expand Down
10 changes: 2 additions & 8 deletions doc/results.rst → doc/known-errors.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
Detailed Results
================

.. todo:: Complete.


Known Errors
------------
Glossary of Known Errors
------------------------

.. known-errors-report:: ../config/errors.ini

Expand Down
163 changes: 163 additions & 0 deletions gen-doc-stubs
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
#! /usr/bin/python3

# This program has to be run before 'sphinx-build'; its function is to
# generate a bunch of stub pages that call Sphinx extensions that
# actually generate the desired documentation.

import configparser
import glob
import os
import re
import sys
from collections import namedtuple, defaultdict

def parse_config_file(cdir, cname=None):
# n.b. really it's cdir that's an optional argument
if cname:
fname = os.path.join(cdir, cname)
else:
fname = cdir
with open(fname) as f:
parser = configparser.RawConfigParser()
parser.read_file(f)
return parser

def hsortkey(h):
"""Sort key for sorting headers. All one-component pathnames
are sorted ahead of all longer pathnames; within a group of
multicomponent pathnames with the same leading component,
all two-component pathnames are sorted ahead of all longer
pathnames; and so on, recursively."""
segs = str(h).lower().replace("\\", "/").split("/")
key = []
for s in segs:
key.extend((1, s))
key[-2] = 0
return tuple(key)

def vsortkey(v):
"""Sort key for sorting version numbers."""
return tuple(int(x) for x in re.split("[^0-9]+", v))

def gen_one_header(hdir, name, label):
os.makedirs(os.path.join(hdir, os.path.dirname(name)),
exist_ok=True)
title = ":file:`{}` — {}".format(name, label)
underline = "=" * len(title)
with open(os.path.join(hdir, name + ".rst"), "wt") as f:
f.write(title)
f.write("\n")
f.write(underline)
f.write("\n\n")
f.write(".. header-report: {}\n".format(name))

def gen_headers(odir, cfgdir):
hcfg = parse_config_file(cfgdir, "headers.ini")

leftover_sections = set(hcfg.sections())
leftover_sections.remove("standards")

hdir = os.path.join(odir, "headers")

with open(os.path.join(odir, "headers.rst"), "wt") as f:
f.write("Detailed results by header\n"
"==========================\n\n")

for tag, label in sorted(hcfg["standards"].items(),
key = lambda kv: kv[1][:2]):
if tag not in leftover_sections:
f.write(".. error::\n\n"
" no section for standard '``{}``'\n\n"
.format(tag))
continue
leftover_sections.remove(tag)

label = label[4:]
f.write(label)
f.write("\n")
f.write("-" * len(label))
f.write("\n\n")
f.write(hcfg[tag].get("DESC", ""))
f.write("\n\n.. toctree::\n\n")
for header, desc in sorted(hcfg[tag].items(),
key = lambda kv: hsortkey(kv[0])):
if header == "DESC" or header == "desc": continue
f.write(" headers/{}\n".format(header))
gen_one_header(hdir, header, desc)

f.write("\n")

def read_compiler_names(cfgdir):
ccfg = parse_config_file(cfgdir, "compilers.ini")
return { section : ccfg[section]["name"]
for section in ccfg.sections()
if section != "META" and section != "meta" }

RuntimeTag = namedtuple("RuntimeTag", ("label", "category"))
def read_runtime_tags(cfgdir):
rcfg = parse_config_file(cfgdir, "runtimes.ini")
return { section : RuntimeTag(rcfg[section]["label"],
rcfg[section]["category"])
for section in rcfg.sections() if section != "META" }


OSData = namedtuple("RuntimeTag",
("compiler", "compiler_v", "runtime", "runtime_v"))

def gen_one_opsys(fname, runtime, runtime_v, compiler, compiler_v):
os.makedirs(os.path.dirname(fname), exist_ok=True)
with open(fname, "wt") as f:
label = "{} {} with {} {}".format(runtime, runtime_v,
compiler, compiler_v)
f.write(label)
f.write("\n")
f.write("=" * len(label))
f.write("\n\n")

def gen_oses(odir, cfgdir, invdir):
compiler_names = read_compiler_names(cfgdir)
runtime_tags = read_runtime_tags(cfgdir)

runtimes_by_category = defaultdict(lambda: defaultdict(list))

for inv in glob.glob(os.path.join(invdir, "*.ini")):
label = parse_config_file(inv)["label"]
data = OSData(label["compiler"], label["compiler_v"],
label["runtime"], label["runtime_v"])

rtag = runtime_tags[data.runtime]
runtimes_by_category[rtag.category][rtag.label].append(data)

with open(os.path.join(odir, "opsys.rst"), "wt") as f:
f.write("Detailed results by operating system\n"
"====================================\n\n")

for category, runtimes in sorted(runtimes_by_category.items(),
key = lambda kv: kv[0]):
f.write(category)
f.write("\n")
f.write("-" * len(category))
f.write("\n\n.. toctree::\n\n")
for label, versions in sorted(runtimes.items(),
key = lambda kv: kv[0]):
versions.sort(key = lambda v: (vsortkey(v.runtime_v),
compiler_names[v.compiler],
vsortkey(v.compiler_v)))
for v in versions:
fname = "opsys/{}{}-{}{}".format(v.runtime, v.runtime_v,
v.compiler, v.compiler_v)

f.write(" {}\n".format(fname))
gen_one_opsys(os.path.join(odir, fname) + ".rst",
label, v.runtime_v,
compiler_names[v.compiler], v.compiler_v)
f.write("\n")

def main():
odir = sys.argv[1]
cfgdir = sys.argv[2]
invdir = sys.argv[3]
gen_headers(odir, cfgdir)
gen_oses(odir, cfgdir, invdir)

main()
Loading

0 comments on commit 94c1c3f

Please sign in to comment.