src/Pure/System/build.ML
author wenzelm
Sun Nov 18 19:01:30 2012 +0100 (2012-11-18 ago)
changeset 50121 97d2b77313a0
parent 49911 262c36fd5f26
child 50255 d0ec1f0d1d7d
permissions -rw-r--r--
isabelle build no longer supports document_dump/document_dump_mode (no INCOMPATIBILITY, since it was never in official release);
always generate sty files, as before c5d0f19ef7cb;
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@50121
    18
  (case Options.string options "document" of "" => true | "false" => true | _ => false);
wenzelm@48500
    19
wenzelm@48465
    20
fun use_thys options =
wenzelm@48457
    21
  Thy_Info.use_thys
wenzelm@48457
    22
    |> Unsynchronized.setmp Proofterm.proofs (Options.int options "proofs")
wenzelm@48457
    23
    |> Unsynchronized.setmp print_mode
wenzelm@48457
    24
        (space_explode "," (Options.string options "print_mode") @ print_mode_value ())
wenzelm@48457
    25
    |> Unsynchronized.setmp Goal.parallel_proofs (Options.int options "parallel_proofs")
wenzelm@48457
    26
    |> Unsynchronized.setmp Goal.parallel_proofs_threshold
wenzelm@48457
    27
        (Options.int options "parallel_proofs_threshold")
wenzelm@48457
    28
    |> Unsynchronized.setmp Multithreading.trace (Options.int options "threads_trace")
wenzelm@48460
    29
    |> Unsynchronized.setmp Multithreading.max_threads (Options.int options "threads")
wenzelm@48500
    30
    |> no_document options ? Present.no_document
wenzelm@48486
    31
    |> Unsynchronized.setmp quick_and_dirty (Options.bool options "quick_and_dirty")
wenzelm@48634
    32
    |> Unsynchronized.setmp Toplevel.skip_proofs (Options.bool options "skip_proofs")
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@48520
    38
    |> Unsynchronized.setmp Thy_Output.display_default (Options.bool options "thy_output_display")
wenzelm@48520
    39
    |> Unsynchronized.setmp Thy_Output.quotes_default (Options.bool options "thy_output_quotes")
wenzelm@48520
    40
    |> Unsynchronized.setmp Thy_Output.indent_default (Options.int options "thy_output_indent")
wenzelm@48520
    41
    |> Unsynchronized.setmp Thy_Output.source_default (Options.bool options "thy_output_source")
wenzelm@48520
    42
    |> Unsynchronized.setmp Thy_Output.break_default (Options.bool options "thy_output_break")
wenzelm@48527
    43
    |> Unsynchronized.setmp Pretty.margin_default (Options.int options "pretty_margin")
wenzelm@48492
    44
    |> Unsynchronized.setmp Toplevel.timing (Options.bool options "timing");
wenzelm@48457
    45
wenzelm@48465
    46
fun use_theories (options, thys) =
wenzelm@48465
    47
  let val condition = space_explode "," (Options.string options "condition") in
wenzelm@48465
    48
    (case filter_out (can getenv_strict) condition of
wenzelm@48927
    49
      [] => use_thys options (map (rpair Position.none) thys)
wenzelm@48465
    50
    | conds =>
wenzelm@48512
    51
        Output.physical_stderr ("Skipping theories " ^ commas_quote thys ^
wenzelm@48477
    52
          " (undefined " ^ commas conds ^ ")\n"))
wenzelm@48465
    53
  end;
wenzelm@48465
    54
wenzelm@48465
    55
in
wenzelm@48465
    56
wenzelm@48681
    57
fun build args_file = Command_Line.tool (fn () =>
wenzelm@48672
    58
    let
wenzelm@48672
    59
      val (do_output, (options, (verbose, (browser_info, (parent_name,
wenzelm@48672
    60
          (name, theories)))))) =
wenzelm@48672
    61
        File.read (Path.explode args_file) |> YXML.parse_body |>
wenzelm@48672
    62
          let open XML.Decode in
wenzelm@48672
    63
            pair bool (pair Options.decode (pair bool (pair string (pair string
wenzelm@48672
    64
              (pair string ((list (pair Options.decode (list string)))))))))
wenzelm@48672
    65
          end;
wenzelm@48418
    66
wenzelm@48804
    67
      val document_variants =
wenzelm@48804
    68
        map Present.read_variant (space_explode ":" (Options.string options "document_variants"));
wenzelm@48672
    69
      val _ =
wenzelm@48805
    70
        (case duplicates (op =) (map fst document_variants) of
wenzelm@48805
    71
          [] => ()
wenzelm@48805
    72
        | dups => error ("Duplicate document variants: " ^ commas_quote dups));
wenzelm@49242
    73
wenzelm@49242
    74
      val _ =
wenzelm@48672
    75
        Session.init do_output false
wenzelm@48672
    76
          (Options.bool options "browser_info") browser_info
wenzelm@48672
    77
          (Options.string options "document")
wenzelm@48672
    78
          (Options.bool options "document_graph")
wenzelm@48805
    79
          (Options.string options "document_output")
wenzelm@48804
    80
          document_variants
wenzelm@48672
    81
          parent_name name
wenzelm@50121
    82
          (false, "") ""
wenzelm@50121
    83
          verbose;
wenzelm@49911
    84
wenzelm@49911
    85
      val res1 =
wenzelm@48673
    86
        theories |>
wenzelm@48673
    87
          (List.app use_theories
wenzelm@48673
    88
            |> Session.with_timing name verbose
wenzelm@49911
    89
            |> Unsynchronized.setmp Multithreading.max_threads (Options.int options "threads")
wenzelm@49911
    90
            |> Exn.capture);
wenzelm@49911
    91
      val res2 = Exn.capture Session.finish ();
wenzelm@49911
    92
      val _ = Par_Exn.release_all [res1, res2];
wenzelm@48673
    93
wenzelm@48734
    94
      val _ = if do_output then () else exit 0;
wenzelm@48681
    95
    in 0 end);
wenzelm@48418
    96
wenzelm@48418
    97
end;
wenzelm@48465
    98
wenzelm@48465
    99
end;