aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/BUILD39
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/Bazel.java1
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/BazelStartupOptionsModule.java58
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java6
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java24
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/CommandLineEvent.java2
-rw-r--r--src/test/java/com/google/devtools/build/lib/BUILD1
-rw-r--r--src/test/java/com/google/devtools/build/lib/runtime/CommandLineEventTest.java35
9 files changed, 111 insertions, 57 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.
*
diff --git a/src/test/java/com/google/devtools/build/lib/BUILD b/src/test/java/com/google/devtools/build/lib/BUILD
index 1502f25437..52c95b19cc 100644
--- a/src/test/java/com/google/devtools/build/lib/BUILD
+++ b/src/test/java/com/google/devtools/build/lib/BUILD
@@ -1196,6 +1196,7 @@ java_test(
":guava_junit_truth",
":test_runner",
":testutil",
+ "//src/main/java/com/google/devtools/build/lib:bazel-modules",
"//src/main/java/com/google/devtools/build/lib:bazel-rules",
"//src/main/java/com/google/devtools/build/lib:build-base",
"//src/main/java/com/google/devtools/build/lib:io",
diff --git a/src/test/java/com/google/devtools/build/lib/runtime/CommandLineEventTest.java b/src/test/java/com/google/devtools/build/lib/runtime/CommandLineEventTest.java
index 71ad575314..228669b3c1 100644
--- a/src/test/java/com/google/devtools/build/lib/runtime/CommandLineEventTest.java
+++ b/src/test/java/com/google/devtools/build/lib/runtime/CommandLineEventTest.java
@@ -17,6 +17,7 @@ import static com.google.common.truth.Truth.assertThat;
import com.google.common.collect.ImmutableList;
import com.google.common.io.BaseEncoding;
+import com.google.devtools.build.lib.bazel.BazelStartupOptionsModule.Options;
import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.BuildEventId.StructuredCommandLineId;
import com.google.devtools.build.lib.runtime.CommandLineEvent.CanonicalCommandLineEvent;
import com.google.devtools.build.lib.runtime.CommandLineEvent.OriginalCommandLineEvent;
@@ -102,11 +103,11 @@ public class CommandLineEventTest {
}
@Test
- public void testActiveBlazercs_OriginalCommandLine() throws OptionsParsingException {
+ public void testActiveBazelrcs_OriginalCommandLine() throws OptionsParsingException {
OptionsParser fakeStartupOptions =
- OptionsParser.newOptionsParser(BlazeServerStartupOptions.class);
+ OptionsParser.newOptionsParser(BlazeServerStartupOptions.class, Options.class);
fakeStartupOptions.parse(
- "--blazerc=/some/path", "--master_blazerc", "--blazerc", "/some/other/path");
+ "--bazelrc=/some/path", "--master_bazelrc", "--bazelrc", "/some/other/path");
OptionsParser fakeCommandOptions = OptionsParser.newOptionsParser(TestOptions.class);
CommandLine line =
@@ -127,20 +128,20 @@ public class CommandLineEventTest {
assertThat(line.getSections(0).getChunkList().getChunk(0)).isEqualTo("testblaze");
assertThat(line.getSections(1).getOptionList().getOptionCount()).isEqualTo(3);
assertThat(line.getSections(1).getOptionList().getOption(0).getCombinedForm())
- .isEqualTo("--blazerc=/some/path");
+ .isEqualTo("--bazelrc=/some/path");
assertThat(line.getSections(1).getOptionList().getOption(1).getCombinedForm())
- .isEqualTo("--master_blazerc");
+ .isEqualTo("--master_bazelrc");
assertThat(line.getSections(1).getOptionList().getOption(2).getCombinedForm())
- .isEqualTo("--blazerc /some/other/path");
+ .isEqualTo("--bazelrc /some/other/path");
assertThat(line.getSections(2).getChunkList().getChunk(0)).isEqualTo("someCommandName");
assertThat(line.getSections(3).getOptionList().getOptionCount()).isEqualTo(0);
assertThat(line.getSections(4).getChunkList().getChunkCount()).isEqualTo(0);
}
@Test
- public void testPassedInBlazercs_OriginalCommandLine() throws OptionsParsingException {
+ public void testPassedInBazelrcs_OriginalCommandLine() throws OptionsParsingException {
OptionsParser fakeStartupOptions =
- OptionsParser.newOptionsParser(BlazeServerStartupOptions.class);
+ OptionsParser.newOptionsParser(BlazeServerStartupOptions.class, Options.class);
OptionsParser fakeCommandOptions = OptionsParser.newOptionsParser(TestOptions.class);
CommandLine line =
@@ -151,9 +152,9 @@ public class CommandLineEventTest {
fakeCommandOptions,
Optional.of(
ImmutableList.of(
- Pair.of("", "--blazerc=/some/path"),
- Pair.of("", "--master_blazerc"),
- Pair.of("", "--blazerc=/some/other/path"),
+ Pair.of("", "--bazelrc=/some/path"),
+ Pair.of("", "--master_bazelrc"),
+ Pair.of("", "--bazelrc=/some/other/path"),
Pair.of("", "--invocation_policy=notARealPolicy"))))
.asStreamProto(null)
.getStructuredCommandLine();
@@ -166,11 +167,11 @@ public class CommandLineEventTest {
assertThat(line.getSections(0).getChunkList().getChunk(0)).isEqualTo("testblaze");
assertThat(line.getSections(1).getOptionList().getOptionCount()).isEqualTo(4);
assertThat(line.getSections(1).getOptionList().getOption(0).getCombinedForm())
- .isEqualTo("--blazerc=/some/path");
+ .isEqualTo("--bazelrc=/some/path");
assertThat(line.getSections(1).getOptionList().getOption(1).getCombinedForm())
- .isEqualTo("--master_blazerc");
+ .isEqualTo("--master_bazelrc");
assertThat(line.getSections(1).getOptionList().getOption(2).getCombinedForm())
- .isEqualTo("--blazerc=/some/other/path");
+ .isEqualTo("--bazelrc=/some/other/path");
assertThat(line.getSections(1).getOptionList().getOption(3).getCombinedForm())
.isEqualTo("--invocation_policy=notARealPolicy");
assertThat(line.getSections(2).getChunkList().getChunk(0)).isEqualTo("someCommandName");
@@ -179,11 +180,11 @@ public class CommandLineEventTest {
}
@Test
- public void testBlazercs_CanonicalCommandLine() throws OptionsParsingException {
+ public void testBazelrcs_CanonicalCommandLine() throws OptionsParsingException {
OptionsParser fakeStartupOptions =
- OptionsParser.newOptionsParser(BlazeServerStartupOptions.class);
+ OptionsParser.newOptionsParser(BlazeServerStartupOptions.class, Options.class);
fakeStartupOptions.parse(
- "--blazerc=/some/path", "--master_blazerc", "--blazerc", "/some/other/path");
+ "--bazelrc=/some/path", "--master_bazelrc", "--bazelrc", "/some/other/path");
OptionsParser fakeCommandOptions = OptionsParser.newOptionsParser(TestOptions.class);
CommandLine line =