Search in sources :

Example 26 with PathPackageLocator

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

the class PackageLoadingTestCase method setUpSkyframe.

protected void setUpSkyframe(RuleVisibility defaultVisibility, String defaultsPackageContents) {
    PackageCacheOptions packageCacheOptions = Options.getDefaults(PackageCacheOptions.class);
    packageCacheOptions.defaultVisibility = defaultVisibility;
    packageCacheOptions.showLoadingProgress = true;
    packageCacheOptions.globbingThreads = GLOBBING_THREADS;
    skyframeExecutor.preparePackageLoading(new PathPackageLocator(outputBase, ImmutableList.of(rootDirectory)), packageCacheOptions, defaultsPackageContents, UUID.randomUUID(), ImmutableMap.<String, String>of(), ImmutableMap.<String, String>of(), new TimestampGranularityMonitor(BlazeClock.instance()));
}
Also used : PathPackageLocator(com.google.devtools.build.lib.pkgcache.PathPackageLocator) PackageCacheOptions(com.google.devtools.build.lib.pkgcache.PackageCacheOptions) TimestampGranularityMonitor(com.google.devtools.build.lib.util.io.TimestampGranularityMonitor)

Example 27 with PathPackageLocator

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

the class GlobFunctionTest method setUp.

@Before
public final void setUp() throws Exception {
    fs = new CustomInMemoryFs(new ManualClock());
    root = fs.getRootDirectory().getRelative("root/workspace");
    writableRoot = fs.getRootDirectory().getRelative("writableRoot/workspace");
    outputBase = fs.getRootDirectory().getRelative("output_base");
    pkgPath = root.getRelative(PKG_ID.getPackageFragment());
    pkgLocator = new AtomicReference<>(new PathPackageLocator(outputBase, ImmutableList.of(writableRoot, root)));
    differencer = new RecordingDifferencer();
    evaluator = new InMemoryMemoizingEvaluator(createFunctionMap(), differencer);
    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);
    createTestFiles();
}
Also used : PathPackageLocator(com.google.devtools.build.lib.pkgcache.PathPackageLocator) RecordingDifferencer(com.google.devtools.build.skyframe.RecordingDifferencer) SequentialBuildDriver(com.google.devtools.build.skyframe.SequentialBuildDriver) ManualClock(com.google.devtools.build.lib.testutil.ManualClock) InMemoryMemoizingEvaluator(com.google.devtools.build.skyframe.InMemoryMemoizingEvaluator) Before(org.junit.Before)

Example 28 with PathPackageLocator

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

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

the class PackageLookupFunctionTest method setUp.

