src/Pure/System/build.ML
author wenzelm
Thu Jul 26 14:29:54 2012 +0200 (2012-07-26)
changeset 48516 c5d0f19ef7cb
parent 48513 ace120a2cb70
child 48520 6d4ea2efa64b
permissions -rw-r--r--
refined "document_dump_mode": "all", "tex+sty", "tex";
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@48486
    33
    |> Unsynchronized.setmp Printer.show_question_marks_default
wenzelm@48486
    34
        (Options.bool options "show_question_marks")
wenzelm@48486
    35
    |> Unsynchronized.setmp Name_Space.names_long_default (Options.bool options "names_long")
wenzelm@48486
    36
    |> Unsynchronized.setmp Name_Space.names_short_default (Options.bool options "names_short")
wenzelm@48492
    37
    |> Unsynchronized.setmp Name_Space.names_unique_default (Options.bool options "names_unique")
wenzelm@48492
    38
    |> Unsynchronized.setmp Toplevel.timing (Options.bool options "timing");
wenzelm@48457
    39
wenzelm@48465
    40
fun use_theories (options, thys) =
wenzelm@48465
    41
  let val condition = space_explode "," (Options.string options "condition") in
wenzelm@48465
    42
    (case filter_out (can getenv_strict) condition of
wenzelm@48465
    43
      [] => use_thys options thys
wenzelm@48465
    44
    | conds =>
wenzelm@48512
    45
        Output.physical_stderr ("Skipping theories " ^ commas_quote thys ^
wenzelm@48477
    46
          " (undefined " ^ commas conds ^ ")\n"))
wenzelm@48465
    47
  end;
wenzelm@48465
    48
wenzelm@48465
    49
in
wenzelm@48465
    50
wenzelm@48418
    51
fun build args_file =
wenzelm@48418
    52
  let
wenzelm@48511
    53
    val (do_output, (options, (timing, (verbose, (browser_info, (parent_base_name,
wenzelm@48459
    54
        (name, (base_name, theories)))))))) =
wenzelm@48418
    55
      File.read (Path.explode args_file) |> YXML.parse_body |>
wenzelm@48457
    56
        let open XML.Decode in
wenzelm@48459
    57
          pair bool (pair Options.decode (pair bool (pair bool (pair string (pair string
wenzelm@48459
    58
            (pair string (pair string ((list (pair Options.decode (list string)))))))))))
wenzelm@48457
    59
        end;
wenzelm@48418
    60
wenzelm@48457
    61
    val _ =
wenzelm@48511
    62
      Session.init do_output false
wenzelm@48457
    63
        (Options.bool options "browser_info") browser_info
wenzelm@48458
    64
        (Options.string options "document")
wenzelm@48457
    65
        (Options.bool options "document_graph")
wenzelm@48466
    66
        (space_explode ":" (Options.string options "document_variants"))
wenzelm@48482
    67
        parent_base_name base_name
wenzelm@48516
    68
        (Options.string options "document_dump", Options.string options "document_dump_mode")
wenzelm@48513
    69
        "" verbose;
wenzelm@48465
    70
    val _ = Session.with_timing name timing (List.app use_theories) theories;
wenzelm@48418
    71
    val _ = Session.finish ();
wenzelm@48511
    72
    val _ = if do_output then () else quit ();
wenzelm@48418
    73
  in () end
wenzelm@48418
    74
  handle exn => (Output.error_msg (ML_Compiler.exn_message exn); exit 1);
wenzelm@48418
    75
wenzelm@48418
    76
end;
wenzelm@48465
    77
wenzelm@48465
    78
end;