diff options
author | 2016-03-21 08:35:35 +0000 | |
---|---|---|
committer | 2016-03-21 09:37:14 +0000 | |
commit | 7857c798300c4eea9cf2172531f150f261ce158d (patch) | |
tree | 4c720a0c52c5a188a95be398b086db938e6062f5 /src/main/java/com/google/devtools/build/lib/analysis | |
parent | 5059a1d26ef86360cc7d701b7cc4bcb322cf6bd1 (diff) |
Make ActionOwner a final class, since all non-test implementations were basically doing the same thing with it.
This simplifies the code and avoids unnecessary re-wrapping, which saves memory.
--
MOS_MIGRATED_REVID=117693050
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/BuildInfoHelper.java | 31 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java | 63 |
2 files changed, 12 insertions, 82 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BuildInfoHelper.java b/src/main/java/com/google/devtools/build/lib/analysis/BuildInfoHelper.java deleted file mode 100644 index 3510eb0bff..0000000000 --- a/src/main/java/com/google/devtools/build/lib/analysis/BuildInfoHelper.java +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2014 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.analysis; - -import com.google.devtools.build.lib.actions.AbstractActionOwner; -import com.google.devtools.build.lib.actions.ActionOwner; - -// TODO(bazel-team): move BUILD_INFO_ACTION_OWNER somewhere else and remove this class. -/** - * Helper class for the CompatibleWriteBuildInfoAction, which holds the - * methods for generating build information. - * Abstracted away to allow non-action code to also generate build info under - * --nobuild or --check_up_to_date. - */ -public abstract class BuildInfoHelper { - /** ActionOwner for BuildInfoActions. */ - public static final ActionOwner BUILD_INFO_ACTION_OWNER = - AbstractActionOwner.SYSTEM_ACTION_OWNER; -} diff --git a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java index 1b696855e3..273d56229f 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java @@ -14,6 +14,7 @@ package com.google.devtools.build.lib.analysis; +import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Joiner; import com.google.common.base.Predicate; import com.google.common.base.Predicates; @@ -130,7 +131,7 @@ public final class RuleContext extends TargetContext } } - static final String HOST_CONFIGURATION_PROGRESS_TAG = "for host"; + private static final String HOST_CONFIGURATION_PROGRESS_TAG = "for host"; private final Rule rule; private final ListMultimap<String, ConfiguredTarget> targetMap; @@ -286,7 +287,7 @@ public final class RuleContext extends TargetContext @Override public ActionOwner getActionOwner() { if (actionOwner == null) { - actionOwner = new RuleActionOwner(rule, getConfiguration()); + actionOwner = createActionOwner(rule, getConfiguration()); } return actionOwner; } @@ -361,55 +362,15 @@ public final class RuleContext extends TargetContext return getAnalysisEnvironment().getBuildInfo(this, key); } - // TODO(bazel-team): This class could be simpler if Rule and BuildConfiguration classes - // were immutable. Then we would need to store only references those two. - @Immutable - private static final class RuleActionOwner implements ActionOwner { - private final Label label; - private final Location location; - private final String mnemonic; - private final String targetKind; - private final String configurationChecksum; - private final boolean hostConfiguration; - - private RuleActionOwner(Rule rule, BuildConfiguration configuration) { - this.label = rule.getLabel(); - this.location = rule.getLocation(); - this.targetKind = rule.getTargetKind(); - this.mnemonic = configuration.getMnemonic(); - this.configurationChecksum = configuration.checksum(); - this.hostConfiguration = configuration.isHostConfiguration(); - } - - @Override - public Location getLocation() { - return location; - } - - @Override - public Label getLabel() { - return label; - } - - @Override - public String getConfigurationMnemonic() { - return mnemonic; - } - - @Override - public String getConfigurationChecksum() { - return configurationChecksum; - } - - @Override - public String getTargetKind() { - return targetKind; - } - - @Override - public String getAdditionalProgressInfo() { - return hostConfiguration ? HOST_CONFIGURATION_PROGRESS_TAG : null; - } + @VisibleForTesting + public static ActionOwner createActionOwner(Rule rule, BuildConfiguration configuration) { + return new ActionOwner( + rule.getLabel(), + rule.getLocation(), + configuration.getMnemonic(), + rule.getTargetKind(), + configuration.checksum(), + configuration.isHostConfiguration() ? HOST_CONFIGURATION_PROGRESS_TAG : null); } @Override |