Skip to content

Commit

Permalink
fix use of stamping in rust_binary_without_process_wrapper (#1218)
Browse files Browse the repository at this point in the history
* don't ever stamp when building process_wrapper

* buildify

* fix `stamp = 0` for all rust_binary_without_process_wrapper
  • Loading branch information
krasimirgg committed Mar 24, 2022
1 parent 8df4517 commit 99b4b25
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions rust/private/rust.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -929,14 +929,27 @@ rust_binary = rule(
"""),
)

def _fake_out_process_wrapper(attrs):
def _common_attrs_for_binary_without_process_wrapper(attrs):
new_attr = dict(attrs.items())

# use a fake process wrapper
new_attr["_process_wrapper"] = attr.label(
default = None,
executable = True,
allow_single_file = True,
cfg = "exec",
)

# fix stamp = 0
new_attr["stamp"] = attr.int(
doc = dedent("""\
Fix `stamp = 0` as stamping is not supported when building without process_wrapper:
https://github.com/bazelbuild/rules_rust/blob/8df4517d370b0c543a01ba38b63e1d5a4104b035/rust/private/rustc.bzl#L955
"""),
default = 0,
values = [0],
)

return new_attr

# Provides an internal rust_binary to use that we can use to build the process
Expand All @@ -945,7 +958,7 @@ def _fake_out_process_wrapper(attrs):
rust_binary_without_process_wrapper = rule(
implementation = _rust_binary_impl,
provides = _common_providers,
attrs = dict(_fake_out_process_wrapper(_common_attrs).items() + _rust_binary_attrs.items()),
attrs = dict(_common_attrs_for_binary_without_process_wrapper(_common_attrs).items() + _rust_binary_attrs.items()),
executable = True,
fragments = ["cpp"],
host_fragments = ["cpp"],
Expand Down

0 comments on commit 99b4b25

Please sign in to comment.