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