Search in sources :

Example 1 with ConfiguredRuleClassProvider

use of com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider in project bazel by bazelbuild.

the class BazelRuleClassProvider method create.

/** Used by the build encyclopedia generator. */
public static ConfiguredRuleClassProvider create() {
    ConfiguredRuleClassProvider.Builder builder = new ConfiguredRuleClassProvider.Builder();
    builder.setToolsRepository(TOOLS_REPOSITORY);
    setup(builder);
    return builder.build();
}
Also used : Builder(com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider.Builder) ConfiguredRuleClassProvider(com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider) Builder(com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider.Builder)

Example 2 with ConfiguredRuleClassProvider

use of com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider in project bazel by bazelbuild.

the class RecursiveFilesystemTraversalFunctionTest method setUp.

@Before
public final void setUp() throws Exception {
    AnalysisMock analysisMock = AnalysisMock.get();
    pkgLocator = new AtomicReference<>(new PathPackageLocator(outputBase, ImmutableList.of(rootDirectory)));
    AtomicReference<ImmutableSet<PackageIdentifier>> deletedPackages = new AtomicReference<>(ImmutableSet.<PackageIdentifier>of());
    BlazeDirectories directories = new BlazeDirectories(rootDirectory, outputBase, rootDirectory, analysisMock.getProductName());
    ExternalFilesHelper externalFilesHelper = new ExternalFilesHelper(pkgLocator, ExternalFileAction.DEPEND_ON_EXTERNAL_PKG_FOR_EXTERNAL_REPO_PATHS, directories);
    ConfiguredRuleClassProvider ruleClassProvider = analysisMock.createRuleClassProvider();
    Map<SkyFunctionName, SkyFunction> skyFunctions = new HashMap<>();
    skyFunctions.put(SkyFunctions.FILE_STATE, new FileStateFunction(new AtomicReference<TimestampGranularityMonitor>(), externalFilesHelper));
    skyFunctions.put(SkyFunctions.FILE, new FileFunction(pkgLocator));
    skyFunctions.put(SkyFunctions.DIRECTORY_LISTING, new DirectoryListingFunction());
    skyFunctions.put(SkyFunctions.DIRECTORY_LISTING_STATE, new DirectoryListingStateFunction(externalFilesHelper));
    skyFunctions.put(SkyFunctions.RECURSIVE_FILESYSTEM_TRAVERSAL, new RecursiveFilesystemTraversalFunction());
    skyFunctions.put(SkyFunctions.PACKAGE_LOOKUP, new PackageLookupFunction(deletedPackages, CrossRepositoryLabelViolationStrategy.ERROR, ImmutableList.of(BuildFileName.BUILD_DOT_BAZEL, BuildFileName.BUILD)));
    skyFunctions.put(SkyFunctions.BLACKLISTED_PACKAGE_PREFIXES, new BlacklistedPackagePrefixesFunction());
    skyFunctions.put(SkyFunctions.PACKAGE, new PackageFunction(null, null, null, null, null, null, null));
    skyFunctions.put(SkyFunctions.WORKSPACE_AST, new WorkspaceASTFunction(ruleClassProvider));
    skyFunctions.put(SkyFunctions.WORKSPACE_FILE, new WorkspaceFileFunction(ruleClassProvider, analysisMock.getPackageFactoryForTesting().create(ruleClassProvider, scratch.getFileSystem()), directories));
    skyFunctions.put(SkyFunctions.EXTERNAL_PACKAGE, new ExternalPackageFunction());
    skyFunctions.put(SkyFunctions.LOCAL_REPOSITORY_LOOKUP, new LocalRepositoryLookupFunction());
    progressReceiver = new RecordingEvaluationProgressReceiver();
    differencer = new RecordingDifferencer();
    evaluator = new InMemoryMemoizingEvaluator(skyFunctions, differencer, progressReceiver);
    driver = new SequentialBuildDriver(evaluator);
    PrecomputedValue.BUILD_ID.set(differencer, UUID.randomUUID());
    PrecomputedValue.PATH_PACKAGE_LOCATOR.set(differencer, pkgLocator.get());
    PrecomputedValue.BLACKLISTED_PACKAGE_PREFIXES_FILE.set(differencer, PathFragment.EMPTY_FRAGMENT);
}
Also used : RecordingDifferencer(com.google.devtools.build.skyframe.RecordingDifferencer) ConfiguredRuleClassProvider(com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider) HashMap(java.util.HashMap) PathPackageLocator(com.google.devtools.build.lib.pkgcache.PathPackageLocator) SequentialBuildDriver(com.google.devtools.build.skyframe.SequentialBuildDriver) SkyFunctionName(com.google.devtools.build.skyframe.SkyFunctionName) ImmutableSet(com.google.common.collect.ImmutableSet) SkyFunction(com.google.devtools.build.skyframe.SkyFunction) InMemoryMemoizingEvaluator(com.google.devtools.build.skyframe.InMemoryMemoizingEvaluator) AtomicReference(java.util.concurrent.atomic.AtomicReference) BlazeDirectories(com.google.devtools.build.lib.analysis.BlazeDirectories) AnalysisMock(com.google.devtools.build.lib.analysis.util.AnalysisMock) Before(org.junit.Before)

Example 3 with ConfiguredRuleClassProvider

use of com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider in project bazel by bazelbuild.

the class ConfigurationCollectionFunction method getHostConfiguration.

