-
Notifications
You must be signed in to change notification settings - Fork 431
Fix directory targets with empty subdirs #11226
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
Merged
Merged
Changes from all commits
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
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 |
---|---|---|
|
@@ -206,6 +206,7 @@ end = struct | |
(* Fact: alias [a] expands to the set of file-digest pairs [digests] *) | ||
Dep.Fact.alias a digests | ||
| File f -> | ||
(* Not necessarily a file, can also be a directory. *) | ||
let+ digest = build_file f in | ||
(* Fact: file [f] has digest [digest] *) | ||
Dep.Fact.file f digest | ||
|
@@ -855,10 +856,14 @@ end = struct | |
|
||
rleshchinskiy: Is this digest ever used? [build_dir] discards it and do we | ||
(or should we) ever use [build_file] to build directories? Perhaps this could | ||
be split in two memo tables, one for files and one for directories. *) | ||
be split in two memo tables, one for files and one for directories. | ||
|
||
ElectreAAS: a lot of functions are called [build_file] or [create_file] | ||
even though they also handle directories, this is expected. | ||
Also yes this digest is used by [Exported.build_dep] defined above. *) | ||
(match Cached_digest.build_file ~allow_dirs:true path with | ||
| Ok digest -> digest, Dir_target { targets } | ||
(* Must be a directory target *) | ||
(* Must be a directory target. *) | ||
| Error _ -> | ||
(* CR-someday amokhov: The most important reason we end up here is | ||
[No_such_file]. I think some of the outcomes above are impossible | ||
|
@@ -1060,7 +1065,8 @@ let file_exists fn = | |
(Path.Build.Map.mem rules_here.by_file_targets (Path.as_in_build_dir_exn fn)) | ||
| Build_under_directory_target { directory_target_ancestor } -> | ||
let+ path_map = build_dir (Path.build directory_target_ancestor) in | ||
Targets.Produced.mem path_map (Path.as_in_build_dir_exn fn) | ||
(* Note that in the case of directory targets, we also check if directories exist. *) | ||
Targets.Produced.mem_any path_map (Path.as_in_build_dir_exn fn) | ||
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. Does this mean that |
||
;; | ||
|
||
let files_of ~dir = | ||
|
@@ -1161,6 +1167,11 @@ let build_file p = | |
() | ||
;; | ||
|
||
let build_dir p = | ||
let+ (_ : Digest.t Targets.Produced.t) = build_dir p in | ||
() | ||
;; | ||
|
||
let with_file p ~f = | ||
let+ () = build_file p in | ||
f p | ||
|
Oops, something went wrong.
Oops, something went wrong.
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.
Maybe while at it, you could rename it to be something neutral? If something is called "file" I would not expect it to be a directory and it something is called a "directory" I would not expect it to be a file.
Maybe "directory entry"/"dirent"? Or "inode", though that might imply a bit too much. Or something else.