[Swift-commit] r2583 - in trunk: . libexec resources src/org/griphyn/vdl/engine src/org/griphyn/vdl/karajan

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Sun Feb 22 11:02:54 CST 2009


Author: benc
Date: 2009-02-22 11:02:54 -0600 (Sun, 22 Feb 2009)
New Revision: 2583

Added:
   trunk/libexec/generate-buildid
Modified:
   trunk/CHANGES.txt
   trunk/build.xml
   trunk/resources/Karajan.stg
   trunk/src/org/griphyn/vdl/engine/Karajan.java
   trunk/src/org/griphyn/vdl/karajan/Loader.java
Log:
Recompilation will happen if a .kml file was compiled with a different
version of Swift to the version being invoked. This is in addition to the
existing behaviour where a .swift file will be recompiled if it is newer
than the corresponding .kml file.

Modified: trunk/CHANGES.txt
===================================================================
--- trunk/CHANGES.txt	2009-02-22 17:01:18 UTC (rev 2582)
+++ trunk/CHANGES.txt	2009-02-22 17:02:54 UTC (rev 2583)
@@ -1,3 +1,9 @@
+(02/09/22)
+*** Recompilation will happen if a .kml file was compiled with a different
+    version of Swift to the version being invoked. This is in addition to the
+    existing behaviour where a .swift file will be recompiled if it is newer
+    than the corresponding .kml file.
+
 (02/09/17)
 *** There is a new command swift-osg-ress-site-catalog which will generate
     a site catalog based on data gathered from OSG's ReSS information

Modified: trunk/build.xml
===================================================================
--- trunk/build.xml	2009-02-22 17:01:18 UTC (rev 2582)
+++ trunk/build.xml	2009-02-22 17:02:54 UTC (rev 2583)
@@ -273,6 +273,7 @@
 	<target name="generateVersion">
 		<echo file="libexec/version.txt">Swift ${version} </echo>
 		<exec os="Linux, Mac OS X" executable="libexec/svn-revision" append="true" output="libexec/version.txt"/>
+		<exec os="Linux, Mac OS X" executable="libexec/generate-buildid" append="false" output="libexec/buildid.txt"/>
 	</target>
 	
 	<target name="redist" depends="distclean, dist">

Added: trunk/libexec/generate-buildid
===================================================================
--- trunk/libexec/generate-buildid	                        (rev 0)
+++ trunk/libexec/generate-buildid	2009-02-22 17:02:54 UTC (rev 2583)
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+UUIDGEN=$(which uuidgen)
+
+if [ -x "$UUIDGEN" ]; then
+  $UUIDGEN
+else
+ # poormans uuidgen
+ echo $(date +%s) $PPID $HOSTNAME
+fi
+


Property changes on: trunk/libexec/generate-buildid
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/resources/Karajan.stg
===================================================================
--- trunk/resources/Karajan.stg	2009-02-22 17:01:18 UTC (rev 2582)
+++ trunk/resources/Karajan.stg	2009-02-22 17:02:54 UTC (rev 2583)
@@ -1,7 +1,7 @@
 group Karajan;
 
-program(types,procedures,declarations,statements,constants) ::= <<
-<project>
+program(types,procedures,declarations,statements,constants,buildversion) ::= <<
+<project><!-- CACHE ID $buildversion$ -->
   <import file="sys.xml"/>
   <import file="scheduler.xml"/>
   <import file="rlog.xml"/>

Modified: trunk/src/org/griphyn/vdl/engine/Karajan.java
===================================================================
--- trunk/src/org/griphyn/vdl/engine/Karajan.java	2009-02-22 17:01:18 UTC (rev 2582)
+++ trunk/src/org/griphyn/vdl/engine/Karajan.java	2009-02-22 17:02:54 UTC (rev 2583)
@@ -34,6 +34,7 @@
 import org.globus.swift.language.Switch.Default;
 import org.globus.swift.language.TypesDocument.Types;
 import org.globus.swift.language.TypesDocument.Types.Type;
