src/Pure/System/build.ML
author wenzelm
Sun, 18 Nov 2012 19:01:30 +0100
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;
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
48731
a45ba78abcc1 more casual exit back to ML toplevel, to accomodate commit in SML/NJ which continues at the saved point;
wenzelm
parents: 48681
diff changeset
     9
  val build: string -> unit
48418
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 =
50121
97d2b77313a0 isabelle build no longer supports document_dump/document_dump_mode (no INCOMPATIBILITY, since it was never in official release);
wenzelm
parents: 49911
diff changeset
    18
  (case Options.string options "document" of "" => true | "false" => true | _ => false);
48500
bf7f434b91d7 clarified no_document situation;
wenzelm
parents: 48492
diff changeset
    19
48465
a25daffda966 observe "condition";
wenzelm
parents: 48464
diff changeset
    20
fun use_thys options =
48457
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    21
  Thy_Info.use_thys
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    22
    |> Unsynchronized.setmp Proofterm.proofs (Options.int options "proofs")
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    23
    |> Unsynchronized.setmp print_mode
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    24
        (space_explode "," (Options.string options "print_mode") @ print_mode_value ())
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    25
    |> Unsynchronized.setmp Goal.parallel_proofs (Options.int options "parallel_proofs")
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    26
    |> Unsynchronized.setmp Goal.parallel_proofs_threshold
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    27
        (Options.int options "parallel_proofs_threshold")
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    28
    |> Unsynchronized.setmp Multithreading.trace (Options.int options "threads_trace")
48460
20170ae271a5 tuned options;
wenzelm
parents: 48459
diff changeset
    29
    |> Unsynchronized.setmp Multithreading.max_threads (Options.int options "threads")
48500
bf7f434b91d7 clarified no_document situation;
wenzelm
parents: 48492
diff changeset
    30
    |> no_document options ? Present.no_document
48486
691d0b44a793 more build options;
wenzelm
parents: 48482
diff changeset
    31
    |> Unsynchronized.setmp quick_and_dirty (Options.bool options "quick_and_dirty")
48634
30a6e841390a explicit option skip_proofs;
wenzelm
parents: 48545
diff changeset
    32
    |> Unsynchronized.setmp Toplevel.skip_proofs (Options.bool options "skip_proofs")
48486
691d0b44a793 more build options;
wenzelm
parents: 48482
diff changeset
    33
    |> Unsynchronized.setmp Printer.show_question_marks_default
691d0b44a793 more build options;
wenzelm
parents: 48482
diff changeset
    34
        (Options.bool options "show_question_marks")
691d0b44a793 more build options;
wenzelm
parents: 48482
diff changeset
    35
    |> Unsynchronized.setmp Name_Space.names_long_default (Options.bool options "names_long")
691d0b44a793 more build options;
wenzelm
parents: 48482
diff changeset
    36
    |> Unsynchronized.setmp Name_Space.names_short_default (Options.bool options "names_short")
48492
03530cf284ca more build options;
wenzelm
parents: 48486
diff changeset
    37
    |> Unsynchronized.setmp Name_Space.names_unique_default (Options.bool options "names_unique")
48520
6d4ea2efa64b more build options;
wenzelm
parents: 48516
diff changeset
    38
    |> Unsynchronized.setmp Thy_Output.display_default (Options.bool options "thy_output_display")
6d4ea2efa64b more build options;
wenzelm
parents: 48516
diff changeset
    39
    |> Unsynchronized.setmp Thy_Output.quotes_default (Options.bool options "thy_output_quotes")
6d4ea2efa64b more build options;
wenzelm
parents: 48516
diff changeset
    40
    |> Unsynchronized.setmp Thy_Output.indent_default (Options.int options "thy_output_indent")
6d4ea2efa64b more build options;
wenzelm
parents: 48516
diff changeset
    41
    |> Unsynchronized.setmp Thy_Output.source_default (Options.bool options "thy_output_source")
6d4ea2efa64b more build options;
wenzelm
parents: 48516
diff changeset
    42
    |> Unsynchronized.setmp Thy_Output.break_default (Options.bool options "thy_output_break")
48527
4ee8d70cd5a3 more build options;
wenzelm
parents: 48520
diff changeset
    43
    |> Unsynchronized.setmp Pretty.margin_default (Options.int options "pretty_margin")
48492
03530cf284ca more build options;
wenzelm
parents: 48486
diff changeset
    44
    |> Unsynchronized.setmp Toplevel.timing (Options.bool options "timing");
