Search in sources :

Example 1 with RuleDefinition

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());
}
Also used : ConfiguredRuleClassProvider(com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider) RuleDefinition(com.google.devtools.build.lib.analysis.RuleDefinition) Before(org.junit.Before)

Example 2 with RuleDefinition

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);
}
Also used : SkylarkRepositoryFunction(com.google.devtools.build.lib.bazel.repository.skylark.SkylarkRepositoryFunction) LocalRepositoryFunction(com.google.devtools.build.lib.rules.repository.LocalRepositoryFunction) NewLocalRepositoryFunction(com.google.devtools.build.lib.rules.repository.NewLocalRepositoryFunction) GitRepositoryFunction(com.google.devtools.build.lib.bazel.repository.GitRepositoryFunction) MavenServerRepositoryFunction(com.google.devtools.build.lib.bazel.repository.MavenServerRepositoryFunction) AndroidNdkRepositoryFunction(com.google.devtools.build.lib.bazel.rules.android.AndroidNdkRepositoryFunction) AndroidSdkRepositoryFunction(com.google.devtools.build.lib.bazel.rules.android.AndroidSdkRepositoryFunction) NewGitRepositoryFunction(com.google.devtools.build.lib.bazel.repository.NewGitRepositoryFunction) RepositoryFunction(com.google.devtools.build.lib.rules.repository.RepositoryFunction) RuleDefinition(com.google.devtools.build.lib.analysis.RuleDefinition)

Example 3 with RuleDefinition

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);
        }
    }
}
Also used : RuleDefinition(com.google.devtools.build.lib.analysis.RuleDefinition)

Example 4 with RuleDefinition

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();
}
Also used : ConfiguredRuleClassProvider(com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider) RuleDefinition(com.google.devtools.build.lib.analysis.RuleDefinition)

Aggregations

RuleDefinition (com.google.devtools.build.lib.analysis.RuleDefinition)4 ConfiguredRuleClassProvider (com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider)2 GitRepositoryFunction (com.google.devtools.build.lib.bazel.repository.GitRepositoryFunction)1 MavenServerRepositoryFunction (com.google.devtools.build.lib.bazel.repository.MavenServerRepositoryFunction)1 NewGitRepositoryFunction (com.google.devtools.build.lib.bazel.repository.NewGitRepositoryFunction)1 SkylarkRepositoryFunction (com.google.devtools.build.lib.bazel.repository.skylark.SkylarkRepositoryFunction)1 AndroidNdkRepositoryFunction (com.google.devtools.build.lib.bazel.rules.android.AndroidNdkRepositoryFunction)1 AndroidSdkRepositoryFunction (com.google.devtools.build.lib.bazel.rules.android.AndroidSdkRepositoryFunction)1 LocalRepositoryFunction (com.google.devtools.build.lib.rules.repository.LocalRepositoryFunction)1 NewLocalRepositoryFunction (com.google.devtools.build.lib.rules.repository.NewLocalRepositoryFunction)1 RepositoryFunction (com.google.devtools.build.lib.rules.repository.RepositoryFunction)1 Before (org.junit.Before)1