Skip to content

Commit

Permalink
Introduce the flag incompatible_skip_genfiles_symlink.
Browse files Browse the repository at this point in the history
When set to true, the genfiles symlink is not created.

#8651

RELNOTES: None.
PiperOrigin-RevId: 259936511
  • Loading branch information
laurentlb authored and copybara-github committed Jul 25, 2019
1 parent c928f7f commit bdce456
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,20 @@ public boolean useTopLevelTargetsForSymlinks() {
+ "with caution.")
public boolean useAsyncExecution;

@Option(
name = "incompatible_skip_genfiles_symlink",
defaultValue = "false",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
metadataTags = {
OptionMetadataTag.INCOMPATIBLE_CHANGE,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
},
effectTags = {OptionEffectTag.LOSES_INCREMENTAL_STATE},
help =
"If set to true, the genfiles symlink will not be created. For more information, see "
+ "https://github.com/bazelbuild/bazel/issues/8651")
public boolean incompatibleSkipGenfilesSymlink;

/**
* Converter for jobs: Takes keyword ({@value #FLAG_SYNTAX}). Values must be between 1 and
* MAX_JOBS.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ void executeBuild(
getReporter(),
targetConfigurations,
request.getBuildOptions().getSymlinkPrefix(productName),
productName);
productName,
!request.getBuildOptions().incompatibleSkipGenfilesSymlink);
}

ActionCache actionCache = getActionCache();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public Optional<Path> getLinkPath(
// Links to create, delete, and use for pretty-printing.
// Note that the order in which items appear in this list controls priority for getPrettyPath.
// It will try each link as a prefix from first to last.
private static final ImmutableList<SymlinkDefinition> LINK_DEFINITIONS =
private static final ImmutableList<SymlinkDefinition> LINK_DEFINITIONS_WITH_GENFILES =
ImmutableList.of(
new ConfigSymlink("bin", BuildConfiguration::getBinDirectory),
new ConfigSymlink("testlogs", BuildConfiguration::getTestLogsDirectory),
Expand All @@ -148,6 +148,15 @@ public Optional<Path> getLinkPath(
OutputSymlink.SYMLINK_PREFIX,
ExecRootSymlink.INSTANCE);

// The genfiles symlink will be removed in the future.
private static final ImmutableList<SymlinkDefinition> LINK_DEFINITIONS_WITHOUT_GENFILES =
ImmutableList.of(
new ConfigSymlink("bin", BuildConfiguration::getBinDirectory),
new ConfigSymlink("testlogs", BuildConfiguration::getTestLogsDirectory),
OutputSymlink.PRODUCT_NAME,
OutputSymlink.SYMLINK_PREFIX,
ExecRootSymlink.INSTANCE);

private static final String NO_CREATE_SYMLINKS_PREFIX = "/";

public static Iterable<String> getOutputSymlinkNames(String productName, String symlinkPrefix) {
Expand Down Expand Up @@ -177,7 +186,8 @@ static void createOutputDirectoryLinks(
EventHandler eventHandler,
Set<BuildConfiguration> targetConfigs,
String symlinkPrefix,
String productName) {
String productName,
boolean createGenfilesSymlink) {
if (NO_CREATE_SYMLINKS_PREFIX.equals(symlinkPrefix)) {
return;
}
Expand All @@ -188,7 +198,9 @@ static void createOutputDirectoryLinks(
String workspaceBaseName = workspace.getBaseName();
RepositoryName repositoryName = RepositoryName.createFromValidStrippedName(workspaceName);

for (SymlinkDefinition definition : LINK_DEFINITIONS) {
List<SymlinkDefinition> defs =
createGenfilesSymlink ? LINK_DEFINITIONS_WITH_GENFILES : LINK_DEFINITIONS_WITHOUT_GENFILES;
for (SymlinkDefinition definition : defs) {
String symlinkName = definition.getLinkName(symlinkPrefix, productName, workspaceBaseName);
if (!createdLinks.add(symlinkName)) {
// already created a link by this name
Expand Down Expand Up @@ -221,7 +233,11 @@ static void createOutputDirectoryLinks(
public static PathPrettyPrinter getPathPrettyPrinter(
String symlinkPrefix, String productName, Path workspaceDirectory, Path workingDirectory) {
return new PathPrettyPrinter(
LINK_DEFINITIONS, symlinkPrefix, productName, workspaceDirectory, workingDirectory);
LINK_DEFINITIONS_WITH_GENFILES,
symlinkPrefix,
productName,
workspaceDirectory,
workingDirectory);
}

/**
Expand All @@ -243,7 +259,7 @@ public static void removeOutputDirectoryLinks(String workspaceName, Path workspa
List<String> failures = new ArrayList<>();

String workspaceBaseName = workspace.getBaseName();
for (SymlinkDefinition link : LINK_DEFINITIONS) {
for (SymlinkDefinition link : LINK_DEFINITIONS_WITH_GENFILES) {
removeLink(
workspace, link.getLinkName(symlinkPrefix, productName, workspaceBaseName), failures);
}
Expand Down

0 comments on commit bdce456

Please sign in to comment.