Commits

Henri Sivonen committed 34ded9e

draft build script

Comments (0)

Files changed (1)

+#!/usr/bin/python
+import os
+
+javacCmd = 'javac'
+jarCmd = 'jar'
+javaCmd = 'java'
+javadocCmd = 'javadoc'
+
+buildRoot = '.'
+
+def runCmd(cmd):
+  print cmd
+  os.system(cmd)
+
+def removeIfExists(filePath):
+  if os.path.exists(filePath):
+    os.unlink(filePath)
+
+def ensureDirExists(dirPath):
+  if not os.path.exists(dirPath):
+    os.makedirs(dirPath)
+
+def findFilesWithExtension(directory, extension):
+  rv = []
+  ext = '.' + extension 
+  for root, dirs, files in os.walk(directory):
+    for file in files:
+      if file.endswith(ext):
+        rv.append(os.path.join(root, file))
+  return rv
+
+def runJavac(sourceDir, classDir, classPath):
+  sourceFiles = findFilesWithExtension(sourceDir, "java")
+  runCmd("%s -classpath '%s' -sourcepath '%s' -d '%s' %s"\
+		% (javacCmd, classPath, sourceDir, classDir, " ".join(sourceFiles)))
+
+def runJar(classDir, jarFile, sourceDir):
+  classFiles = findFilesWithExtension(classDir, "class")
+  metaDir = os.path.join(sourceDir, "META-INF")
+  classList = map(lambda x: "-C '" + classDir + "' " + x[len(classDir)+1:], 
+                  classFiles)
+  if os.path.exists(metaDir):
+    # XXX get rid of CVS directories here
+    runCmd("%s cf '%s' -C '%s' META-INF %s" 
+      % (jarCmd, jarFile, sourceDir, " ".join(classList)))
+  else:  
+    runCmd("%s cf '%s' %s" 
+      % (jarCmd, jarFile, " ".join(classList)))
+
+def buildModule(rootDir, jarName, classPath):
+  sourceDir = os.path.join(rootDir, "src")
+  classDir = os.path.join(rootDir, "classes")
+  distDir = os.path.join(rootDir, "dist")
+  jarFile = os.path.join(distDir, jarName + ".jar")
+  removeIfExists(jarFile)
+  ensureDirExists(classDir)
+  ensureDirExists(distDir)
+  runJavac(sourceDir, classDir, classPath)
+  runJar(classDir, jarFile, sourceDir)
+
+def dependencyJarPaths():
+  return findFilesWithExtension("dependencies", "jar")
+
+def buildDatatypeLibrary():
+  classPath = os.pathsep.join(dependencyJarPaths())
+  buildModule(
+    os.path.join(buildRoot, "syntax", "relaxng", "datatype", "java"), 
+    "html5-datatypes", 
+    classPath)
+
+def buildNonSchema():
+  classPath = os.pathsep.join(dependencyJarPaths())
+  buildModule(
+    os.path.join(buildRoot, "syntax", "relaxng", "datatype", "java"), 
+    "html5-datatypes", 
+    classPath)
+
+
+def buildValidator():
+  pass
+
+def ensureValidator():
+  buildValidator()
+
+def run():
+  ensureValidator()
+  
+buildDatatypeLibrary()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.