use of com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider in project bazel by bazelbuild.
the class BuildEncyclopediaGenerator method createRuleClassProvider.
private static ConfiguredRuleClassProvider createRuleClassProvider(String classProvider) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
Class<?> providerClass = Class.forName(classProvider);
Method createMethod = providerClass.getMethod("create");
return (ConfiguredRuleClassProvider) createMethod.invoke(null);
}
use of com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider in project bazel by bazelbuild.
the class ListRuleMain method createRuleClassProvider.
private static ConfiguredRuleClassProvider createRuleClassProvider(String classProvider) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
Class<?> providerClass = Class.forName(classProvider);
Method createMethod = providerClass.getMethod("create");
return (ConfiguredRuleClassProvider) createMethod.invoke(null);
}
use of com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider in project bazel by bazelbuild.
the class HelpCommand method emitCompletionHelp.
private void emitCompletionHelp(BlazeRuntime runtime, OutErr outErr) {
// First startup_options
Iterable<BlazeModule> blazeModules = runtime.getBlazeModules();
ConfiguredRuleClassProvider ruleClassProvider = runtime.getRuleClassProvider();
Map<String, BlazeCommand> commandsByName = getSortedCommands(runtime);
outErr.printOutLn("BAZEL_COMMAND_LIST=\"" + SPACE_JOINER.join(commandsByName.keySet()) + "\"");
outErr.printOutLn("BAZEL_INFO_KEYS=\"");
for (String name : InfoCommand.getHardwiredInfoItemNames(runtime.getProductName())) {
outErr.printOutLn(name);
}
outErr.printOutLn("\"");
outErr.printOutLn("BAZEL_STARTUP_OPTIONS=\"");
Iterable<Class<? extends OptionsBase>> options = BlazeCommandUtils.getStartupOptions(blazeModules);
outErr.printOut(OptionsParser.newOptionsParser(options).getOptionsCompletion());
outErr.printOutLn("\"");
for (Map.Entry<String, BlazeCommand> e : commandsByName.entrySet()) {
BlazeCommand command = e.getValue();
String varName = e.getKey().toUpperCase(Locale.US).replace('-', '_');
Command annotation = command.getClass().getAnnotation(Command.class);
if (!annotation.completion().isEmpty()) {
outErr.printOutLn("BAZEL_COMMAND_" + varName + "_ARGUMENT=\"" + annotation.completion() + "\"");
}
options = BlazeCommandUtils.getOptions(command.getClass(), blazeModules, ruleClassProvider);
outErr.printOutLn("BAZEL_COMMAND_" + varName + "_FLAGS=\"");
outErr.printOut(OptionsParser.newOptionsParser(options).getOptionsCompletion());
outErr.printOutLn("\"");
}
}
use of com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider 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();
}
Aggregations