Skip to content

Commit d214d17

Browse files
ComputerDruidFuchsia Internal LUCI
authored andcommitted
[build][rust] stop requiring output_name for rustc_binaries
This is Step 4 of the transition plan from https://fxbug.dev/64100 This makes it so that output_name defaults to the target name without any `-` -> `_` remapping. By now, we've been forcing output_name to be set to disambiguate between the old behavior and the new behavior for a month, which is longer than the week I wanted to wait (oops). So this change should be a no-op for everyone who has updated their pending CLs sometime in the last month :) Bug: 64100 Change-Id: I83c10bae9e797797f39b376be1881c5e36b70942 Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/680140 Commit-Queue: Dan Johnson <computerdruid@google.com> Reviewed-by: Joseph Ryan <josephry@google.com>
1 parent f050e47 commit d214d17

File tree

1 file changed

+10
-23
lines changed

1 file changed

+10
-23
lines changed

build/rust/rustc_binary.gni

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,11 @@ import("//build/rust/rustc_test.gni")
1111
#
1212
# output_name (optional)
1313
# Name of the output file. Also used as the crate name of the binary,
14-
# except the crate name has dashes replaced with underscores.
15-
#
16-
# Defaults to an underscore-translated version of target name
17-
# (see http://fxbug.dev/64100).
14+
# except the crate name has dashes replaced with underscores. If not
15+
# specified, it defaults to the target name.
1816
#
1917
# name (optional, deprecated)
20-
# Deprecated version of output_name. If not specified, it is
21-
# assumed to be the same as the target name. Unlike output_name, all
22-
# dashes will be replaced with underscores in both the output file name
23-
# and the crate name.
18+
# Deprecated version of output_name.
2419
#
2520
# output_dir (optional)
2621
# Directory that the resulting binary should be placed in.
@@ -73,8 +68,8 @@ import("//build/rust/rustc_test.gni")
7368
#
7469
# with_unit_tests (optional)
7570
# Builds unit tests associated with the binary. This will create a
76-
# `<name_underscored>_bin_test` test file in the output directory, and a
77-
# new GN target called <name>_test.
71+
# `<output_name_underscored>_bin_test` test file in the output directory,
72+
# and a new GN target called <name>_test.
7873
# Equivalent to adding a `rustc_test` target with that name and the same
7974
# source_root.
8075
#
@@ -155,29 +150,21 @@ template("rustc_binary") {
155150
# use the target name unless another name is specified
156151
assert(!(defined(invoker.output_name) && defined(invoker.name)),
157152
"Only one of output_name and name may be specified.")
158-
package_name = target_name
153+
_output_name = target_name
159154
if (defined(invoker.output_name)) {
160-
package_name = invoker.output_name
155+
_output_name = invoker.output_name
161156
} else if (defined(invoker.name)) {
162-
package_name = invoker.name
157+
_output_name = invoker.name
163158
}
164159

165160
# rustc does not support dashes in crate names
166-
_crate_name = string_replace(package_name, "-", "_")
167-
if (defined(invoker.output_name)) {
168-
_output_name = invoker.output_name
169-
} else {
170-
assert(
171-
_crate_name == package_name,
172-
"rustc_binary will soon change to allow binaries with `-` in the name. To disambiguate in the meantime, please set output_name fxbug.dev/64100")
173-
_output_name = _crate_name
174-
}
161+
_crate_name = string_replace(_output_name, "-", "_")
175162

176163
# if "with_unit_tests" is set to true, generate an additional rust test target
177164
# TODO(https://fxbug.dev/72931): accept a string.
178165
if (defined(invoker.with_unit_tests) && invoker.with_unit_tests == true) {
179166
rustc_test_internal("${target_name}_test") {
180-
output_name = "${package_name}_bin_test"
167+
output_name = "${_output_name}_bin_test"
181168

182169
if (defined(invoker.test_args)) {
183170
args = invoker.test_args

0 commit comments

Comments
 (0)