[Swift-commit] r3479 - trunk/src/org/griphyn/vdl/engine

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Tue Jul 27 20:43:34 CDT 2010


Author: jonmon
Date: 2010-07-27 20:43:34 -0500 (Tue, 27 Jul 2010)
New Revision: 3479

Modified:
   trunk/src/org/griphyn/vdl/engine/Karajan.java
Log:
o trunk/src/org/griphyn/vdl/engine/Karajan/java
  -- Added a functionality for a SWIFT_LIB enviroment variable. If the import directive cannot find the file to import relatively it then checks the SWIFT_LIB enviroment variable.



Modified: trunk/src/org/griphyn/vdl/engine/Karajan.java
===================================================================
--- trunk/src/org/griphyn/vdl/engine/Karajan.java	2010-07-28 01:11:31 UTC (rev 3478)
+++ trunk/src/org/griphyn/vdl/engine/Karajan.java	2010-07-28 01:43:34 UTC (rev 3479)
@@ -8,12 +8,14 @@
 import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.LinkedList;
+import java.util.List;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
+import java.util.StringTokenizer;
 
 import javax.xml.namespace.QName;
 
@@ -43,6 +45,7 @@
 import org.griphyn.vdl.karajan.Loader;
 import org.griphyn.vdl.karajan.CompilationException;
 import org.griphyn.vdl.toolkit.VDLt2VDLx;
+import org.griphyn.vdl.toolkit.VDLt2VDLx.ParsingException;
 import org.safehaus.uuid.UUIDGenerator;
 import org.w3c.dom.Node;
 
@@ -162,9 +165,30 @@
 					// TODO PATH/PERL5LIB-style path handling
 					//String swiftfilename = "./"+moduleToImport+".swift";
 					//String xmlfilename = "./"+moduleToImport+".xml";
+				    String lib_path = System.getenv("SWIFT_LIB");
 					String swiftfilename = moduleToImport+".swift";
 					String xmlfilename = moduleToImport+".xml";
-
+					
+					File local = new File(swiftfilename);
+					if( !( lib_path == null || local.exists() ) )
+					{
+					    StringTokenizer st = new StringTokenizer(lib_path, ":");
+					    while(st.hasMoreTokens())
+					    {
+					        String path = st.nextToken();
+					        String lib_script_location = path + "/" + swiftfilename; 
+					        File tmp = new File(lib_script_location);
+					        
+					        if(tmp.exists())
+					        {
+					            swiftfilename = path + "/" + swiftfilename;
+					            xmlfilename = path + "/" + xmlfilename;
+					            moduleToImport = path + "/" + moduleToImport;
+					            break;
+					        }
+					    }  
+					}
+					
 					try {
         	    		VDLt2VDLx.compile(new FileInputStream(swiftfilename),new PrintStream(new FileOutputStream(xmlfilename)));
 						logger.debug("Compiled. Now reading in compiled XML for "+moduleToImport);




More information about the Swift-commit mailing list