Skip to content
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

Remove incorrect validation step for dir targets #10331

Conversation

gridbugs
Copy link
Collaborator

The validation in question was comparing directory targets discovered in the project from directories that are the target of enabled rules (rules which lack an enabled_if field, or whose enabled_if condition is false). This was incorrect as it doesn't account for directory targets which are the target of disabled rules so the validation fails if any rule with a directory target is disabled. The validation step was introduced in 1fd19d7 but there aren't any clues to why it was necessary.

Fixes #10310

The validation in question was comparing directory targets discovered
in the project from directories that are the target of enabled rules
(rules which lack an `enabled_if` field, or whose `enabled_if` condition
is false). This was incorrect as it doesn't account for directory
targets which are the target of disabled rules so the validation fails
if any rule with a directory target is disabled. The validation step was
introduced in 1fd19d7 but there aren't any clues to why it was
necessary.

Fixes ocaml#10310

Signed-off-by: Stephen Sherratt <stephen@sherra.tt>
@gridbugs gridbugs requested a review from rgrinberg March 29, 2024 08:45
@gridbugs
Copy link
Collaborator Author

@jeremiedimino tagging you since you wrote the original version of this validation step. Please let me know if I've misunderstood something.

@gridbugs gridbugs requested a review from emillon March 29, 2024 08:47
@jeremiedimino
Copy link

jeremiedimino commented Mar 29, 2024 via email

@emillon
Copy link
Collaborator

emillon commented Mar 29, 2024

Hi Jeremie! 👋🏻

I agree, this check is here for a reason. Before removing it we would need a solid case. @rgrinberg will have the most up to date idea of the state of this.
What does the test do when the check is present? Can you submit a PR with just the test first?

@vouillon
Copy link
Member

I suspect the correct fix is to check in function Dir_status.extract_directory_targets whether the rules are enabled.

@rgrinberg
Copy link
Member

The validation step is indeed correct. Jerome has the right idea.

@rgrinberg rgrinberg closed this Mar 30, 2024
@gridbugs
Copy link
Collaborator Author

gridbugs commented Apr 2, 2024

Thanks for the explanation @jeremiedimino! I will dig deeper.

@vouillon
Copy link
Member

vouillon commented Apr 2, 2024

@gridbugs
I think you can add these lines to Dir_status.extract_directory_targets.

    | Rule { targets = Static { targets = l; _ }; enabled_if; loc = rule_loc; _ } ->
      let* available = (Expander.eval_blang expander enabled_if) in
      if not available then Memo.return acc else
      [...]

where expander is defined in Gen_rules.gen_rules_regular_directory:

  let* sctx = sctx in
  let* expander =
    let+ expander = Super_context.expander sctx ~dir in
    Dir_contents.add_sources_to_expander sctx expander
  in
  [...]

replicating what is done in Dir_contents.load_text_files and Simple_rules.user_rule.

@gridbugs
Copy link
Collaborator Author

gridbugs commented Apr 3, 2024

Thanks for the tip @vouillon. I have a new PR based on your suggestion #10367.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash with directory targets and multiple workspace contexts
5 participants