Merge pull request #1091 from ocaml/compiler-version-predicates
Extract predicates for compiler versions
This commit is contained in:
commit
48ece7ffe6
|
@ -50,7 +50,7 @@ type t =
|
||||||
; natdynlink_supported : bool
|
; natdynlink_supported : bool
|
||||||
; ocaml_config : Ocaml_config.t
|
; ocaml_config : Ocaml_config.t
|
||||||
; version_string : string
|
; version_string : string
|
||||||
; version : int * int * int
|
; version : Ocaml_version.t
|
||||||
; stdlib_dir : Path.t
|
; stdlib_dir : Path.t
|
||||||
; ccomp_type : string
|
; ccomp_type : string
|
||||||
; c_compiler : string
|
; c_compiler : string
|
||||||
|
@ -274,16 +274,16 @@ let create ~(kind : Kind.t) ~path ~env ~env_nodes ~name ~merlin ~targets
|
||||||
ocaml_config_ok_exn
|
ocaml_config_ok_exn
|
||||||
(Ocaml_config.Vars.of_lines lines >>= Ocaml_config.make))
|
(Ocaml_config.Vars.of_lines lines >>= Ocaml_config.make))
|
||||||
>>= fun (findlib_path, ocfg) ->
|
>>= fun (findlib_path, ocfg) ->
|
||||||
let version = Ocaml_config.version ocfg in
|
let version = Ocaml_version.of_ocaml_config ocfg in
|
||||||
let env =
|
let env =
|
||||||
(* See comment in ansi_color.ml for setup_env_for_colors. For
|
(* See comment in ansi_color.ml for setup_env_for_colors.
|
||||||
OCaml < 4.05, OCAML_COLOR is not supported so we use
|
For versions where OCAML_COLOR is not supported, but 'color' is in
|
||||||
OCAMLPARAM. OCaml 4.02 doesn't support 'color' in OCAMLPARAM,
|
OCAMLPARAM, use the latter.
|
||||||
so we just don't force colors with 4.02. *)
|
If 'color' is not supported, we just don't force colors with 4.02. *)
|
||||||
if !Clflags.capture_outputs
|
if !Clflags.capture_outputs
|
||||||
&& Lazy.force Colors.stderr_supports_colors
|
&& Lazy.force Colors.stderr_supports_colors
|
||||||
&& version >= (4, 03, 0)
|
&& Ocaml_version.supports_color_in_ocamlparam version
|
||||||
&& version < (4, 05, 0) then
|
&& not (Ocaml_version.supports_ocaml_color version) then
|
||||||
let value =
|
let value =
|
||||||
match Env.get env "OCAMLPARAM" with
|
match Env.get env "OCAMLPARAM" with
|
||||||
| None -> "color=always,_"
|
| None -> "color=always,_"
|
||||||
|
@ -332,8 +332,8 @@ let create ~(kind : Kind.t) ~path ~env ~env_nodes ~name ~merlin ~targets
|
||||||
in
|
in
|
||||||
let stdlib_dir = Path.of_string (Ocaml_config.standard_library ocfg) in
|
let stdlib_dir = Path.of_string (Ocaml_config.standard_library ocfg) in
|
||||||
let natdynlink_supported = Ocaml_config.natdynlink_supported ocfg in
|
let natdynlink_supported = Ocaml_config.natdynlink_supported ocfg in
|
||||||
let version = Ocaml_config.version ocfg in
|
|
||||||
let version_string = Ocaml_config.version_string ocfg in
|
let version_string = Ocaml_config.version_string ocfg in
|
||||||
|
let version = Ocaml_version.of_ocaml_config ocfg in
|
||||||
let arch_sixtyfour = Ocaml_config.word_size ocfg = 64 in
|
let arch_sixtyfour = Ocaml_config.word_size ocfg = 64 in
|
||||||
Fiber.return
|
Fiber.return
|
||||||
{ name
|
{ name
|
||||||
|
|
|
@ -90,7 +90,7 @@ type t =
|
||||||
|
|
||||||
; ocaml_config : Ocaml_config.t
|
; ocaml_config : Ocaml_config.t
|
||||||
; version_string : string
|
; version_string : string
|
||||||
; version : int * int * int
|
; version : Ocaml_version.t
|
||||||
; stdlib_dir : Path.t
|
; stdlib_dir : Path.t
|
||||||
; ccomp_type : string
|
; ccomp_type : string
|
||||||
; c_compiler : string
|
; c_compiler : string
|
||||||
|
|
|
@ -17,7 +17,8 @@ module Gen(P : Install_rules.Params) = struct
|
||||||
let sctx = P.sctx
|
let sctx = P.sctx
|
||||||
let ctx = SC.context sctx
|
let ctx = SC.context sctx
|
||||||
|
|
||||||
let opaque = ctx.profile = "dev" && ctx.version >= (4, 03, 0)
|
let opaque =
|
||||||
|
ctx.profile = "dev" && Ocaml_version.supports_opaque_for_mli ctx.version
|
||||||
|
|
||||||
(* +-----------------------------------------------------------------+
|
(* +-----------------------------------------------------------------+
|
||||||
| Library stuff |
|
| Library stuff |
|
||||||
|
@ -143,10 +144,11 @@ module Gen(P : Install_rules.Params) = struct
|
||||||
]));
|
]));
|
||||||
dst
|
dst
|
||||||
|
|
||||||
(* In 4.02, the compiler reads the cmi for module alias even with
|
(* If the compiler reads the cmi for module alias even with
|
||||||
[-w -49 -no-alias-deps], so we must sandbox the build of the
|
[-w -49 -no-alias-deps], we must sandbox the build of the
|
||||||
alias module since the modules it references are built after. *)
|
alias module since the modules it references are built after. *)
|
||||||
let alias_module_build_sandbox = ctx.version < (4, 03, 0)
|
let alias_module_build_sandbox =
|
||||||
|
Ocaml_version.always_reads_alias_cmi ctx.version
|
||||||
|
|
||||||
let library_rules (lib : Library.t) ~dir_contents ~dir ~scope
|
let library_rules (lib : Library.t) ~dir_contents ~dir ~scope
|
||||||
~compile_info ~dir_kind =
|
~compile_info ~dir_kind =
|
||||||
|
|
|
@ -95,10 +95,10 @@ let build_cm cctx ?sandbox ?(dynlink=true) ~dep_graphs ~cm_kind (m : Module.t) =
|
||||||
in
|
in
|
||||||
let dir, no_keep_locs =
|
let dir, no_keep_locs =
|
||||||
if CC.no_keep_locs cctx && cm_kind = Cmi then begin
|
if CC.no_keep_locs cctx && cm_kind = Cmi then begin
|
||||||
if ctx.version < (4, 03, 0) then
|
if Ocaml_version.supports_no_keep_locs ctx.version then
|
||||||
(obj_dir, Arg_spec.As [])
|
(ctx.build_dir, Arg_spec.As ["-no-keep-locs"])
|
||||||
else
|
else
|
||||||
(ctx.build_dir, As ["-no-keep-locs"])
|
(obj_dir, As [])
|
||||||
end else
|
end else
|
||||||
(ctx.build_dir, As [])
|
(ctx.build_dir, As [])
|
||||||
in
|
in
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
type t = int * int * int
|
||||||
|
|
||||||
|
let of_ocaml_config ocfg =
|
||||||
|
Ocaml_config.version ocfg
|
||||||
|
|
||||||
|
let supports_no_keep_locs version =
|
||||||
|
version >= (4, 03, 0)
|
||||||
|
|
||||||
|
let supports_opaque_for_mli version =
|
||||||
|
version >= (4, 03, 0)
|
||||||
|
|
||||||
|
let always_reads_alias_cmi version =
|
||||||
|
version < (4, 03, 0)
|
||||||
|
|
||||||
|
let supports_color_in_ocamlparam version =
|
||||||
|
version >= (4, 03, 0)
|
||||||
|
|
||||||
|
let supports_ocaml_color version =
|
||||||
|
version >= (4, 05, 0)
|
|
@ -0,0 +1,20 @@
|
||||||
|
(** Version numbers for ocamlc and ocamlopt *)
|
||||||
|
type t
|
||||||
|
|
||||||
|
val of_ocaml_config : Ocaml_config.t -> t
|
||||||
|
|
||||||
|
(** Does this support [-no-keep-locs]? *)
|
||||||
|
val supports_no_keep_locs : t -> bool
|
||||||
|
|
||||||
|
(** Does this support [-opaque] for [.mli] files? *)
|
||||||
|
val supports_opaque_for_mli : t -> bool
|
||||||
|
|
||||||
|
(** Does it read the [.cmi] file of module alias
|
||||||
|
even when [-no-alias-deps] is passed? *)
|
||||||
|
val always_reads_alias_cmi : t -> bool
|
||||||
|
|
||||||
|
(** Does this support ['color'] in [OCAMLPARAM]? *)
|
||||||
|
val supports_color_in_ocamlparam : t -> bool
|
||||||
|
|
||||||
|
(** Does this support [OCAML_COLOR]? *)
|
||||||
|
val supports_ocaml_color : t -> bool
|
Loading…
Reference in New Issue