@Before
public final void setUp() throws Exception {
    emptyPackagePath = rootDirectory.getRelative("somewhere/else");
    scratch.file("parentpackage/BUILD");
    AnalysisMock analysisMock = AnalysisMock.get();
    AtomicReference<PathPackageLocator> pkgLocator = new AtomicReference<>(new PathPackageLocator(outputBase, ImmutableList.of(emptyPackagePath, rootDirectory)));
    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);
    Map<SkyFunctionName, SkyFunction> skyFunctions = new HashMap<>();
    skyFunctions.put(SkyFunctions.PACKAGE_LOOKUP, new PackageLookupFunction(deletedPackages, crossRepositoryLabelViolationStrategy(), ImmutableList.of(BuildFileName.BUILD_DOT_BAZEL, BuildFileName.BUILD)));
    skyFunctions.put(SkyFunctions.PACKAGE, new PackageFunction(null, null, null, null, null, null, null));
    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.BLACKLISTED_PACKAGE_PREFIXES, new BlacklistedPackagePrefixesFunction());
    RuleClassProvider ruleClassProvider = analysisMock.createRuleClassProvider();
    skyFunctions.put(SkyFunctions.WORKSPACE_AST, new WorkspaceASTFunction(ruleClassProvider));
    skyFunctions.put(SkyFunctions.WORKSPACE_FILE, new WorkspaceFileFunction(ruleClassProvider, analysisMock.getPackageFactoryForTesting().create(ruleClassProvider, new PackageFactory.EmptyEnvironmentExtension(), scratch.getFileSystem()), directories));
    skyFunctions.put(SkyFunctions.EXTERNAL_PACKAGE, new ExternalPackageFunction());
    skyFunctions.put(SkyFunctions.LOCAL_REPOSITORY_LOOKUP, new LocalRepositoryLookupFunction());
    skyFunctions.put(SkyFunctions.FILE_SYMLINK_CYCLE_UNIQUENESS, new FileSymlinkCycleUniquenessFunction());
    ImmutableMap<String, RepositoryFunction> repositoryHandlers = ImmutableMap.of(LocalRepositoryRule.NAME, (RepositoryFunction) new LocalRepositoryFunction());
    skyFunctions.put(SkyFunctions.REPOSITORY_DIRECTORY, new RepositoryDelegatorFunction(repositoryHandlers, null, new AtomicBoolean(true)));
    skyFunctions.put(SkyFunctions.REPOSITORY, new RepositoryLoaderFunction());
    differencer = new RecordingDifferencer();
    evaluator = new InMemoryMemoizingEvaluator(skyFunctions, differencer);
    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);
    PrecomputedValue.BLAZE_DIRECTORIES.set(differencer, directories);
}
Also used : RecordingDifferencer(com.google.devtools.build.skyframe.RecordingDifferencer) HashMap(java.util.HashMap) RepositoryLoaderFunction(com.google.devtools.build.lib.rules.repository.RepositoryLoaderFunction) RuleClassProvider(com.google.devtools.build.lib.packages.RuleClassProvider) PathPackageLocator(com.google.devtools.build.lib.pkgcache.PathPackageLocator) SequentialBuildDriver(com.google.devtools.build.skyframe.SequentialBuildDriver) PackageFactory(com.google.devtools.build.lib.packages.PackageFactory) SkyFunctionName(com.google.devtools.build.skyframe.SkyFunctionName) LocalRepositoryFunction(com.google.devtools.build.lib.rules.repository.LocalRepositoryFunction) RepositoryFunction(com.google.devtools.build.lib.rules.repository.RepositoryFunction) SkyFunction(com.google.devtools.build.skyframe.SkyFunction) InMemoryMemoizingEvaluator(com.google.devtools.build.skyframe.InMemoryMemoizingEvaluator) RepositoryDelegatorFunction(com.google.devtools.build.lib.rules.repository.RepositoryDelegatorFunction) AtomicReference(java.util.concurrent.atomic.AtomicReference) LocalRepositoryFunction(com.google.devtools.build.lib.rules.repository.LocalRepositoryFunction) BlazeDirectories(com.google.devtools.build.lib.analysis.BlazeDirectories) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) PackageIdentifier(com.google.devtools.build.lib.cmdline.PackageIdentifier) AnalysisMock(com.google.devtools.build.lib.analysis.util.AnalysisMock) Before(org.junit.Before)

Example 30 with PathPackageLocator

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

the class FileFunctionTest method testSymlinkAcrossPackageRoots.

@Test
public void testSymlinkAcrossPackageRoots() throws Exception {
    Path otherPkgRoot = fs.getRootDirectory().getRelative("other_root");
    pkgLocator = new PathPackageLocator(outputBase, ImmutableList.of(pkgRoot, otherPkgRoot));
    symlink("a", "/other_root/b");
    assertValueChangesIfContentsOfFileChanges("/other_root/b", true, "a");
}
Also used : RootedPath(com.google.devtools.build.lib.vfs.RootedPath) Path(com.google.devtools.build.lib.vfs.Path) PathPackageLocator(com.google.devtools.build.lib.pkgcache.PathPackageLocator) Test(org.junit.Test)

Aggregations

PathPackageLocator (com.google.devtools.build.lib.pkgcache.PathPackageLocator)32 Before (org.junit.Before)13 BlazeDirectories (com.google.devtools.build.lib.analysis.BlazeDirectories)12 TimestampGranularityMonitor (com.google.devtools.build.lib.util.io.TimestampGranularityMonitor)12 InMemoryMemoizingEvaluator (com.google.devtools.build.skyframe.InMemoryMemoizingEvaluator)11 RecordingDifferencer (com.google.devtools.build.skyframe.RecordingDifferencer)11 SequentialBuildDriver (com.google.devtools.build.skyframe.SequentialBuildDriver)11 AtomicReference (java.util.concurrent.atomic.AtomicReference)10 PackageCacheOptions (com.google.devtools.build.lib.pkgcache.PackageCacheOptions)9 SkyFunction (com.google.devtools.build.skyframe.SkyFunction)9 SkyFunctionName (com.google.devtools.build.skyframe.SkyFunctionName)9 Path (com.google.devtools.build.lib.vfs.Path)8 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)7 RootedPath (com.google.devtools.build.lib.vfs.RootedPath)6 HashMap (java.util.HashMap)6 Test (org.junit.Test)5 PackageIdentifier (com.google.devtools.build.lib.cmdline.PackageIdentifier)4 PackageFactory (com.google.devtools.build.lib.packages.PackageFactory)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 AnalysisMock (com.google.devtools.build.lib.analysis.util.AnalysisMock)3