use of com.google.devtools.build.lib.analysis.RuleDefinition in project bazel by bazelbuild.
the class PackageLoadingTestCase method initializeSkyframeExecutor.
@Before
public final void initializeSkyframeExecutor() throws Exception {
loadingMock = LoadingMock.get();
List<RuleDefinition> extraRules = getExtraRules();
if (!extraRules.isEmpty()) {
ConfiguredRuleClassProvider.Builder builder = new ConfiguredRuleClassProvider.Builder();
TestRuleClassProvider.addStandardRules(builder);
for (RuleDefinition def : extraRules) {
builder.addRuleDefinition(def);
}
ruleClassProvider = builder.build();
} else {
ruleClassProvider = loadingMock.createRuleClassProvider();
}
packageFactory = loadingMock.getPackageFactoryForTesting().create(ruleClassProvider, null, getEnvironmentExtensions(), scratch.getFileSystem());
skyframeExecutor = createSkyframeExecutor(getPreprocessorFactorySupplier());
setUpSkyframe(parsePackageCacheOptions());
}
use of com.google.devtools.build.lib.analysis.RuleDefinition in project bazel by bazelbuild.
the class BazelRepositoryModule method initializeRuleClasses.
@Override
public void initializeRuleClasses(ConfiguredRuleClassProvider.Builder builder) {
for (Entry<String, RepositoryFunction> handler : repositoryHandlers.entrySet()) {
// TODO(bazel-team): Migrate away from Class<?>
RuleDefinition ruleDefinition;
try {
ruleDefinition = handler.getValue().getRuleDefinition().newInstance();
} catch (IllegalAccessException | InstantiationException e) {
throw new IllegalStateException(e);
}
builder.addRuleDefinition(ruleDefinition);
}
builder.addSkylarkModule(SkylarkRepositoryModule.class);
}
use of com.google.devtools.build.lib.analysis.RuleDefinition in project bazel by bazelbuild.
the class RuleDocumentationAttribute method visitAncestor.
private void visitAncestor(Class<? extends RuleDefinition> usingClass, Map<Class<? extends RuleDefinition>, Integer> visited, LinkedList<Class<? extends RuleDefinition>> toVisit, ConfiguredRuleClassProvider ruleClassProvider) {
RuleDefinition instance = getRuleDefinition(usingClass, ruleClassProvider);
for (Class<? extends RuleDefinition> ancestor : instance.getMetadata().ancestors()) {
if (!visited.containsKey(ancestor)) {
toVisit.addLast(ancestor);
visited.put(ancestor, visited.get(usingClass) + 1);
}
}
}
use of com.google.devtools.build.lib.analysis.RuleDefinition in project bazel by bazelbuild.
the class AnalysisTestCase method setRulesAvailableInTests.
/**
* Makes {@code rules} available in tests, in addition to all the rules available to Blaze at
* running time (e.g., java_library).
*/
protected final void setRulesAvailableInTests(RuleDefinition... rules) throws Exception {
ConfiguredRuleClassProvider.Builder builder = new ConfiguredRuleClassProvider.Builder();
TestRuleClassProvider.addStandardRules(builder);
for (RuleDefinition rule : rules) {
builder.addRuleDefinition(rule);
}
useRuleClassProvider(builder.build());
update();
}
Aggregations