Use pattern matching when possible
Signed-off-by: Etienne Millon <me@emillon.org>
This commit is contained in:
parent
0ec9baf257
commit
27b460c320
16
src/exe.ml
16
src/exe.ml
|
@ -76,25 +76,27 @@ module Linkage = struct
|
||||||
let flags =
|
let flags =
|
||||||
match m.kind with
|
match m.kind with
|
||||||
| Exe ->
|
| Exe ->
|
||||||
if wanted_mode = Native && real_mode = Byte then
|
begin
|
||||||
["-custom"]
|
match wanted_mode, real_mode with
|
||||||
else
|
| Native, Byte -> ["-custom"]
|
||||||
[]
|
| _ -> []
|
||||||
|
end
|
||||||
| Object -> o_flags
|
| Object -> o_flags
|
||||||
| Shared_object ->
|
| Shared_object ->
|
||||||
let so_flags =
|
let so_flags =
|
||||||
if ctx.os_type = "Win32" then
|
if String.equal ctx.os_type "Win32" then
|
||||||
so_flags_windows
|
so_flags_windows
|
||||||
else
|
else
|
||||||
so_flags_unix
|
so_flags_unix
|
||||||
in
|
in
|
||||||
if real_mode = Native then
|
match real_mode with
|
||||||
|
| Native ->
|
||||||
(* The compiler doesn't pass these flags in native mode. This
|
(* The compiler doesn't pass these flags in native mode. This
|
||||||
looks like a bug in the compiler. *)
|
looks like a bug in the compiler. *)
|
||||||
List.concat_map ctx.native_c_libraries ~f:(fun flag ->
|
List.concat_map ctx.native_c_libraries ~f:(fun flag ->
|
||||||
["-cclib"; flag])
|
["-cclib"; flag])
|
||||||
@ so_flags
|
@ so_flags
|
||||||
else
|
| Byte ->
|
||||||
so_flags
|
so_flags
|
||||||
in
|
in
|
||||||
{ ext
|
{ ext
|
||||||
|
|
|
@ -487,9 +487,10 @@ module Gen(P : Install_rules.Params) = struct
|
||||||
let l =
|
let l =
|
||||||
let has_native = Option.is_some ctx.ocamlopt in
|
let has_native = Option.is_some ctx.ocamlopt in
|
||||||
List.filter_map (L.Set.to_list exes.modes) ~f:(fun (mode : L.t) ->
|
List.filter_map (L.Set.to_list exes.modes) ~f:(fun (mode : L.t) ->
|
||||||
if not has_native && mode.mode = Native then
|
match has_native, mode.mode with
|
||||||
|
| false, Native ->
|
||||||
None
|
None
|
||||||
else
|
| _ ->
|
||||||
Some (Exe.Linkage.of_user_config ctx mode))
|
Some (Exe.Linkage.of_user_config ctx mode))
|
||||||
in
|
in
|
||||||
(* If bytecode was requested but not native or best version,
|
(* If bytecode was requested but not native or best version,
|
||||||
|
|
|
@ -870,15 +870,9 @@ module Mode_conf = struct
|
||||||
let default = of_list [Byte; Best]
|
let default = of_list [Byte; Best]
|
||||||
|
|
||||||
let eval t ~has_native =
|
let eval t ~has_native =
|
||||||
let best : Mode.t =
|
|
||||||
if has_native then
|
|
||||||
Native
|
|
||||||
else
|
|
||||||
Byte
|
|
||||||
in
|
|
||||||
let has_best = mem t Best in
|
let has_best = mem t Best in
|
||||||
let byte = mem t Byte || (has_best && best = Byte) in
|
let byte = mem t Byte || (has_best && (not has_native)) in
|
||||||
let native = best = Native && (mem t Native || has_best) in
|
let native = has_native && (mem t Native || has_best) in
|
||||||
{ Mode.Dict.byte; native }
|
{ Mode.Dict.byte; native }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue