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();
}
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);
}
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);
}
}
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();
}
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));
}
Aggregations