Search in sources :

Example 11 with PackageCacheOptions

use of com.google.devtools.build.lib.pkgcache.PackageCacheOptions in project bazel by bazelbuild.

the class PackageFunctionTest method testGlobOrderStableWithLegacyAndSkyframeComponents.

@Test
public void testGlobOrderStableWithLegacyAndSkyframeComponents() throws Exception {
    scratch.file("foo/BUILD", "sh_library(name = 'foo', srcs = glob(['*.txt']))");
    scratch.file("foo/b.txt");
    scratch.file("foo/a.config");
    preparePackageLoading(rootDirectory);
    SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//foo"));
    assertSrcs(validPackage(skyKey), "foo", "//foo:b.txt");
    scratch.overwriteFile("foo/BUILD", "sh_library(name = 'foo', srcs = glob(['*.txt', '*.config']))");
    getSkyframeExecutor().invalidateFilesUnderPathForTesting(reporter, ModifiedFileSet.builder().modify(new PathFragment("foo/BUILD")).build(), rootDirectory);
    assertSrcs(validPackage(skyKey), "foo", "//foo:a.config", "//foo:b.txt");
    scratch.overwriteFile("foo/BUILD", "sh_library(name = 'foo', srcs = glob(['*.txt', '*.config'])) # comment");
    getSkyframeExecutor().invalidateFilesUnderPathForTesting(reporter, ModifiedFileSet.builder().modify(new PathFragment("foo/BUILD")).build(), rootDirectory);
    assertSrcs(validPackage(skyKey), "foo", "//foo:a.config", "//foo:b.txt");
    getSkyframeExecutor().resetEvaluator();
    PackageCacheOptions packageCacheOptions = Options.getDefaults(PackageCacheOptions.class);
    packageCacheOptions.defaultVisibility = ConstantRuleVisibility.PUBLIC;
    packageCacheOptions.showLoadingProgress = true;
    packageCacheOptions.globbingThreads = 7;
    getSkyframeExecutor().preparePackageLoading(new PathPackageLocator(outputBase, ImmutableList.<Path>of(rootDirectory)), packageCacheOptions, "", UUID.randomUUID(), ImmutableMap.<String, String>of(), ImmutableMap.<String, String>of(), tsgm);
    assertSrcs(validPackage(skyKey), "foo", "//foo:a.config", "//foo:b.txt");
}
Also used : SkyKey(com.google.devtools.build.skyframe.SkyKey) PathPackageLocator(com.google.devtools.build.lib.pkgcache.PathPackageLocator) RootedPath(com.google.devtools.build.lib.vfs.RootedPath) Path(com.google.devtools.build.lib.vfs.Path) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) PackageCacheOptions(com.google.devtools.build.lib.pkgcache.PackageCacheOptions) Test(org.junit.Test)

Example 12 with PackageCacheOptions

use of com.google.devtools.build.lib.pkgcache.PackageCacheOptions 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

PackageCacheOptions (com.google.devtools.build.lib.pkgcache.PackageCacheOptions)12 PathPackageLocator (com.google.devtools.build.lib.pkgcache.PathPackageLocator)9 TimestampGranularityMonitor (com.google.devtools.build.lib.util.io.TimestampGranularityMonitor)9 Path (com.google.devtools.build.lib.vfs.Path)4 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)4 Test (org.junit.Test)3 BuildView (com.google.devtools.build.lib.analysis.BuildView)2 ConfigurationFactory (com.google.devtools.build.lib.analysis.config.ConfigurationFactory)2 PackageFactory (com.google.devtools.build.lib.packages.PackageFactory)2 Target (com.google.devtools.build.lib.packages.Target)2 SubincludePreprocessor (com.google.devtools.build.lib.packages.util.SubincludePreprocessor)2 SkyValueDirtinessChecker (com.google.devtools.build.lib.skyframe.SkyValueDirtinessChecker)2 SkyKey (com.google.devtools.build.skyframe.SkyKey)2 Before (org.junit.Before)2 ImmutableList (com.google.common.collect.ImmutableList)1 BlazeDirectories (com.google.devtools.build.lib.analysis.BlazeDirectories)1 ConfiguredRuleClassProvider (com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider)1 BinTools (com.google.devtools.build.lib.analysis.config.BinTools)1 BuildOptions (com.google.devtools.build.lib.analysis.config.BuildOptions)1 RepositoryOptions (com.google.devtools.build.lib.bazel.repository.RepositoryOptions)1