src/Pure/System/build.ML
author wenzelm
Thu, 26 Jul 2012 13:38:43 +0200
changeset 49528 ace120a2cb70
parent 49527 a69d7dc49f41
child 49531 c5d0f19ef7cb
permissions -rw-r--r--
discontinued slightly odd "browser_info_remote" -- it could point to a completely different version of the Isabelle library;
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@49480
    15
local
wenzelm@49480
    16
wenzelm@49515
    17
fun no_document options =
wenzelm@49515
    18
  (case Options.string options "document" of "" => true | "false" => true | _ => false) andalso
wenzelm@49515
    19
  (Options.string options "document_dump" = "");
wenzelm@49515
    20
wenzelm@49480
    21
fun use_thys options =
wenzelm@49472
    22
  Thy_Info.use_thys
wenzelm@49472
    23
    |> Unsynchronized.setmp Proofterm.proofs (Options.int options "proofs")
wenzelm@49472
    24
    |> Unsynchronized.setmp print_mode
wenzelm@49472
    25
        (space_explode "," (Options.string options "print_mode") @ print_mode_value ())
wenzelm@49472
    26
    |> Unsynchronized.setmp Goal.parallel_proofs (Options.int options "parallel_proofs")
wenzelm@49472
    27
    |> Unsynchronized.setmp Goal.parallel_proofs_threshold
wenzelm@49472
    28
        (Options.int options "parallel_proofs_threshold")
wenzelm@49472
    29
    |> Unsynchronized.setmp Multithreading.trace (Options.int options "threads_trace")
wenzelm@49475
    30
    |> Unsynchronized.setmp Multithreading.max_threads (Options.int options "threads")
wenzelm@49515
    31
    |> no_document options ? Present.no_document
wenzelm@49501
    32
    |> Unsynchronized.setmp quick_and_dirty (Options.bool options "quick_and_dirty")
wenzelm@49501
    33
    |> Unsynchronized.setmp Printer.show_question_marks_default
wenzelm@49501
    34
        (Options.bool options "show_question_marks")
wenzelm@49501
    35
    |> Unsynchronized.setmp Name_Space.names_long_default (Options.bool options "names_long")
wenzelm@49501
    36
    |> Unsynchronized.setmp Name_Space.names_short_default (Options.bool options "names_short")
wenzelm@49507
    37
    |> Unsynchronized.setmp Name_Space.names_unique_default (Options.bool options "names_unique")
wenzelm@49507
    38
    |> Unsynchronized.setmp Toplevel.timing (Options.bool options "timing");
wenzelm@49472
    39
wenzelm@49480
    40
fun use_theories (options, thys) =
wenzelm@49480
    41
  let val condition = space_explode "," (Options.string options "condition") in
wenzelm@49480
    42
    (case filter_out (can getenv_strict) condition of
wenzelm@49480
    43
      [] => use_thys options thys
wenzelm@49480
    44
    | conds =>
wenzelm@49527
    45
        Output.physical_stderr ("Skipping theories " ^ commas_quote thys ^
wenzelm@49492
    46
          " (undefined " ^ commas conds ^ ")\n"))
wenzelm@49480
    47
  end;
wenzelm@49480
    48
wenzelm@49480
    49
in
wenzelm@49480
    50
wenzelm@49433
    51
fun build args_file =
wenzelm@49433
    52
  let
wenzelm@49526
    53
    val (do_output, (options, (timing, (verbose, (browser_info, (parent_base_name,
wenzelm@49474
    54
        (name, (base_name, theories)))))))) =
wenzelm@49433
    55
      File.read (Path.explode args_file) |> YXML.parse_body |>
wenzelm@49472
    56
        let open XML.Decode in
wenzelm@49474
    57
          pair bool (pair Options.decode (pair bool (pair bool (pair string (pair string
wenzelm@49474
    58
            (pair string (pair string ((list (pair Options.decode (list string)))))))))))
wenzelm@49472
    59
        end;
wenzelm@49433
    60
wenzelm@49472
    61
    val _ =
wenzelm@49526
    62
      Session.init do_output false
wenzelm@49472
    63
        (Options.bool options "browser_info") browser_info
wenzelm@49473
    64
        (Options.string options "document")
wenzelm@49472
    65
        (Options.bool options "document_graph")
wenzelm@49481
    66
        (space_explode ":" (Options.string options "document_variants"))
wenzelm@49497
    67
        parent_base_name base_name
wenzelm@49483
    68
        (not (Options.bool options "document_dump_only"), Options.string options "document_dump")
wenzelm@49528
    69
        "" verbose;
wenzelm@49480
    70
    val _ = Session.with_timing name timing (List.app use_theories) theories;
wenzelm@49433
    71
    val _ = Session.finish ();
wenzelm@49526
    72
    val _ = if do_output then () else quit ();
wenzelm@49433
    73
  in () end
wenzelm@49433
    74
  handle exn => (Output.error_msg (ML_Compiler.exn_message exn); exit 1);
wenzelm@49433
    75
wenzelm@49433
    76
end;
wenzelm@49480
    77
wenzelm@49480
    78
end;