0201.Scala SDK (bin/*)

Scala Development Kit / Commands

Scala 在安裝後, 會在其所在位置的 /bin 裡, 放置許多有用的指令集給你協助開發.
  • $SCALA_HOME/bin/*
Setting the Classpath [Solaris and Linux] [Windows]
How Classes are Found [Solaris, Linux and Windows]



bin/scala*


Basic Tools (sbaz, fsc, scala, scalac, scaladoc, scalap)
fsc         The fast Scala compiler.
sbaz        The Scala sharing tool.
scala       Run Scala code.
scalac      Compile Scala code ahead of time.
scaladoc    The API document generator.
scalap      The Scala class file decoder.


scala (主程式)


$ scala
    執行 Scala 互動式終端介面

$ scala [FileName].scala
   
執行以 Scala 編寫的 Scripts

    $ scala [ClassName]
       
執行被編譯成 .class 二進位 Bytecode 的 Scala 檔


$ scala -e "script..."



scalac (編譯器/Compiler)


$ scalac [FileName].scala
   
編譯成二進位 Bytecode 的 .class 檔





fsc(快速 Scala 編譯器)


fsc 是個很棒的設計 ... Scala編譯器後台服務:daemon
通常在你進行編譯完成之前或許會有一個可感知的停頓。原因在於每次編譯器啟動時,它都要花一些時間來掃瞄 jar 的文件內容,並且就算你送交的是新原始碼文件, 也仍會進行再次編輯器初始化的工作。因此,Scala 的 /bin 裡還包括了一個叫做 fsc

你可以這樣使用
$ fsc Fish.scala Summer.scala

第一次執行 fsc 時,會創建一個綁定在你電腦Port上的本地 Server 後台進程。然後它就會把文件列表通過端口發送給後台進程去編譯,後台進程完成編譯。下一 次你執行 fsc 時,後台進程就已經在運行了,於是 fsc 將只是把文件列表發給後台進程,它會立刻開始編譯文件。使用 fsc,你只需要在第一次等待 Java 運行時環境的啟動。如果想停止 fsc 後台進程,可以執行 fsc -shutdown 來關閉。

不論執行 scalac 還是 fsc 命令,都將創建 Java class 文件,然後你可以用 scala 命令,就像之前的例子裡調用解釋器那樣運行它。

fsc man page, http://www.scala-lang.org/docu/files/tools/fsc.html


ChaoYi$ fsc -help
Usage: fsc <options> <source files>
where possible standard options include:
  -D<prop>                       set a Java property
  -J<flag>                       Pass <flag> directly to runtime system
  -P:<plugin>:<opt>              Pass an option to a plugin
  -X                             Print a synopsis of advanced options
  -bootclasspath <path>          Override location of bootstrap class files
  -classpath <path>              Specify where to find user class files
  -d <directory>                 Specify where to place generated class files
  -dependencyfile <file>         Specify the file in which dependencies are tracked
  -deprecation                   Output source locations where deprecated APIs are used
  -encoding <encoding>           Specify character encoding used by source files
  -explaintypes                  Explain type errors in more detail
  -extdirs <dirs>                Override location of installed extensions
  -g:<g>                         Specify level of generated debugging info (none,source,line,vars,notailcalls)
  -help                          Print a synopsis of standard options
  -javabootclasspath <path>      Override java boot classpath.
  -javaextdirs <path>            Override java extdirs classpath.
  -make:<strategy>               Specify recompilation detection strategy (all,changed,immediate,transitive,transitivenocp)
  -no-specialization             Ignore @specialize annotations.
  -nowarn                        Generate no warnings
  -optimise                      Generates faster bytecode by applying optimisations to the program
  -print                         Print program with all Scala-specific features removed
  -reset                         Reset compile server caches
  -server <hostname:portnumber>  Specify compile server socket
  -shutdown                      Shutdown the fsc daemon
  -sourcepath <path>             Specify where to find input source files
  -target:<target>               Specify for which target object files should be built (jvm-1.5,msil)
  -unchecked                     Enable detailed unchecked warnings
  -uniqid                        Print identifiers with unique names for debugging
  -usejavacp                     Utilize the java.class.path in classpath resolution.
  -verbose                       Output messages about what the compiler is doing
  -version                       Print product version and exit
  @<file>                        A text file containing compiler arguments (options and source files)
Options for plugin continuations:
  -P:continuations:enable        Enable continuations




scaladoc (API文件產生器)


$ scaladoc
   
產出 Scala API 說明文件




scalap (反編譯器)







References


scala(1), scalac(1), scaladoc(1)
Comments