-
Notifications
You must be signed in to change notification settings - Fork 410
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
Do not use the transitive closure in generated META files #405
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,33 +144,36 @@ let create findlib ~scopes internal_libraries = | |
let internal_libs_without_non_installable_optional_ones t = | ||
String_map.values t.instalable_internal_libs | ||
|
||
let interpret_lib_dep t ~dir lib_dep = | ||
match lib_dep with | ||
| Lib_dep.Direct name -> begin | ||
match find_exn t ~from:dir name with | ||
| x -> Inl [x] | ||
| exception e -> | ||
(* Call [find] again to get a proper backtrace *) | ||
Inr { fail = fun () -> ignore (find_exn t ~from:dir name : Lib.t); raise e } | ||
end | ||
| Select { choices; loc; _ } -> | ||
match | ||
List.find_map choices ~f:(fun { required; forbidden; _ } -> | ||
if String_set.exists forbidden ~f:(lib_is_available t ~from:dir) then | ||
None | ||
else | ||
match | ||
List.map (String_set.elements required) ~f:(find_exn t ~from:dir) | ||
with | ||
| l -> Some l | ||
| exception _ -> None) | ||
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. Unrelated: Maybe we should just add 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. indeed |
||
with | ||
| Some l -> Inl l | ||
| None -> | ||
Inr { fail = fun () -> | ||
Loc.fail loc "No solution found for this select form" | ||
} | ||
|
||
let interpret_lib_deps t ~dir lib_deps = | ||
let libs, failures = | ||
List.partition_map lib_deps ~f:(function | ||
| Lib_dep.Direct name -> begin | ||
match find_exn t ~from:dir name with | ||
| x -> Inl [x] | ||
| exception e -> | ||
(* Call [find] again to get a proper backtrace *) | ||
Inr { fail = fun () -> ignore (find_exn t ~from:dir name : Lib.t); raise e } | ||
end | ||
| Select { choices; loc; _ } -> | ||
match | ||
List.find_map choices ~f:(fun { required; forbidden; _ } -> | ||
if String_set.exists forbidden ~f:(lib_is_available t ~from:dir) then | ||
None | ||
else | ||
match | ||
List.map (String_set.elements required) ~f:(find_exn t ~from:dir) | ||
with | ||
| l -> Some l | ||
| exception _ -> None) | ||
with | ||
| Some l -> Inl l | ||
| None -> | ||
Inr { fail = fun () -> | ||
Loc.fail loc "No solution found for this select form" | ||
}) | ||
List.partition_map lib_deps ~f:(interpret_lib_dep t ~dir) | ||
in | ||
let internals, externals = | ||
List.partition_map (List.concat libs) ~f:(function | ||
|
@@ -182,6 +185,12 @@ let interpret_lib_deps t ~dir lib_deps = | |
| [] -> None | ||
| f :: _ -> Some f) | ||
|
||
let best_lib_dep_names_exn t ~dir lib_deps = | ||
List.concat_map lib_deps ~f:(fun lib_dep -> | ||
match interpret_lib_dep t ~dir lib_dep with | ||
| Inl libs -> List.map libs ~f:Lib.best_name | ||
| Inr fail -> fail.fail ()) | ||
|
||
type resolved_select = | ||
{ src_fn : string | ||
; dst_fn : string | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Would you mind explaining this trick a bit? How does calling find_exn again get us a proper back trace? Isn't it going to just raise and we won't re-raise e?
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.
yes, that's the expectation. In fact we could just replace the
raise e
byassert false
. By callingfind_exn
, we get a more precise backtrace. For instance it might start in findlib.mlThere 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.
OK, I think doing
assert false
will be a little nicer since we won't even have to binde
in the pattern match.