48457
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    45
48465
a25daffda966 observe "condition";
wenzelm
parents: 48464
diff changeset
    46
fun use_theories (options, thys) =
a25daffda966 observe "condition";
wenzelm
parents: 48464
diff changeset
    47
  let val condition = space_explode "," (Options.string options "condition") in
a25daffda966 observe "condition";
wenzelm
parents: 48464
diff changeset
    48
    (case filter_out (can getenv_strict) condition of
48927
ef462b5558eb theory def/ref position reports, which enable hyperlinks etc.;
wenzelm
parents: 48805
diff changeset
    49
      [] => use_thys options (map (rpair Position.none) thys)
48465
a25daffda966 observe "condition";
wenzelm
parents: 48464
diff changeset
    50
    | conds =>
48512
wenzelm
parents: 48511
diff changeset
    51
        Output.physical_stderr ("Skipping theories " ^ commas_quote thys ^
48477
322fbf571782 tuned message;
wenzelm
parents: 48472
diff changeset
    52
          " (undefined " ^ commas conds ^ ")\n"))
48465
a25daffda966 observe "condition";
wenzelm
parents: 48464
diff changeset
    53
  end;
a25daffda966 observe "condition";
wenzelm
parents: 48464
diff changeset
    54
a25daffda966 observe "condition";
wenzelm
parents: 48464
diff changeset
    55
in
a25daffda966 observe "condition";
wenzelm
parents: 48464
diff changeset
    56
48681
181b91e1d1c1 prefer general Command_Line.tool wrapper (cf. Scala version);
wenzelm
parents: 48673
diff changeset
    57
