forked from bazelbuild/bazel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make print() work from starlark transition implementation functions.
Give each starlark transition a stored event handler. After starlark transitions are applied (after top level transitions and inside configuration resolver), replay and then clear events. Declare a new abstract class for starlark transitions to consolidate fields/behavior. Add behavior to ComposingTransitions to allow decomposition. This is helpful here but will also be helpful in future work where we'll need to post-process starlark transitions after they've been applied (e.g. output type verification). bazelbuild#5574 RELNOTES: None. PiperOrigin-RevId: 229417148
- Loading branch information
1 parent
d1f482d
commit 4b7680b
Showing
12 changed files
with
294 additions
and
22 deletions.
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
52 changes: 52 additions & 0 deletions
52
src/main/java/com/google/devtools/build/lib/analysis/skylark/StarlarkTransition.java
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2019 The Bazel Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package com.google.devtools.build.lib.analysis.skylark; | ||
|
||
import com.google.devtools.build.lib.analysis.config.StarlarkDefinedConfigTransition; | ||
import com.google.devtools.build.lib.analysis.config.transitions.ConfigurationTransition; | ||
import com.google.devtools.build.lib.events.ExtendedEventHandler; | ||
import java.util.Objects; | ||
|
||
/** A marker class for configuration transitions that are defined in Starlark. */ | ||
public abstract class StarlarkTransition implements ConfigurationTransition { | ||
|
||
private final StarlarkDefinedConfigTransition starlarkDefinedConfigTransition; | ||
|
||
StarlarkTransition(StarlarkDefinedConfigTransition starlarkDefinedConfigTransition) { | ||
this.starlarkDefinedConfigTransition = starlarkDefinedConfigTransition; | ||
} | ||
|
||
public void replayOn(ExtendedEventHandler eventHandler) { | ||
starlarkDefinedConfigTransition.getEventHandler().replayOn(eventHandler); | ||
starlarkDefinedConfigTransition.getEventHandler().clear(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object object) { | ||
if (object == this) { | ||
return true; | ||
} | ||
if (object instanceof StarlarkTransition) { | ||
StarlarkDefinedConfigTransition starlarkDefinedConfigTransition = | ||
((StarlarkTransition) object).starlarkDefinedConfigTransition; | ||
return Objects.equals(starlarkDefinedConfigTransition, this.starlarkDefinedConfigTransition); | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hashCode(starlarkDefinedConfigTransition); | ||
} | ||
} |
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
Oops, something went wrong.