Skip to content

Commit 002bd04

Browse files
lberkicopybara-github
authored andcommitted
Remove the command line option --remove_all_convenience_symlinks.
RELNOTES[INC]: The command line option --remove_all_convenience_symlinks is not available anymore. PiperOrigin-RevId: 569149907 Change-Id: I24ca4f4f21285bac9cc69b8a990b23a8412b9178
1 parent 53b0081 commit 002bd04

File tree

2 files changed

+11
-86
lines changed

2 files changed

+11
-86
lines changed

src/main/java/com/google/devtools/build/lib/buildtool/OutputDirectoryLinksUtils.java

Lines changed: 8 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
package com.google.devtools.build.lib.buildtool;
1515

1616
import com.google.common.base.Joiner;
17-
import com.google.common.base.Preconditions;
1817
import com.google.common.collect.ImmutableList;
1918
import com.google.common.collect.ImmutableSet;
2019
import com.google.common.collect.Iterables;
@@ -35,7 +34,6 @@
3534
import com.google.devtools.build.lib.vfs.PathFragment;
3635
import java.io.IOException;
3736
import java.util.ArrayList;
38-
import java.util.Collection;
3937
import java.util.LinkedHashSet;
4038
import java.util.List;
4139
import java.util.Set;
@@ -186,49 +184,6 @@ public static PathPrettyPrinter getPathPrettyPrinter(
186184
getAllLinkDefinitions(symlinkDefinitions), symlinkPrefix, productName, workspaceDirectory);
187185
}
188186

