Skip to content

Commit

Permalink
C++: Check feature presence before patching
Browse files Browse the repository at this point in the history
In CppActionConfigs we weren't checking if the feature
build_interface_libraries was present before patching it.

RELNOTES:none
PiperOrigin-RevId: 247941044
  • Loading branch information
oquenchil authored and copybara-github committed May 13, 2019
1 parent 93185ef commit 4eb7683
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -374,23 +374,26 @@ public static ImmutableList<CToolchain.Feature> getLegacyFeatures(
" }")));
}

featureBuilder.add(
getFeature(
Joiner.on("\n")
.join(
" name: 'build_interface_libraries'",
" flag_set {",
" with_feature { feature: 'supports_interface_shared_libraries' }",
" action: 'c++-link-dynamic-library'",
" action: 'c++-link-nodeps-dynamic-library'",
" flag_group {",
" expand_if_all_available: 'generate_interface_library'",
" flag: '%{generate_interface_library}'",
" flag: '%{interface_library_builder_path}'",
" flag: '%{interface_library_input_path}'",
" flag: '%{interface_library_output_path}'",
" }",
" }")));
if (!existingFeatureNames.contains(CppRuleClasses.BUILD_INTERFACE_LIBRARIES)) {
featureBuilder.add(
getFeature(
Joiner.on("\n")
.join(
" name: 'build_interface_libraries'",
" flag_set {",
" with_feature { feature: 'supports_interface_shared_libraries' }",
" action: 'c++-link-dynamic-library'",
" action: 'c++-link-nodeps-dynamic-library'",
" flag_group {",
" expand_if_all_available: 'generate_interface_library'",
" flag: '%{generate_interface_library}'",
" flag: '%{interface_library_builder_path}'",
" flag: '%{interface_library_input_path}'",
" flag: '%{interface_library_output_path}'",
" }",
" }")));
}

// Order of feature declaration matters, cppDynamicLibraryLinkerTool has to
// follow right after build_interface_libraries.
if (!existingFeatureNames.contains("dynamic_library_linker_tool")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@ public static Label ccToolchainTypeAttribute(RuleDefinitionEnvironment env) {
/** A string constant for the autofdo feature. */
public static final String AUTOFDO = "autofdo";

/** A string constant for the build_interface_libraries feature. */
public static final String BUILD_INTERFACE_LIBRARIES = "build_interface_libraries";

/** A string constant for the xbinaryfdo feature. */
public static final String XBINARYFDO = "xbinaryfdo";

Expand Down

0 comments on commit 4eb7683

Please sign in to comment.