Search in sources :

Example 6 with OptionsParser

use of com.google.devtools.common.options.OptionsParser in project bazel by bazelbuild.

the class BuildViewTestCase method parsePackageCacheOptions.

private PackageCacheOptions parsePackageCacheOptions(String... options) throws Exception {
    OptionsParser parser = OptionsParser.newOptionsParser(PackageCacheOptions.class);
    parser.parse("--default_visibility=public");
    parser.parse(options);
    return parser.getOptions(PackageCacheOptions.class);
}
Also used : OptionsParser(com.google.devtools.common.options.OptionsParser)

Example 7 with OptionsParser

use of com.google.devtools.common.options.OptionsParser in project bazel by bazelbuild.

the class DefaultsPackageUtil method getDefaultsPackageForOptions.

public static String getDefaultsPackageForOptions(Class<? extends FragmentOptions> optionsClass, String... options) throws OptionsParsingException {
    OptionsParser parser = OptionsParser.newOptionsParser(ImmutableList.<Class<? extends OptionsBase>>of(BuildConfiguration.Options.class, optionsClass));
    parser.parse(options);
    InvocationPolicyEnforcer enforcer = AnalysisMock.get().getInvocationPolicyEnforcer();
    enforcer.enforce(parser);
    return DefaultsPackage.getDefaultsPackageContent(BuildOptions.of(ImmutableList.<Class<? extends FragmentOptions>>of(BuildConfiguration.Options.class, optionsClass), parser));
}
Also used : BuildConfiguration(com.google.devtools.build.lib.analysis.config.BuildConfiguration) BuildOptions(com.google.devtools.build.lib.analysis.config.BuildOptions) FragmentOptions(com.google.devtools.build.lib.analysis.config.FragmentOptions) FragmentOptions(com.google.devtools.build.lib.analysis.config.FragmentOptions) InvocationPolicyEnforcer(com.google.devtools.build.lib.flags.InvocationPolicyEnforcer) OptionsParser(com.google.devtools.common.options.OptionsParser)

Example 8 with OptionsParser

use of com.google.devtools.common.options.OptionsParser in project bazel by bazelbuild.

the class BlazeExecutorTest method testDebugPrintActionContexts.

@Test
public void testDebugPrintActionContexts() throws Exception {
    TestExecutorBuilder builder = new TestExecutorBuilder(directories, binTools);
    OptionsParser parser = OptionsParser.newOptionsParser(TestExecutorBuilder.DEFAULT_OPTIONS);
    parser.parse("--debug_print_action_contexts");
    Reporter reporter = new Reporter(new EventBus());
    StoredEventHandler storedEventHandler = new StoredEventHandler();
    reporter.addHandler(storedEventHandler);
    SpawnActionContext mockStrategy = Mockito.mock(SpawnActionContext.class);
    builder.setReporter(reporter).setOptionsParser(parser).setExecution("mock", mockStrategy);
    builder.build();
    Event event = Iterables.find(storedEventHandler.getEvents(), new Predicate<Event>() {

        @Override
        public boolean apply(@Nullable Event event) {
            return event.getMessage().contains("SpawnActionContextMap: \"mock\" = ");
        }
    });
    assertThat(event).isNotNull();
    assertThat(event.getMessage()).contains("\"mock\" = " + mockStrategy.getClass().getSimpleName());
}
Also used : TestExecutorBuilder(com.google.devtools.build.lib.exec.util.TestExecutorBuilder) StoredEventHandler(com.google.devtools.build.lib.events.StoredEventHandler) Reporter(com.google.devtools.build.lib.events.Reporter) Event(com.google.devtools.build.lib.events.Event) EventBus(com.google.common.eventbus.EventBus) OptionsParser(com.google.devtools.common.options.OptionsParser) SpawnActionContext(com.google.devtools.build.lib.actions.SpawnActionContext) Test(org.junit.Test)

Example 9 with OptionsParser

use of com.google.devtools.common.options.OptionsParser in project bazel by bazelbuild.

the class PackageLoadingTestCase method parsePackageCacheOptions.

private PackageCacheOptions parsePackageCacheOptions(String... options) throws Exception {
    OptionsParser parser = OptionsParser.newOptionsParser(PackageCacheOptions.class);
    parser.parse(new String[] { "--default_visibility=public" });
    parser.parse(options);
    return parser.getOptions(PackageCacheOptions.class);
}
Also used : OptionsParser(com.google.devtools.common.options.OptionsParser)

Example 10 with OptionsParser

use of com.google.devtools.common.options.OptionsParser in project bazel by bazelbuild.

the class CrosstoolConfigurationLoaderTest method createBuildOptionsForTest.

private BuildOptions createBuildOptionsForTest(String... args) {
    ImmutableList<Class<? extends FragmentOptions>> testFragments = TestRuleClassProvider.getRuleClassProvider().getConfigurationOptions();
    OptionsParser optionsParser = OptionsParser.newOptionsParser(testFragments);
    try {
        optionsParser.parse(args);
        InvocationPolicyEnforcer optionsPolicyEnforcer = analysisMock.getInvocationPolicyEnforcer();
        optionsPolicyEnforcer.enforce(optionsParser);
    } catch (OptionsParsingException e) {
        throw new IllegalStateException(e);
    }
    return BuildOptions.applyStaticConfigOverride(BuildOptions.of(testFragments, optionsParser));
}
Also used : FragmentOptions(com.google.devtools.build.lib.analysis.config.FragmentOptions) InvocationPolicyEnforcer(com.google.devtools.build.lib.flags.InvocationPolicyEnforcer) OptionsParsingException(com.google.devtools.common.options.OptionsParsingException) OptionsParser(com.google.devtools.common.options.OptionsParser)

Aggregations

OptionsParser (com.google.devtools.common.options.OptionsParser)50 Path (java.nio.file.Path)11 IOException (java.io.IOException)10 Stopwatch (com.google.common.base.Stopwatch)8 Test (org.junit.Test)7 InvocationPolicyEnforcer (com.google.devtools.build.lib.flags.InvocationPolicyEnforcer)6 OptionsParsingException (com.google.devtools.common.options.OptionsParsingException)6 AaptConfigOptions (com.google.devtools.build.android.AndroidResourceProcessor.AaptConfigOptions)5 OptionsBase (com.google.devtools.common.options.OptionsBase)5 MergingException (com.android.ide.common.res2.MergingException)4 Path (com.google.devtools.build.lib.vfs.Path)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3 EventBus (com.google.common.eventbus.EventBus)3 FlagAaptOptions (com.google.devtools.build.android.AndroidResourceProcessor.FlagAaptOptions)3 InputStream (java.io.InputStream)3 ArrayList (java.util.ArrayList)3 VariantType (com.android.builder.core.VariantType)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 DexingOptions (com.google.devtools.build.android.dexer.Dexing.DexingOptions)2 SpawnActionContext (com.google.devtools.build.lib.actions.SpawnActionContext)2