Remove a few unused things

This commit is contained in:
Jeremie Dimino 2017-06-02 16:27:05 +01:00
parent d8be1aa894
commit 1a8fc057f4
7 changed files with 30 additions and 58 deletions

View File

@ -3,22 +3,17 @@ open Jbuild
type t =
{ context : Context.t
; provides : Path.t String_map.t
; local_bins : String_set.t
; local_libs : Public_lib.t String_map.t
}
let create context stanzas =
let local_bins, local_libs, provides =
List.fold_left stanzas ~init:(String_set.empty, String_map.empty, String_map.empty)
~f:(fun acc (dir, stanzas) ->
let local_bins, local_libs =
List.fold_left stanzas ~init:(String_set.empty, String_map.empty)
~f:(fun acc (_dir, stanzas) ->
List.fold_left stanzas ~init:acc
~f:(fun (local_bins, local_libs, provides) stanza ->
~f:(fun (local_bins, local_libs) stanza ->
match (stanza : Stanza.t) with
| Provides { name; file } ->
(local_bins,
local_libs,
String_map.add provides ~key:name ~data:(Path.relative dir file))
| Install { section = Bin; files; _ } ->
(List.fold_left files ~init:local_bins
~f:(fun acc { Install_conf. src; dst } ->
@ -28,17 +23,14 @@ let create context stanzas =
| None -> Filename.basename src
in
String_set.add name acc),
local_libs,
provides)
local_libs)
| Library { public = Some pub; _ } ->
(local_bins,
String_map.add local_libs ~key:pub.name ~data:pub,
provides)
String_map.add local_libs ~key:pub.name ~data:pub)
| _ ->
(local_bins, local_libs, provides)))
(local_bins, local_libs)))
in
{ context
; provides
; local_bins
; local_libs
}
@ -50,19 +42,16 @@ let binary t ?hint ?(in_the_tree=true) name =
if String_set.mem name t.local_bins then
Ok (Path.relative (Config.local_install_bin_dir ~context:t.context.name) name)
else
match String_map.find name t.provides with
match Context.which t.context name with
| Some p -> Ok p
| None ->
match Context.which t.context name with
| Some p -> Ok p
| None ->
Error
{ fail = fun () ->
Utils.program_not_found name
~context:t.context.name
?hint
~in_the_tree:true
}
Error
{ fail = fun () ->
Utils.program_not_found name
~context:t.context.name
?hint
~in_the_tree:true
}
end else begin
match Context.which t.context name with
| Some p -> Ok p
@ -76,7 +65,7 @@ let binary t ?hint ?(in_the_tree=true) name =
}
end
let file_of_lib ?(use_provides=false) t ~from ~lib ~file =
let file_of_lib t ~from ~lib ~file =
match String_map.find lib t.local_libs with
| Some { package; sub_dir; _ } ->
let lib_install_dir =
@ -95,23 +84,15 @@ let file_of_lib ?(use_provides=false) t ~from ~lib ~file =
| Some pkg ->
Ok (Path.relative pkg.dir file)
| None ->
match
if use_provides then
String_map.find (sprintf "%s:%s" lib file) t.provides
else
None
with
| Some p -> Ok p
| None ->
Error
{ fail = fun () ->
ignore (Findlib.find_exn t.context.findlib lib
~required_by:[Utils.jbuild_name_in ~dir:from]
: Findlib.package);
assert false
}
Error
{ fail = fun () ->
ignore (Findlib.find_exn t.context.findlib lib
~required_by:[Utils.jbuild_name_in ~dir:from]
: Findlib.package);
assert false
}
let file_of_lib t ?use_provides ~from name =
let file_of_lib t ~from name =
let lib, file =
match String.lsplit2 name ~on:':' with
| None ->
@ -119,4 +100,4 @@ let file_of_lib t ?use_provides ~from name =
"invalid ${lib:...} form: %s" name
| Some x -> x
in
(lib, file_of_lib t ~from ~lib ~file ?use_provides)
(lib, file_of_lib t ~from ~lib ~file)

View File

