浏览代码

Simplified jtalkc.

Göran Krampe 12 年之前
父节点
当前提交
e33660d33e

+ 46 - 76
bin/jtalkc

@@ -15,15 +15,15 @@ popd >/dev/null
 
 function usage {
 	cat <<ENDOFHELP
-Usage: $0 [-N|D|E] [-K|C|J] [-o] [-O|-A] [-d] [-s suffix] [-m class] [-M file]
-          [-i] [-I file] [file1 [file2 ...]] [Program]
+Usage: $0 [-L level] [-l lib1,lib2...] [-i file] [-m class] [-M file]
+          [-o] [-O|-A] [-d] [-s suffix] [-S suffix] [file1 [file2 ...]] [Program]
 
    Will compile Jtalk files - either separately or into a runnable complete
-   program. If no files are listed only a linking stage is performed.
+   program. If no .st files are listed only a linking stage is performed.
    Files listed will be handled using these rules:
 
    *.js
-     Files are concatenated in listed order.
+     Files are linked (concatenated) in listed order.
      If not found we look in $JTALK/js
 
    *.st
@@ -37,29 +37,38 @@ Usage: $0 [-N|D|E] [-K|C|J] [-o] [-O|-A] [-d] [-s suffix] [-m class] [-M file]
    a .js file. Otherwise a <Program>.js file is linked together based on
    the options:
 
-  -N or -D or -E
-     Compilation target. Currently Node.js, D8 (V8 shell) or Enyo (webOS 3.0).
-     All currentl imply "-K -I" so boot.js and Kernel.js are added first and init.js
-     is added last.
+  -L level
+     Add libraries to a predefined level (default is KERNEL) of environment
+     where level is:
 
-  -K
-     Add libraries to get minimal Jtalk Kernel running.
+        KERNEL    - a reasonable level for server side programs or libraries.
+        PARSER    - if you need to parse stuff, includes PetitParser etc.
+        COMPILER  - if you need to compile Jtalk code.
+        CANVAS    - if you need HTML DOM manipulation, typical for client side.
+        JQUERY    - if you want JQuery stuff on top of Canvas.
+        IDE       - if you are extending the IDE with new tools etc.
 
-  -C
-     Add libraries to get minimal Jtalk Compiler running.
+  -l library1,library2
+     Additionally add listed libraries (no spaces or .js) in listed order.
+
+  -i file
+     Add library initializer <file> instead of default $JTALK/js/init.js 
 
-  -J
-     Add libraries to get minimal Jtalk IDE running.
+  -m class
+     Add at end a call to #main in class <class>. 
 
+  -M file
+     Add at end javascript file <file> acting as main.
+        
   -o
      Optimize each js file using the Google closure compiler.
-     Using Closure at ~/compiler.jar    
+     Using Closure compiler found at ~/compiler.jar    
 
   -O
      Optimize final <Program>.js using the Google closure compiler.
-     Using Closure at ~/compiler.jar
+     Using Closure compiler found at ~/compiler.jar
 
-  -A Same as -O but use --compilation_level ADVANCED_OPTIMIZATIONS 
+  -A Same as -O but use --compilation_level ADVANCED_OPTIMIZATIONS
 
   -d
      Additionally export code for deploy - stripped from source etc.
@@ -70,26 +79,8 @@ Usage: $0 [-N|D|E] [-K|C|J] [-o] [-O|-A] [-d] [-s suffix] [-m class] [-M file]
      File.<suffix>.js.
 
   -S suffix
-     Use <suffix> for all libraries accessed using -l or -L and other options.
-
-  -l library1,library2
-     Load listed libraries (no spaces or .js) into Compiler before compiling.
-
-  -L library1,library2
-     Load listed libraries (no spaces or .js) into Compiler before compiling
-     and also into Program.js in listed order.
-
-  -i file
-     Add library initializer <file>.
-
-  -I
-     Add library standard initializer $JTALK/js/init.js  
-
-  -m class
-     Add call to #main in class <class>. 
-
-  -M file
-     Add javascript file <file> at the end acting as main.
+     Use <suffix> for all libraries accessed using -L or -l. This makes it possible
+     to have multiple flavors of Jtalk and libraries in the same place.
 
 
      Example invocations:
@@ -99,8 +90,7 @@ Usage: $0 [-N|D|E] [-K|C|J] [-o] [-O|-A] [-d] [-s suffix] [-m class] [-M file]
         jtalkc Kernel.st
 
      Compile Hello.st to Hello.js and create complete program called
-     Program.js for Node.js and adding a call to class method #main
-     in class Hello:
+     Program.js and adding a call to class method #main in class Hello:
 
         jtalkc -N -m Hello Hello.st Program
 
@@ -108,7 +98,7 @@ Usage: $0 [-N|D|E] [-K|C|J] [-o] [-O|-A] [-d] [-s suffix] [-m class] [-M file]
      and link with specific myboot.js, myKernel.js, myinit.js
      and main.js and create complete program called Program.js:
 
-        jtalkc -M main.js -I myinit.js myboot.js myKernel.js Cat1.st Cat2.st Program
+        jtalkc -M main.js myinit.js myboot.js myKernel.js Cat1.st Cat2.st Program
 
 ENDOFHELP
 	exit 1;
@@ -122,9 +112,11 @@ fi
 # Define our predefined library combinations
 BOOT="boot"
 KERNEL="$BOOT Kernel"
-COMPILER="$KERNEL Parser Compiler"
+PARSER="$KERNEL Parser"
+COMPILER="$PARSER Compiler"
 CANVAS="$COMPILER Canvas"
-IDE="$CANVAS JQuery IDE SUnit Examples"
+JQUERY="$COMPILER JQuery"
+IDE="$JQUERY IDE SUnit Examples"
 
 # Predefined initializer
 INITIALIZER="$JTALK/js/init.js"
@@ -136,7 +128,6 @@ MAIN=
 MAINFILE=
 BASE=$KERNEL
 LOAD=
-LOADANDADD=
 CLOSUREOPTS=
 # Ok, bad coding practice but hey, who would use such a suffix?
 SUFFIX=no-silly-suffix
@@ -145,20 +136,13 @@ DEPLOY=false
 NODECOMPILE=nodecompile
 
 # Read options and shift them away
-while getopts "NDEKCJoOAdS:s:l:L:i:IM:m:h?" o; do
+while getopts "L:l:i:m:M:oOAds:S:h?" o; do
 case "$o" in
-   N) ENV=NODE
-      BASE=$KERNEL
-      INIT=$INITIALIZER;;
-   D) ENV=D8
-      BASE=$KERNEL
-      INIT=$INITIALIZER;;
-   E) ENV=ENYO
-      BASE=$KERNEL
-      INIT=$INITIALIZER;;
-   K) BASE=$KERNEL;;
-   C) BASE=$COMPILER;;
-   J) BASE=$IDE;;
+   L) BASE=${!OPTARG};;  # If OPTARG is "KERNEL" this sets BASE to $KERNEL.
+   l) LOAD=$OPTARG;;
+   i) INIT=$OPTARG;;
+   m) MAIN=$OPTARG;;
+   M) MAINFILE=$OPTARG;;
    o) CLOSURE=true
       CLOSUREPARTS=true;;
    O) CLOSURE=true
@@ -167,16 +151,10 @@ case "$o" in
       CLOSUREOPTS="$CLOSUREOPTS --compilation_level ADVANCED_OPTIMIZATIONS"
       CLOSUREFULL=true;;
    d) DEPLOY=true;;
-   S) LOADSUFFIX=$OPTARG
-      SUFFIXUSED=$SUFFIX;;
    s) SUFFIX=$OPTARG
       SUFFIXUSED=$SUFFIX;;
-   l) LOAD=$OPTARG;;
-   L) LOADANDADD=$OPTARG;;
-   I) INIT=$INITIALIZER;;
-   i) INIT=$OPTARG;;
-   M) MAINFILE=$OPTARG;;
-   m) MAIN=$OPTARG;;
+   S) LOADSUFFIX=$OPTARG
+      SUFFIXUSED=$SUFFIX;;
    h) usage;;
    [?])  usage;;
    esac
@@ -222,14 +200,6 @@ done
 # Resolve listed libraries in $LOAD separated by ,
 LOAD=${LOAD//,/\ }
 for FILE in $LOAD
-do
-   resolvejs $FILE
-   TOLOAD="$TOLOAD $RESOLVED"
-done
-
-# Resolve listed libraries in $LOADANDADD separated by ,
-LOADANDADD=${LOADANDADD//,/\ }
-for FILE in $LOADANDADD
 do
    resolvejs $FILE
    TOLOAD="$TOLOAD $RESOLVED"
@@ -240,16 +210,16 @@ done
 for FILE in $COMPILER
 do
    resolvejs $FILE
-   TOOURCOMPILER="$TOOURCOMPILER $RESOLVED"
+   TOCOMPILER="$TOCOMPILER $RESOLVED"
 done
 # Add supplied libraries to load (they are already resolved)
-TOOURCOMPILER="$TOOURCOMPILER$TOLOAD"
+TOCOMPILER="$TOCOMPILER$TOLOAD"
 THEREST="init $JTALK/bin/$NODECOMPILE"
 # Resolve init and nodecompile
 for FILE in $THEREST
 do
    resolvejs $FILE
-   TOOURCOMPILER="$TOOURCOMPILER $RESOLVED"
+   TOCOMPILER="$TOCOMPILER $RESOLVED"
 done
 
 # Add supplied libraries
@@ -301,7 +271,7 @@ done
 # --------------------------------------------------
 
 # Create compiler dynamically
-cat $TOOURCOMPILER > $TMPDIR/compiler.js
+cat $TOCOMPILER > $TMPDIR/compiler.js
  
 # Compile all collected .st files to .js
 echo "Loading libraries$TOOURCOMPILER and compiling ..."

+ 1 - 1
examples/nodejs/benchfib/Makefile

@@ -1,5 +1,5 @@
 Program.js: Benchfib.st
-	../../../bin/jtalkc -N -m Benchfib Benchfib.st Program
+	../../../bin/jtalkc -m Benchfib Benchfib.st Program
 
 run: Program.js
 	./benchfib

+ 1 - 1
examples/nodejs/hello/Makefile

@@ -1,5 +1,5 @@
 Program.js: Hello.st
-	../../../bin/jtalkc -N -m Hello Hello.st Program
+	../../../bin/jtalkc -m Hello Hello.st Program
 
 run: Program.js
 	./hello

+ 1 - 1
examples/nodejs/meta/Makefile

@@ -1,5 +1,5 @@
 Program.js: MyScript.st
-	../../../bin/jtalkc -N -C -m MyScript MyScript.st Program
+	../../../bin/jtalkc -m MyScript MyScript.st Program
 
 run: Program.js
 	node Program.js

+ 1 - 1
examples/nodejs/trivialserver/Makefile

@@ -1,5 +1,5 @@
 Program.js: TrivialServer.st
-	../../../bin/jtalkc -N -m TrivialServer TrivialServer.st Program
+	../../../bin/jtalkc -m TrivialServer TrivialServer.st Program
 
 run: Program.js
 	./trivial

+ 2 - 3
examples/webos/eris/Makefile

@@ -1,14 +1,13 @@
 #
 # If you copy this file for an Enyo/Jtalk project, just
-# modify these first two lines
+# modify these first three lines
 # and then add .st files as you please. This Makefile
 # should pick them all up and compile into Program.js.
 #
 PACKAGE  := jtalk.eris
 VERSION  := 0.0.1
+FLAGS    := -L COMPILER
 
-# -E for Enyo, -O for Closure optimization of js code.
-FLAGS    := -E -C
 IPK      := $(PACKAGE)_$(VERSION)_all.ipk
 FILE     := Program
 SOURCES  := $(wildcard *.st)

+ 2 - 2
examples/webos/hellojtalk/Makefile

@@ -7,8 +7,8 @@
 PACKAGE  := jtalk.hellojtalk
 VERSION  := 1.0.0
 
-# -E for Enyo, -O for Closure optimization of js code.
-FLAGS    := -E -O
+# -O for Closure optimization of js code.
+FLAGS    := -O
 IPK      := $(PACKAGE)_$(VERSION)_all.ipk
 FILE     := Program
 SOURCES  := $(wildcard *.st)

+ 4 - 4
st/Makefile

@@ -52,19 +52,19 @@ Compiler.js: Compiler.st Parser.js
 #
 # JQuery uses Canvas
 JQuery.js: JQuery.st Canvas.js
-	$(JTALKC) $(FLAGS) -l Canvas $<
+	$(JTALKC) $(FLAGS) -L CANVAS $<
 
 # IDE uses JQuery
 IDE.js: IDE.st JQuery.js
-	$(JTALKC) $(FLAGS) -l Canvas,JQuery $<
+	$(JTALKC) $(FLAGS) -L JQUERY $<
 
 # The SUnit TestRunner uses UI stuff from IDE.
 SUnit.js: SUnit.st IDE.js
-	$(JTALKC) $(FLAGS) -l Canvas,JQuery,IDE $<
+	$(JTALKC) $(FLAGS) -L IDE $<
 
 # Some Examples use SUnit
 Examples.js: Examples.st SUnit.js
-	$(JTALKC) $(FLAGS) -l Canvas,JQuery,IDE,SUnit $<;
+	$(JTALKC) $(FLAGS) -L IDE -l SUnit $<;
 
 
 # Installing is simply copying all js files to js directory.