From e4336da1f25e12f7fdc705c0531a86f5d4c13b95 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Thu, 15 Feb 2018 01:19:37 -0800 Subject: Remove code that allows RunfilesSupport.owningExecutable to be null. RunfilesSupport.owningExecutable can clearly never be null because the first thing the constructor does is reject it if it's null. Change-Id: Ie861d96a2a2ab6937f1e27a6745cf1cb2f50e0fb PiperOrigin-RevId: 185806352 --- .../devtools/build/lib/analysis/RunfilesSupport.java | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'src/main/java/com/google') diff --git a/src/main/java/com/google/devtools/build/lib/analysis/RunfilesSupport.java b/src/main/java/com/google/devtools/build/lib/analysis/RunfilesSupport.java index 5302e5297e..8456ffd9de 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/RunfilesSupport.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/RunfilesSupport.java @@ -85,15 +85,11 @@ public final class RunfilesSupport { * Creates the RunfilesSupport helper with the given executable and runfiles. * * @param ruleContext the rule context to create the runfiles support for - * @param executable the executable for whose runfiles this runfiles support is responsible, may - * be null + * @param executable the executable for whose runfiles this runfiles support is responsible * @param runfiles the runfiles */ private RunfilesSupport( - RuleContext ruleContext, - Artifact executable, - Runfiles runfiles, - CommandLine args) { + RuleContext ruleContext, Artifact executable, Runfiles runfiles, CommandLine args) { owningExecutable = Preconditions.checkNotNull(executable); boolean createManifest = ruleContext.getConfiguration().buildRunfilesManifests(); createSymlinks = createManifest && ruleContext.getConfiguration().buildRunfiles(); @@ -116,7 +112,7 @@ public final class RunfilesSupport { Preconditions.checkState(!runfiles.isEmpty()); Map symlinks = getRunfilesSymlinks(); - if (executable != null && !symlinks.containsValue(executable)) { + if (!symlinks.containsValue(executable)) { throw new IllegalStateException("main program " + executable + " not included in runfiles"); } @@ -142,9 +138,8 @@ public final class RunfilesSupport { } /** - * Returns the exec path of the directory where the runfiles contained in this - * RunfilesSupport are generated. When the owning rule has no executable, - * returns null. + * Returns the exec path of the directory where the runfiles contained in this RunfilesSupport are + * generated. */ public PathFragment getRunfilesDirectoryExecPath() { PathFragment executablePath = owningExecutable.getExecPath(); @@ -176,10 +171,7 @@ public final class RunfilesSupport { } private Artifact createRunfilesInputManifestArtifact(RuleContext context) { - // The executable may be null for emptyRunfiles - PathFragment relativePath = (owningExecutable != null) - ? owningExecutable.getRootRelativePath() - : context.getPackageDirectory().getRelative(context.getLabel().getName()); + PathFragment relativePath = owningExecutable.getRootRelativePath(); String basename = relativePath.getBaseName(); PathFragment inputManifestPath = relativePath.replaceName(basename + ".runfiles_manifest"); return context.getDerivedArtifact(inputManifestPath, -- cgit v1.2.3