@ -16,15 +16,13 @@ val binary
-> string
-> (Path.t, fail) result
(** [file_of_lib ?use_provides t ~from name] a named artifact that is looked up in the
given library.
(** [file_of_lib t ~from name] a named artifact that is looked up in the given library.
[name] is expected to be of the form "<lib>:<file>". Raises immediately if it is not
the case. Returns "<lib>" as well as the resolved artifact.
*)
val file_of_lib
: t
-> ?use_provides:bool
-> from:Path.t
-> string
-> string * (Path.t, fail) result

View File

@ -93,10 +93,6 @@ module Gen(P : Params) = struct
; Dyn (fun (cm_files, _) -> Deps cm_files)
]))
let expand_includes ~dir includes =
Arg_spec.As (List.concat_map includes ~f:(fun s ->
["-I"; SC.expand_vars sctx ~dir s]))
let build_c_file (lib : Library.t) ~dir ~requires ~h_files c_name =
let src = Path.relative dir (c_name ^ ".c") in
let dst = Path.relative dir (c_name ^ ctx.ext_obj) in
@ -113,7 +109,6 @@ module Gen(P : Params) = struct
~dir
(Dep ctx.ocamlc)
[ As (Utils.g ())
; expand_includes ~dir lib.includes
; Dyn (fun (c_flags, libs) ->
S [ Lib.c_include_flags libs
; As (List.concat_map c_flags ~f:(fun f -> ["-ccopt"; f]))
@ -141,7 +136,6 @@ module Gen(P : Params) = struct
(* The C compiler surely is not in the tree *)
~in_the_tree:false)
[ S [A "-I"; Path ctx.stdlib_dir]
; expand_includes ~dir lib.includes
; As (SC.cxx_flags sctx)
; Dyn (fun (cxx_flags, libs) ->
S [ Lib.c_include_flags libs

View File

@ -428,6 +428,8 @@ module Buildable = struct
>>= fun preprocess ->
field "preprocessor_deps" (list Dep_conf.t) ~default:[]
>>= fun preprocessor_deps ->
(* CR-someday jdimino: remove this. There are still a few Jane Street packages using
this *)
field_o "lint" (Per_file.t Lint.t)
>>= fun _lint ->
field "modules" (fun s -> Ordered_set_lang.(map (t s)) ~f:String.capitalize_ascii)
@ -507,7 +509,6 @@ module Library = struct
; c_names : string list
; cxx_flags : Ordered_set_lang.Unexpanded.t
; cxx_names : string list
; includes : String_with_vars.t list
; library_flags : String_with_vars.t list
; c_library_flags : Ordered_set_lang.Unexpanded.t
; self_build_stubs_archive : string option
@ -551,7 +552,6 @@ module Library = struct
; c_flags
; cxx_names
; cxx_flags
; includes = []
; library_flags
; c_library_flags
; self_build_stubs_archive

View File

@ -135,7 +135,6 @@ module Library : sig
; c_names : string list
; cxx_flags : Ordered_set_lang.Unexpanded.t
; cxx_names : string list
; includes : String_with_vars.t list
; library_flags : String_with_vars.t list
; c_library_flags : Ordered_set_lang.Unexpanded.t
; self_build_stubs_archive : string option

View File

@ -18,7 +18,7 @@ let in_build_dir ~ctx =
let runtime_file ~sctx ~dir fname =
let _lib, file =
Artifacts.file_of_lib (SC.artifacts sctx) ~from:dir ~use_provides:false
Artifacts.file_of_lib (SC.artifacts sctx) ~from:dir
(sprintf "js_of_ocaml-compiler:%s" fname)
in
match file with

View File

@ -522,7 +522,7 @@ module Action = struct
(* CR-someday jdimino: allow this only for (jbuild_version jane_street) *)
| Some ("findlib" , s) ->
let lib_dep, res =
A.file_of_lib (artifacts sctx) ~from:dir s ~use_provides:true
A.file_of_lib (artifacts sctx) ~from:dir s
in
add_artifact acc ~key ~lib_dep:(lib_dep, Required) (map_result res)
| Some ("version", s) -> begin