Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /sml/trunk/src/system/smlnj/internal/boot-env-fn.sml
ViewVC logotype

View of /sml/trunk/src/system/smlnj/internal/boot-env-fn.sml

Parent Directory Parent Directory | Revision Log Revision Log

Revision 573 - (download) (annotate)
Thu Mar 9 15:23:52 2000 UTC (20 years, 4 months ago) by blume
File size: 2841 byte(s)
merging back changes from blume_devel_v110_26_2
 * Copyright 1996 by Bell Laboratories
 *  boot.sml -- bootstrap environments
 *   completely redone by M.Blume (5/1998)
 *   ... and again in the course of switching over to the new CM
 *       (M. Blume, 7/1999)
signature BOOTENV = sig
    val init:
	string -> { heapfile: string, procCmdLine: (unit -> unit) option }

functor BootEnvF (datatype envrequest = AUTOLOAD | BARE
		  val architecture: string
		  val cminit : string * DynamicEnv.dynenv * envrequest ->
		               (unit -> unit) option
		  val cmbmake: string -> unit) :> BOOTENV = struct

    exception BootFailure

    (* To be able to use ml-yacc and ml-lex at -rebuild time it is necessary
     * to force their plugins to be _always_ plugged in.  We achieve this
     * by simply mentioning the structure names here. *)
    structure YaccTool = YaccTool and LexTool = LexTool

    structure DynE = DynamicEnv
    structure Print = GenericVC.Control.Print

    fun say s = (Print.say s; Print.flush ())
    fun die s = (say s; raise BootFailure)

    (* just run CMB.make to make a new set of binfiles... *)
    fun recompile bindir =
	(say (concat ["[building new binfiles in ", bindir, "]\n"]);
	 cmbmake bindir;
	 OS.Process.exit OS.Process.success)

	structure U = Unsafe
	fun initialize (bootdir, er) = let
	    fun mkDE (U.NILrde, de) = de
	      | mkDE (U.CONSrde (rawdynpid, obj, rest), de) = let
		    val dynpid = GenericVC.PersStamps.fromBytes rawdynpid
		    mkDE (rest, DynE.bind (dynpid, obj, de))
	    val de = mkDE (!U.pStruct, DynE.empty)
	    U.pStruct := U.NILrde;
	    cminit (bootdir, de, er)

    fun init bootdir = let
	(* grab relevant command line arguments... *)
	fun vArg (prefix, arg) =
	    if String.isPrefix prefix arg then
		SOME (String.extract (arg, size prefix, NONE))
	    else NONE
	fun bootArgs ([], newbindir, heapfile, er) = (newbindir, heapfile, er)
	  | bootArgs ("@SMLbare" :: rest, newbindir, heapfile, _) =
	    bootArgs (rest, newbindir, heapfile, BARE)
	  | bootArgs (head :: rest, newbindir, heapfile, er) =
	    (case vArg ("@SMLrebuild=", head) of
		 nbd as SOME _ => bootArgs (rest, nbd, heapfile, er)
	       | NONE =>
		     (case vArg ("@SMLheap=", head) of
			  SOME hf => bootArgs (rest, newbindir, hf, er)
			| NONE => bootArgs (rest, newbindir, heapfile, er)))

	val (newbindir, heapfile, er) =
	    bootArgs (SMLofNJ.getAllArgs (),
		      "sml." ^ architecture,
	val newbindir = Option.map OS.Path.mkCanonical newbindir
	case newbindir of
	    NONE => let
		val procCmdLine = initialize (bootdir, er)
		{ heapfile = heapfile, procCmdLine = procCmdLine }
	  | SOME nbd =>
		if nbd = bootdir then
		    die "@SMLboot= and @SMLrebuild= name the same directory\n"
		else recompile nbd

ViewVC Help
Powered by ViewVC 1.0.0