src/Pure/System/build.ML
author wenzelm
Wed, 01 Aug 2012 15:46:45 +0200
changeset 48634 30a6e841390a
parent 48545 c168bc64f2a8
child 48662 b171bcd5dd86
permissions -rw-r--r--
explicit option skip_proofs;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
48418
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/System/build.ML
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
     3
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
     4
Build Isabelle sessions.
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
     5
*)
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
     6
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
     7
signature BUILD =
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
     8
sig
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
     9
  val build: string -> unit
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    10
end;
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    11
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    12
structure Build: BUILD =
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    13
struct
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    14
48465
a25daffda966 observe "condition";
wenzelm
parents: 48464
diff changeset
    15
local
a25daffda966 observe "condition";
wenzelm
parents: 48464
diff changeset
    16
48500
bf7f434b91d7 clarified no_document situation;
wenzelm
parents: 48492
diff changeset
    17
fun no_document options =
bf7f434b91d7 clarified no_document situation;
wenzelm
parents: 48492
diff changeset
    18
  (case Options.string options "document" of "" => true | "false" => true | _ => false) andalso
bf7f434b91d7 clarified no_document situation;
wenzelm
parents: 48492
diff changeset
    19
  (Options.string options "document_dump" = "");
bf7f434b91d7 clarified no_document situation;
wenzelm
parents: 48492
diff changeset
    20
48465
a25daffda966 observe "condition";
wenzelm
parents: 48464
diff changeset
    21
fun use_thys options =
48457
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    22
  Thy_Info.use_thys
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    23
    |> Unsynchronized.setmp Proofterm.proofs (Options.int options "proofs")
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    24
    |> Unsynchronized.setmp print_mode
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    25
        (space_explode "," (Options.string options "print_mode") @ print_mode_value ())
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    26
    |> Unsynchronized.setmp Goal.parallel_proofs (Options.int options "parallel_proofs")
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    27
    |> Unsynchronized.setmp Goal.parallel_proofs_threshold
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    28
        (Options.int options "parallel_proofs_threshold")
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    29
    |> Unsynchronized.setmp Multithreading.trace (Options.int options "threads_trace")
48460
20170ae271a5 tuned options;
wenzelm
parents: 48459
diff changeset
    30
    |> Unsynchronized.setmp Multithreading.max_threads (Options.int options "threads")
48500
bf7f434b91d7 clarified no_document situation;
wenzelm
parents: 48492
diff changeset
    31
    |> no_document options ? Present.no_document
48486
691d0b44a793 more build options;
wenzelm
parents: 48482
diff changeset
    32
    |> Unsynchronized.setmp quick_and_dirty (Options.bool options "quick_and_dirty")
48634
30a6e841390a explicit option skip_proofs;
wenzelm
parents: 48545
diff changeset
    33
    |> Unsynchronized.setmp Toplevel.skip_proofs (Options.bool options "skip_proofs")
48486
691d0b44a793 more build options;
wenzelm
parents: 48482
diff changeset
    34
    |> Unsynchronized.setmp Printer.show_question_marks_default
691d0b44a793 more build options;
wenzelm
parents: 48482
diff changeset
    35
        (Options.bool options "show_question_marks")
691d0b44a793 more build options;
wenzelm
parents: 48482
diff changeset
    36
    |> Unsynchronized.setmp Name_Space.names_long_default (Options.bool options "names_long")
691d0b44a793 more build options;
wenzelm
parents: 48482
diff changeset
    37
    |> Unsynchronized.setmp Name_Space.names_short_default (Options.bool options "names_short")
48492
03530cf284ca more build options;
wenzelm
parents: 48486
diff changeset
    38
    |> Unsynchronized.setmp Name_Space.names_unique_default (Options.bool options "names_unique")
48520
6d4ea2efa64b more build options;
wenzelm
parents: 48516
diff changeset
    39
    |> Unsynchronized.setmp Thy_Output.display_default (Options.bool options "thy_output_display")
6d4ea2efa64b more build options;
wenzelm
parents: 48516
diff changeset
    40
    |> Unsynchronized.setmp Thy_Output.quotes_default (Options.bool options "thy_output_quotes")
6d4ea2efa64b more build options;
wenzelm
parents: 48516
diff changeset
    41
    |> Unsynchronized.setmp Thy_Output.indent_default (Options.int options "thy_output_indent")
6d4ea2efa64b more build options;
wenzelm
parents: 48516
diff changeset
    42
    |> Unsynchronized.setmp Thy_Output.source_default (Options.bool options "thy_output_source")
6d4ea2efa64b more build options;
wenzelm
parents: 48516
diff changeset
    43
    |> Unsynchronized.setmp Thy_Output.break_default (Options.bool options "thy_output_break")
