diff options
Diffstat (limited to 'tests/run-make-fulldeps/link-cfg')
-rw-r--r-- | tests/run-make-fulldeps/link-cfg/Makefile | 22 | ||||
-rw-r--r-- | tests/run-make-fulldeps/link-cfg/dep-with-staticlib.rs | 8 | ||||
-rw-r--r-- | tests/run-make-fulldeps/link-cfg/dep.rs | 8 | ||||
-rw-r--r-- | tests/run-make-fulldeps/link-cfg/no-deps.rs | 20 | ||||
-rw-r--r-- | tests/run-make-fulldeps/link-cfg/return1.c | 6 | ||||
-rw-r--r-- | tests/run-make-fulldeps/link-cfg/return2.c | 6 | ||||
-rw-r--r-- | tests/run-make-fulldeps/link-cfg/return3.c | 6 | ||||
-rw-r--r-- | tests/run-make-fulldeps/link-cfg/with-deps.rs | 14 | ||||
-rw-r--r-- | tests/run-make-fulldeps/link-cfg/with-staticlib-deps.rs | 14 |
9 files changed, 104 insertions, 0 deletions
diff --git a/tests/run-make-fulldeps/link-cfg/Makefile b/tests/run-make-fulldeps/link-cfg/Makefile new file mode 100644 index 000000000..0b25ccded --- /dev/null +++ b/tests/run-make-fulldeps/link-cfg/Makefile @@ -0,0 +1,22 @@ +include ../tools.mk + +all: $(call DYLIB,return1) $(call DYLIB,return2) $(call NATIVE_STATICLIB,return3) + ls $(TMPDIR) + $(BARE_RUSTC) --print cfg --target x86_64-unknown-linux-musl | $(CGREP) crt-static + + $(RUSTC) no-deps.rs --cfg foo + $(call RUN,no-deps) + $(RUSTC) no-deps.rs --cfg bar + $(call RUN,no-deps) + + $(RUSTC) dep.rs + $(RUSTC) with-deps.rs --cfg foo + $(call RUN,with-deps) + $(RUSTC) with-deps.rs --cfg bar + $(call RUN,with-deps) + + $(RUSTC) dep-with-staticlib.rs + $(RUSTC) with-staticlib-deps.rs --cfg foo + $(call RUN,with-staticlib-deps) + $(RUSTC) with-staticlib-deps.rs --cfg bar + $(call RUN,with-staticlib-deps) diff --git a/tests/run-make-fulldeps/link-cfg/dep-with-staticlib.rs b/tests/run-make-fulldeps/link-cfg/dep-with-staticlib.rs new file mode 100644 index 000000000..5ad66475d --- /dev/null +++ b/tests/run-make-fulldeps/link-cfg/dep-with-staticlib.rs @@ -0,0 +1,8 @@ +#![feature(link_cfg)] +#![crate_type = "rlib"] + +#[link(name = "return1", cfg(foo))] +#[link(name = "return3", kind = "static", cfg(bar))] +extern "C" { + pub fn my_function() -> i32; +} diff --git a/tests/run-make-fulldeps/link-cfg/dep.rs b/tests/run-make-fulldeps/link-cfg/dep.rs new file mode 100644 index 000000000..40de77f05 --- /dev/null +++ b/tests/run-make-fulldeps/link-cfg/dep.rs @@ -0,0 +1,8 @@ +#![feature(link_cfg)] +#![crate_type = "rlib"] + +#[link(name = "return1", cfg(foo))] +#[link(name = "return2", cfg(bar))] +extern "C" { + pub fn my_function() -> i32; +} diff --git a/tests/run-make-fulldeps/link-cfg/no-deps.rs b/tests/run-make-fulldeps/link-cfg/no-deps.rs new file mode 100644 index 000000000..ba5a8711a --- /dev/null +++ b/tests/run-make-fulldeps/link-cfg/no-deps.rs @@ -0,0 +1,20 @@ +#![feature(link_cfg)] + +#[link(name = "return1", cfg(foo))] +#[link(name = "return2", cfg(bar))] +extern "C" { + fn my_function() -> i32; +} + +fn main() { + unsafe { + let v = my_function(); + if cfg!(foo) { + assert_eq!(v, 1); + } else if cfg!(bar) { + assert_eq!(v, 2); + } else { + panic!("unknown"); + } + } +} diff --git a/tests/run-make-fulldeps/link-cfg/return1.c b/tests/run-make-fulldeps/link-cfg/return1.c new file mode 100644 index 000000000..41c2809ad --- /dev/null +++ b/tests/run-make-fulldeps/link-cfg/return1.c @@ -0,0 +1,6 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int my_function() { + return 1; +} diff --git a/tests/run-make-fulldeps/link-cfg/return2.c b/tests/run-make-fulldeps/link-cfg/return2.c new file mode 100644 index 000000000..622aeaa29 --- /dev/null +++ b/tests/run-make-fulldeps/link-cfg/return2.c @@ -0,0 +1,6 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int my_function() { + return 2; +} diff --git a/tests/run-make-fulldeps/link-cfg/return3.c b/tests/run-make-fulldeps/link-cfg/return3.c new file mode 100644 index 000000000..f29dc60d5 --- /dev/null +++ b/tests/run-make-fulldeps/link-cfg/return3.c @@ -0,0 +1,6 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int my_function() { + return 3; +} diff --git a/tests/run-make-fulldeps/link-cfg/with-deps.rs b/tests/run-make-fulldeps/link-cfg/with-deps.rs new file mode 100644 index 000000000..48b782815 --- /dev/null +++ b/tests/run-make-fulldeps/link-cfg/with-deps.rs @@ -0,0 +1,14 @@ +extern crate dep; + +fn main() { + unsafe { + let v = dep::my_function(); + if cfg!(foo) { + assert_eq!(v, 1); + } else if cfg!(bar) { + assert_eq!(v, 2); + } else { + panic!("unknown"); + } + } +} diff --git a/tests/run-make-fulldeps/link-cfg/with-staticlib-deps.rs b/tests/run-make-fulldeps/link-cfg/with-staticlib-deps.rs new file mode 100644 index 000000000..23e5926a7 --- /dev/null +++ b/tests/run-make-fulldeps/link-cfg/with-staticlib-deps.rs @@ -0,0 +1,14 @@ +extern crate dep_with_staticlib; + +fn main() { + unsafe { + let v = dep_with_staticlib::my_function(); + if cfg!(foo) { + assert_eq!(v, 1); + } else if cfg!(bar) { + assert_eq!(v, 3); + } else { + panic!("unknown"); + } + } +} |