Skip to content

Commit cdd7ebc

Browse files
JakobDegenfacebook-github-bot
authored andcommitted
Only one linker_flags attribute
Summary: This attribute was present in both `rust_common_attributes` and `rust_common.linker_flags`. `rust_binary` happened to have it added to its attribute dict twice. Refactor so that we only define the attribute once. The particular reason for choosing this refactor is the next diff Reviewed By: IanChilds Differential Revision: D49004164 fbshipit-source-id: 64b682a80541ffff27f0ee62142a3ea5c7abece8
1 parent 9a26235 commit cdd7ebc

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

prelude/decls/rust_common.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def _rustc_flags_arg():
6565

6666
def _linker_flags_arg():
6767
return {
68-
"linker_flags": attrs.list(attrs.arg(), default = [], doc = """
68+
"linker_flags": attrs.list(attrs.arg(anon_target_compatible = True), default = [], doc = """
6969
The set of additional flags to pass to the linker.
7070
"""),
7171
}

prelude/decls/rust_rules.bzl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,6 @@ def _rust_common_attributes(is_binary: bool):
7777
"incremental_enabled": attrs.bool(default = False),
7878
"labels": attrs.list(attrs.string(), default = []),
7979
"licenses": attrs.list(attrs.source(), default = []),
80-
# linker_flags weren't supported for rust_library in Buck v1 but the
81-
# fbcode macros pass them anyway. They're typically empty since the
82-
# config-level flags don't get injected, but it doesn't hurt to accept
83-
# them and it simplifies the implementation of Rust rules since they
84-
# don't have to know whether we're building a rust_binary or a
85-
# rust_library.
86-
"linker_flags": attrs.list(attrs.arg(anon_target_compatible = True), default = []),
8780
"resources": attrs.named_set(attrs.one_of(attrs.dep(), attrs.source()), sorted = True, default = []),
8881
"rustdoc_flags": attrs.list(attrs.arg(), default = []),
8982
"version_universe": attrs.option(attrs.string(), default = None),
@@ -231,6 +224,13 @@ rust_library = prelude_rule(
231224
rust_common.edition_arg() |
232225
rust_common.features_arg() |
233226
rust_common.rustc_flags_arg() |
227+
# linker_flags weren't supported for rust_library in Buck v1 but the
228+
# fbcode macros pass them anyway. They're typically empty since the
229+
# config-level flags don't get injected, but it doesn't hurt to accept
230+
# them and it simplifies the implementation of Rust rules since they
231+
# don't have to know whether we're building a rust_binary or a
232+
# rust_library.
233+
rust_common.linker_flags_arg() |
234234
rust_common.env_arg() |
235235
rust_common.crate(crate_type = attrs.option(attrs.string(), default = None)) |
236236
rust_common.crate_root() |
@@ -318,6 +318,7 @@ rust_test = prelude_rule(
318318
rust_common.edition_arg() |
319319
rust_common.features_arg() |
320320
rust_common.rustc_flags_arg() |
321+
rust_common.linker_flags_arg() |
321322
rust_common.env_arg() |
322323
rust_common.crate(crate_type = attrs.option(attrs.string(), default = None)) |
323324
rust_common.crate_root() |

0 commit comments

Comments
 (0)