src/Pure/System/build.ML
author wenzelm
Tue Jul 24 00:29:36 2012 +0200 (2012-07-24)
changeset 48457 fd9e28d5a143
parent 48419 6d7b6e47f3ef
child 48458 09710d6fc3d1
permissions -rw-r--r--
pass build options to ML;
some imitation of usedir Session.init;
wenzelm@48418
     1
(*  Title:      Pure/System/build.ML
wenzelm@48418
     2
    Author:     Makarius
wenzelm@48418
     3
wenzelm@48418
     4
Build Isabelle sessions.
wenzelm@48418
     5
*)
wenzelm@48418
     6
wenzelm@48418
     7
signature BUILD =
wenzelm@48418
     8
sig
wenzelm@48418
     9
  val build: string -> unit
wenzelm@48418
    10
end;
wenzelm@48418
    11
wenzelm@48418
    12
structure Build: BUILD =
wenzelm@48418
    13
struct
wenzelm@48418
    14
wenzelm@48457
    15
fun use_theories name options =
wenzelm@48457
    16
  Thy_Info.use_thys
wenzelm@48457
    17
    |> Session.with_timing name (Options.bool options "timing")
wenzelm@48457
    18
    |> Unsynchronized.setmp Proofterm.proofs (Options.int options "proofs")
wenzelm@48457
    19
    |> Unsynchronized.setmp print_mode
wenzelm@48457
    20
        (space_explode "," (Options.string options "print_mode") @ print_mode_value ())
wenzelm@48457
    21
    |> Unsynchronized.setmp Goal.parallel_proofs (Options.int options "parallel_proofs")
wenzelm@48457
    22
    |> Unsynchronized.setmp Goal.parallel_proofs_threshold
wenzelm@48457
    23
        (Options.int options "parallel_proofs_threshold")
wenzelm@48457
    24
    |> Unsynchronized.setmp Multithreading.trace (Options.int options "threads_trace")
wenzelm@48457
    25
    |> Unsynchronized.setmp Multithreading.max_threads (Options.int options "threads_limit");
wenzelm@48457
    26
wenzelm@48418
    27
fun build args_file =
wenzelm@48418
    28
  let
wenzelm@48457
    29
    val (save, (options, (verbose, (browser_info, (parent, (name, (base_name, theories))))))) =
wenzelm@48418
    30
      File.read (Path.explode args_file) |> YXML.parse_body |>
wenzelm@48457
    31
        let open XML.Decode in
wenzelm@48457
    32
          pair bool (pair Options.decode (pair bool (pair string (pair string
wenzelm@48457
    33
            (pair string (pair string ((list (pair Options.decode (list string))))))))))
wenzelm@48457
    34
        end;
wenzelm@48418
    35
wenzelm@48457
    36
    val _ =
wenzelm@48457
    37
      Session.init
wenzelm@48457
    38
        save
wenzelm@48457
    39
        false (* FIXME reset!? *)
wenzelm@48457
    40
        (Options.bool options "browser_info") browser_info
wenzelm@48457
    41
        (Options.string options "document_format")   (* FIXME dependent on "document" (!?) *)
wenzelm@48457
    42
        (Options.bool options "document_graph")
wenzelm@48457
    43
        (space_explode "," (Options.string options "document_variants"))
wenzelm@48457
    44
        parent
wenzelm@48457
    45
        base_name
wenzelm@48457
    46
        (true (* FIXME copy document/ files on Scala side!? *),
wenzelm@48457
    47
          Options.string options "document_dump")
wenzelm@48457
    48
        ""
wenzelm@48457
    49
        verbose;
wenzelm@48457
    50
wenzelm@48457
    51
    val _ = List.app (uncurry (use_theories name)) theories;
wenzelm@48418
    52
    val _ = Session.finish ();
wenzelm@48418
    53
wenzelm@48419
    54
    val _ = if save then () else quit ();
wenzelm@48418
    55
  in () end
wenzelm@48418
    56
  handle exn => (Output.error_msg (ML_Compiler.exn_message exn); exit 1);
wenzelm@48418
    57
wenzelm@48418
    58
end;