src/Pure/System/build.ML
author wenzelm
Sat Aug 04 17:26:30 2012 +0200 (2012-08-04)
changeset 48673 b2b09970c571
parent 48672 9bc7922ba2ae
child 48681 181b91e1d1c1
permissions -rw-r--r--
let with_timing report overall number of threads;
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@48500
    17
fun no_document options =
wenzelm@48500
    18
  (case Options.string options "document" of "" => true | "false" => true | _ => false) andalso
wenzelm@48500
    19
  (Options.string options "document_dump" = "");
wenzelm@48500
    20
wenzelm@48465
    21
fun use_thys options =
wenzelm@48457
    22
  Thy_Info.use_thys
wenzelm@48457
    23
    |> Unsynchronized.setmp Proofterm.proofs (Options.int options "proofs")
wenzelm@48457
    24
    |> Unsynchronized.setmp print_mode
wenzelm@48457
    25
        (space_explode "," (Options.string options "print_mode") @ print_mode_value ())
wenzelm@48457
    26
    |> Unsynchronized.setmp Goal.parallel_proofs (Options.int options "parallel_proofs")
wenzelm@48457
    27
    |> Unsynchronized.setmp Goal.parallel_proofs_threshold
wenzelm@48457
    28
        (Options.int options "parallel_proofs_threshold")
wenzelm@48457
    29
    |> Unsynchronized.setmp Multithreading.trace (Options.int options "threads_trace")
wenzelm@48460
    30
    |> Unsynchronized.setmp Multithreading.max_threads (Options.int options "threads")
wenzelm@48500
    31
    |> no_document options ? Present.no_document
wenzelm@48486
    32
    |> Unsynchronized.setmp quick_and_dirty (Options.bool options "quick_and_dirty")
wenzelm@48634
    33
    |> Unsynchronized.setmp Toplevel.skip_proofs (Options.bool options "skip_proofs")
wenzelm@48486
    34
    |> Unsynchronized.setmp Printer.show_question_marks_default
wenzelm@48486
    35
        (Options.bool options "show_question_marks")
wenzelm@48486
    36
    |> Unsynchronized.setmp Name_Space.names_long_default (Options.bool options "names_long")
wenzelm@48486
    37
    |> Unsynchronized.setmp Name_Space.names_short_default (Options.bool options "names_short")
wenzelm@48492
    38
    |> Unsynchronized.setmp Name_Space.names_unique_default (Options.bool options "names_unique")
wenzelm@48520
    39
    |> Unsynchronized.setmp Thy_Output.display_default (Options.bool options "thy_output_display")
wenzelm@48520
    40
    |> Unsynchronized.setmp Thy_Output.quotes_default (Options.bool options "thy_output_quotes")
wenzelm@48520
    41
    |> Unsynchronized.setmp Thy_Output.indent_default (Options.int options "thy_output_indent")
wenzelm@48520
    42
    |> Unsynchronized.setmp Thy_Output.source_default (Options.bool options "thy_output_source")
wenzelm@48520
    43
    |> Unsynchronized.setmp Thy_Output.break_default (Options.bool options "thy_output_break")
wenzelm@48527
    44
    |> Unsynchronized.setmp Pretty.margin_default (Options.int options "pretty_margin")
wenzelm@48492
    45
    |> Unsynchronized.setmp Toplevel.timing (Options.bool options "timing");
wenzelm@48457
    46
wenzelm@48465
    47
fun use_theories (options, thys) =
wenzelm@48465
    48
  let val condition = space_explode "," (Options.string options "condition") in
wenzelm@48465
    49
    (case filter_out (can getenv_strict) condition of
wenzelm@48465
    50
      [] => use_thys options thys
wenzelm@48465
    51
    | conds =>
wenzelm@48512
    52
        Output.physical_stderr ("Skipping theories " ^ commas_quote thys ^
wenzelm@48477
    53
          " (undefined " ^ commas conds ^ ")\n"))
wenzelm@48465
    54
  end;
wenzelm@48465
    55
wenzelm@48465
    56
in
wenzelm@48465
    57
wenzelm@48672
    58
fun build args_file = uninterruptible (fn restore_attributes => fn () =>
wenzelm@48672
    59
  restore_attributes (fn () =>
wenzelm@48672
    60
    let
wenzelm@48672
    61
      val (do_output, (options, (verbose, (browser_info, (parent_name,
wenzelm@48672
    62
          (name, theories)))))) =
wenzelm@48672
    63
        File.read (Path.explode args_file) |> YXML.parse_body |>
wenzelm@48672
    64
          let open XML.Decode in
wenzelm@48672
    65
            pair bool (pair Options.decode (pair bool (pair string (pair string
wenzelm@48672
    66
              (pair string ((list (pair Options.decode (list string)))))))))
wenzelm@48672
    67
          end;
wenzelm@48418
    68
wenzelm@48672
    69
      val _ =
wenzelm@48672
    70
        Session.init do_output false
wenzelm@48672
    71
          (Options.bool options "browser_info") browser_info
wenzelm@48672
    72
          (Options.string options "document")
wenzelm@48672
    73
          (Options.bool options "document_graph")
wenzelm@48672
    74
          (space_explode ":" (Options.string options "document_variants"))
wenzelm@48672
    75
          parent_name name
wenzelm@48672
    76
          (Options.string options "document_dump",
wenzelm@48672
    77
            Present.dump_mode (Options.string options "document_dump_mode"))
wenzelm@48672
    78
          "" verbose;
wenzelm@48673
    79
      val _ =
wenzelm@48673
    80
        theories |>
wenzelm@48673
    81
          (List.app use_theories
wenzelm@48673
    82
            |> Session.with_timing name verbose
wenzelm@48673
    83
            |> Unsynchronized.setmp Multithreading.max_threads (Options.int options "threads"));
wenzelm@48673
    84
wenzelm@48672
    85
      val _ = Session.finish ();
wenzelm@48672
    86
      val _ = if do_output then () else quit ();
wenzelm@48672
    87
    in () end) ()) ()
wenzelm@48662
    88
  handle exn =>
wenzelm@48662
    89
    (Output.error_msg (ML_Compiler.exn_message exn);
wenzelm@48662
    90
     if Exn.is_interrupt exn then exit 130 else exit 1);
wenzelm@48418
    91
wenzelm@48418
    92
end;
wenzelm@48465
    93
wenzelm@48465
    94
end;