Search in sources :

Example 1 with ConfigurationFactory

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

the class BuildViewTest method lateBoundSplitAttributeConfigs.

@Test
public void lateBoundSplitAttributeConfigs() throws Exception {
    useRuleClassProvider(LateBoundSplitUtil.getRuleClassProvider());
    // Register the latebound split fragment with the config creation environment.
    useConfigurationFactory(new ConfigurationFactory(ruleClassProvider.getConfigurationCollectionFactory(), ruleClassProvider.getConfigurationFragments()));
    scratch.file("foo/BUILD", "rule_with_latebound_split(", "    name = 'foo')", "rule_with_test_fragment(", "    name = 'latebound_dep')");
    update("//foo:foo");
    assertNotNull(getConfiguredTarget("//foo:foo"));
    Iterable<ConfiguredTarget> deps = SkyframeExecutorTestUtils.getExistingConfiguredTargets(skyframeExecutor, Label.parseAbsolute("//foo:latebound_dep"));
    assertThat(deps).hasSize(2);
    assertThat(ImmutableList.of(LateBoundSplitUtil.getOptions(Iterables.get(deps, 0).getConfiguration()).fooFlag, LateBoundSplitUtil.getOptions(Iterables.get(deps, 1).getConfiguration()).fooFlag)).containsExactly("one", "two");
}
Also used : ConfigurationFactory(com.google.devtools.build.lib.analysis.config.ConfigurationFactory) Test(org.junit.Test)

Example 2 with ConfigurationFactory

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

the class BuildViewTestCase method initializeSkyframeExecutor.

@Before
public final void initializeSkyframeExecutor() throws Exception {
    analysisMock = getAnalysisMock();
    directories = new BlazeDirectories(outputBase, outputBase, rootDirectory, analysisMock.getProductName());
    binTools = BinTools.forUnitTesting(directories, analysisMock.getEmbeddedTools());
    mockToolsConfig = new MockToolsConfig(rootDirectory, false);
    analysisMock.setupMockClient(mockToolsConfig);
    analysisMock.setupMockWorkspaceFiles(directories.getEmbeddedBinariesRoot());
    packageCacheOptions = parsePackageCacheOptions();
    workspaceStatusActionFactory = new AnalysisTestUtil.DummyWorkspaceStatusActionFactory(directories);
    mutableActionGraph = new MapBasedActionGraph();
    ruleClassProvider = getRuleClassProvider();
    configurationFactory = analysisMock.createConfigurationFactory(ruleClassProvider.getConfigurationFragments());
    pkgFactory = analysisMock.getPackageFactoryForTesting().create(ruleClassProvider, getPlatformSetRegexps(), getEnvironmentExtensions(), scratch.getFileSystem());
    tsgm = new TimestampGranularityMonitor(BlazeClock.instance());
    skyframeExecutor = SequencedSkyframeExecutor.create(pkgFactory, directories, binTools, workspaceStatusActionFactory, ruleClassProvider.getBuildInfoFactories(), ImmutableList.<DiffAwareness.Factory>of(), Predicates.<PathFragment>alwaysFalse(), getPreprocessorFactorySupplier(), analysisMock.getSkyFunctions(), getPrecomputedValues(), ImmutableList.<SkyValueDirtinessChecker>of(), analysisMock.getProductName(), CrossRepositoryLabelViolationStrategy.ERROR, ImmutableList.of(BuildFileName.BUILD_DOT_BAZEL, BuildFileName.BUILD));
    packageCacheOptions.defaultVisibility = ConstantRuleVisibility.PUBLIC;
    packageCacheOptions.showLoadingProgress = true;
    packageCacheOptions.globbingThreads = 7;
    skyframeExecutor.preparePackageLoading(new PathPackageLocator(outputBase, ImmutableList.of(rootDirectory)), packageCacheOptions, "", UUID.randomUUID(), ImmutableMap.<String, String>of(), ImmutableMap.<String, String>of(), tsgm);
    useConfiguration();
    setUpSkyframe();
    // Also initializes ResourceManager.
    ResourceManager.instance().setAvailableResources(getStartingResources());
}
Also used : MockToolsConfig(com.google.devtools.build.lib.packages.util.MockToolsConfig) PathPackageLocator(com.google.devtools.build.lib.pkgcache.PathPackageLocator) BlazeDirectories(com.google.devtools.build.lib.analysis.BlazeDirectories) MapBasedActionGraph(com.google.devtools.build.lib.actions.MapBasedActionGraph) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) PackageFactory(com.google.devtools.build.lib.packages.PackageFactory) MiddlemanFactory(com.google.devtools.build.lib.actions.MiddlemanFactory) ConfigurationFactory(com.google.devtools.build.lib.analysis.config.ConfigurationFactory) TimestampGranularityMonitor(com.google.devtools.build.lib.util.io.TimestampGranularityMonitor) SkyValueDirtinessChecker(com.google.devtools.build.lib.skyframe.SkyValueDirtinessChecker) Before(org.junit.Before)

