From 05899953a1726328b0ff9d940720e363260ce5c4 Mon Sep 17 00:00:00 2001
From: Nicholas Junge
+ For example, compiled Windows .res files can be provided here to be embedded in + the binary target. +
+ */ + .add( + attr("additional_linker_inputs", LABEL_LIST) + .orderIndependent() + .direct_compile_time_input() + .allowedFileTypes(FileTypeSet.ANY_FILE)) /* Remove matching options from the C++ compilation command. Subject to "Make" variable substitution. @@ -458,18 +470,6 @@ public static final class CcBinaryBaseRule implements RuleDefinition { @Override public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env) { return builder - /* - Pass these files to the C++ linker command. -- For example, compiled Windows .res files can be provided here to be embedded in - the binary target. -
- */ - .add( - attr("additional_linker_inputs", LABEL_LIST) - .orderIndependent() - .direct_compile_time_input() - .allowedFileTypes(FileTypeSet.ANY_FILE)) .override( attr("deps", LABEL_LIST) .allowedRuleClasses(DEPS_ALLOWED_RULES) diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_library.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_library.bzl index f36de71a639c59..c55f3f7ebe0eea 100755 --- a/src/main/starlark/builtins_bzl/common/cc/cc_library.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/cc_library.bzl @@ -148,7 +148,7 @@ def _cc_library_impl(ctx): compilation_outputs = compilation_outputs, cc_toolchain = cc_toolchain, feature_configuration = feature_configuration, - additional_inputs = _filter_linker_scripts(ctx.files.deps), + additional_inputs = _filter_linker_scripts(ctx.files.deps) + ctx.files.additional_linker_inputs, linking_contexts = linking_contexts, grep_includes = ctx.executable._grep_includes, user_link_flags = cc_helper.linkopts(ctx, additional_make_variable_substitutions, cc_toolchain), @@ -206,11 +206,12 @@ def _cc_library_impl(ctx): else: user_link_flags = cc_helper.linkopts(ctx, additional_make_variable_substitutions, cc_toolchain) linker_scripts = _filter_linker_scripts(ctx.files.deps) - if len(user_link_flags) > 0 or len(linker_scripts) > 0 or not semantics.should_create_empty_archive(): + additional_linker_inputs = ctx.files.additional_linker_inputs + if len(user_link_flags) > 0 or len(linker_scripts) > 0 or len(additional_linker_inputs) > 0 or not semantics.should_create_empty_archive(): linker_input = cc_common.create_linker_input( owner = ctx.label, user_link_flags = user_link_flags, - additional_inputs = depset(linker_scripts), + additional_inputs = depset(linker_scripts + additional_linker_inputs), ) contexts_to_merge.append(cc_common.create_linking_context(linker_inputs = depset([linker_input]))) @@ -575,6 +576,10 @@ attrs = { ), "linkstamp": attr.label(allow_single_file = True), "linkopts": attr.string_list(), + "additional_linker_inputs": attr.label_list( + allow_files = True, + flags = ["ORDER_INDEPENDENT", "DIRECT_COMPILE_TIME_INPUT"], + ), "includes": attr.string_list(), "defines": attr.string_list(), "copts": attr.string_list(),