Skip to content

Commit

Permalink
Use Artifact#getRunfilesPath for Windows Java exe launcher classpath …
Browse files Browse the repository at this point in the history
…generation.

PiperOrigin-RevId: 345675167
  • Loading branch information
Googler authored and copybara-github committed Dec 4, 2020
1 parent c0809f7 commit 11d85c0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1340,8 +1340,8 @@ public SourceArtifact deserialize(DeserializationContext context, CodedInputStre
public static final Function<Artifact, String> ROOT_RELATIVE_PATH_STRING =
artifact -> artifact.getRootRelativePath().getPathString();

public static final Function<Artifact, String> OUTPUT_DIR_RELATIVE_PATH_STRING =
artifact -> artifact.getOutputDirRelativePath(false).getPathString();
public static final Function<Artifact, String> RUNFILES_PATH_STRING =
artifact -> artifact.getRunfilesPath().getPathString();

/**
* Converts a collection of artifacts into execution-time path strings, and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ private static Artifact createWindowsExeLauncher(
.addJoinedValues(
"classpath",
";",
Iterables.transform(classpath.toList(), Artifact.OUTPUT_DIR_RELATIVE_PATH_STRING))
Iterables.transform(classpath.toList(), Artifact.RUNFILES_PATH_STRING))
// TODO(laszlocsomor): Change the Launcher to accept multiple jvm_flags entries. As of
// 2019-02-13 the Launcher accepts just one jvm_flags entry, which contains all the
// flags, joined by TAB characters. The Launcher splits up the string to get the
Expand Down
10 changes: 6 additions & 4 deletions src/tools/launcher/launcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,12 @@ wstring BinaryLauncherBase::Rlocation(wstring path,
return path;
}

if (path.find(L"external/") == 0) {
// Ignore 'has_workspace_name' when the path is under "external/". Such
// paths already have a workspace name in the next path component.
path = path.substr(9);
if (path.find(L"../") == 0) {
// Ignore 'has_workspace_name' when the runfile path is under "../". Such
// paths already have a workspace name in the next path component. We could
// append it to this->workspace_name and re-evaluate it, but this is
// simpler.
path = path.substr(3);
} else if (!has_workspace_name) {
path = this->workspace_name + L"/" + path;
}
Expand Down

0 comments on commit 11d85c0

Please sign in to comment.