Skip to content

Commit

Permalink
Extract a HasExecPath interface from ActionInput.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 678372011
Change-Id: I640e2e8adceed167ce87d039cbc24b490beec58f
  • Loading branch information
justinhorvitz authored and copybara-github committed Sep 24, 2024
1 parent 85b100b commit abe1f66
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,16 @@
/**
* Represents an input file to a build action, with an appropriate relative path.
*
* <p>Artifact is the only notable implementer of the interface, but the interface remains
* because 1) some Google specific rules ship files that could be Artifacts to remote execution
* by instantiating ad-hoc derived classes of ActionInput. 2) historically, Google C++ rules
* allow underspecified C++ builds. For that case, we have extra logic to guess the undeclared
* header inclusions (eg. computed inclusions). The extra logic lives in a file that is not
* needed for remote execution, but is a dependency, and it is inserted as a non-Artifact
* ActionInput.
*
* <p>ActionInput is used as a cache "key" for ActionInputFileCache: for Artifacts, the
* digest/size is already stored in Artifact, but for non-artifacts, we use getExecPathString
* to find this data in a filesystem related cache.
* <p>Artifact is the only notable implementer of the interface, but the interface remains because
* 1) some Google specific rules ship files that could be Artifacts to remote execution by
* instantiating ad-hoc derived classes of ActionInput. 2) historically, Google C++ rules allow
* underspecified C++ builds. For that case, we have extra logic to guess the undeclared header
* inclusions (eg. computed inclusions). The extra logic lives in a file that is not needed for
* remote execution, but is a dependency, and it is inserted as a non-Artifact ActionInput.
*/
public interface ActionInput {

/** @return the relative path to the input file. */
String getExecPathString();
public interface ActionInput extends HasExecPathString {

/**
* @return the relative path to the input file.
*/
/** Same as {@link #getExecPathString}, but returns a {@link PathFragment}. */
PathFragment getExecPath();

/** The input is a directory. */
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/google/devtools/build/lib/actions/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ java_library(
"ArtifactResolver.java",
"ArtifactRoot.java",
"Artifacts.java",
"HasExecPathString.java",
"PathMapper.java",
],
deps = [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2024 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

package com.google.devtools.build.lib.actions;

/**
* A file that has an exec path string.
*
* <p>Mainly implemented by classes that also implement {@link ActionInput}, but has other
* implementations in the Google-internal spawn execution service.
*/
public interface HasExecPathString {

/**
* Returns the path to this file.
*
* <p>The path may be relative to the exec root or absolute.
*/
String getExecPathString();
}

0 comments on commit abe1f66

Please sign in to comment.