+import org.griphyn.vdl.karajan.Loader;
 import org.griphyn.vdl.karajan.CompilationException;
 import org.safehaus.uuid.UUIDGenerator;
 import org.w3c.dom.Node;
@@ -142,6 +143,8 @@
 		VariableScope scope = new VariableScope(this, null);
 		scope.bodyTemplate = template("program");
 
+		scope.bodyTemplate.setAttribute("buildversion",Loader.buildVersion);
+
 		types = prog.getTypes();
 		if (types != null) {
 			for (int i = 0; i < types.sizeOfTypeArray(); i++) {

Modified: trunk/src/org/griphyn/vdl/karajan/Loader.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/Loader.java	2009-02-22 17:01:18 UTC (rev 2582)
+++ trunk/src/org/griphyn/vdl/karajan/Loader.java	2009-02-22 17:02:54 UTC (rev 2583)
@@ -3,12 +3,15 @@
  */
 package org.griphyn.vdl.karajan;
 
+import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
+import java.io.FileReader;
 import java.io.IOException;
 import java.io.PrintStream;
+import java.io.Reader;
 import java.security.NoSuchAlgorithmException;
 import java.security.SecureRandom;
 import java.text.DateFormat;
@@ -61,6 +64,8 @@
 	public static final String VDL_OPERATION_TYPECHECK = "typecheck";
 	public static final String VDL_OPERATION_DRYRUN = "dryrun";
 
+	public static String buildVersion;
+
 	public static void main(String[] argv) {
 		logger.debug("Loader started");
 		ArgumentParser ap = buildArgumentParser();
@@ -194,17 +199,50 @@
 		System.err.print("For usage information:  swift -help\n\n");
 	}
 
-	public static String compile(String project) 
+	public static String compile(String project)
 		throws FileNotFoundException, ParsingException,
-		IncorrectInvocationException, CompilationException {
+		IncorrectInvocationException, CompilationException,
+		IOException {
 		File swiftscript = new File(project);
 		File dir = swiftscript.getParentFile();
 		String projectBase = project.substring(0, project.lastIndexOf('.'));
 		File xml = new File(projectBase + ".xml");
 		File kml = new File(projectBase + ".kml");
 
+		loadBuildVersion();
+
+		boolean recompile = false;
+
 		if (swiftscript.lastModified() > kml.lastModified()) {
 			logger.info(project + ": source file is new. Recompiling.");
+			recompile = true;
+		}
+
+		if (kml.exists()) {
+			// read first line of kml
+			Reader fr = new FileReader(kml);
+			BufferedReader br = new BufferedReader(fr);
+			String firstLine = br.readLine();
+			String prefix = "<!-- CACHE ID ";
+			int offset = firstLine.indexOf(prefix);
+			if(offset < 0) {
+				// no build version in the KML
+				logger.info(project + ": has no build version. Recompiling.");
+				recompile = true;
+			} else {
+				String cut = firstLine.substring(offset+prefix.length());
+				int endOffset = cut.indexOf(" -->");
+				String kmlversion = cut.substring(0,endOffset);
+				logger.debug("kmlversion is >"+kmlversion+"<");
+				logger.debug("build version is >"+buildVersion+"<");
+				if(!(kmlversion.equals(buildVersion))) {
+					logger.info(project + ": source file was compiled with a different version of Swift. Recompiling.");
+					recompile=true;
+				}
+			}
+		}
+
+		if (recompile) {
 			VDLt2VDLx.compile(new FileInputStream(swiftscript), new PrintStream(new FileOutputStream(xml)));
 
 			try {
@@ -237,6 +275,12 @@
 		return kml.getAbsolutePath();
 	}
 
+	private static void loadBuildVersion() throws IOException {
+		File f = new File(System.getProperty("swift.home")+"/libexec/buildid.txt");
+		BufferedReader br = new BufferedReader(new FileReader(f));
+		buildVersion = br.readLine();
+	}
+
 	private static VDL2Config loadConfig(ArgumentParser ap, VariableStack stack) throws IOException {
 		VDL2Config conf;
 		if (ap.hasValue(ARG_INSTANCE_CONFIG)) {




More information about the Swift-commit mailing list