Allow building on cygwin.
authorCameron McCormack <cam@mcc.id.au>
Wed, 25 Jul 2012 01:40:33 +1000
changeset 30 74884712dfc7
parent 29 c0f94921f354
child 31 1f6f1e11046e
Allow building on cygwin.
build.py
--- a/build.py	Fri Jun 01 09:44:52 2012 +1000
+++ b/build.py	Wed Jul 25 01:40:33 2012 +1000
@@ -64,7 +64,7 @@
 
 
 
-import os, sys, signal
+import os, sys, signal, commands
 from os.path import isfile, abspath, getmtime, exists, join, normpath
 
 def exit(code, *message):
@@ -75,6 +75,12 @@
       sys.stderr.write(message[0] + '\n')
   sys.exit(code)
 
+def native_path(s):
+  if exists("/usr/bin/cygpath.exe"):
+    status, output = commands.getstatusoutput("cygpath -a -w %s" % s)
+    return output
+  return s
+
 # could allow this to be passed in:
 repo_dir = os.getcwd()
 
@@ -145,8 +151,8 @@
 
 if not isfile(svg_idlx) or getmtime(svg_idl) > getmtime(svg_idlx):
   toremove = [svg_idlx]
-  run("java -classpath " + join(tools_dir, "idlparser", "idlparser.jar") +
-      " au.id.mcc.idlparser.IDLToXML " + svg_idl + ">" + svg_idlx)
+  run("java -classpath \"" + native_path(str(join(tools_dir, "idlparser", "idlparser.jar"))) +
+      "\" au.id.mcc.idlparser.IDLToXML \"" + native_path(svg_idl) + "\" > " + svg_idlx)
   toremove = []
 
 # Build chapters as required:
@@ -177,10 +183,11 @@
 if tobuild:
   toremove = tobuild
   os.chdir(master_dir)
-  run("java -classpath " + join(tools_dir, 'saxonb', 'saxon9.jar') +
-      " net.sf.saxon.Transform -ext:on -dtd:off -expand:off -l:on " +
-      join(master_dir, "publish.xml") + " " + join(tools_dir, "publish.xsl") +
-      " chapters-to-build=\"" + " ".join(tobuild_names) + "\"" +
+  run("java -classpath \"" + native_path(join(tools_dir, 'saxonb', 'saxon9.jar')) +
+      "\" net.sf.saxon.Transform -ext:on -dtd:off -expand:off -l:on \"" +
+      native_path(join(master_dir, "publish.xml")) + "\" \"" +
+      native_path(join(tools_dir, "publish.xsl")) +
+      "\" chapters-to-build=\"" + " ".join(tobuild_names) + "\"" +
       (" local-style-sheets=\"yes\""
        if os.environ.get("SVG_BUILD_LOCAL_STYLE_SHEETS") else ""))
   toremove = []