1
0
Преглед на файлове

Changed prefix to suffix in jtalkc. This can be used to produce different js files from the same st file.

Göran Krampe преди 13 години
родител
ревизия
411bd6e38c
променени са 2 файла, в които са добавени 32 реда и са изтрити 17 реда
  1. 13 13
      bin/jtalkc
  2. 19 4
      nodejs/nodecompile.js

+ 13 - 13
bin/jtalkc

@@ -15,7 +15,7 @@ popd >/dev/null
 
 
 function usage {
 function usage {
 	cat <<ENDOFHELP
 	cat <<ENDOFHELP
-Usage: $0 [-N|D|E] [-K|C|J] [-o] [-O|-A] [-g] [-p prefix] [-m class] [-M file]
+Usage: $0 [-N|D|E] [-K|C|J] [-o] [-O|-A] [-g] [-s suffix] [-m class] [-M file]
           [-i] [-I file] [file1 [file2 ...]] [Program]
           [-i] [-I file] [file1 [file2 ...]] [Program]
 
 
    Will compile Jtalk files - either separately or into a runnable complete
    Will compile Jtalk files - either separately or into a runnable complete
@@ -64,9 +64,9 @@ Usage: $0 [-N|D|E] [-K|C|J] [-o] [-O|-A] [-g] [-p prefix] [-m class] [-M file]
   -g
   -g
      Compile Jtalk code in debug mode - include source and references etc.
      Compile Jtalk code in debug mode - include source and references etc.
 
 
-  -p prefix
-     Add <prefix> to compiled js files so that File.st is compiled into
-     <prefix>File.st.
+  -s suffix
+     Add <suffix> to compiled js files so that File.st is compiled into
+     File.<suffix>.st.
 
 
   -l library1,library2
   -l library1,library2
      Load listed libraries (no spaces) into Compiler before compiling.
      Load listed libraries (no spaces) into Compiler before compiling.
@@ -134,14 +134,14 @@ BASE=
 LOAD=
 LOAD=
 LOADANDADD=
 LOADANDADD=
 CLOSUREOPTS=
 CLOSUREOPTS=
-# Ok, bad coding practice but hey, who would use such a prefix?
-PREFIX=no-silly-prefix
-PREFIXUSED=
+# Ok, bad coding practice but hey, who would use such a suffix?
+SUFFIX=no-silly-suffix
+SUFFIXUSED=
 DEBUG=false
 DEBUG=false
 NODECOMPILE=nodecompile.js
 NODECOMPILE=nodecompile.js
 
 
 # Read options and shift them away
 # Read options and shift them away
-while getopts "NDEKCJoOAgp:l:L:i:IM:m:h?" o; do
+while getopts "NDEKCJoOAgs:l:L:i:IM:m:h?" o; do
 case "$o" in
 case "$o" in
    N) ENV=NODE
    N) ENV=NODE
       BASE=$KERNEL
       BASE=$KERNEL
@@ -163,8 +163,8 @@ case "$o" in
       CLOSUREOPTS="$CLOSUREOPTS --compilation_level ADVANCED_OPTIMIZATIONS"
       CLOSUREOPTS="$CLOSUREOPTS --compilation_level ADVANCED_OPTIMIZATIONS"
       CLOSUREFULL=true;;
       CLOSUREFULL=true;;
    g) DEBUG=true;;
    g) DEBUG=true;;
-   p) PREFIX=$OPTARG
-      PREFIXUSED=$PREFIX;;
+   s) SUFFIX=$OPTARG
+      SUFFIXUSED=$SUFFIX;;
    l) LOAD=$OPTARG;;
    l) LOAD=$OPTARG;;
    L) LOADANDADD=$OPTARG;;
    L) LOADANDADD=$OPTARG;;
    I) INIT=$INITIALIZER;;
    I) INIT=$INITIALIZER;;
@@ -259,11 +259,11 @@ do
         CATEGORY=`basename $1 .st`
         CATEGORY=`basename $1 .st`
         if [ -f "$1" ]; then
         if [ -f "$1" ]; then
            COMPILE="$COMPILE $1 $CATEGORY"
            COMPILE="$COMPILE $1 $CATEGORY"
-           COMPILED="$COMPILED $PREFIXUSED$CATEGORY.js"
+           COMPILED="$COMPILED $CATEGORY$SUFFIXUSED.js"
         else
         else
            if [ -f $JTALK/st/$1 ]; then
            if [ -f $JTALK/st/$1 ]; then
              COMPILE="$COMPILE $JTALK/st/$1 $CATEGORY"
              COMPILE="$COMPILE $JTALK/st/$1 $CATEGORY"
-             COMPILED="$COMPILED $PREFIXUSED$CATEGORY.js"
+             COMPILED="$COMPILED $CATEGORY$SUFFIXUSED.js"
            else
            else
              echo "JTalk file not found: $1"
              echo "JTalk file not found: $1"
              exit 1
              exit 1
@@ -292,7 +292,7 @@ cat $TOOURCOMPILER > $TMPDIR/compiler.js
  
  
 # Compile all collected .st files to .js
 # Compile all collected .st files to .js
 echo "Loading libraries $TOOURCOMPILER and compiling ..."
 echo "Loading libraries $TOOURCOMPILER and compiling ..."
-node $TMPDIR/compiler.js $DEBUG $PREFIX $COMPILE
+node $TMPDIR/compiler.js $DEBUG $SUFFIX $COMPILE
 
 
 # Verify all .js files corresponding to .st files were created, otherwise exit
 # Verify all .js files corresponding to .st files were created, otherwise exit
 IFS=" "
 IFS=" "

+ 19 - 4
nodejs/nodecompile.js

@@ -4,8 +4,23 @@
 // as aCategoryName.js.
 // as aCategoryName.js.
 var sys = require('sys'), fs = require('fs');
 var sys = require('sys'), fs = require('fs');
 
 
-// Only care about our arguments, strip away node and all.js
-var arguments = process.argv.splice(2);
+// Only care about our arguments, strip away node, all.js and debug flag.
+var arguments = process.argv.splice(4);
+
+// First argument is debugMode: "true" or "false"
+if (process.argv[2] == "true") {
+  smalltalk.debugMode = true;
+} else {
+  smalltalk.debugMode = false;
+}
+
+// Second argument is suffix: "no-silly-suffix" means none
+suffix = process.argv[3];
+if (suffix == "no-silly-suffix") {
+  suffix = "";
+}
+
+console.log("Compiling in debugMode: " + smalltalk.debugMode);
 
 
 // If it ends with .st, import it, otherwise export category as .js
 // If it ends with .st, import it, otherwise export category as .js
 arguments.forEach(function(val, index, array) {
 arguments.forEach(function(val, index, array) {
@@ -14,7 +29,7 @@ arguments.forEach(function(val, index, array) {
     code = fs.readFileSync(val, "utf8");
     code = fs.readFileSync(val, "utf8");
     smalltalk.Importer._new()._import_(code._stream());
     smalltalk.Importer._new()._import_(code._stream());
   } else {
   } else {
-    sys.puts("Exporting category " + val);
-    fs.writeFileSync(val + ".js", smalltalk.Exporter._new()._exportCategory_(val));
+    sys.puts("Exporting category " + val + " as " + val + suffix + ".js");
+    fs.writeFileSync(val + suffix + ".js", smalltalk.Exporter._new()._exportCategory_(val));
   }
   }
 });
 });