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