Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bin/dslc.in16
-rw-r--r--src/current/src/com/lovullo/dslc/DslCompiler.java38
2 files changed, 34 insertions, 20 deletions
diff --git a/bin/dslc.in b/bin/dslc.in
index e9dac7c..226ba92 100644
--- a/bin/dslc.in
+++ b/bin/dslc.in
@@ -22,7 +22,21 @@
declare -r mypath=$( dirname "$( readlink -f "$0" )" )
declare -r dslc_jar="$mypath/../src/current/src/dslc.jar"
+# TODO: decouple from old rater/ directory
+rater-path()
+{
+ # use rater/ in cwd if available to maintain previous behavior
+ if [ -d "$(pwd)/rater" ]; then
+ echo "$(pwd)/rater"
+ return
+ fi
+
+ # otherwise use our own
+ echo "$mypath/../rater"
+}
+
CLASSPATH="$CLASSPATH:@DSLC_CLASSPATH@:$dslc_jar" \
"@JAVA@" @JAVA_OPTS@ \
- com.lovullo.dslc.DslCompiler
+ com.lovullo.dslc.DslCompiler \
+ "$( rater-path )"
diff --git a/src/current/src/com/lovullo/dslc/DslCompiler.java b/src/current/src/com/lovullo/dslc/DslCompiler.java
index 2f51945..52456d7 100644
--- a/src/current/src/com/lovullo/dslc/DslCompiler.java
+++ b/src/current/src/com/lovullo/dslc/DslCompiler.java
@@ -54,10 +54,12 @@ public class DslCompiler
private Path _pathRoot;
- public _DslCompiler()
+ public _DslCompiler( String path_root )
+ throws IOException
{
- _xsd = _createXsd();
- _xsl = new HashMap<String,Transformer>();
+ _pathRoot = Paths.get( path_root ).toRealPath();
+ _xsd = _createXsd();
+ _xsl = new HashMap<String,Transformer>();
}
@@ -84,9 +86,6 @@ public class DslCompiler
System.exit( 4 );
}
- // root path of TAME
- _pathRoot = Paths.get( "rater/tame" ).toRealPath();
-
// transform to dest
File destfile = new File( dest );
try
@@ -140,7 +139,7 @@ public class DslCompiler
String relroot = new String( new char[ dircount ] ).replace( "\0", "../" );
Transformer t = _xsl.get( cmd );
- t.setParameter( "__path-root", _pathRoot.toString() );
+ t.setParameter( "__path-root", _pathRoot.toString() + "/tame" );
t.setParameter( "__srcpkg", srcpkg );
t.setParameter( "__relroot", relroot );
t.setParameter( "__rseed", (int)( Math.random() * 10e6 ) );
@@ -193,7 +192,7 @@ public class DslCompiler
try
{
final Schema schema =
- factory.newSchema( new File( "rater/rater.xsd" ) );
+ factory.newSchema( new File( _pathRoot.toString() + "/rater.xsd" ) );
return schema.newValidator();
}
@@ -219,7 +218,9 @@ public class DslCompiler
"net.sf.saxon.TransformerFactoryImpl", null
);
- final Source xsl = new StreamSource( "rater/" + src + ".xsl" );
+ final Source xsl = new StreamSource(
+ _pathRoot.toString() + "/" + src + ".xsl"
+ );
return factory.newTransformer( xsl );
}
@@ -245,23 +246,22 @@ public class DslCompiler
new InputStreamReader( System.in )
);
- String src = ( args.length > 0 ) ? args[0] : "";
+ String src = "";
+ String path_root = ( args.length > 0 ) ? args[0] : "";
- _DslCompiler dslc = new _DslCompiler();
+ if ( path_root == "" )
+ {
+ throw new Exception( "Missing rater/ root path" );
+ }
+
+ _DslCompiler dslc = new _DslCompiler( path_root );
try
{
- if ( src != "" )
+ while ( ( src = stdin.readLine() ) != null )
{
compileSrc( dslc, src );
}
- else
- {
- while ( ( src = stdin.readLine() ) != null )
- {
- compileSrc( dslc, src );
- }
- }
}
catch ( IOException e )
{