Skip to content

Commit dc3c82b

Browse files
ericktCommit Bot
authored and
Commit Bot
committed
[cargo-gnaw] Tweak tests to fix cargo roll
In rust-lang/cargo#10243, cargo was changed to disallow crate-types that produce the same filename. This can happen with `lib` and `rlib`, or `dylib` and `cdylib`. This changes the `multiple_crate_type` to split out these into multiple sub-crates. Note that because cargo-gnaw currently only supports generating rules for `lib` types, we don't produce anything for the `sub-crate-with-rlib`. Change-Id: Id1c15e884de228f9024a6df1fc315e03a4a33bb4 Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/637408 Fuchsia-Auto-Submit: Erick Tryzelaar <[email protected]> Reviewed-by: Adam Perry <[email protected]> Commit-Queue: Auto-Submit <[email protected]>
1 parent 079c48d commit dc3c82b

File tree

11 files changed

+88
-16
lines changed

11 files changed

+88
-16
lines changed

tools/cargo-gnaw/tests/BUILD.gn

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,12 @@ if (is_host) {
7272
"multiple_crate_types/Cargo.lock",
7373
"multiple_crate_types/Cargo.toml",
7474
"multiple_crate_types/src/lib.rs",
75-
"multiple_crate_types/sub-crate/Cargo.toml",
76-
"multiple_crate_types/sub-crate/src/lib.rs",
75+
"multiple_crate_types/sub-crate-with-cdylib/Cargo.toml",
76+
"multiple_crate_types/sub-crate-with-cdylib/src/lib.rs",
77+
"multiple_crate_types/sub-crate-with-dylib/Cargo.toml",
78+
"multiple_crate_types/sub-crate-with-dylib/src/lib.rs",
79+
"multiple_crate_types/sub-crate-with-rlib/Cargo.toml",
80+
"multiple_crate_types/sub-crate-with-rlib/src/lib.rs",
7781
"platform_deps/.cargo/config",
7882
"platform_deps/BUILD.gn",
7983
"platform_deps/Cargo.lock",

tools/cargo-gnaw/tests/multiple_crate_types/BUILD.gn

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ rust_library("multiple_crate_types-v1_0_25") {
1414
output_name = "multiple_crate_types-8be5e59704cbf5a4"
1515

1616
deps = []
17-
deps += [ ":sub-crate-v1_0_25" ]
17+
deps += [ ":sub-crate-with-cdylib-v1_0_25" ]
18+
deps += [ ":sub-crate-with-dylib-v1_0_25" ]
19+
deps += [ ":sub-crate-with-rlib-v1_0_25" ]
1820

1921
rustenv = []
2022

@@ -28,10 +30,10 @@ rust_library("multiple_crate_types-v1_0_25") {
2830
visibility = [ ":*" ]
2931
}
3032

31-
rust_library("sub-crate-v1_0_25") {
32-
crate_name = "sub_crate"
33-
crate_root = "//multiple_crate_types/sub-crate/src/lib.rs"
34-
output_name = "sub_crate-c933a0443c39195"
33+
rust_library("sub-crate-with-cdylib-v1_0_25") {
34+
crate_name = "sub_crate_with_cdylib"
35+
crate_root = "//multiple_crate_types/sub-crate-with-cdylib/src/lib.rs"
36+
output_name = "sub_crate_with_cdylib-2c19a9098651391d"
3537

3638
deps = []
3739

@@ -40,8 +42,29 @@ rust_library("sub-crate-v1_0_25") {
4042
rustflags = [
4143
"--cap-lints=allow",
4244
"--edition=2018",
43-
"-Cmetadata=c933a0443c39195",
44-
"-Cextra-filename=-c933a0443c39195",
45+
"-Cmetadata=2c19a9098651391d",
46+
"-Cextra-filename=-2c19a9098651391d",
47+
]
48+
49+
visibility = []
50+
visibility += [ ":*" ]
51+
visibility += [ "//foo/bar/*" ]
52+
}
53+
54+
rust_library("sub-crate-with-dylib-v1_0_25") {
55+
crate_name = "sub_crate_with_dylib"
56+
crate_root = "//multiple_crate_types/sub-crate-with-dylib/src/lib.rs"
57+
output_name = "sub_crate_with_dylib-cba782ed0389a004"
58+
59+
deps = []
60+
61+
rustenv = []
62+
63+
rustflags = [
64+
"--cap-lints=allow",
65+
"--edition=2018",
66+
"-Cmetadata=cba782ed0389a004",
67+
"-Cextra-filename=-cba782ed0389a004",
4568
]
4669

4770
visibility = []

tools/cargo-gnaw/tests/multiple_crate_types/Cargo.lock

Lines changed: 12 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/cargo-gnaw/tests/multiple_crate_types/Cargo.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ authors = ["Erick Tryzelaar <[email protected]>"]
55
edition = "2018"
66

77
[dependencies]
8-
sub-crate = { version = "1.0.25", path = "sub-crate" }
8+
sub-crate-with-cdylib = { version = "1.0.25", path = "sub-crate-with-cdylib" }
9+
sub-crate-with-dylib = { version = "1.0.25", path = "sub-crate-with-dylib" }
10+
sub-crate-with-rlib = { version = "1.0.25", path = "sub-crate-with-rlib" }
911

10-
[gn.package.sub-crate."1.0.25"]
12+
[gn.package.sub-crate-with-cdylib."1.0.25"]
13+
visibility = [":*", "//foo/bar/*"]
14+
15+
[gn.package.sub-crate-with-dylib."1.0.25"]
1116
visibility = [":*", "//foo/bar/*"]

tools/cargo-gnaw/tests/multiple_crate_types/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
fn some_fn() {
5+
pub fn some_fn() {
66
println!("Hello, world!");
77
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[package]
2-
name = "sub-crate"
2+
name = "sub-crate-with-cdylib"
33
version = "1.0.25"
44
authors = ["Erick Tryzelaar <[email protected]>"]
55
edition = "2018"
66

77
[lib]
8-
crate-type = ["lib", "rlib", "staticlib", "dylib", "cdylib"]
8+
crate-type = ["cdylib", "lib", "staticlib"]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "sub-crate-with-dylib"
3+
version = "1.0.25"
4+
authors = ["Erick Tryzelaar <[email protected]>"]
5+
edition = "2018"
6+
7+
[lib]
8+
crate-type = ["dylib", "lib", "staticlib"]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright 2020 The Fuchsia Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// no-op
6+
// hello there
7+
pub const EXPORTED: u32 = 777;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "sub-crate-with-rlib"
3+
version = "1.0.25"
4+
authors = ["Erick Tryzelaar <[email protected]>"]
5+
edition = "2018"
6+
7+
[lib]
8+
crate-type = ["rlib", "staticlib"]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright 2020 The Fuchsia Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// no-op
6+
// hello there
7+
pub const EXPORTED: u32 = 777;

0 commit comments

Comments
 (0)