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 =
|
||||
match m.kind with
|
||||
| Exe ->
|
||||
if wanted_mode = Native && real_mode = Byte then
|
||||
["-custom"]
|
||||
else
|
||||
[]
|
||||
begin
|
||||
match wanted_mode, real_mode with
|
||||
| Native, Byte -> ["-custom"]
|
||||
| _ -> []
|
||||
end
|
||||
| Object -> o_flags
|
||||
| Shared_object ->
|
||||
let so_flags =
|
||||
if ctx.os_type = "Win32" then
|
||||
if String.equal ctx.os_type "Win32" then
|
||||
so_flags_windows
|
||||
else
|
||||
so_flags_unix
|
||||
in
|
||||
if real_mode = Native then
|
||||
match real_mode with
|
||||
| Native ->
|
||||
(* The compiler doesn't pass these flags in native mode. This
|
||||
looks like a bug in the compiler. *)
|
||||
List.concat_map ctx.native_c_libraries ~f:(fun flag ->
|
||||
["-cclib"; flag])
|
||||
@ so_flags
|
||||
else
|
||||
| Byte ->
|
||||
so_flags
|
||||
in
|
||||
{ ext
|
||||
|
|
|
@ -487,9 +487,10 @@ module Gen(P : Install_rules.Params) = struct
|
|||
let l =
|
||||
let has_native = Option.is_some ctx.ocamlopt in
|
||||
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
|
||||
else
|
||||
| _ ->
|
||||
Some (Exe.Linkage.of_user_config ctx mode))
|
||||
in
|
||||
(* 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 eval t ~has_native =
|
||||
let best : Mode.t =
|
||||
if has_native then
|
||||
Native
|
||||
else
|
||||
Byte
|
||||
in
|
||||
let has_best = mem t Best in
|
||||
let byte = mem t Byte || (has_best && best = Byte) in
|
||||
let native = best = Native && (mem t Native || has_best) in
|
||||
let byte = mem t Byte || (has_best && (not has_native)) in
|
||||
let native = has_native && (mem t Native || has_best) in
|
||||
{ Mode.Dict.byte; native }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue