[MLton-commit] r6992

Ville Laurikari ville at mlton.org
Fri Nov 21 05:23:22 PST 2008


Now "-stop o" and "-stop g" use the name given with "-output ..." so
the location and name for the generated files can be customized.

Because "-stop o" and "-stop g" typically generate multiple files, the
suffix (if any) is first stripped from the name given with -output.

For example, this allows one to add "-stop o" to a command to build an
executable with "-output bar/foo.exe" and still get a reasonable
result: object files in bar/foo.*.o.

----------------------------------------------------------------------

U   mlton/trunk/mlton/main/main.fun

----------------------------------------------------------------------

Modified: mlton/trunk/mlton/main/main.fun
===================================================================
--- mlton/trunk/mlton/main/main.fun	2008-11-16 15:10:19 UTC (rev 6991)
+++ mlton/trunk/mlton/main/main.fun	2008-11-21 13:23:21 UTC (rev 6992)
@@ -1159,6 +1159,10 @@
                         case !output of
                            NONE => suffix suf
                          | SOME f => f
+                     fun maybeOutBase suf =
+                        case !output of
+                           NONE => suffix suf
+                         | SOME f => concat [File.base f, suf]
                      val { base = outputBase, ext=_ } =
                         OS.Path.splitBaseExt (maybeOut ".ext")
                      val { file = defLibname, dir=_ } =
@@ -1266,14 +1270,12 @@
                            if !keepGenerated
                               orelse start = Place.Generated
                               then
-                                 concat [File.base input,
-                                         ".o"]
+                                 maybeOutBase ".o"
                               else
-                                 suffix
-                                 (concat [".",
-                                          Int.toString
-                                          (Counter.next c),
-                                          ".o"])
+                                 maybeOutBase
+                                    (concat [".",
+                                             Int.toString (Counter.next c),
+                                             ".o"])
                         else temp ".o"
                   fun compileC (c: Counter.t, input: File.t): File.t =
                      let
@@ -1354,7 +1356,7 @@
                               val _ = Int.inc r
                               val file = (if !keepGenerated
                                              orelse stop = Place.Generated
-                                             then suffix
+                                             then maybeOutBase
                                           else temp) suf
                               val _ = List.push (outputs, file)
                               val out = Out.openOut file




More information about the MLton-commit mailing list