[MLton-commit] r4164

Matthew Fluet MLton@mlton.org
Sun, 6 Nov 2005 13:12:47 -0800


Need to setTargetType to "self" for non x86-linux platforms.


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

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

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

Modified: mlton/trunk/mlton/main/main.fun
===================================================================
--- mlton/trunk/mlton/main/main.fun	2005-11-06 20:04:36 UTC (rev 4163)
+++ mlton/trunk/mlton/main/main.fun	2005-11-06 21:12:46 UTC (rev 4164)
@@ -90,6 +90,17 @@
            end
       | _ => Error.bug (concat ["strange target mapping: ", line])))
 
+fun setTargetType (target: string, usage): unit =
+   case List.peek (targetMap (), fn {target = t, ...} => target = t) of
+      NONE => usage (concat ["invalid target: ", target])
+    | SOME {arch, os, ...} =>
+         let 
+            open Control
+         in
+            targetArch := arch
+            ; targetOS := os
+         end
+
 fun hasNative () =
    let
       datatype z = datatype Control.arch
@@ -439,9 +450,7 @@
         SpaceString
         (fn t =>
          (target := (if t = "self" then Self else Cross t);
-          case List.peek (targetMap (), fn {target = t', ...} => t = t') of
-             NONE => usage (concat ["invalid target: ", t])
-           | SOME {arch, os, ...} => (targetArch := arch; targetOS := os)))),
+          setTargetType (t, usage)))),
        (Normal, "target-as-opt", " <target> <opt>", "target-dependent assembler option",
         (SpaceString2
          (fn (target, opt) =>
@@ -501,6 +510,7 @@
                (libDir := OS.Path.mkCanonical lib
                 ; args)
           | _ => Error.bug "incorrect args from shell script"
+      val () = setTargetType ("self", usage)
       val result = parse args
       val targetArch = !targetArch
       val () =