Skip to content

Commit

Permalink
Fix make depend for jane street stdlib modules (#2493)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccasin committed Apr 26, 2024
1 parent cb697c0 commit e89bc69
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 10 deletions.
2 changes: 0 additions & 2 deletions ocaml/.depend
Original file line number Diff line number Diff line change
Expand Up @@ -1768,7 +1768,6 @@ typing/typecore.cmo : \
typing/typedtree.cmi \
typing/typedecl.cmi \
typing/subst.cmi \
typing/solver.cmi \
typing/shape.cmi \
typing/rec_check.cmi \
typing/printtyp.cmi \
Expand Down Expand Up @@ -1811,7 +1810,6 @@ typing/typecore.cmx : \
typing/typedtree.cmx \
typing/typedecl.cmx \
typing/subst.cmx \
typing/solver.cmx \
typing/shape.cmx \
typing/rec_check.cmx \
typing/printtyp.cmx \
Expand Down
Binary file modified ocaml/boot/ocamlc
Binary file not shown.
28 changes: 26 additions & 2 deletions ocaml/driver/makedepend.ml
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,38 @@ let add_to_synonym_list synonyms suffix =
(* Find file 'name' (capitalized) in search path *)
let find_module_in_load_path name =
let names = List.map (fun ext -> name ^ ext) (!mli_synonyms @ !ml_synonyms) in
let uname = String.uncapitalize_ascii name in
let unames =
let uname = String.uncapitalize_ascii name in
List.map (fun ext -> uname ^ ext) (!mli_synonyms @ !ml_synonyms)
in
let stdlib_unames =
(* Jane Street: This is a hack to deal with the fact that we refer to our
custom stdlib modules with names like [Stdlib__Int32_u] from within the
stdlib.
Dependencies are calculated by looking at all modules mentioned by the
code in question and checking to see if there is a corresponding ml file.
But in our case there is no corresponding ml file, because the references
look like `Stdlib__Int32_u.foo` and the ml file's name is just
`int32_u.ml`. This is unlike normal stdlib modules, which are exposed
with names that match their ml files. So, the code here just teaches
make depend to optionally ignore a `Stdlib__` prefix for the purposes of
checking for a matching ml file. *)
let stdlib_prefix = "stdlib__" in
if String.starts_with ~prefix:stdlib_prefix uname then
let plen = String.length stdlib_prefix in
let uname =
String.sub name plen (String.length name - plen)
in
let uname = String.uncapitalize_ascii uname in
List.map (fun ext -> uname ^ ext) (!mli_synonyms @ !ml_synonyms)
else
[]
in
let rec find_in_array a pos =
if pos >= Array.length a then None else begin
let s = a.(pos) in
if List.mem s names || List.mem s unames then
if List.mem s names || List.mem s unames || List.mem s stdlib_unames then
Some s
else
find_in_array a (pos + 1)
Expand Down
10 changes: 4 additions & 6 deletions ocaml/ocamldoc/.depend
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,7 @@ odoc_info.cmi : \
odoc_extension.cmi \
odoc_exception.cmi \
odoc_class.cmi \
../parsing/location.cmi \
../parsing/asttypes.cmi
../parsing/location.cmi
odoc_latex.cmo : \
odoc_to_text.cmi \
odoc_messages.cmi \
Expand Down Expand Up @@ -594,8 +593,7 @@ odoc_misc.cmx : \
odoc_misc.cmi : \
../typing/types.cmi \
odoc_types.cmi \
../parsing/longident.cmi \
../parsing/asttypes.cmi
../parsing/longident.cmi
odoc_module.cmo : \
../typing/types.cmi \
odoc_value.cmi \
Expand Down Expand Up @@ -743,6 +741,7 @@ odoc_see_lexer.cmx : \
odoc_see_lexer.cmi : \
odoc_parser.cmi
odoc_sig.cmo : \
../typing/typetexp.cmi \
../typing/types.cmi \
../typing/typedtree.cmi \
../parsing/parsetree.cmi \
Expand All @@ -769,6 +768,7 @@ odoc_sig.cmo : \
../parsing/asttypes.cmi \
odoc_sig.cmi
odoc_sig.cmx : \
../typing/typetexp.cmx \
../typing/types.cmx \
../typing/typedtree.cmx \
../parsing/parsetree.cmi \
Expand Down Expand Up @@ -950,15 +950,13 @@ odoc_value.cmo : \
odoc_parameter.cmi \
odoc_name.cmi \
odoc_misc.cmi \
../parsing/asttypes.cmi \
odoc_value.cmi
odoc_value.cmx : \
../typing/types.cmx \
odoc_types.cmx \
odoc_parameter.cmx \
odoc_name.cmx \
odoc_misc.cmx \
../parsing/asttypes.cmi \
odoc_value.cmi
odoc_value.cmi : \
../typing/types.cmi \
Expand Down
6 changes: 6 additions & 0 deletions ocaml/stdlib/.depend
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,14 @@ stdlib__Int64.cmx : int64.ml \
stdlib__Int64.cmi : int64.mli \
stdlib.cmi
stdlib__Int64_u.cmo : int64_u.ml \
stdlib__Nativeint_u.cmi \
stdlib__Int32_u.cmi \
stdlib.cmi \
stdlib__Int64.cmi \
stdlib__Int64_u.cmi
stdlib__Int64_u.cmx : int64_u.ml \
stdlib__Nativeint_u.cmx \
stdlib__Int32_u.cmx \
stdlib.cmx \
stdlib__Int64.cmx \
stdlib__Int64_u.cmi
Expand Down Expand Up @@ -666,10 +670,12 @@ stdlib__Nativeint.cmx : nativeint.ml \
stdlib__Nativeint.cmi : nativeint.mli \
stdlib.cmi
stdlib__Nativeint_u.cmo : nativeint_u.ml \
stdlib__Int32_u.cmi \
stdlib.cmi \
stdlib__Nativeint.cmi \
stdlib__Nativeint_u.cmi
stdlib__Nativeint_u.cmx : nativeint_u.ml \
stdlib__Int32_u.cmx \
stdlib.cmx \
stdlib__Nativeint.cmx \
stdlib__Nativeint_u.cmi
Expand Down

0 comments on commit e89bc69

Please sign in to comment.