Skip to content

Commit

Permalink
Add features to identify java and python launcher links and native de…
Browse files Browse the repository at this point in the history
…ps links

PiperOrigin-RevId: 344814633
  • Loading branch information
Googler authored and copybara-github committed Nov 30, 2020
1 parent 7337126 commit d3a3162
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,15 @@ public static Label ccToolchainTypeAttribute(RuleDefinitionEnvironment env) {
public static final String THIN_LTO_ALL_LINKSTATIC_USE_SHARED_NONLTO_BACKENDS =
"thin_lto_all_linkstatic_use_shared_nonlto_backends";

/** A string constant for native deps links. */
public static final String NATIVE_DEPS_LINK = "native_deps_link";

/** A string constant for java launcher links. */
public static final String JAVA_LAUNCHER_LINK = "java_launcher_link";

/** A string constant for python launcher links. */
public static final String PY_LAUNCHER_LINK = "py_launcher_link";

/**
* A string constant for the PDB file generation feature, should only be used for toolchains
* targeting Windows that include a linker producing PDB files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.
package com.google.devtools.build.lib.rules.java;

import static com.google.devtools.build.lib.rules.cpp.CppRuleClasses.JAVA_LAUNCHER_LINK;
import static com.google.devtools.build.lib.rules.cpp.CppRuleClasses.STATIC_LINKING_MODE;
import static com.google.devtools.build.lib.rules.java.DeployArchiveBuilder.Compression.COMPRESSED;

Expand Down Expand Up @@ -151,6 +152,7 @@ public ConfiguredTarget create(RuleContext ruleContext)
/* requestedFeatures= */ ImmutableSet.<String>builder()
.addAll(ruleContext.getFeatures())
.add(STATIC_LINKING_MODE)
.add(JAVA_LAUNCHER_LINK)
.build(),
/* unsupportedFeatures= */ ruleContext.getDisabledFeatures(),
ccToolchain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package com.google.devtools.build.lib.rules.nativedeps;

import static com.google.devtools.build.lib.rules.cpp.CppRuleClasses.NATIVE_DEPS_LINK;
import static com.google.devtools.build.lib.rules.cpp.CppRuleClasses.STATIC_LINKING_MODE;

import com.google.common.base.Preconditions;
Expand Down Expand Up @@ -211,7 +212,8 @@ public static NativeDepsRunfiles createNativeDepsAction(
ImmutableSortedSet.Builder<String> requestedFeaturesBuilder =
ImmutableSortedSet.<String>naturalOrder()
.addAll(ruleContext.getFeatures())
.add(STATIC_LINKING_MODE);
.add(STATIC_LINKING_MODE)
.add(NATIVE_DEPS_LINK);
if (!ruleContext.getDisabledFeatures().contains(CppRuleClasses.LEGACY_WHOLE_ARCHIVE)) {
requestedFeaturesBuilder.add(CppRuleClasses.LEGACY_WHOLE_ARCHIVE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ _FEATURE_NAMES = struct(
enable_fdo_thinlto = "enable_fdo_thinlto",
xbinaryfdo_implicit_thinlto = "xbinaryfdo_implicit_thinlto",
enable_xbinaryfdo_thinlto = "enable_xbinaryfdo_thinlto",
native_deps_link = "native_deps_link",
java_launcher_link = "java_launcher_link",
py_launcher_link = "py_launcher_link",
autofdo = "autofdo",
is_cc_fake_binary = "is_cc_fake_binary",
xbinaryfdo = "xbinaryfdo",
Expand Down Expand Up @@ -578,6 +581,36 @@ _enable_xbinaryfdo_thinlto_feature = feature(

_xbinaryfdo_implicit_thinlto_feature = feature(name = _FEATURE_NAMES.xbinaryfdo_implicit_thinlto)

_native_deps_link_feature = feature(
name = _FEATURE_NAMES.native_deps_link,
flag_sets = [
flag_set(
actions = [ACTION_NAMES.cpp_link_dynamic_library],
flag_groups = [flag_group(flags = ["native_deps_link"])],
),
],
)

_java_launcher_link_feature = feature(
name = _FEATURE_NAMES.java_launcher_link,
flag_sets = [
flag_set(
actions = [ACTION_NAMES.cpp_link_executable],
flag_groups = [flag_group(flags = ["java_launcher_link"])],
),
],
)

_py_launcher_link_feature = feature(
name = _FEATURE_NAMES.py_launcher_link,
flag_sets = [
flag_set(
actions = [ACTION_NAMES.cpp_link_executable],
flag_groups = [flag_group(flags = ["py_launcher_link"])],
),
],
)

_autofdo_feature = feature(
name = _FEATURE_NAMES.autofdo,
flag_sets = [
Expand Down Expand Up @@ -1168,6 +1201,9 @@ _feature_name_to_feature = {
_FEATURE_NAMES.fdo_implicit_thinlto: _fdo_implicit_thinlto_feature,
_FEATURE_NAMES.enable_xbinaryfdo_thinlto: _enable_xbinaryfdo_thinlto_feature,
_FEATURE_NAMES.xbinaryfdo_implicit_thinlto: _xbinaryfdo_implicit_thinlto_feature,
_FEATURE_NAMES.native_deps_link: _native_deps_link_feature,
_FEATURE_NAMES.java_launcher_link: _java_launcher_link_feature,
_FEATURE_NAMES.py_launcher_link: _py_launcher_link_feature,
_FEATURE_NAMES.autofdo: _autofdo_feature,
_FEATURE_NAMES.is_cc_fake_binary: _is_cc_fake_binary_feature,
_FEATURE_NAMES.xbinaryfdo: _xbinaryfdo_feature,
Expand Down

0 comments on commit d3a3162

Please sign in to comment.