-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DataProvider] Add
SkymeldUsed
Datum and provide it (#116)
As a first step to supporting Bazel profiles where Skymeld was used, add a `Datum` that indices whether the profile looks like it was generated while using Skymeld. Contributes to #91 Contributes to #97 --------- Signed-off-by: Sara Adams <sara.e.adams@gmail.com>
- Loading branch information
Showing
15 changed files
with
453 additions
and
247 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
54 changes: 54 additions & 0 deletions
54
analyzer/java/com/engflow/bazel/invocation/analyzer/dataproviders/SkymeldUsed.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,54 @@ | ||
/* | ||
* Copyright 2023 EngFlow Inc. | ||
* | ||
* 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.engflow.bazel.invocation.analyzer.dataproviders; | ||
|
||
import com.engflow.bazel.invocation.analyzer.core.Datum; | ||
|
||
/** | ||
* Whether evidence was found that Skymeld was used. | ||
* | ||
* @see <a href="https://github.com/bazelbuild/bazel/issues/14057">Project Skymeld GitHub issue</a> | ||
*/ | ||
public class SkymeldUsed implements Datum { | ||
private final boolean skymeldUsed; | ||
|
||
public SkymeldUsed(boolean skymeldUsed) { | ||
this.skymeldUsed = skymeldUsed; | ||
} | ||
|
||
public boolean isSkymeldUsed() { | ||
return skymeldUsed; | ||
} | ||
|
||
@Override | ||
public boolean isEmpty() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public String getEmptyReason() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "Whether the Bazel Profile includes events indicating that Skymeld was used."; | ||
} | ||
|
||
@Override | ||
public String getSummary() { | ||
return String.valueOf(skymeldUsed); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...zer/java/com/engflow/bazel/invocation/analyzer/dataproviders/SkymeldUsedDataProvider.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,50 @@ | ||
/* | ||
* Copyright 2022 EngFlow Inc. | ||
* | ||
* 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.engflow.bazel.invocation.analyzer.dataproviders; | ||
|
||
import com.engflow.bazel.invocation.analyzer.bazelprofile.BazelProfilePhase; | ||
import com.engflow.bazel.invocation.analyzer.core.DataProvider; | ||
import com.engflow.bazel.invocation.analyzer.core.DatumSupplier; | ||
import com.engflow.bazel.invocation.analyzer.core.DatumSupplierSpecification; | ||
import com.engflow.bazel.invocation.analyzer.core.InvalidProfileException; | ||
import com.engflow.bazel.invocation.analyzer.core.MissingInputException; | ||
import com.engflow.bazel.invocation.analyzer.core.NullDatumException; | ||
import com.google.common.annotations.VisibleForTesting; | ||
import java.util.List; | ||
|
||
/** | ||
* A {@link DataProvider} that returns whether the profile looks like it was generated while using | ||
* Skymeld. | ||
* | ||
* @see <a href="https://github.com/bazelbuild/bazel/issues/14057">Project Skymeld GitHub issue</a> | ||
*/ | ||
public class SkymeldUsedDataProvider extends DataProvider { | ||
|
||
@Override | ||
public List<DatumSupplierSpecification<?>> getSuppliers() { | ||
return List.of( | ||
DatumSupplierSpecification.of( | ||
SkymeldUsed.class, DatumSupplier.memoized(this::getSkymeldUsed))); | ||
} | ||
|
||
@VisibleForTesting | ||
SkymeldUsed getSkymeldUsed() | ||
throws InvalidProfileException, MissingInputException, NullDatumException { | ||
BazelPhaseDescriptions bazelPhaseDescriptions = | ||
getDataManager().getDatum(BazelPhaseDescriptions.class); | ||
return new SkymeldUsed( | ||
bazelPhaseDescriptions.get(BazelProfilePhase.ANALYZE_AND_EXECUTE).isPresent()); | ||
} | ||
} |
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
Oops, something went wrong.