src/Pure/System/build.ML
author wenzelm
Tue, 24 Jul 2012 00:29:36 +0200
changeset 48457 fd9e28d5a143
parent 48419 6d7b6e47f3ef
child 48458 09710d6fc3d1
permissions -rw-r--r--
pass build options to ML; some imitation of usedir Session.init;
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
48457
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    15
fun use_theories name options =
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    16
  Thy_Info.use_thys
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    17
    |> Session.with_timing name (Options.bool options "timing")
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    18
    |> Unsynchronized.setmp Proofterm.proofs (Options.int options "proofs")
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    19
    |> Unsynchronized.setmp print_mode
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    20
        (space_explode "," (Options.string options "print_mode") @ print_mode_value ())
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    21
    |> Unsynchronized.setmp Goal.parallel_proofs (Options.int options "parallel_proofs")
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    22
    |> Unsynchronized.setmp Goal.parallel_proofs_threshold
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    23
        (Options.int options "parallel_proofs_threshold")
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    24
    |> Unsynchronized.setmp Multithreading.trace (Options.int options "threads_trace")
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    25
    |> Unsynchronized.setmp Multithreading.max_threads (Options.int options "threads_limit");
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    26
48418
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    27
fun build args_file =
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    28
  let
48457
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    29
    val (save, (options, (verbose, (browser_info, (parent, (name, (base_name, theories))))))) =
48418
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    30
      File.read (Path.explode args_file) |> YXML.parse_body |>
48457
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    31
        let open XML.Decode in
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    32
          pair bool (pair Options.decode (pair bool (pair string (pair string
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    33
            (pair string (pair string ((list (pair Options.decode (list string))))))))))
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    34
        end;
48418
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    35
48457
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    36
    val _ =
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    37
      Session.init
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    38
        save
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    39
        false (* FIXME reset!? *)
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    40
        (Options.bool options "browser_info") browser_info
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    41
        (Options.string options "document_format")   (* FIXME dependent on "document" (!?) *)
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    42
        (Options.bool options "document_graph")
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    43
        (space_explode "," (Options.string options "document_variants"))
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    44
        parent
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    45
        base_name
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    46
        (true (* FIXME copy document/ files on Scala side!? *),
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    47
          Options.string options "document_dump")
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    48
        ""
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    49
        verbose;
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    50
fd9e28d5a143 pass build options to ML;
wenzelm
parents: 48419
diff changeset
    51
    val _ = List.app (uncurry (use_theories name)) theories;
48418
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    52
    val _ = Session.finish ();
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    53
48419
6d7b6e47f3ef save image for inner nodes only;
wenzelm
parents: 48418
diff changeset
    54
    val _ = if save then () else quit ();
48418
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    55
  in () end
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    56
  handle exn => (Output.error_msg (ML_Compiler.exn_message exn); exit 1);
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    57
1a634f9614fb some actual build function on ML side;
wenzelm
parents:
diff changeset
    58
end;