Damien Martin-Guillerez | f88f4d8 | 2015-09-25 13:56:55 +0000 | [diff] [blame] | 1 | // Copyright 2014 The Bazel Authors. All rights reserved. |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package com.google.devtools.build.lib.actions; |
| 16 | |
tomlu | a155b53 | 2017-11-08 20:12:47 +0100 | [diff] [blame] | 17 | import com.google.common.base.Preconditions; |
kush | 2ce45a2 | 2018-05-02 14:15:37 -0700 | [diff] [blame] | 18 | import com.google.common.collect.ImmutableList; |
Klaus Aehlig | d2fcd9d | 2016-08-26 08:16:25 +0000 | [diff] [blame] | 19 | import com.google.common.collect.ImmutableMap; |
ulfjack | 77c9f5e | 2017-06-19 14:17:52 +0200 | [diff] [blame] | 20 | import com.google.common.eventbus.EventBus; |
Michael Thvedt | 434e68e | 2016-02-09 00:57:46 +0000 | [diff] [blame] | 21 | import com.google.devtools.build.lib.actions.Artifact.ArtifactExpander; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 22 | import com.google.devtools.build.lib.actions.cache.MetadataHandler; |
philwo | 3bcb9f6 | 2017-09-06 12:52:21 +0200 | [diff] [blame] | 23 | import com.google.devtools.build.lib.clock.Clock; |
ulfjack | 77c9f5e | 2017-06-19 14:17:52 +0200 | [diff] [blame] | 24 | import com.google.devtools.build.lib.cmdline.Label; |
| 25 | import com.google.devtools.build.lib.events.Event; |
ulfjack | 77c9f5e | 2017-06-19 14:17:52 +0200 | [diff] [blame] | 26 | import com.google.devtools.build.lib.events.EventKind; |
Benjamin Peterson | 1bbeadc | 2018-04-26 05:27:10 -0700 | [diff] [blame] | 27 | import com.google.devtools.build.lib.events.ExtendedEventHandler; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 28 | import com.google.devtools.build.lib.util.io.FileOutErr; |
tomlu | f903eb5 | 2017-10-27 12:12:11 -0400 | [diff] [blame] | 29 | import com.google.devtools.build.lib.vfs.FileSystem; |
ulfjack | 77c9f5e | 2017-06-19 14:17:52 +0200 | [diff] [blame] | 30 | import com.google.devtools.build.lib.vfs.Path; |
kush | 2ce45a2 | 2018-05-02 14:15:37 -0700 | [diff] [blame] | 31 | import com.google.devtools.build.lib.vfs.PathFragment; |
shahan | b1dd4e3 | 2018-05-09 08:23:31 -0700 | [diff] [blame] | 32 | import com.google.devtools.build.lib.vfs.Root; |
Janak Ramakrishnan | 29c5ab4 | 2015-05-14 19:38:12 +0000 | [diff] [blame] | 33 | import com.google.devtools.build.skyframe.SkyFunction; |
| 34 | import com.google.devtools.build.skyframe.SkyFunction.Environment; |
ulfjack | 77c9f5e | 2017-06-19 14:17:52 +0200 | [diff] [blame] | 35 | import com.google.devtools.common.options.OptionsClassProvider; |
ulfjack | 1a328e3 | 2017-04-06 10:25:16 +0000 | [diff] [blame] | 36 | import java.io.Closeable; |
| 37 | import java.io.IOException; |
Klaus Aehlig | d2fcd9d | 2016-08-26 08:16:25 +0000 | [diff] [blame] | 38 | import java.util.Map; |
Janak Ramakrishnan | 29c5ab4 | 2015-05-14 19:38:12 +0000 | [diff] [blame] | 39 | import javax.annotation.Nullable; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 40 | |
| 41 | /** |
| 42 | * A class that groups services in the scope of the action. Like the FileOutErr object. |
| 43 | */ |
ulfjack | 1a328e3 | 2017-04-06 10:25:16 +0000 | [diff] [blame] | 44 | public class ActionExecutionContext implements Closeable { |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 45 | |
| 46 | private final Executor executor; |
shahan | 499503b | 2018-06-07 18:57:07 -0700 | [diff] [blame] | 47 | private final MetadataProvider actionInputFileCache; |
ulfjack | 7599a4d | 2017-07-21 13:58:33 +0200 | [diff] [blame] | 48 | private final ActionInputPrefetcher actionInputPrefetcher; |
tomlu | 3d1a194 | 2017-11-29 14:01:21 -0800 | [diff] [blame] | 49 | private final ActionKeyContext actionKeyContext; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 50 | private final MetadataHandler metadataHandler; |
| 51 | private final FileOutErr fileOutErr; |
Klaus Aehlig | d2fcd9d | 2016-08-26 08:16:25 +0000 | [diff] [blame] | 52 | private final ImmutableMap<String, String> clientEnv; |
kush | 2ce45a2 | 2018-05-02 14:15:37 -0700 | [diff] [blame] | 53 | private final ImmutableMap<PathFragment, ImmutableList<FilesetOutputSymlink>> |
| 54 | inputFilesetMappings; |
shahan | b1dd4e3 | 2018-05-09 08:23:31 -0700 | [diff] [blame] | 55 | @Nullable private final ArtifactExpander artifactExpander; |
| 56 | @Nullable private final Environment env; |
| 57 | |
| 58 | @Nullable private final FileSystem actionFileSystem; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 59 | |
kush | 2ce45a2 | 2018-05-02 14:15:37 -0700 | [diff] [blame] | 60 | @Nullable private ImmutableList<FilesetOutputSymlink> outputSymlinks; |
| 61 | |
felly | d3d8644 | 2018-06-08 18:29:43 -0700 | [diff] [blame^] | 62 | private final ArtifactPathResolver pathResolver; |
| 63 | |
Klaus Aehlig | d2fcd9d | 2016-08-26 08:16:25 +0000 | [diff] [blame] | 64 | private ActionExecutionContext( |
| 65 | Executor executor, |
shahan | 499503b | 2018-06-07 18:57:07 -0700 | [diff] [blame] | 66 | MetadataProvider actionInputFileCache, |
ulfjack | 7599a4d | 2017-07-21 13:58:33 +0200 | [diff] [blame] | 67 | ActionInputPrefetcher actionInputPrefetcher, |
tomlu | 3d1a194 | 2017-11-29 14:01:21 -0800 | [diff] [blame] | 68 | ActionKeyContext actionKeyContext, |
Klaus Aehlig | d2fcd9d | 2016-08-26 08:16:25 +0000 | [diff] [blame] | 69 | MetadataHandler metadataHandler, |
| 70 | FileOutErr fileOutErr, |
| 71 | Map<String, String> clientEnv, |
kush | 2ce45a2 | 2018-05-02 14:15:37 -0700 | [diff] [blame] | 72 | ImmutableMap<PathFragment, ImmutableList<FilesetOutputSymlink>> inputFilesetMappings, |
Michael Thvedt | 434e68e | 2016-02-09 00:57:46 +0000 | [diff] [blame] | 73 | @Nullable ArtifactExpander artifactExpander, |
shahan | b1dd4e3 | 2018-05-09 08:23:31 -0700 | [diff] [blame] | 74 | @Nullable SkyFunction.Environment env, |
| 75 | @Nullable FileSystem actionFileSystem) { |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 76 | this.actionInputFileCache = actionInputFileCache; |
ulfjack | 7599a4d | 2017-07-21 13:58:33 +0200 | [diff] [blame] | 77 | this.actionInputPrefetcher = actionInputPrefetcher; |
tomlu | 3d1a194 | 2017-11-29 14:01:21 -0800 | [diff] [blame] | 78 | this.actionKeyContext = actionKeyContext; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 79 | this.metadataHandler = metadataHandler; |
| 80 | this.fileOutErr = fileOutErr; |
Klaus Aehlig | d2fcd9d | 2016-08-26 08:16:25 +0000 | [diff] [blame] | 81 | this.clientEnv = ImmutableMap.copyOf(clientEnv); |
kush | 2ce45a2 | 2018-05-02 14:15:37 -0700 | [diff] [blame] | 82 | this.inputFilesetMappings = inputFilesetMappings; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 83 | this.executor = executor; |
Michael Thvedt | 434e68e | 2016-02-09 00:57:46 +0000 | [diff] [blame] | 84 | this.artifactExpander = artifactExpander; |
Janak Ramakrishnan | 29c5ab4 | 2015-05-14 19:38:12 +0000 | [diff] [blame] | 85 | this.env = env; |
shahan | b1dd4e3 | 2018-05-09 08:23:31 -0700 | [diff] [blame] | 86 | this.actionFileSystem = actionFileSystem; |
felly | d3d8644 | 2018-06-08 18:29:43 -0700 | [diff] [blame^] | 87 | this.pathResolver = createPathResolver(actionFileSystem, |
| 88 | // executor is only ever null in testing. |
| 89 | executor == null ? null : executor.getExecRoot()); |
Janak Ramakrishnan | 29c5ab4 | 2015-05-14 19:38:12 +0000 | [diff] [blame] | 90 | } |
| 91 | |
Klaus Aehlig | d2fcd9d | 2016-08-26 08:16:25 +0000 | [diff] [blame] | 92 | public ActionExecutionContext( |
| 93 | Executor executor, |
shahan | 499503b | 2018-06-07 18:57:07 -0700 | [diff] [blame] | 94 | MetadataProvider actionInputFileCache, |
ulfjack | 7599a4d | 2017-07-21 13:58:33 +0200 | [diff] [blame] | 95 | ActionInputPrefetcher actionInputPrefetcher, |
tomlu | 3d1a194 | 2017-11-29 14:01:21 -0800 | [diff] [blame] | 96 | ActionKeyContext actionKeyContext, |
Klaus Aehlig | d2fcd9d | 2016-08-26 08:16:25 +0000 | [diff] [blame] | 97 | MetadataHandler metadataHandler, |
| 98 | FileOutErr fileOutErr, |
| 99 | Map<String, String> clientEnv, |
kush | 2ce45a2 | 2018-05-02 14:15:37 -0700 | [diff] [blame] | 100 | ImmutableMap<PathFragment, ImmutableList<FilesetOutputSymlink>> inputFilesetMappings, |
shahan | b1dd4e3 | 2018-05-09 08:23:31 -0700 | [diff] [blame] | 101 | ArtifactExpander artifactExpander, |
| 102 | @Nullable FileSystem actionFileSystem) { |
Klaus Aehlig | d2fcd9d | 2016-08-26 08:16:25 +0000 | [diff] [blame] | 103 | this( |
| 104 | executor, |
| 105 | actionInputFileCache, |
ulfjack | 7599a4d | 2017-07-21 13:58:33 +0200 | [diff] [blame] | 106 | actionInputPrefetcher, |
tomlu | 3d1a194 | 2017-11-29 14:01:21 -0800 | [diff] [blame] | 107 | actionKeyContext, |
Klaus Aehlig | d2fcd9d | 2016-08-26 08:16:25 +0000 | [diff] [blame] | 108 | metadataHandler, |
| 109 | fileOutErr, |
| 110 | clientEnv, |
kush | 2ce45a2 | 2018-05-02 14:15:37 -0700 | [diff] [blame] | 111 | inputFilesetMappings, |
Klaus Aehlig | d2fcd9d | 2016-08-26 08:16:25 +0000 | [diff] [blame] | 112 | artifactExpander, |
shahan | b1dd4e3 | 2018-05-09 08:23:31 -0700 | [diff] [blame] | 113 | /*env=*/ null, |
| 114 | actionFileSystem); |
Janak Ramakrishnan | 29c5ab4 | 2015-05-14 19:38:12 +0000 | [diff] [blame] | 115 | } |
| 116 | |
Klaus Aehlig | d2fcd9d | 2016-08-26 08:16:25 +0000 | [diff] [blame] | 117 | public static ActionExecutionContext forInputDiscovery( |
| 118 | Executor executor, |
shahan | 499503b | 2018-06-07 18:57:07 -0700 | [diff] [blame] | 119 | MetadataProvider actionInputFileCache, |
ulfjack | 7599a4d | 2017-07-21 13:58:33 +0200 | [diff] [blame] | 120 | ActionInputPrefetcher actionInputPrefetcher, |
tomlu | 3d1a194 | 2017-11-29 14:01:21 -0800 | [diff] [blame] | 121 | ActionKeyContext actionKeyContext, |
Klaus Aehlig | d2fcd9d | 2016-08-26 08:16:25 +0000 | [diff] [blame] | 122 | MetadataHandler metadataHandler, |
| 123 | FileOutErr fileOutErr, |
| 124 | Map<String, String> clientEnv, |
shahan | b1dd4e3 | 2018-05-09 08:23:31 -0700 | [diff] [blame] | 125 | Environment env, |
| 126 | @Nullable FileSystem actionFileSystem) { |
Klaus Aehlig | d2fcd9d | 2016-08-26 08:16:25 +0000 | [diff] [blame] | 127 | return new ActionExecutionContext( |
ulfjack | 7599a4d | 2017-07-21 13:58:33 +0200 | [diff] [blame] | 128 | executor, |
| 129 | actionInputFileCache, |
| 130 | actionInputPrefetcher, |
tomlu | 3d1a194 | 2017-11-29 14:01:21 -0800 | [diff] [blame] | 131 | actionKeyContext, |
ulfjack | 7599a4d | 2017-07-21 13:58:33 +0200 | [diff] [blame] | 132 | metadataHandler, |
| 133 | fileOutErr, |
| 134 | clientEnv, |
kush | 2ce45a2 | 2018-05-02 14:15:37 -0700 | [diff] [blame] | 135 | ImmutableMap.of(), |
shahan | b1dd4e3 | 2018-05-09 08:23:31 -0700 | [diff] [blame] | 136 | /*artifactExpander=*/ null, |
| 137 | env, |
| 138 | actionFileSystem); |
ulfjack | 7599a4d | 2017-07-21 13:58:33 +0200 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | public ActionInputPrefetcher getActionInputPrefetcher() { |
| 142 | return actionInputPrefetcher; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 143 | } |
| 144 | |
shahan | 499503b | 2018-06-07 18:57:07 -0700 | [diff] [blame] | 145 | public MetadataProvider getMetadataProvider() { |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 146 | return actionInputFileCache; |
| 147 | } |
| 148 | |
| 149 | public MetadataHandler getMetadataHandler() { |
| 150 | return metadataHandler; |
| 151 | } |
| 152 | |
tomlu | f903eb5 | 2017-10-27 12:12:11 -0400 | [diff] [blame] | 153 | public FileSystem getFileSystem() { |
felly | 7fd3b00 | 2018-05-24 15:03:40 -0700 | [diff] [blame] | 154 | if (actionFileSystem != null) { |
| 155 | return actionFileSystem; |
| 156 | } |
tomlu | f903eb5 | 2017-10-27 12:12:11 -0400 | [diff] [blame] | 157 | return executor.getFileSystem(); |
| 158 | } |
| 159 | |
ulfjack | 77c9f5e | 2017-06-19 14:17:52 +0200 | [diff] [blame] | 160 | public Path getExecRoot() { |
felly | 7fd3b00 | 2018-05-24 15:03:40 -0700 | [diff] [blame] | 161 | return actionFileSystem != null |
| 162 | ? actionFileSystem.getPath(executor.getExecRoot().asFragment()) |
| 163 | : executor.getExecRoot(); |
ulfjack | 77c9f5e | 2017-06-19 14:17:52 +0200 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | /** |
shahan | 18726b7 | 2018-03-15 14:18:46 -0700 | [diff] [blame] | 167 | * Returns the path for an ActionInput. |
| 168 | * |
| 169 | * <p>Notably, in the future, we want any action-scoped artifacts to resolve paths using this |
| 170 | * method instead of {@link Artifact#getPath} because that does not allow filesystem injection. |
| 171 | * |
shahan | b1dd4e3 | 2018-05-09 08:23:31 -0700 | [diff] [blame] | 172 | * <p>TODO(shahan): cleanup {@link Action}-scoped references to {@link Artifact.getPath} and |
| 173 | * {@link Artifact.getRoot}. |
shahan | 18726b7 | 2018-03-15 14:18:46 -0700 | [diff] [blame] | 174 | */ |
| 175 | public Path getInputPath(ActionInput input) { |
felly | d3d8644 | 2018-06-08 18:29:43 -0700 | [diff] [blame^] | 176 | return pathResolver.toPath(input); |
shahan | 18726b7 | 2018-03-15 14:18:46 -0700 | [diff] [blame] | 177 | } |
| 178 | |
shahan | b1dd4e3 | 2018-05-09 08:23:31 -0700 | [diff] [blame] | 179 | public Root getRoot(Artifact artifact) { |
felly | d3d8644 | 2018-06-08 18:29:43 -0700 | [diff] [blame^] | 180 | return pathResolver.transformRoot(artifact.getRoot().getRoot()); |
| 181 | } |
| 182 | |
| 183 | private static ArtifactPathResolver createPathResolver(FileSystem actionFileSystem, |
| 184 | Path execRoot) { |
| 185 | if (actionFileSystem == null) { |
| 186 | return ArtifactPathResolver.forExecRoot(execRoot); |
| 187 | } else { |
| 188 | return ArtifactPathResolver.withTransformedFileSystem( |
| 189 | actionFileSystem.getPath(execRoot.asFragment())); |
shahan | b1dd4e3 | 2018-05-09 08:23:31 -0700 | [diff] [blame] | 190 | } |
felly | d3d8644 | 2018-06-08 18:29:43 -0700 | [diff] [blame^] | 191 | } |
| 192 | |
| 193 | public ArtifactPathResolver getPathResolver() { |
| 194 | return pathResolver; |
shahan | b1dd4e3 | 2018-05-09 08:23:31 -0700 | [diff] [blame] | 195 | } |
| 196 | |
shahan | 18726b7 | 2018-03-15 14:18:46 -0700 | [diff] [blame] | 197 | /** |
ulfjack | 77c9f5e | 2017-06-19 14:17:52 +0200 | [diff] [blame] | 198 | * Returns whether failures should have verbose error messages. |
| 199 | */ |
| 200 | public boolean getVerboseFailures() { |
| 201 | return executor.getVerboseFailures(); |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * Returns the command line options of the Blaze command being executed. |
| 206 | */ |
| 207 | public OptionsClassProvider getOptions() { |
| 208 | return executor.getOptions(); |
| 209 | } |
| 210 | |
| 211 | public Clock getClock() { |
| 212 | return executor.getClock(); |
| 213 | } |
| 214 | |
| 215 | public EventBus getEventBus() { |
| 216 | return executor.getEventBus(); |
| 217 | } |
| 218 | |
Benjamin Peterson | 1bbeadc | 2018-04-26 05:27:10 -0700 | [diff] [blame] | 219 | public ExtendedEventHandler getEventHandler() { |
ulfjack | 77c9f5e | 2017-06-19 14:17:52 +0200 | [diff] [blame] | 220 | return executor.getEventHandler(); |
| 221 | } |
| 222 | |
kush | 2ce45a2 | 2018-05-02 14:15:37 -0700 | [diff] [blame] | 223 | public ImmutableMap<PathFragment, ImmutableList<FilesetOutputSymlink>> getInputFilesetMappings() { |
| 224 | return inputFilesetMappings; |
| 225 | } |
| 226 | |
| 227 | @Nullable |
| 228 | public ImmutableList<FilesetOutputSymlink> getOutputSymlinks() { |
| 229 | return outputSymlinks; |
| 230 | } |
| 231 | |
| 232 | public void setOutputSymlinks(ImmutableList<FilesetOutputSymlink> outputSymlinks) { |
| 233 | Preconditions.checkState( |
| 234 | this.outputSymlinks == null, |
| 235 | "Unexpected reassignment of the outputSymlinks of a Fileset from\n:%s to:\n%s", |
| 236 | this.outputSymlinks, |
| 237 | outputSymlinks); |
| 238 | this.outputSymlinks = outputSymlinks; |
| 239 | } |
| 240 | |
ulfjack | 77c9f5e | 2017-06-19 14:17:52 +0200 | [diff] [blame] | 241 | /** |
| 242 | * Looks up and returns an action context implementation of the given interface type. |
| 243 | */ |
| 244 | public <T extends ActionContext> T getContext(Class<? extends T> type) { |
| 245 | return executor.getContext(type); |
| 246 | } |
| 247 | |
ulfjack | 77c9f5e | 2017-06-19 14:17:52 +0200 | [diff] [blame] | 248 | /** |
| 249 | * Whether this Executor reports subcommands. If not, reportSubcommand has no effect. |
| 250 | * This is provided so the caller of reportSubcommand can avoid wastefully constructing the |
| 251 | * subcommand string. |
| 252 | */ |
| 253 | public boolean reportsSubcommands() { |
| 254 | return executor.reportsSubcommands(); |
| 255 | } |
| 256 | |
| 257 | /** |
| 258 | * Report a subcommand event to this Executor's Reporter and, if action |
| 259 | * logging is enabled, post it on its EventBus. |
| 260 | */ |
| 261 | public void reportSubcommand(Spawn spawn) { |
| 262 | String reason; |
| 263 | ActionOwner owner = spawn.getResourceOwner().getOwner(); |
| 264 | if (owner == null) { |
| 265 | reason = spawn.getResourceOwner().prettyPrint(); |
| 266 | } else { |
| 267 | reason = Label.print(owner.getLabel()) |
| 268 | + " [" + spawn.getResourceOwner().prettyPrint() + "]"; |
| 269 | } |
| 270 | String message = Spawns.asShellCommand(spawn, getExecRoot()); |
| 271 | getEventHandler().handle(Event.of(EventKind.SUBCOMMAND, null, "# " + reason + "\n" + message)); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 272 | } |
| 273 | |
Klaus Aehlig | 4c10f3f | 2016-08-26 15:58:48 +0000 | [diff] [blame] | 274 | public ImmutableMap<String, String> getClientEnv() { |
| 275 | return clientEnv; |
| 276 | } |
| 277 | |
Michael Thvedt | 434e68e | 2016-02-09 00:57:46 +0000 | [diff] [blame] | 278 | public ArtifactExpander getArtifactExpander() { |
| 279 | return artifactExpander; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | /** |
| 283 | * Provide that {@code FileOutErr} that the action should use for redirecting the output and error |
| 284 | * stream. |
| 285 | */ |
| 286 | public FileOutErr getFileOutErr() { |
| 287 | return fileOutErr; |
| 288 | } |
| 289 | |
shahan | d370290 | 2018-05-11 12:14:32 -0700 | [diff] [blame] | 290 | public boolean hasActionFileSystem() { |
| 291 | return actionFileSystem != null; |
| 292 | } |
| 293 | |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 294 | /** |
Janak Ramakrishnan | 29c5ab4 | 2015-05-14 19:38:12 +0000 | [diff] [blame] | 295 | * Provides a mechanism for the action to request values from Skyframe while it discovers inputs. |
| 296 | */ |
| 297 | public Environment getEnvironmentForDiscoveringInputs() { |
| 298 | return Preconditions.checkNotNull(env); |
| 299 | } |
| 300 | |
tomlu | 3d1a194 | 2017-11-29 14:01:21 -0800 | [diff] [blame] | 301 | public ActionKeyContext getActionKeyContext() { |
| 302 | return actionKeyContext; |
| 303 | } |
| 304 | |
ulfjack | 1a328e3 | 2017-04-06 10:25:16 +0000 | [diff] [blame] | 305 | @Override |
| 306 | public void close() throws IOException { |
| 307 | fileOutErr.close(); |
| 308 | } |
| 309 | |
Janak Ramakrishnan | 29c5ab4 | 2015-05-14 19:38:12 +0000 | [diff] [blame] | 310 | /** |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 311 | * Allows us to create a new context that overrides the FileOutErr with another one. This is |
| 312 | * useful for muting the output for example. |
| 313 | */ |
| 314 | public ActionExecutionContext withFileOutErr(FileOutErr fileOutErr) { |
Klaus Aehlig | d2fcd9d | 2016-08-26 08:16:25 +0000 | [diff] [blame] | 315 | return new ActionExecutionContext( |
| 316 | executor, |
| 317 | actionInputFileCache, |
ulfjack | 7599a4d | 2017-07-21 13:58:33 +0200 | [diff] [blame] | 318 | actionInputPrefetcher, |
tomlu | 3d1a194 | 2017-11-29 14:01:21 -0800 | [diff] [blame] | 319 | actionKeyContext, |
Klaus Aehlig | d2fcd9d | 2016-08-26 08:16:25 +0000 | [diff] [blame] | 320 | metadataHandler, |
| 321 | fileOutErr, |
| 322 | clientEnv, |
kush | 2ce45a2 | 2018-05-02 14:15:37 -0700 | [diff] [blame] | 323 | inputFilesetMappings, |
Klaus Aehlig | d2fcd9d | 2016-08-26 08:16:25 +0000 | [diff] [blame] | 324 | artifactExpander, |
shahan | b1dd4e3 | 2018-05-09 08:23:31 -0700 | [diff] [blame] | 325 | env, |
| 326 | actionFileSystem); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 327 | } |
| 328 | } |