summaryrefslogtreecommitdiff
path: root/SConstruct
diff options
context:
space:
mode:
authorPeter Simons <simons@cryp.to>2009-04-30 01:43:11 +0200
committerPeter Simons <simons@cryp.to>2009-05-05 01:43:35 +0200
commit3b300028e416c3a787e26157602c00eefa47b895 (patch)
tree8cd7ae0b589cf96a9c5872b948069b8f74820e10 /SConstruct
parent04e8fe01cc30aa770fbee37f1c9814bf1c77a245 (diff)
downloadautoconf-archive-3b300028e416c3a787e26157602c00eefa47b895.tar.gz
maint: added initial version of the toolchain
The build process requires python, the python StringTemplate module, and preferably SCons. A make-based build exists, but it is really slow and awkward, compared to the SConstruct file.
Diffstat (limited to 'SConstruct')
-rw-r--r--SConstruct37
1 files changed, 37 insertions, 0 deletions
diff --git a/SConstruct b/SConstruct
new file mode 100644
index 0000000..ad6e89a
--- /dev/null
+++ b/SConstruct
@@ -0,0 +1,37 @@
+from SCons.Script import *
+import os.path as path
+from macro import Macro, writeFile
+from stringtemplate3 import StringTemplateGroup, StringTemplate
+
+__formatters = { "canon.st" : StringTemplateGroup(fileName = "canon.st")
+ , "markdown.st" : StringTemplateGroup(fileName = "markdown.st")
+ }
+
+def formatMacro(target, source, env):
+ assert len(target) == 1
+ outFile = target[0]
+ (m4File,stFile) = source
+ m = Macro(m4File.path, env["inputEncoding"])
+ f = __formatters[stFile.path].getInstanceOf("canon")
+ for (k,v) in m.__dict__.items():
+ f[k] = v
+ writeFile(outFile.path, env["outputEncoding"], f.toString().strip() + '\n')
+
+##### Build Script #####
+
+m4dir = "m4"
+stagedir = "stage"
+
+cssfile = "autoconf-archive.css"
+cssfile = Command(path.join(stagedir, cssfile), cssfile, Copy("$TARGET", "$SOURCE"))
+
+for m in Glob(path.join(m4dir, "*.m4")):
+ t = path.join(stagedir, path.basename(m.path))
+ s = Command(t, [m, "canon.st"], formatMacro, inputEncoding = "latin1", outputEncoding = "latin1")
+ AddPostAction(s, "@diff -ub $SOURCE $TARGET")
+ t = path.splitext(t)[0] + ".mdown"
+ s = Command(t, [s, "markdown.st"], formatMacro, inputEncoding = "latin1", outputEncoding = "utf-8")
+ t = path.splitext(t)[0] + ".html"
+ s = Command(t, [s, cssfile, "header.html"], "pandoc --standalone --title-prefix='Autoconf Macro: ' --include-before-body=header.html --css=autoconf-archive.css --from=markdown --to=html -o $TARGET $SOURCE")
+
+Clean(".", [stagedir])