1 (**************************************************************************)
2 (* *)
3 (* OCaml *)
4 (* *)
5 (* Sebastien Hinderer, projet Gallium, INRIA Paris *)
6 (* *)
7 (* Copyright 2016 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 (* Backends of the OCaml compiler and their properties *)
17
18 type t = Native | Bytecode
19
20 let is_bytecode t = t=Bytecode
21
22 let is_native t = t=Native
23
24 let string_of_backend = function
25 | Native -> "native"
26 | Bytecode -> "bytecode"
27
28 (* Creates a function that returns its first argument for Bytecode *)
29 (* and its second argument for Native code *)
30 let make_backend_function bytecode_value native_value = function
31 | Bytecode -> bytecode_value
32 | Native -> native_value
33
34 let module_extension = make_backend_function "cmo" "cmx"
35
36 let library_extension = make_backend_function "cma" "cmxa"
37
38 let executable_extension = make_backend_function "byte" "opt"
39