Search in sources :

Example 11 with ConfiguredRuleClassProvider

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);
}
Also used : ConfiguredRuleClassProvider(com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider) Method(java.lang.reflect.Method)

Example 12 with ConfiguredRuleClassProvider

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);
}
Also used : ConfiguredRuleClassProvider(com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider) Method(java.lang.reflect.Method)

Example 13 with ConfiguredRuleClassProvider

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("\"");
    }
}
Also used : OptionsBase(com.google.devtools.common.options.OptionsBase) BlazeCommand(com.google.devtools.build.lib.runtime.BlazeCommand) ConfiguredRuleClassProvider(com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider) BlazeCommand(com.google.devtools.build.lib.runtime.BlazeCommand) Command(com.google.devtools.build.lib.runtime.Command) RuleClass(com.google.devtools.build.lib.packages.RuleClass) BlazeModule(com.google.devtools.build.lib.runtime.BlazeModule) Map(java.util.Map) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 14 with ConfiguredRuleClassProvider

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

ConfiguredRuleClassProvider (com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider)14 Before (org.junit.Before)4 ImmutableMap (com.google.common.collect.ImmutableMap)2 BlazeDirectories (com.google.devtools.build.lib.analysis.BlazeDirectories)2 RuleClass (com.google.devtools.build.lib.packages.RuleClass)2 PathPackageLocator (com.google.devtools.build.lib.pkgcache.PathPackageLocator)2 BlazeCommand (com.google.devtools.build.lib.runtime.BlazeCommand)2 SkyFunction (com.google.devtools.build.skyframe.SkyFunction)2 SkyFunctionName (com.google.devtools.build.skyframe.SkyFunctionName)2 Method (java.lang.reflect.Method)2 Test (org.junit.Test)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)1 Builder (com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider.Builder)1 RuleSet (com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider.RuleSet)1 NoBuildEvent (com.google.devtools.build.lib.analysis.NoBuildEvent)1 BuildConfiguration (com.google.devtools.build.lib.analysis.config.BuildConfiguration)1 BuildOptions (com.google.devtools.build.lib.analysis.config.BuildOptions)1 ConfigurationFactory (com.google.devtools.build.lib.analysis.config.ConfigurationFactory)1 InvalidConfigurationException (com.google.devtools.build.lib.analysis.config.InvalidConfigurationException)1