diff options
author | 2018-05-16 09:13:27 -0700 | |
---|---|---|
committer | 2018-05-16 09:15:11 -0700 | |
commit | 7a491b7e62a033aa5f0f8efdfd77dac5ec5fa1b3 (patch) | |
tree | e52e0c6ffb782a25e49089a6b66963337bb5f7ec /src/main/java/com/google/devtools | |
parent | cd76c1f8a9a645f0ecc2a95a66548b7178b35155 (diff) |
Port bazelrc flags into their own module.
This way the documentation logs them correctly as named "bazel," and describes the correct behavior.
Needed for #4502.
RELNOTES: None.
PiperOrigin-RevId: 196837021
Diffstat (limited to 'src/main/java/com/google/devtools')
7 files changed, 92 insertions, 40 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/BUILD b/src/main/java/com/google/devtools/build/lib/BUILD index 8259018bc3..b5c5bf8e3d 100644 --- a/src/main/java/com/google/devtools/build/lib/BUILD +++ b/src/main/java/com/google/devtools/build/lib/BUILD @@ -681,10 +681,7 @@ java_library( java_library( name = "bazel-main", - srcs = glob( - ["bazel/*.java"], - exclude = ["bazel/BazelRepositoryModule.java"], - ), + srcs = ["bazel/Bazel.java"], resources = [ "bazel/rules/java/java_stub_template.txt", "bazel/rules/java/java_stub_template_windows.txt", @@ -696,6 +693,7 @@ java_library( ":exitcode-external", "//src/main/java/com/google/devtools/build/lib:bazel", "//src/main/java/com/google/devtools/build/lib:bazel-commands", + "//src/main/java/com/google/devtools/build/lib:bazel-modules", "//src/main/java/com/google/devtools/build/lib:bazel-repository", "//src/main/java/com/google/devtools/build/lib:bazel-rules", "//src/main/java/com/google/devtools/build/lib:build-base", @@ -704,26 +702,45 @@ java_library( "//src/main/java/com/google/devtools/build/lib:io", "//src/main/java/com/google/devtools/build/lib:packages-internal", "//src/main/java/com/google/devtools/build/lib:util", - "//src/main/java/com/google/devtools/build/lib/actions", "//src/main/java/com/google/devtools/build/lib/bazel/repository/cache", "//src/main/java/com/google/devtools/build/lib/bazel/repository/downloader", "//src/main/java/com/google/devtools/build/lib/buildeventservice", - "//src/main/java/com/google/devtools/build/lib/clock", "//src/main/java/com/google/devtools/build/lib/profiler/callcounts:callcounts_module", "//src/main/java/com/google/devtools/build/lib/profiler/memory:allocationtracker_module", "//src/main/java/com/google/devtools/build/lib/remote", "//src/main/java/com/google/devtools/build/lib/sandbox", - "//src/main/java/com/google/devtools/build/lib/shell", - "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec", "//src/main/java/com/google/devtools/build/lib/ssd", "//src/main/java/com/google/devtools/build/lib/standalone", - "//src/main/java/com/google/devtools/build/lib/vfs", "//src/main/java/com/google/devtools/build/lib/worker", "//src/main/java/com/google/devtools/build/skyframe:skyframe-objects", + "//third_party:guava", + ], +) + +java_library( + name = "bazel-modules", + srcs = glob( + ["bazel/*.java"], + exclude = [ + "bazel/Bazel.java", + "bazel/BazelRepositoryModule.java", + ], + ), + deps = [ + ":exitcode-external", + "//src/main/java/com/google/devtools/build/lib:build-base", + "//src/main/java/com/google/devtools/build/lib:build-info", + "//src/main/java/com/google/devtools/build/lib:events", + "//src/main/java/com/google/devtools/build/lib:io", + "//src/main/java/com/google/devtools/build/lib:runtime", + "//src/main/java/com/google/devtools/build/lib:util", + "//src/main/java/com/google/devtools/build/lib/actions", + "//src/main/java/com/google/devtools/build/lib/shell", + "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec", + "//src/main/java/com/google/devtools/build/lib/vfs", + "//src/main/java/com/google/devtools/build/lib/vfs:pathfragment", "//src/main/java/com/google/devtools/common/options", - "//src/test/java/com/google/devtools/build/lib:testutil/BazelPackageBuilderHelperForTesting", "//third_party:guava", - "//third_party:jsr305", ], ) diff --git a/src/main/java/com/google/devtools/build/lib/bazel/Bazel.java b/src/main/java/com/google/devtools/build/lib/bazel/Bazel.java index 8490efe37c..6c3e1d777f 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/Bazel.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/Bazel.java @@ -37,6 +37,7 @@ public final class Bazel { */ public static final ImmutableList<Class<? extends BlazeModule>> BAZEL_MODULES = ImmutableList.of( + BazelStartupOptionsModule.class, com.google.devtools.build.lib.runtime.BazelFileSystemModule.class, com.google.devtools.build.lib.runtime.mobileinstall.MobileInstallModule.class, com.google.devtools.build.lib.bazel.BazelWorkspaceStatusModule.class, diff --git a/src/main/java/com/google/devtools/build/lib/bazel/BazelStartupOptionsModule.java b/src/main/java/com/google/devtools/build/lib/bazel/BazelStartupOptionsModule.java new file mode 100644 index 0000000000..07fdfe37a8 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/bazel/BazelStartupOptionsModule.java @@ -0,0 +1,58 @@ +// Copyright 2018 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.google.devtools.build.lib.bazel; + +import com.google.common.collect.ImmutableList; +import com.google.devtools.build.lib.runtime.BlazeModule; +import com.google.devtools.common.options.Option; +import com.google.devtools.common.options.OptionDocumentationCategory; +import com.google.devtools.common.options.OptionEffectTag; +import com.google.devtools.common.options.OptionsBase; + +/** Provides Bazel startup flags. */ +public class BazelStartupOptionsModule extends BlazeModule { + /** Bazelrc file flags. */ + public static final class Options extends OptionsBase { + @Option( + name = "bazelrc", + defaultValue = "null", // NOTE: purely decorative, rc files are read by the client. + documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS, + effectTags = {OptionEffectTag.CHANGES_INPUTS}, + valueHelp = "<path>", + help = + "The location of the user .bazelrc file containing default values of " + + "Bazel options. If unspecified, Bazel uses the first .bazelrc file it finds in " + + "the following two locations: the workspace directory, then the user's home " + + "directory. Use /dev/null to disable the search for a user rc file, e.g. in " + + "release builds.") + public String blazerc; + + @Option( + name = "master_bazelrc", + defaultValue = "true", // NOTE: purely decorative, rc files are read by the client. + documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS, + effectTags = {OptionEffectTag.CHANGES_INPUTS}, + help = + "If this option is false, the master bazelrcs are not read. Otherwise, Bazel looks for " + + "master rcs in three locations, reading them all, in order: " + + "$workspace/tools/bazel.rc, a .bazelrc file near the bazel binary, and the " + + "global rc, /etc/bazel.bazelrc.") + public boolean masterBlazerc; + } + + @Override + public Iterable<Class<? extends OptionsBase>> getStartupOptions() { + return ImmutableList.of(Options.class); + } +} diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java index 6844412463..54d409979f 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java @@ -265,7 +265,7 @@ public class BlazeCommandDispatcher { // Record the command's starting time for use by the commands themselves. env.recordCommandStartTime(firstContactTime); - // Temporary: there is one module that outputs events during beforeCommand, but the reporter + // Temporary: there are modules that output events during beforeCommand, but the reporter // isn't setup yet. Add the stored event handler to catch those events. env.getReporter().addHandler(storedEventHandler); for (BlazeModule module : runtime.getBlazeModules()) { diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java index 9ccef65167..51cfb2783e 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java @@ -960,11 +960,11 @@ public final class BlazeRuntime { /** * Parses the command line arguments into a {@link OptionsParser} object. * - * <p>This function needs to parse the --option_sources option manually so that the real option + * <p>This function needs to parse the --option_sources option manually so that the real option * parser can set the source for every option correctly. If that cannot be parsed or is missing, * we just report an unknown source for every startup option. */ - private static OptionsProvider parseOptions( + private static OptionsProvider parseStartupOptions( Iterable<BlazeModule> modules, List<String> args) throws OptionsParsingException { ImmutableList<Class<? extends OptionsBase>> optionClasses = BlazeCommandUtils.getStartupOptions(modules); @@ -1006,7 +1006,7 @@ public final class BlazeRuntime { private static BlazeRuntime newRuntime(Iterable<BlazeModule> blazeModules, List<String> args, Runnable abruptShutdownHandler) throws AbruptExitException, OptionsParsingException { - OptionsProvider options = parseOptions(blazeModules, args); + OptionsProvider options = parseStartupOptions(blazeModules, args); for (BlazeModule module : blazeModules) { module.globalInit(options); } diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java index 90684c5946..1ec6e13d88 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java @@ -300,30 +300,6 @@ public class BlazeServerStartupOptions extends OptionsBase { public boolean ignoreAllRcFiles; @Option( - name = "blazerc", - defaultValue = "null", // NOTE: purely decorative, rc files are read by the client. - documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS, - effectTags = {OptionEffectTag.CHANGES_INPUTS}, - valueHelp = "<path>", - help = - "The location of the .%{product}rc file containing default values of " - + "Blaze command options. By default, Blaze first checks the current directory, then " - + "the user's home directory, and then looks for a file named .$(basename $0)rc " - + "(i.e. .%{product}rc). Use /dev/null to disable the search for a %{product}rc file, " - + "e.g. in release builds." - ) - public String blazerc; - - @Option( - name = "master_blazerc", - defaultValue = "true", // NOTE: purely decorative, rc files are read by the client. - documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS, - effectTags = {OptionEffectTag.CHANGES_INPUTS}, - help = "If this option is false, the master %{product}rc next to the binary is not read." - ) - public boolean masterBlazerc; - - @Option( name = "fatal_event_bus_exceptions", defaultValue = "false", // NOTE: only for documentation, value is always passed by the client. documentationCategory = OptionDocumentationCategory.UNDOCUMENTED, diff --git a/src/main/java/com/google/devtools/build/lib/runtime/CommandLineEvent.java b/src/main/java/com/google/devtools/build/lib/runtime/CommandLineEvent.java index 1bf99be2c4..b01706f3c4 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/CommandLineEvent.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/CommandLineEvent.java @@ -305,7 +305,7 @@ public abstract class CommandLineEvent implements BuildEventWithOrderConstraint /** * Returns the effective startup options. * - * <p>Since in this command line the command options include invocation policy's and blazercs' + * <p>Since in this command line the command options include invocation policy's and rcs' * contents expanded fully, the list of startup options should prevent reapplication of these * contents. * |