Skip to content

Commit 3222439

Browse files
committed
Add test for pipelined builds
This makes sure that building a crate with an rmeta dependency is viable as a linkable crate.
1 parent 758c00e commit 3222439

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed

src/test/run-make/pipelined/Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-include ../../run-make-fulldeps/tools.mk
2+
3+
O=$(TMPDIR)
4+
5+
all: $O/main
6+
$O/main
7+
8+
$O/main: $O/libmiddle.rlib $O/libleaf.rlib
9+
$(RUSTC) main.rs --extern middle=$O/libmiddle.rlib -Ldependency=$O
10+
11+
$O/libmiddle.rlib: middle.rs $O/libleaf.rmeta
12+
$(RUSTC) --emit link middle.rs --extern leaf=$O/libleaf.rmeta
13+
14+
$O/libleaf.rlib $O/libleaf.rmeta: leaf.rs
15+
$(RUSTC) --emit metadata,link leaf.rs

src/test/run-make/pipelined/leaf.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#![crate_type = "rlib"]
2+
3+
pub static FOO: &str = "this is a static";
4+
5+
#[derive(Debug)]
6+
pub struct Plain {
7+
pub a: u32,
8+
pub b: u32,
9+
}
10+
11+
#[derive(Debug)]
12+
pub struct GenericStruct<A> {
13+
pub a: A,
14+
pub b: Option<A>,
15+
}
16+
17+
pub fn simple(a: u32, b: u32) -> u32 {
18+
let c = a + b;
19+
println!("simple {} + {} => {}", a, b, c);
20+
c
21+
}
22+
23+
pub fn generic<D: std::fmt::Debug>(d: D) {
24+
println!("generically printing {:?}", d);
25+
}

src/test/run-make/pipelined/main.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![crate_type = "bin"]
2+
3+
fn main() {
4+
middle::do_a_thing();
5+
6+
println!("middle::BAR {}", middle::BAR);
7+
8+
assert_eq!(middle::simple(2, 3), 5);
9+
}

src/test/run-make/pipelined/middle.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#![crate_type = "rlib"]
2+
3+
extern crate leaf;
4+
5+
pub static BAR: &str = leaf::FOO;
6+
7+
pub use leaf::simple;
8+
9+
pub fn do_a_thing() {
10+
let s = leaf::GenericStruct {
11+
a: "hello",
12+
b: Some("world")
13+
};
14+
15+
let u = leaf::GenericStruct {
16+
a: leaf::Plain { a: 1, b: 2 },
17+
b: None
18+
};
19+
20+
leaf::generic(s);
21+
leaf::generic(u);
22+
}

0 commit comments

Comments
 (0)