189-
private static void removeAllSymlinks(
190-
List<String> failures, Path workspace, Path outputBase, String symlinkPrefix) {
191-
192-
// Get the prefix directory relative to the workspace.
193-
Path symlinkPrefixDirectory = workspace.getRelative(symlinkPrefix);
194-
Path directoryWithSymlinks =
195-
// Handle the special case when the prefix is just a path.
196-
// Otherwise we need to go one level up.
197-
symlinkPrefix.endsWith("/")
198-
? symlinkPrefixDirectory
199-
// This will return the workspace if the prefix was not a directory.
200-
: symlinkPrefixDirectory.getParentDirectory();
201-
Preconditions.checkNotNull(
202-
directoryWithSymlinks, "Invalid symlink_prefix provided: %s", symlinkPrefix);
203-
204-
// Try to get a list of all symlinks in the workspace.
205-
Collection<Path> pathsInWorkspace;
206-
try {
207-
pathsInWorkspace = directoryWithSymlinks.getDirectoryEntries();
208-
} catch (IOException e) {
209-
failures.add(
210-
String.format(
211-
"Failed to list files under path %s: %s",
212-
directoryWithSymlinks.getPathString(), e.getMessage()));
213-
return;
214-
}
215-
216-
// Iterate through all the files and delete any symbolic links that start with the prefix
217-
// and point to the output directory.
218-
for (Path entry : pathsInWorkspace) {
219-
try {
220-
if (entry.isSymbolicLink()
221-
&& entry.relativeTo(workspace).getPathString().startsWith(symlinkPrefix)
222-
&& entry.readSymbolicLink().startsWith(outputBase.asFragment())) {
223-
logger.atFinest().log("Removing %s", entry);
224-
entry.delete();
225-
}
226-
} catch (IOException e) {
227-
failures.add(String.format("%s: %s", entry.getBaseName(), e.getMessage()));
228-
}
229-
}
230-
}
231-
232187
/**
233188
* Attempts to remove the convenience symlinks in the workspace directory.
234189
*
@@ -242,35 +197,28 @@ private static void removeAllSymlinks(
242197
* @param eventHandler the error eventHandler
243198
* @param symlinkPrefix the symlink prefix which should be removed
244199
* @param productName the product name
245-
* @param removeAllConvenienceSymlinks Delete all symlinks with the given prefix, not just
246-
* predefined links.
247200
*/
248201
public static void removeOutputDirectoryLinks(
249202
Iterable<SymlinkDefinition> symlinkDefinitions,
250203
Path workspace,
251204
Path outputBase,
252205
EventHandler eventHandler,
253206
String symlinkPrefix,
254-
String productName,
255-
boolean removeAllConvenienceSymlinks) {
207+
String productName) {
256208
if (NO_CREATE_SYMLINKS_PREFIX.equals(symlinkPrefix)) {
257209
return;
258210
}
259211
List<String> failures = new ArrayList<>();
260212

261213
String workspaceBaseName = workspace.getBaseName();
262214

263-
if (removeAllConvenienceSymlinks) {
264-
removeAllSymlinks(failures, workspace, outputBase, symlinkPrefix);
265-
} else {
266-
for (SymlinkDefinition link : getAllLinkDefinitions(symlinkDefinitions)) {
267-
removeLink(
268-
workspace,
269-
link.getLinkName(symlinkPrefix, productName, workspaceBaseName),
270-
failures,
271-
ImmutableList.builder(),
272-
false);
273-
}
215+
for (SymlinkDefinition link : getAllLinkDefinitions(symlinkDefinitions)) {
216+
removeLink(
217+
workspace,
218+
link.getLinkName(symlinkPrefix, productName, workspaceBaseName),
219+
failures,
220+
ImmutableList.builder(),
221+
false);
274222
}
275223

276224
FileSystemUtils.removeDirectoryAndParents(workspace, PathFragment.create(symlinkPrefix));

src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,6 @@ public static class Options extends OptionsBase {
102102
+ "in the background."
103103
)
104104
public boolean async;
105-
106-
@Option(
107-
name = "remove_all_convenience_symlinks",
108-
defaultValue = "false",
109-
documentationCategory = OptionDocumentationCategory.OUTPUT_SELECTION,
110-
effectTags = {OptionEffectTag.AFFECTS_OUTPUTS},
111-
help =
112-
"If true, all symlinks in the workspace with the prefix symlink_prefix will be"
113-
+ " deleted. Without this flag, only symlinks with the predefined suffixes are"
114-
+ " cleaned.")
115-
public boolean removeAllConvenienceSymlinks;
116105
}
117106

118107
private final OS os;
@@ -149,13 +138,7 @@ public BlazeCommandResult exec(CommandEnvironment env, OptionsParsingResult opti
149138
options
150139
.getOptions(BuildRequestOptions.class)
151140
.getSymlinkPrefix(env.getRuntime().getProductName());
152-
return actuallyClean(
153-
env,
154-
env.getOutputBase(),
155-
cleanOptions.expunge,
156-
async,
157-
symlinkPrefix,
158-
cleanOptions.removeAllConvenienceSymlinks);
141+
return actuallyClean(env, env.getOutputBase(), cleanOptions.expunge, async, symlinkPrefix);
159142
} catch (CleanException e) {
160143
env.getReporter().handle(Event.error(e.getMessage()));
161144
return BlazeCommandResult.failureDetail(e.getFailureDetail());
@@ -227,12 +210,7 @@ private static void asyncClean(CommandEnvironment env, Path path, String pathIte
227210
}
228211

229212
private BlazeCommandResult actuallyClean(
230-
CommandEnvironment env,
231-
Path outputBase,
232-
boolean expunge,
233-
boolean async,
234-
String symlinkPrefix,
235-
boolean removeAllConvenienceSymlinks)
213+
CommandEnvironment env, Path outputBase, boolean expunge, boolean async, String symlinkPrefix)
236214
throws CleanException, InterruptedException {
237215
BlazeRuntime runtime = env.getRuntime();
238216
if (env.getOutputService() != null) {
@@ -317,8 +295,7 @@ private BlazeCommandResult actuallyClean(
317295
env.getOutputBase(),
318296
env.getReporter(),
319297
symlinkPrefix,
320-
env.getRuntime().getProductName(),
321-
removeAllConvenienceSymlinks);
298+
env.getRuntime().getProductName());
322299

323300
// shutdown on expunge cleans
324301
if (expunge) {

0 commit comments

Comments
 (0)