-
Notifications
You must be signed in to change notification settings - Fork 87
Make visible and hidden libloc files separate #3974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,19 +165,18 @@ let mk_H f = | |
"<dir> Add <dir> to the list of \"hidden\" include directories\n\ | ||
\ (Like -I, but the program can not directly reference these dependencies)" | ||
|
||
let mk_libloc f = | ||
"-libloc", Arg.String f, "<dir>:<libs>:<hidden_libs> Add .libloc directory configuration.\n\ | ||
\ .libloc directory is alternative (to -I and -H flags) way of telling\n\ | ||
\ compiler where to find files. Each `.libloc` directory should have a\n\ | ||
\ structure of `.libloc/<lib>/cmi-cmx`, where `<lib>` is a library name\n\ | ||
\ and `cmi-cmx` is a file where each line is of format `<filename> <path>`\n\ | ||
\ telling compiler that <filename> for library <lib> is accessible\n\ | ||
\ at <path>. If <path> is relative, then it is relative to a parent directory\n\ | ||
\ of a `.libloc` directory.\n\ | ||
\ <libs> and <hidden_libs> are comma-separated lists of libraries, to let\n\ | ||
\ compiler know which libraries should be accessible via this `.libloc`\n\ | ||
\ directory. Difference between <libs> and <hidden_libs> is the same as\n\ | ||
\ the difference between -I and -H flags" | ||
let mk_I_paths f = | ||
"-I-paths", Arg.String f, "<file> Read list of paths that compiler can reference from\n\ | ||
\ a given file. This option is alternative to -I flag, but lists available files\n\ | ||
\ directly instead of adding the whole directory to the search path.\n\ | ||
\ Each line of <file> describes one file available to compiler and should be of\n\ | ||
\ format '<filename> <path>', which tells compiler that <filename> is available at\n\ | ||
\ <path>. If <path> is relative, then it is relative to a parent directory\n\ | ||
\ of <file>." | ||
Comment on lines
+174
to
+175
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This sentence is still confusing, it was confusing in the oridingal version too. Is it avoidable? It would be nice to match the logic of |
||
|
||
let mk_H_paths f = | ||
"-H-paths", Arg.String f, "<file> Same as -I-paths, but adds given paths to the list\n\ | ||
\ of \"hidden\" files (see -H for more details)" | ||
|
||
let mk_impl f = | ||
"-impl", Arg.String f, "<file> Compile <file> as a .ml file" | ||
|
@@ -911,7 +910,8 @@ module type Common_options = sig | |
val _alert : string -> unit | ||
val _I : string -> unit | ||
val _H : string -> unit | ||
val _libloc : string -> unit | ||
val _I_paths : string -> unit | ||
val _H_paths : string -> unit | ||
val _labels : unit -> unit | ||
val _alias_deps : unit -> unit | ||
val _no_alias_deps : unit -> unit | ||
|
@@ -1207,7 +1207,8 @@ struct | |
mk_i F._i; | ||
mk_I F._I; | ||
mk_H F._H; | ||
mk_libloc F._libloc; | ||
mk_I_paths F._I_paths; | ||
mk_H_paths F._H_paths; | ||
mk_impl F._impl; | ||
mk_instantiate_byt F._instantiate; | ||
mk_intf F._intf; | ||
|
@@ -1318,7 +1319,8 @@ struct | |
mk_alert F._alert; | ||
mk_I F._I; | ||
mk_H F._H; | ||
mk_libloc F._libloc; | ||
mk_I_paths F._I_paths; | ||
mk_H_paths F._H_paths; | ||
mk_init F._init; | ||
mk_labels F._labels; | ||
mk_alias_deps F._alias_deps; | ||
|
@@ -1436,7 +1438,8 @@ struct | |
mk_i F._i; | ||
mk_I F._I; | ||
mk_H F._H; | ||
mk_libloc F._libloc; | ||
mk_I_paths F._I_paths; | ||
mk_H_paths F._H_paths; | ||
mk_impl F._impl; | ||
mk_inline F._inline; | ||
mk_inline_toplevel F._inline_toplevel; | ||
|
@@ -1579,7 +1582,8 @@ module Make_opttop_options (F : Opttop_options) = struct | |
mk_compact F._compact; | ||
mk_I F._I; | ||
mk_H F._H; | ||
mk_libloc F._libloc; | ||
mk_I_paths F._I_paths; | ||
mk_H_paths F._H_paths; | ||
mk_init F._init; | ||
mk_inline F._inline; | ||
mk_inline_toplevel F._inline_toplevel; | ||
|
@@ -1687,7 +1691,8 @@ struct | |
mk_alert F._alert; | ||
mk_I F._I; | ||
mk_H F._H; | ||
mk_libloc F._libloc; | ||
mk_I_paths F._I_paths; | ||
mk_H_paths F._H_paths; | ||
mk_impl F._impl; | ||
mk_intf F._intf; | ||
mk_intf_suffix F._intf_suffix; | ||
|
@@ -1840,18 +1845,8 @@ module Default = struct | |
include Common | ||
let _I dir = include_dirs := dir :: (!include_dirs) | ||
let _H dir = hidden_include_dirs := dir :: (!hidden_include_dirs) | ||
let _libloc s = | ||
match String.split_on_char ':' s with | ||
| [ path; libs; hidden_libs ] -> | ||
let split libs = | ||
match libs |> String.split_on_char ',' with | ||
| [ "" ] -> [] | ||
| libs -> libs | ||
in | ||
let libs = split libs in | ||
let hidden_libs = split hidden_libs in | ||
libloc := { Libloc.path; libs; hidden_libs } :: !libloc | ||
| _ -> Compenv.fatal "Incorrect -libloc format, expected: <path>:<lib1>,<lib2>,...:<hidden_lib1>,<hidden_lib2>,..." | ||
let _I_paths file = include_paths_files := file :: !include_paths_files | ||
let _H_paths file = hidden_include_paths_files := file :: !hidden_include_paths_files | ||
let _color = Misc.set_or_ignore color_reader.parse color | ||
let _dlambda = set dump_lambda | ||
let _dletreclambda = set dump_letreclambda | ||
|
@@ -2110,7 +2105,8 @@ module Default = struct | |
Odoc_global.hidden_include_dirs := | ||
(s :: (!Odoc_global.hidden_include_dirs)) | ||
*) () | ||
let _libloc(_:string) = () | ||
let _I_paths(_:string) = () | ||
let _H_paths(_:string) = () | ||
let _impl (_:string) = | ||
(* placeholder: | ||
Odoc_global.files := ((!Odoc_global.files) @ [Odoc_global.Impl_file s]) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ module Dir : sig | |
val hidden : t -> bool | ||
|
||
val create : hidden:bool -> string -> t | ||
val create_libloc : hidden:bool -> libloc:string -> string -> t | ||
val create_from_path_list_file : hidden:bool -> path_list_file:string -> t | ||
|
||
val find : t -> string -> string option | ||
val find_normalized : t -> string -> string option | ||
|
@@ -80,7 +80,7 @@ end = struct | |
|> List.map (fun basename -> { basename; path = Filename.concat path basename }) in | ||
{ path; files; hidden } | ||
|
||
let read_libloc_file path = | ||
let read_path_list_file path = | ||
let ic = open_in path in | ||
Misc.try_finally | ||
(fun () -> | ||
|
@@ -94,18 +94,17 @@ end = struct | |
loop []) | ||
~always:(fun () -> close_in ic) | ||
|
||
let create_libloc ~hidden ~libloc libname = | ||
let libloc_lib_path = Filename.concat libloc libname in | ||
let files = read_libloc_file (Filename.concat libloc_lib_path "cmi-cmx") in | ||
let create_from_path_list_file ~hidden ~path_list_file = | ||
let files = read_path_list_file path_list_file in | ||
let files = List.map (fun { basename; path } -> | ||
let path = if Filename.is_relative path then | ||
(* Paths are relative to parent directory of libloc directory *) | ||
Filename.concat (Filename.dirname libloc) path | ||
(* Paths are relative to parent directory of path list file *) | ||
Filename.concat (Filename.dirname path_list_file) path | ||
else | ||
path | ||
in | ||
Comment on lines
100
to
105
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider moving this logic into |
||
{ basename; path }) files in | ||
{ path = libloc_lib_path; files; hidden } | ||
{ path = path_list_file; files; hidden } | ||
end | ||
|
||
type visibility = Visible | Hidden | ||
|
@@ -216,10 +215,12 @@ let init ~auto_include ~visible ~hidden = | |
reset (); | ||
visible_dirs := List.rev_map (Dir.create ~hidden:false) visible; | ||
hidden_dirs := List.rev_map (Dir.create ~hidden:true) hidden; | ||
List.iter (fun (libloc : Clflags.Libloc.t) -> | ||
visible_dirs := Misc.rev_map_end (fun lib -> Dir.create_libloc ~hidden:false ~libloc:libloc.path lib) libloc.libs !visible_dirs; | ||
hidden_dirs := Misc.rev_map_end (fun lib -> Dir.create_libloc ~hidden:true ~libloc:libloc.path lib) libloc.hidden_libs !hidden_dirs | ||
) !Clflags.libloc; | ||
List.iter (fun path_list_file -> | ||
visible_dirs := Dir.create_from_path_list_file ~hidden:false ~path_list_file :: !visible_dirs; | ||
) !Clflags.include_paths_files; | ||
List.iter (fun path_list_file -> | ||
hidden_dirs := Dir.create_from_path_list_file ~hidden:true ~path_list_file :: !hidden_dirs; | ||
) !Clflags.hidden_include_paths_files; | ||
Comment on lines
+218
to
+223
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not symmetric to the use of |
||
List.iter Path_cache.prepend_add !hidden_dirs; | ||
List.iter Path_cache.prepend_add !visible_dirs; | ||
auto_include_callback := auto_include | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the motivation for the proposed format, in particular, do we have to separate
basename
andpath
? It'd be much simpler and more intuitvite to have each line of the input file as a single path. Then we could update the doc to something like this: