package / ocaml-base-compiler.4.10.0 / ocamltest / ocaml_toplevels.ml
1 (**************************************************************************)
2 (* *)
3 (* OCaml *)
4 (* *)
5 (* Sebastien Hinderer, projet Gallium, INRIA Paris *)
6 (* *)
7 (* Copyright 2018 Institut National de Recherche en Informatique et *)
8 (* en Automatique. *)
9 (* *)
10 (* All rights reserved. This file is distributed under the terms of *)
11 (* the GNU Lesser General Public License version 2.1, with the *)
12 (* special exception on linking described in the file LICENSE. *)
13 (* *)
14 (**************************************************************************)
15
16 (* Description of the OCaml toplevels *)
17
18 open Ocamltest_stdlib
19
20 class toplevel
21 ~(name : string -> string)
22 ~(flags : string)
23 ~(directory : string)
24 ~(exit_status_variable : Variables.t)
25 ~(reference_variable : Variables.t)
26 ~(output_variable : Variables.t)
27 ~(backend : Ocaml_backends.t)
28 ~(compiler : Ocaml_compilers.compiler)
29 = object (self) inherit Ocaml_tools.tool
30 ~name:name
31 ~family:"toplevel"
32 ~flags:flags
33 ~directory:directory
34 ~exit_status_variable:exit_status_variable
35 ~reference_variable:reference_variable
36 ~output_variable:output_variable
37 as tool
38 method backend = backend
39 method compiler = compiler
40 method ! reference_file env prefix =
41 let default = tool#reference_file env prefix in
42 if Sys.file_exists default then default else
43 let suffix = self#reference_filename_suffix env in
44 let mk s = (Filename.make_filename prefix s) ^ suffix in
45 let filename = mk
46 (Ocaml_backends.string_of_backend self#backend) in
47 if Sys.file_exists filename then filename else
48 mk "compilers"
49
50 end
51
52 let ocaml = new toplevel
53 ~name: Ocaml_commands.ocamlrun_ocaml
54 ~flags: ""
55 ~directory: "ocaml"
56 ~exit_status_variable: Ocaml_variables.ocaml_exit_status
57 ~reference_variable: Ocaml_variables.compiler_reference
58 ~output_variable: Ocaml_variables.compiler_output
59 ~backend: Ocaml_backends.Bytecode
60 ~compiler: Ocaml_compilers.ocamlc_byte
61
62 let ocamlnat = new toplevel
63 ~name: Ocaml_files.ocamlnat
64 ~flags: "-S" (* Keep intermediate assembly files *)
65 ~directory: "ocamlnat"
66 ~exit_status_variable: Ocaml_variables.ocamlnat_exit_status
67 ~reference_variable: Ocaml_variables.compiler_reference2
68 ~output_variable: Ocaml_variables.compiler_output2
69 ~backend: Ocaml_backends.Native
70 ~compiler: Ocaml_compilers.ocamlc_opt
71