Example 3 with ConfigurationFactory

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

the class ConfigurationTestCase method initializeSkyframeExecutor.

@Before
public final void initializeSkyframeExecutor() throws Exception {
    workspace = rootDirectory;
    analysisMock = getAnalysisMock();
    ConfiguredRuleClassProvider ruleClassProvider = analysisMock.createRuleClassProvider();
    PathPackageLocator pkgLocator = new PathPackageLocator(outputBase, ImmutableList.of(rootDirectory));
    final PackageFactory pkgFactory;
    BlazeDirectories directories = new BlazeDirectories(outputBase, outputBase, rootDirectory, analysisMock.getProductName());
    pkgFactory = analysisMock.getPackageFactoryForTesting().create(ruleClassProvider, scratch.getFileSystem());
    AnalysisTestUtil.DummyWorkspaceStatusActionFactory workspaceStatusActionFactory = new AnalysisTestUtil.DummyWorkspaceStatusActionFactory(directories);
    skyframeExecutor = SequencedSkyframeExecutor.create(pkgFactory, directories, BinTools.forUnitTesting(directories, analysisMock.getEmbeddedTools()), workspaceStatusActionFactory, ruleClassProvider.getBuildInfoFactories(), ImmutableList.<DiffAwareness.Factory>of(), Predicates.<PathFragment>alwaysFalse(), Preprocessor.Factory.Supplier.NullSupplier.INSTANCE, analysisMock.getSkyFunctions(), ImmutableList.<PrecomputedValue.Injected>of(), ImmutableList.<SkyValueDirtinessChecker>of(), analysisMock.getProductName(), CrossRepositoryLabelViolationStrategy.ERROR, ImmutableList.of(BuildFileName.BUILD_DOT_BAZEL, BuildFileName.BUILD));
    PackageCacheOptions packageCacheOptions = Options.getDefaults(PackageCacheOptions.class);
    packageCacheOptions.showLoadingProgress = true;
    packageCacheOptions.globbingThreads = 7;
    skyframeExecutor.preparePackageLoading(pkgLocator, packageCacheOptions, ruleClassProvider.getDefaultsPackageContent(analysisMock.getInvocationPolicyEnforcer().getInvocationPolicy()), UUID.randomUUID(), ImmutableMap.<String, String>of(), ImmutableMap.<String, String>of(), new TimestampGranularityMonitor(BlazeClock.instance()));
    mockToolsConfig = new MockToolsConfig(rootDirectory);
    analysisMock.setupMockClient(mockToolsConfig);
    analysisMock.setupMockWorkspaceFiles(directories.getEmbeddedBinariesRoot());
    configurationFactory = analysisMock.createConfigurationFactory();
    buildOptionClasses = ruleClassProvider.getConfigurationOptions();
}
Also used : MockToolsConfig(com.google.devtools.build.lib.packages.util.MockToolsConfig) ConfiguredRuleClassProvider(com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) ConfigurationFactory(com.google.devtools.build.lib.analysis.config.ConfigurationFactory) PackageFactory(com.google.devtools.build.lib.packages.PackageFactory) PackageCacheOptions(com.google.devtools.build.lib.pkgcache.PackageCacheOptions) PathPackageLocator(com.google.devtools.build.lib.pkgcache.PathPackageLocator) PackageFactory(com.google.devtools.build.lib.packages.PackageFactory) BlazeDirectories(com.google.devtools.build.lib.analysis.BlazeDirectories) SkyValueDirtinessChecker(com.google.devtools.build.lib.skyframe.SkyValueDirtinessChecker) TimestampGranularityMonitor(com.google.devtools.build.lib.util.io.TimestampGranularityMonitor) Before(org.junit.Before)

Aggregations

ConfigurationFactory (com.google.devtools.build.lib.analysis.config.ConfigurationFactory)3 BlazeDirectories (com.google.devtools.build.lib.analysis.BlazeDirectories)2 PackageFactory (com.google.devtools.build.lib.packages.PackageFactory)2 MockToolsConfig (com.google.devtools.build.lib.packages.util.MockToolsConfig)2 PathPackageLocator (com.google.devtools.build.lib.pkgcache.PathPackageLocator)2 SkyValueDirtinessChecker (com.google.devtools.build.lib.skyframe.SkyValueDirtinessChecker)2 TimestampGranularityMonitor (com.google.devtools.build.lib.util.io.TimestampGranularityMonitor)2 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)2 Before (org.junit.Before)2 MapBasedActionGraph (com.google.devtools.build.lib.actions.MapBasedActionGraph)1 MiddlemanFactory (com.google.devtools.build.lib.actions.MiddlemanFactory)1 ConfiguredRuleClassProvider (com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider)1 PackageCacheOptions (com.google.devtools.build.lib.pkgcache.PackageCacheOptions)1 Test (org.junit.Test)1