1616
1717import com .google .common .base .Preconditions ;
1818import com .google .common .collect .ImmutableSet ;
19- import com .google .common .collect .Iterables ;
2019import com .google .devtools .build .lib .actions .AbstractAction ;
2120import com .google .devtools .build .lib .actions .ActionExecutionContext ;
2221import com .google .devtools .build .lib .actions .ActionExecutionException ;
@@ -187,7 +186,7 @@ public ActionResult execute(ActionExecutionContext actionExecutionContext)
187186 String message =
188187 String .format (
189188 "failed to create symbolic link '%s' to '%s' due to I/O error: %s" ,
190- Iterables . getOnlyElement ( getOutputs ()). prettyPrint (), printInputs (), e .getMessage ());
189+ getPrimaryOutput (). getExecPathString (), printInputs (), e .getMessage ());
191190 DetailedExitCode code = createDetailedExitCode (message , Code .LINK_CREATION_IO_EXCEPTION );
192191 throw new ActionExecutionException (message , e , this , false , code );
193192 }
@@ -206,26 +205,24 @@ private void maybeVerifyTargetIsExecutable(ActionExecutionContext actionExecutio
206205 try {
207206 // Validate that input path is a file with the executable bit set.
208207 if (!inputPath .isFile ()) {
209- String message =
210- String .format ("'%s' is not a file" , getInputs ().getSingleton ().prettyPrint ());
208+ String message = String .format ("'%s' is not a file" , getPrimaryInput ().getExecPathString ());
211209 throw new ActionExecutionException (
212210 message , this , false , createDetailedExitCode (message , Code .EXECUTABLE_INPUT_NOT_FILE ));
213211 }
214212 if (!inputPath .isExecutable ()) {
215213 String message =
216214 String .format (
217215 "failed to create symbolic link '%s': file '%s' is not executable" ,
218- Iterables .getOnlyElement (getOutputs ()).prettyPrint (),
219- getInputs ().getSingleton ().prettyPrint ());
216+ getPrimaryOutput ().getExecPathString (), getPrimaryInput ().getExecPathString ());
220217 throw new ActionExecutionException (
221218 message , this , false , createDetailedExitCode (message , Code .EXECUTABLE_INPUT_IS_NOT ));
222219 }
223220 } catch (IOException e ) {
224221 String message =
225222 String .format (
226223 "failed to create symbolic link '%s' to the '%s' due to I/O error: %s" ,
227- Iterables . getOnlyElement ( getOutputs ()). prettyPrint (),
228- getInputs ().getSingleton (). prettyPrint (),
224+ getPrimaryOutput (). getExecPathString (),
225+ getPrimaryInput ().getExecPathString (),
229226 e .getMessage ());
230227 DetailedExitCode detailedExitCode =
231228 createDetailedExitCode (message , Code .EXECUTABLE_INPUT_CHECK_IO_EXCEPTION );
@@ -255,8 +252,8 @@ private void updateInputMtimeIfNeeded(ActionExecutionContext actionExecutionCont
255252 String message =
256253 String .format (
257254 "failed to touch symbolic link '%s' to the '%s' due to I/O error: %s" ,
258- Iterables . getOnlyElement ( getOutputs ()). prettyPrint (),
259- getInputs ().getSingleton (). prettyPrint (),
255+ getPrimaryOutput (). getExecPathString (),
256+ getPrimaryInput ().getExecPathString (),
260257 e .getMessage ());
261258 DetailedExitCode code = createDetailedExitCode (message , Code .LINK_TOUCH_IO_EXCEPTION );
262259 throw new ActionExecutionException (message , e , this , false , code );
@@ -267,7 +264,7 @@ private String printInputs() {
267264 if (getInputs ().isEmpty ()) {
268265 return inputPath .getPathString ();
269266 } else if (getInputs ().isSingleton ()) {
270- return getInputs ().getSingleton (). prettyPrint ();
267+ return getPrimaryInput ().getExecPathString ();
271268 } else {
272269 throw new IllegalStateException (
273270 "Inputs unexpectedly contains more than 1 element: " + getInputs ());
0 commit comments