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

Fix a couple of bugs with Incompatible Target Skipping #12560

Closed
wants to merge 1 commit into from

Conversation

philsc
Copy link
Contributor

@philsc philsc commented Nov 25, 2020

While adding target_compatible_with attributes in the FRC team 971's
code base I came across bug #12553. It wasn't possible to make a
Python target depend on another incompatible Python target.

This patch fixes that issue by teaching RuleContext about
incompatible prerequisites. This also fixes an issue with the
validation of file extensions.

It's possible that validateDirectPrerequisite() skips a bit too much
validation. It was unfortunately the cleanest way I could think of.

I struggled a bit to come up with what ended up becoming
RuleContextConstraintSemantics.IncompatibleCheckResult. The purpose
of that class is to centralize the logic for checking for
OutputFileConfiguredTarget dependencies. Such dependencies need a
bit of special logic in order to find IncompatiblePlatformProvider
instances. When I implemented this patch, I realized that the
TopLevelConstraintSemantics logic had a very similar problem. It
didn't deal with the OutputFileConfiguredTarget problem at all. I
took the liberty of fixing that issue in this patch also because it
nicely re-used the same new helper.

I could not figure out a good way to avoid making RuleContext depend
on RuleContextConstraintSemantics.

Fixes #12553

@philsc
Copy link
Contributor Author

philsc commented Dec 2, 2020

Okay, this is ready for review.

I'm still not happy about making RuleContext.java import RuleContextConstraintSemantics, but I can't think of a better way.

frc971-automation pushed a commit to frc971/971-Robot-Code that referenced this pull request Dec 5, 2020
This is the same version as 4.0.0rc2 except with 2 cherry-picks:
a3c94ec2ed Fix builds for filegroup targets with incompatible dependencies
b3c9d7381c Fix a couple of bugs with Incompatible Target Skipping

The patch for the filegroup fix has already merged on master:
bazelbuild/bazel#12601

The other patch is still under review:
bazelbuild/bazel#12560

This should enable us to convert the code base to use platforms.

Change-Id: I35f078c2576f5268d5e3fb33e9bd86732529f744
Copy link
Contributor

@gregestren gregestren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This overall looks good to me. I also don't think it's that huge a deal with the new dependency from RuleContext, although I appreciate the general concern about that.

Just the code placing comment as my only nit.

While adding `target_compatible_with` attributes in the FRC team 971's
code base I came across bug bazelbuild#12553. It wasn't possible to make a
Python target depend on another incompatible Python target.

This patch fixes that issue by teaching `RuleContext` about
incompatible prerequisites. This also fixes an issue with the
validation of file extensions.

It's possible that `validateDirectPrerequisite()` skips a bit too much
validation. It was unfortunately the cleanest way I could think of.

I struggled a bit to come up with what ended up becoming
`RuleContextConstraintSemantics.IncompatibleCheckResult`. The purpose
of that class is to centralize the logic for checking for
`OutputFileConfiguredTarget` dependencies. Such dependencies need a
bit of special logic in order to find `IncompatiblePlatformProvider`
instances. When I implemented this patch, I realized that the
`TopLevelConstraintSemantics` logic had a very similar problem. It
didn't deal with the `OutputFileConfiguredTarget` problem at all. I
took the liberty of fixing that issue in this patch also because it
nicely re-used the same new helper.

I could not figure out a good way to avoid making `RuleContext` depend
on `RuleContextConstraintSemantics`.

Fixes bazelbuild#12553
@bazel-io bazel-io closed this in 3e969ff Dec 10, 2020
@philsc philsc deleted the fix12553 branch December 11, 2020 15:43
frc971-automation pushed a commit to frc971/971-Robot-Code that referenced this pull request Dec 13, 2020
This is the upstream rc6 branch with two cherry-picks:

Fix a couple of bugs with Incompatible Target Skipping
bazelbuild/bazel#12560

Add --{no,}autodetect_server_javabase
bazelbuild/bazel#12542

This patch also uses the new --noautodetect_server_javabase flag.

Change-Id: I7a397e4a9f17b942d0f81c7affb829d2de385a30
meisterT pushed a commit that referenced this pull request Dec 15, 2020
While adding `target_compatible_with` attributes in the FRC team 971's
code base I came across bug #12553. It wasn't possible to make a
Python target depend on another incompatible Python target.

This patch fixes that issue by teaching `RuleContext` about
incompatible prerequisites. This also fixes an issue with the
validation of file extensions.

It's possible that `validateDirectPrerequisite()` skips a bit too much
validation. It was unfortunately the cleanest way I could think of.

I struggled a bit to come up with what ended up becoming
`RuleContextConstraintSemantics.IncompatibleCheckResult`. The purpose
of that class is to centralize the logic for checking for
`OutputFileConfiguredTarget` dependencies. Such dependencies need a
bit of special logic in order to find `IncompatiblePlatformProvider`
instances. When I implemented this patch, I realized that the
`TopLevelConstraintSemantics` logic had a very similar problem. It
didn't deal with the `OutputFileConfiguredTarget` problem at all. I
took the liberty of fixing that issue in this patch also because it
nicely re-used the same new helper.

I could not figure out a good way to avoid making `RuleContext` depend
on `RuleContextConstraintSemantics`.

Fixes #12553

Closes #12560.

PiperOrigin-RevId: 346796174
ulfjack pushed a commit to EngFlow/bazel that referenced this pull request Mar 5, 2021
While adding `target_compatible_with` attributes in the FRC team 971's
code base I came across bug bazelbuild#12553. It wasn't possible to make a
Python target depend on another incompatible Python target.

This patch fixes that issue by teaching `RuleContext` about
incompatible prerequisites. This also fixes an issue with the
validation of file extensions.

It's possible that `validateDirectPrerequisite()` skips a bit too much
validation. It was unfortunately the cleanest way I could think of.

I struggled a bit to come up with what ended up becoming
`RuleContextConstraintSemantics.IncompatibleCheckResult`. The purpose
of that class is to centralize the logic for checking for
`OutputFileConfiguredTarget` dependencies. Such dependencies need a
bit of special logic in order to find `IncompatiblePlatformProvider`
instances. When I implemented this patch, I realized that the
`TopLevelConstraintSemantics` logic had a very similar problem. It
didn't deal with the `OutputFileConfiguredTarget` problem at all. I
took the liberty of fixing that issue in this patch also because it
nicely re-used the same new helper.

I could not figure out a good way to avoid making `RuleContext` depend
on `RuleContextConstraintSemantics`.

Fixes bazelbuild#12553

Closes bazelbuild#12560.

PiperOrigin-RevId: 346796174
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes team-Configurability platforms, toolchains, cquery, select(), config transitions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incompatible Target Skipping breaks rules with custom providers
3 participants