Search in sources :

Example 1 with RuleClassProvider

use of com.google.devtools.build.lib.packages.RuleClassProvider in project bazel by bazelbuild.

the class LocalRepositoryLookupFunctionTest method setUp.

@Before
public final void setUp() throws Exception {
    AnalysisMock analysisMock = AnalysisMock.get();
    AtomicReference<PathPackageLocator> pkgLocator = new AtomicReference<>(new PathPackageLocator(outputBase, ImmutableList.of(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.ERROR, ImmutableList.of(BuildFileName.BUILD_DOT_BAZEL, BuildFileName.BUILD)));
    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));
    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());
    differencer = new RecordingDifferencer();
    evaluator = new InMemoryMemoizingEvaluator(skyFunctions, differencer);
    driver = new SequentialBuildDriver(evaluator);
    PrecomputedValue.PATH_PACKAGE_LOCATOR.set(differencer, pkgLocator.get());
}
Also used : RecordingDifferencer(com.google.devtools.build.skyframe.RecordingDifferencer) HashMap(java.util.HashMap) 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) 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) PackageIdentifier(com.google.devtools.build.lib.cmdline.PackageIdentifier) AnalysisMock(com.google.devtools.build.lib.analysis.util.AnalysisMock) Before(org.junit.Before)

Example 2 with RuleClassProvider

use of com.google.devtools.build.lib.packages.RuleClassProvider in project bazel by bazelbuild.

the class ListRuleMain method main.

public static void main(String[] args) throws Exception {
    if (args.length == 0) {
        System.err.println("Expected one input parameter, please provide the name of the rule class provider");
    }
    RuleClassProvider provider = createRuleClassProvider(args[0]);
    Map<String, RuleClass> rcMap = provider.getRuleClassMap();
    for (String name : rcMap.keySet()) {
        System.out.println(name);
    }
}
Also used : ConfiguredRuleClassProvider(com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider) RuleClassProvider(com.google.devtools.build.lib.packages.RuleClassProvider) RuleClass(com.google.devtools.build.lib.packages.RuleClass)

Example 3 with RuleClassProvider

use of com.google.devtools.build.lib.packages.RuleClassProvider 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)

Aggregations

RuleClassProvider (com.google.devtools.build.lib.packages.RuleClassProvider)3 BlazeDirectories (com.google.devtools.build.lib.analysis.BlazeDirectories)2 AnalysisMock (com.google.devtools.build.lib.analysis.util.AnalysisMock)2 PackageIdentifier (com.google.devtools.build.lib.cmdline.PackageIdentifier)2 PackageFactory (com.google.devtools.build.lib.packages.PackageFactory)2 PathPackageLocator (com.google.devtools.build.lib.pkgcache.PathPackageLocator)2 InMemoryMemoizingEvaluator (com.google.devtools.build.skyframe.InMemoryMemoizingEvaluator)2 RecordingDifferencer (com.google.devtools.build.skyframe.RecordingDifferencer)2 SequentialBuildDriver (com.google.devtools.build.skyframe.SequentialBuildDriver)2 SkyFunction (com.google.devtools.build.skyframe.SkyFunction)2 SkyFunctionName (com.google.devtools.build.skyframe.SkyFunctionName)2 HashMap (java.util.HashMap)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 Before (org.junit.Before)2 ConfiguredRuleClassProvider (com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider)1 RuleClass (com.google.devtools.build.lib.packages.RuleClass)1 LocalRepositoryFunction (com.google.devtools.build.lib.rules.repository.LocalRepositoryFunction)1 RepositoryDelegatorFunction (com.google.devtools.build.lib.rules.repository.RepositoryDelegatorFunction)1 RepositoryFunction (com.google.devtools.build.lib.rules.repository.RepositoryFunction)1 RepositoryLoaderFunction (com.google.devtools.build.lib.rules.repository.RepositoryLoaderFunction)1