src/Pure/System/build.ML
author wenzelm
Tue Jul 24 17:15:26 2012 +0200 (2012-07-24)
changeset 48477 322fbf571782
parent 48472 6ebb6cdd36a5
child 48482 45137257399a
permissions -rw-r--r--
tuned message;
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@48465
    15
local
wenzelm@48465
    16
wenzelm@48465
    17
fun use_thys options =
wenzelm@48457
    18
  Thy_Info.use_thys
wenzelm@48457
    19
    |> Unsynchronized.setmp Proofterm.proofs (Options.int options "proofs")
wenzelm@48457
    20
    |> Unsynchronized.setmp print_mode
wenzelm@48457
    21
        (space_explode "," (Options.string options "print_mode") @ print_mode_value ())
wenzelm@48457
    22
    |> Unsynchronized.setmp Goal.parallel_proofs (Options.int options "parallel_proofs")
wenzelm@48457
    23
    |> Unsynchronized.setmp Goal.parallel_proofs_threshold
wenzelm@48457
    24
        (Options.int options "parallel_proofs_threshold")
wenzelm@48457
    25
    |> Unsynchronized.setmp Multithreading.trace (Options.int options "threads_trace")
wenzelm@48460
    26
    |> Unsynchronized.setmp Multithreading.max_threads (Options.int options "threads")
wenzelm@48472
    27
    |> (case Options.string options "document" of "" => true | "false" => true | _ => false) ?
wenzelm@48470
    28
        Present.no_document
wenzelm@48464
    29
    |> Unsynchronized.setmp quick_and_dirty (Options.bool options "quick_and_dirty");
wenzelm@48457
    30
wenzelm@48465
    31
fun use_theories (options, thys) =
wenzelm@48465
    32
  let val condition = space_explode "," (Options.string options "condition") in
wenzelm@48465
    33
    (case filter_out (can getenv_strict) condition of
wenzelm@48465
    34
      [] => use_thys options thys
wenzelm@48465
    35
    | conds =>
wenzelm@48465
    36
        Output.physical_stderr ("Ignoring theories " ^ commas_quote thys ^
wenzelm@48477
    37
          " (undefined " ^ commas conds ^ ")\n"))
wenzelm@48465
    38
  end;
wenzelm@48465
    39
wenzelm@48465
    40
in
wenzelm@48465
    41
wenzelm@48418
    42
fun build args_file =
wenzelm@48418
    43
  let
wenzelm@48459
    44
    val (save, (options, (timing, (verbose, (browser_info, (parent,
wenzelm@48459
    45
        (name, (base_name, theories)))))))) =
wenzelm@48418
    46
      File.read (Path.explode args_file) |> YXML.parse_body |>
wenzelm@48457
    47
        let open XML.Decode in
wenzelm@48459
    48
          pair bool (pair Options.decode (pair bool (pair bool (pair string (pair string
wenzelm@48459
    49
            (pair string (pair string ((list (pair Options.decode (list string)))))))))))
wenzelm@48457
    50
        end;
wenzelm@48418
    51
wenzelm@48457
    52
    val _ =
wenzelm@48462
    53
      Session.init save false
wenzelm@48457
    54
        (Options.bool options "browser_info") browser_info
wenzelm@48458
    55
        (Options.string options "document")
wenzelm@48457
    56
        (Options.bool options "document_graph")
wenzelm@48466
    57
        (space_explode ":" (Options.string options "document_variants"))
wenzelm@48462
    58
        parent base_name
wenzelm@48468
    59
        (not (Options.bool options "document_dump_only"), Options.string options "document_dump")
wenzelm@48463
    60
        (Options.string options "browser_info_remote")
wenzelm@48457
    61
        verbose;
wenzelm@48465
    62
    val _ = Session.with_timing name timing (List.app use_theories) theories;
wenzelm@48418
    63
    val _ = Session.finish ();
wenzelm@48419
    64
    val _ = if save then () else quit ();
wenzelm@48418
    65
  in () end
wenzelm@48418
    66
  handle exn => (Output.error_msg (ML_Compiler.exn_message exn); exit 1);
wenzelm@48418
    67
wenzelm@48418
    68
end;
wenzelm@48465
    69
wenzelm@48465
    70
end;