OSDN Git Service

I've added --keep-files option to save temporary files.
authormzp <mzpppp@gmail.com>
Tue, 17 Mar 2009 00:00:28 +0000 (09:00 +0900)
committermzp <mzpppp@gmail.com>
Tue, 17 Mar 2009 00:00:28 +0000 (09:00 +0900)
ChangeLog
driver/src/cmdOpt.ml
driver/src/cmdOpt.mli
driver/src/main.ml

index e94f315..8af5701 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 Version 0.4.1
-       * Support -I option.
+       * Add -I option. Add include directories
        * Add standard library(std and flash)
+       * Add --keep-files to keep temporary files
 
 Version 0.4.0
        * Support module
index ab9f71d..ba1b6fa 100644 (file)
@@ -26,8 +26,9 @@ type swfx = {
 }
 
 type general = {
-  verbose: bool;
+  verbose:    bool;
   just_print: bool;
+  keep_files: bool;
 }
 
 type t = {
@@ -173,9 +174,16 @@ let general =
       ~short_name:'n'
       ~long_name:"just-print"
       ~help:"Don't actually run any commands; just print them" () in
+  let keep_files =
+    bool_option
+      ~default:false
+      ~short_name:'k'
+      ~long_name:"keep-files"
+      ~help:"Keep temporary files" () in
     fun () -> {
-      verbose = Opt.get verbose;
+      verbose    = Opt.get verbose;
       just_print = Opt.get just_print;
+      keep_files = Opt.get keep_files
     }
 
 let output_type =
index 4ab943a..3919f64 100644 (file)
@@ -8,8 +8,16 @@ type abcx = {
   main_class: string;
 }
 
-type swfx = { swfx_cmd : string; }
-type general = { verbose : bool; just_print: bool; }
+type swfx = {
+  swfx_cmd : string;
+}
+
+type general = {
+  verbose : bool;
+  just_print: bool;
+  keep_files: bool;
+}
+
 type t = {
   inputs : string list;
   output : string;
index 6807d0e..f95604c 100644 (file)
@@ -43,7 +43,7 @@ let rules = [
             "__ABCX__",input;
             "__MAIN_CLASS__",main;
             "__WIDTH__",string_of_int w;
-            "__HEIGHT__",string_of_int h; 
+            "__HEIGHT__",string_of_int h;
           ])
          template output]);
   one_to_one "swfx" "swf"
@@ -84,8 +84,11 @@ let main _ =
     Rule.commands ctx rules inputs output in
     if ctx.general.just_print then
       List.iter print_endline commands
-    else
-      execute ctx commands
+    else begin
+      execute ctx commands;
+      if not ctx.general.keep_files then
+       List.iter Sys.remove @@ Rule.temp_files ctx rules inputs output
+    end
 
 let _ =
   if not !Sys.interactive then