48527
4ee8d70cd5a3 more build options;
wenzelm
parents: 48520
diff changeset
    44
    |> Unsynchronized.setmp Pretty.margin_default (Options.int options "pretty_margin")
48492
03530cf284ca more build options;
wenzelm
parents: 48486
diff changeset
    45
    |> Unsynchronized.setmp Toplevel.timing (Options.bool options "timing");
48457
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    46
48465
a25daffda966 observe "condition";
wenzelm
parents: 48464
diff changeset
    47
fun use_theories (options, thys) =
a25daffda966 observe "condition";
wenzelm
parents: 48464
diff changeset
    48
  let val condition = space_explode "," (Options.string options "condition") in
a25daffda966 observe "condition";
wenzelm
parents: 48464
diff changeset
    49
    (case filter_out (can getenv_strict) condition of
a25daffda966 observe "condition";
wenzelm
parents: 48464
diff changeset
    50
      [] => use_thys options thys
a25daffda966 observe "condition";
wenzelm
parents: 48464
diff changeset
    51
    | conds =>
48512
wenzelm
parents: 48511
diff changeset
    52
        Output.physical_stderr ("Skipping theories " ^ commas_quote thys ^
48477
322fbf571782 tuned message;
wenzelm
parents: 48472
diff changeset
    53
          " (undefined " ^ commas conds ^ ")\n"))
48465
a25daffda966 observe "condition";
wenzelm
parents: 48464
diff changeset
    54
  end;
a25daffda966 observe "condition";
wenzelm
parents: 48464
diff changeset
    55
a25daffda966 observe "condition";
wenzelm
parents: 48464
diff changeset
    56
in
a25daffda966 observe "condition";
wenzelm
parents: 48464
diff changeset
    57
48418
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    58
fun build args_file =
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    59
  let
48545
c168bc64f2a8 fewer options;
wenzelm
parents: 48543
diff changeset
    60
    val (do_output, (options, (verbose, (browser_info, (parent_name,
c168bc64f2a8 fewer options;
wenzelm
parents: 48543
diff changeset
    61
        (name, theories)))))) =
48418
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    62
      File.read (Path.explode args_file) |> YXML.parse_body |>
48457
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    63
        let open XML.Decode in
48545
c168bc64f2a8 fewer options;
wenzelm
parents: 48543
diff changeset
    64
          pair bool (pair Options.decode (pair bool (pair string (pair string
c168bc64f2a8 fewer options;
wenzelm
parents: 48543
diff changeset
    65
            (pair string ((list (pair Options.decode (list string)))))))))
48457
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    66
        end;
48418
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    67
48457
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    68
    val _ =
48511
37999ee01156 remove old output heaps, to ensure that result is valid wrt. check_stamps;
wenzelm
parents: 48500
diff changeset
    69
      Session.init do_output false
48457
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    70
        (Options.bool options "browser_info") browser_info
48458
09710d6fc3d1 clarified document options;
wenzelm
parents: 48457
diff changeset
    71
        (Options.string options "document")
48457
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    72
        (Options.bool options "document_graph")
48466
3b2fb20df17d further imitation of ISABELLE_USEDIR_OPTIONS via options;
wenzelm
parents: 48465
diff changeset
    73
        (space_explode ":" (Options.string options "document_variants"))
48541
f31ef1a0285a more precise imitation of usedir wrt. Session.name (cf. 45137257399a);
wenzelm
parents: 48527
diff changeset
    74
        parent_name name
48543
93b558e05f21 prefer explicit datatype Present.dump_mode;
wenzelm
parents: 48541
diff changeset
    75
        (Options.string options "document_dump",
93b558e05f21 prefer explicit datatype Present.dump_mode;
wenzelm
parents: 48541
diff changeset
    76
          Present.dump_mode (Options.string options "document_dump_mode"))
48513
ace120a2cb70 discontinued slightly odd "browser_info_remote" -- it could point to a completely different version of the Isabelle library;
wenzelm
parents: 48512
diff changeset
    77
        "" verbose;
48545
c168bc64f2a8 fewer options;
wenzelm
parents: 48543
diff changeset
    78
    val _ = Session.with_timing name verbose (List.app use_theories) theories;
48418
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    79
    val _ = Session.finish ();
48511
37999ee01156 remove old output heaps, to ensure that result is valid wrt. check_stamps;
wenzelm
parents: 48500
diff changeset
    80
    val _ = if do_output then () else quit ();
48418
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    81
  in () end
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    82
  handle exn => (Output.error_msg (ML_Compiler.exn_message exn); exit 1);
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    83
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    84
end;
48465
a25daffda966 observe "condition";
wenzelm
parents: 48464
diff changeset
    85
a25daffda966 observe "condition";
wenzelm
parents: 48464
diff changeset
    86
end;