fun build args_file = Command_Line.tool (fn () =>
48672
9bc7922ba2ae further robustification of interrupts during build;
wenzelm
parents: 48662
diff changeset
    58
    let
9bc7922ba2ae further robustification of interrupts during build;
wenzelm
parents: 48662
diff changeset
    59
      val (do_output, (options, (verbose, (browser_info, (parent_name,
9bc7922ba2ae further robustification of interrupts during build;
wenzelm
parents: 48662
diff changeset
    60
          (name, theories)))))) =
9bc7922ba2ae further robustification of interrupts during build;
wenzelm
parents: 48662
diff changeset
    61
        File.read (Path.explode args_file) |> YXML.parse_body |>
9bc7922ba2ae further robustification of interrupts during build;
wenzelm
parents: 48662
diff changeset
    62
          let open XML.Decode in
9bc7922ba2ae further robustification of interrupts during build;
wenzelm
parents: 48662
diff changeset
    63
            pair bool (pair Options.decode (pair bool (pair string (pair string
9bc7922ba2ae further robustification of interrupts during build;
wenzelm
parents: 48662
diff changeset
    64
              (pair string ((list (pair Options.decode (list string)))))))))
9bc7922ba2ae further robustification of interrupts during build;
wenzelm
parents: 48662
diff changeset
    65
          end;
48418
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    66
48804
6348e5fca42e more direct interpretation of document_variants for build (unchanged for usedir);
wenzelm
parents: 48734
diff changeset
    67
      val document_variants =
6348e5fca42e more direct interpretation of document_variants for build (unchanged for usedir);
wenzelm
parents: 48734
diff changeset
    68
        map Present.read_variant (space_explode ":" (Options.string options "document_variants"));
48672
9bc7922ba2ae further robustification of interrupts during build;
wenzelm
parents: 48662
diff changeset
    69
      val _ =
48805
c3ea910b3581 explicit document_output directory, without implicit purge of default in ISABELLE_BROWSER_INFO;
wenzelm
parents: 48804
diff changeset
    70
        (case duplicates (op =) (map fst document_variants) of
c3ea910b3581 explicit document_output directory, without implicit purge of default in ISABELLE_BROWSER_INFO;
wenzelm
parents: 48804
diff changeset
    71
          [] => ()
c3ea910b3581 explicit document_output directory, without implicit purge of default in ISABELLE_BROWSER_INFO;
wenzelm
parents: 48804
diff changeset
    72
        | dups => error ("Duplicate document variants: " ^ commas_quote dups));
49242
e28b5d8f5613 more explicit indication of legacy features;
wenzelm
parents: 48927
diff changeset
    73
e28b5d8f5613 more explicit indication of legacy features;
wenzelm
parents: 48927
diff changeset
    74
      val _ =
48672
9bc7922ba2ae further robustification of interrupts during build;
wenzelm
parents: 48662
diff changeset
    75
        Session.init do_output false
9bc7922ba2ae further robustification of interrupts during build;
wenzelm
parents: 48662
diff changeset
    76
          (Options.bool options "browser_info") browser_info
9bc7922ba2ae further robustification of interrupts during build;
wenzelm
parents: 48662
diff changeset
    77
          (Options.string options "document")
9bc7922ba2ae further robustification of interrupts during build;
wenzelm
parents: 48662
diff changeset
    78
          (Options.bool options "document_graph")
48805
c3ea910b3581 explicit document_output directory, without implicit purge of default in ISABELLE_BROWSER_INFO;
wenzelm
parents: 48804
diff changeset
    79
          (Options.string options "document_output")
48804
6348e5fca42e more direct interpretation of document_variants for build (unchanged for usedir);
wenzelm
parents: 48734
diff changeset
    80
          document_variants
48672
9bc7922ba2ae further robustification of interrupts during build;
wenzelm
parents: 48662
diff changeset
    81
          parent_name name
50121
97d2b77313a0 isabelle build no longer supports document_dump/document_dump_mode (no INCOMPATIBILITY, since it was never in official release);
wenzelm
parents: 49911
diff changeset
    82
          (false, "") ""
97d2b77313a0 isabelle build no longer supports document_dump/document_dump_mode (no INCOMPATIBILITY, since it was never in official release);
wenzelm
parents: 49911
diff changeset
    83
          verbose;
49911
262c36fd5f26 collective errors from use_thys and Session.finish/Goal.finish_futures -- avoid uninformative interrupts stemming from failure of goal forks that are not registered in the theory (e.g. unnamed theorems);
wenzelm
parents: 49242
diff changeset
    84
262c36fd5f26 collective errors from use_thys and Session.finish/Goal.finish_futures -- avoid uninformative interrupts stemming from failure of goal forks that are not registered in the theory (e.g. unnamed theorems);
wenzelm
parents: 49242
diff changeset
    85
      val res1 =
48673
b2b09970c571 let with_timing report overall number of threads;
wenzelm
parents: 48672
diff changeset
    86
        theories |>
b2b09970c571 let with_timing report overall number of threads;
wenzelm
parents: 48672
diff changeset
    87
          (List.app use_theories
b2b09970c571 let with_timing report overall number of threads;
wenzelm
parents: 48672
diff changeset
    88
            |> Session.with_timing name verbose
49911
262c36fd5f26 collective errors from use_thys and Session.finish/Goal.finish_futures -- avoid uninformative interrupts stemming from failure of goal forks that are not registered in the theory (e.g. unnamed theorems);
wenzelm
parents: 49242
diff changeset
    89
            |> Unsynchronized.setmp Multithreading.max_threads (Options.int options "threads")
262c36fd5f26 collective errors from use_thys and Session.finish/Goal.finish_futures -- avoid uninformative interrupts stemming from failure of goal forks that are not registered in the theory (e.g. unnamed theorems);
wenzelm
parents: 49242
diff changeset
    90
            |> Exn.capture);
262c36fd5f26 collective errors from use_thys and Session.finish/Goal.finish_futures -- avoid uninformative interrupts stemming from failure of goal forks that are not registered in the theory (e.g. unnamed theorems);
wenzelm
parents: 49242
diff changeset
    91
      val res2 = Exn.capture Session.finish ();
262c36fd5f26 collective errors from use_thys and Session.finish/Goal.finish_futures -- avoid uninformative interrupts stemming from failure of goal forks that are not registered in the theory (e.g. unnamed theorems);
wenzelm
parents: 49242
diff changeset
    92
      val _ = Par_Exn.release_all [res1, res2];
48673
b2b09970c571 let with_timing report overall number of threads;
wenzelm
parents: 48672
diff changeset
    93
48734
af91cd2301ba back to implicit commit via isabelle-process -- save image only once (cf. 181b91e1d1c1);
wenzelm
parents: 48731
diff changeset
    94
      val _ = if do_output then () else exit 0;
48681
181b91e1d1c1 prefer general Command_Line.tool wrapper (cf. Scala version);
wenzelm
parents: 48673
diff changeset
    95
    in 0 end);
48418
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    96
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    97
end;
48465
a25daffda966 observe "condition";
wenzelm
parents: 48464
diff changeset
    98
a25daffda966 observe "condition";
wenzelm
parents: 48464
diff changeset
    99
end;