src/Pure/System/build.ML
author wenzelm
Wed Aug 08 12:33:40 2012 +0200 (2012-08-08 ago)
changeset 48731 a45ba78abcc1
parent 48681 181b91e1d1c1
child 48734 af91cd2301ba
permissions -rw-r--r--
more casual exit back to ML toplevel, to accomodate commit in SML/NJ which continues at the saved point;
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@48731
     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@48681
    58
fun build args_file = Command_Line.tool (fn () =>
wenzelm@48672
    59
    let
wenzelm@48672
    60
      val (do_output, (options, (verbose, (browser_info, (parent_name,
wenzelm@48672
    61
          (name, theories)))))) =
wenzelm@48672
    62
        File.read (Path.explode args_file) |> YXML.parse_body |>
wenzelm@48672
    63
          let open XML.Decode in
wenzelm@48672
    64
            pair bool (pair Options.decode (pair bool (pair string (pair string
wenzelm@48672
    65
              (pair string ((list (pair Options.decode (list string)))))))))
wenzelm@48672
    66
          end;
wenzelm@48418
    67
wenzelm@48672
    68
      val _ =
wenzelm@48672
    69
        Session.init do_output false
wenzelm@48672
    70
          (Options.bool options "browser_info") browser_info
wenzelm@48672
    71
          (Options.string options "document")
wenzelm@48672
    72
          (Options.bool options "document_graph")
wenzelm@48672
    73
          (space_explode ":" (Options.string options "document_variants"))
wenzelm@48672
    74
          parent_name name
wenzelm@48672
    75
          (Options.string options "document_dump",
wenzelm@48672
    76
            Present.dump_mode (Options.string options "document_dump_mode"))
wenzelm@48672
    77
          "" verbose;
wenzelm@48673
    78
      val _ =
wenzelm@48673
    79
        theories |>
wenzelm@48673
    80
          (List.app use_theories
wenzelm@48673
    81
            |> Session.with_timing name verbose
wenzelm@48673
    82
            |> Unsynchronized.setmp Multithreading.max_threads (Options.int options "threads"));
wenzelm@48673
    83
wenzelm@48672
    84
      val _ = Session.finish ();
wenzelm@48681
    85
      val _ = if do_output then Secure.commit () else ();
wenzelm@48681
    86
    in 0 end);
wenzelm@48418
    87
wenzelm@48418
    88
end;
wenzelm@48465
    89
wenzelm@48465
    90
end;