Skip to content

Commit

Permalink
Remove --incompatible_disable_depset_in_cc_user_flags
Browse files Browse the repository at this point in the history
Because the flag was flipped by #6383, we can now remove the old code paths.

RELNOTES: None.
PiperOrigin-RevId: 240122125
  • Loading branch information
hlopko authored and copybara-github committed Mar 25, 2019
1 parent 7dd062f commit dd1d59a
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@
public class BazelRulesModule extends BlazeModule {
/** This is where deprecated options go to die. */
public static class GraveyardOptions extends OptionsBase {
@Option(
name = "incompatible_disable_depset_in_cc_user_flags",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS},
metadataTags = {
OptionMetadataTag.DEPRECATED,
OptionMetadataTag.INCOMPATIBLE_CHANGE,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
},
help = "Deprecated no-op.")
public boolean disableDepsetInUserFlags;

@Option(
name = "incompatible_dont_emit_static_libgcc",
oldName = "experimental_dont_emit_static_libgcc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public CcToolchainVariables getCompileBuildVariables(
/* dwoFile= */ null,
/* ltoIndexingFile= */ null,
/* includes= */ ImmutableList.of(),
userFlagsToIterable(ccToolchainProvider.getCppConfiguration(), userCompileFlags),
userFlagsToIterable(userCompileFlags),
/* cppModuleMap= */ null,
usePic,
/* fakeOutputFile= */ null,
Expand Down Expand Up @@ -260,7 +260,7 @@ public CcToolchainVariables getLinkBuildVariables(
featureConfiguration,
useTestOnlyFlags,
/* isLtoIndexing= */ false,
userFlagsToIterable(ccToolchainProvider.getCppConfiguration(), userLinkFlags),
userFlagsToIterable(userLinkFlags),
/* interfaceLibraryBuilder= */ null,
/* interfaceLibraryOutput= */ null,
/* ltoOutputRootPrefix= */ null,
Expand Down Expand Up @@ -311,26 +311,14 @@ protected ImmutableList<String> asStringImmutableList(Object o) {
}
}

/**
* Converts an object that represents user flags and can be either SkylarkNestedSet , SkylarkList,
* or None into Iterable.
*/
protected Iterable<String> userFlagsToIterable(CppConfiguration cppConfiguration, Object o)
throws EvalException {
if (o instanceof SkylarkNestedSet) {
if (cppConfiguration.disableDepsetInUserFlags()) {
throw new EvalException(
Location.BUILTIN,
"Passing depset into user flags is deprecated (see "
+ "--incompatible_disable_depset_in_cc_user_flags), use list instead.");
}
return asStringNestedSet(o);
} else if (o instanceof SkylarkList) {
/** Converts an object that represents user flags as either SkylarkList or None into Iterable. */
protected Iterable<String> userFlagsToIterable(Object o) throws EvalException {
if (o instanceof SkylarkList) {
return asStringImmutableList(o);
} else if (o instanceof NoneType) {
return ImmutableList.of();
} else {
throw new EvalException(Location.BUILTIN, "Only depset and list is allowed.");
throw new EvalException(Location.BUILTIN, "Only list is allowed.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,10 +560,6 @@ public static String getLegacyCrosstoolFieldErrorMessage(String field) {
+ "migration instructions).";
}

public boolean disableDepsetInUserFlags() {
return cppOptions.disableDepsetInUserFlags;
}

public boolean removeCpuCompilerCcToolchainAttributes() {
return cppOptions.removeCpuCompilerCcToolchainAttributes;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -807,21 +807,6 @@ public Label getFdoPrefetchHintsLabel() {
+ "across subpackage boundaries.")
public boolean experimentalIncludesAttributeSubpackageTraversal;

@Option(
name = "incompatible_disable_depset_in_cc_user_flags",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS},
metadataTags = {
OptionMetadataTag.INCOMPATIBLE_CHANGE,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
},
help =
"If true, C++ toolchain Starlark API will not accept depset in `user_compile_flags` "
+ "param of `create_compile_variables`, and in `user_link_flags` of "
+ "`create_link_variables`. Use list instead.")
public boolean disableDepsetInUserFlags;

@Option(
name = "experimental_do_not_use_cpu_transformer",
defaultValue = "false",
Expand Down Expand Up @@ -914,7 +899,6 @@ public FragmentOptions getHost() {

host.doNotUseCpuTransformer = doNotUseCpuTransformer;
host.disableGenruleCcToolchainDependency = disableGenruleCcToolchainDependency;
host.disableDepsetInUserFlags = disableDepsetInUserFlags;
host.disableExpandIfAllAvailableInFlagSet = disableExpandIfAllAvailableInFlagSet;
host.disableLegacyCcProvider = disableLegacyCcProvider;
host.removeCpuCompilerCcToolchainAttributes = removeCpuCompilerCcToolchainAttributes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,17 +261,14 @@ SkylarkDict<String, String> getEnvironmentVariable(
noneable = true),
@Param(
name = "user_compile_flags",
doc =
"List of additional compilation flags (copts). Passing depset is deprecated and "
+ "will be removed by --incompatible_disable_depset_in_cc_user_flags flag.",
doc = "List of additional compilation flags (copts).",
positional = false,
named = true,
defaultValue = "None",
noneable = true,
allowedTypes = {
@ParamType(type = NoneType.class),
@ParamType(type = SkylarkList.class),
@ParamType(type = SkylarkNestedSet.class)
}),
@Param(
name = "include_directories",
Expand Down Expand Up @@ -387,17 +384,14 @@ CcToolchainVariablesT getCompileBuildVariables(
}),
@Param(
name = "user_link_flags",
doc =
"List of additional link flags (linkopts). Passing depset is deprecated and "
+ "will be removed by --incompatible_disable_depset_in_cc_user_flags flag.",
doc = "List of additional link flags (linkopts).",
positional = false,
named = true,
defaultValue = "None",
noneable = true,
allowedTypes = {
@ParamType(type = NoneType.class),
@ParamType(type = SkylarkList.class),
@ParamType(type = SkylarkNestedSet.class)
@ParamType(type = SkylarkList.class)
}),
@Param(
name = "output_file",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,20 +615,6 @@ public void testCompileBuildVariablesForPic() throws Exception {

@Test
public void testUserCompileFlags() throws Exception {
useConfiguration("--noincompatible_disable_depset_in_cc_user_flags");
assertThat(
commandLineForVariables(
CppActionNames.CPP_COMPILE,
"cc_common.create_compile_variables(",
"feature_configuration = feature_configuration,",
"cc_toolchain = toolchain,",
"user_compile_flags = depset(['-foo'])",
")"))
.contains("-foo");
}

@Test
public void testUserCompileFlagsAsList() throws Exception {
assertThat(
commandLineForVariables(
CppActionNames.CPP_COMPILE,
Expand All @@ -640,22 +626,6 @@ public void testUserCompileFlagsAsList() throws Exception {
.contains("-foo");
}

@Test
public void testUserCompileFlagsAsDepsetWhenDisabled() throws Exception {
useConfiguration("--incompatible_disable_depset_in_cc_user_flags");
reporter.removeHandler(failFastHandler);
assertThat(
commandLineForVariables(
CppActionNames.CPP_COMPILE,
"cc_common.create_compile_variables(",
"feature_configuration = feature_configuration,",
"cc_toolchain = toolchain,",
"user_compile_flags = depset(['-foo'])",
")"))
.isNull();
assertContainsEvent("Passing depset into user flags is deprecated");
}

@Test
public void testEmptyLinkVariables() throws Exception {
assertThat(
Expand Down Expand Up @@ -728,20 +698,6 @@ public void testRuntimeLibrarySearchDirectoriesLinkVariables() throws Exception

@Test
public void testUserLinkFlagsLinkVariables() throws Exception {
useConfiguration("--noincompatible_disable_depset_in_cc_user_flags");
assertThat(
commandLineForVariables(
CppActionNames.CPP_LINK_EXECUTABLE,
"cc_common.create_link_variables(",
"feature_configuration = feature_configuration,",
"cc_toolchain = toolchain,",
"user_link_flags = depset([ '-avocado' ]),",
")"))
.contains("-avocado");
}

@Test
public void testUserLinkFlagsLinkVariablesAsList() throws Exception {
assertThat(
commandLineForVariables(
CppActionNames.CPP_LINK_EXECUTABLE,
Expand All @@ -753,22 +709,6 @@ public void testUserLinkFlagsLinkVariablesAsList() throws Exception {
.contains("-avocado");
}

@Test
public void testUserLinkFlagsLinkVariablesAsDepsetWhenDisabled() throws Exception {
useConfiguration("--incompatible_disable_depset_in_cc_user_flags");
reporter.removeHandler(failFastHandler);
assertThat(
commandLineForVariables(
CppActionNames.CPP_LINK_EXECUTABLE,
"cc_common.create_link_variables(",
"feature_configuration = feature_configuration,",
"cc_toolchain = toolchain,",
"user_link_flags = depset([ '-avocado' ]),",
")"))
.isNull();
assertContainsEvent("Passing depset into user flags is deprecated");
}

@Test
public void testIfsoRelatedVariablesAreNotExposed() throws Exception {
AnalysisMock.get()
Expand Down

0 comments on commit dd1d59a

Please sign in to comment.