/** Returns the host configuration, or null on missing Skyframe deps. */
private BuildConfiguration getHostConfiguration(Environment env, BuildConfiguration targetConfiguration) throws InvalidConfigurationException, InterruptedException {
    if (targetConfiguration.useDynamicConfigurations()) {
        BuildOptions targetOptions = targetConfiguration.getOptions();
        BuildOptions hostOptions = targetOptions.get(BuildConfiguration.Options.class).useDistinctHostConfiguration ? HostTransition.INSTANCE.apply(targetConfiguration.getOptions()) : targetOptions;
        SkyKey hostConfigKey = BuildConfigurationValue.key(targetConfiguration.trimConfigurations() ? targetConfiguration.fragmentClasses() : ((ConfiguredRuleClassProvider) ruleClassProvider).getAllFragments(), hostOptions);
        BuildConfigurationValue skyValHost = (BuildConfigurationValue) env.getValueOrThrow(hostConfigKey, InvalidConfigurationException.class);
        // Also preload the target configuration so the configured target functions for
        // top-level targets don't have to waste cycles from a missing Skyframe dep.
        SkyKey targetConfigKey = BuildConfigurationValue.key(targetConfiguration.fragmentClasses(), targetOptions);
        BuildConfigurationValue skyValTarget = (BuildConfigurationValue) env.getValueOrThrow(targetConfigKey, InvalidConfigurationException.class);
        if (skyValHost == null || skyValTarget == null) {
            return null;
        }
        return skyValHost.getConfiguration();
    } else {
        return targetConfiguration.getConfiguration(Attribute.ConfigurationTransition.HOST);
    }
}
Also used : BuildConfiguration(com.google.devtools.build.lib.analysis.config.BuildConfiguration) SkyKey(com.google.devtools.build.skyframe.SkyKey) BuildOptions(com.google.devtools.build.lib.analysis.config.BuildOptions) ConfiguredRuleClassProvider(com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider) InvalidConfigurationException(com.google.devtools.build.lib.analysis.config.InvalidConfigurationException)

Example 4 with ConfiguredRuleClassProvider

use of com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider in project bazel by bazelbuild.

the class WorkspaceASTFunctionTest method setUp.

@Before
public final void setUp() throws Exception {
    ConfiguredRuleClassProvider ruleClassProvider = TestRuleClassProvider.getRuleClassProvider();
    ConfiguredRuleClassProvider ruleClassProviderSpy = Mockito.spy(ruleClassProvider);
    // Prevent returning default workspace file.
    Mockito.when(ruleClassProviderSpy.getDefaultWorkspacePrefix()).thenReturn("");
    Mockito.when(ruleClassProviderSpy.getDefaultWorkspaceSuffix()).thenReturn("");
    astSkyFunc = new WorkspaceASTFunction(ruleClassProviderSpy);
    fakeWorkspaceFileValue = new FakeFileValue();
}
Also used : ConfiguredRuleClassProvider(com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider) FakeFileValue(com.google.devtools.build.lib.skyframe.WorkspaceFileFunctionTest.FakeFileValue) Before(org.junit.Before)

Example 5 with ConfiguredRuleClassProvider

use of com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider in project bazel by bazelbuild.

the class AbstractCommandTest method testOptionsAreInherited.

@Test
public void testOptionsAreInherited() {
    ConfiguredRuleClassProvider ruleClassProvider = new ConfiguredRuleClassProvider.Builder().setToolsRepository(TestConstants.TOOLS_REPOSITORY).build();
    assertThat(BlazeCommandUtils.getOptions(CommandA.class, ImmutableList.<BlazeModule>of(), ruleClassProvider)).containsExactlyElementsIn(optionClassesWithDefault(FooOptions.class));
    assertThat(BlazeCommandUtils.getOptions(CommandB.class, ImmutableList.<BlazeModule>of(), ruleClassProvider)).containsExactlyElementsIn(optionClassesWithDefault(FooOptions.class, BarOptions.class));
}
Also used : ConfiguredRuleClassProvider(com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider) Test(org.junit.Test)

Aggregations

ConfiguredRuleClassProvider (com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider)14 Before (org.junit.Before)4 ImmutableMap (com.google.common.collect.ImmutableMap)2 BlazeDirectories (com.google.devtools.build.lib.analysis.BlazeDirectories)2 RuleClass (com.google.devtools.build.lib.packages.RuleClass)2 PathPackageLocator (com.google.devtools.build.lib.pkgcache.PathPackageLocator)2 BlazeCommand (com.google.devtools.build.lib.runtime.BlazeCommand)2 SkyFunction (com.google.devtools.build.skyframe.SkyFunction)2 SkyFunctionName (com.google.devtools.build.skyframe.SkyFunctionName)2 Method (java.lang.reflect.Method)2 Test (org.junit.Test)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)1 Builder (com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider.Builder)1 RuleSet (com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider.RuleSet)1 NoBuildEvent (com.google.devtools.build.lib.analysis.NoBuildEvent)1 BuildConfiguration (com.google.devtools.build.lib.analysis.config.BuildConfiguration)1 BuildOptions (com.google.devtools.build.lib.analysis.config.BuildOptions)1 ConfigurationFactory (com.google.devtools.build.lib.analysis.config.ConfigurationFactory)1 InvalidConfigurationException (com.google.devtools.build.lib.analysis.config.InvalidConfigurationException)1