2019-11-25 02:42:45 +00:00
|
|
|
//! Tests for custom json target specifications.
|
|
|
|
|
2019-09-12 17:14:29 +00:00
|
|
|
use cargo_test_support::is_nightly;
|
|
|
|
use cargo_test_support::{basic_manifest, project};
|
2018-03-24 20:38:48 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-03-24 20:38:48 +00:00
|
|
|
fn custom_target_minimal() {
|
|
|
|
if !is_nightly() {
|
2019-03-26 20:56:14 +00:00
|
|
|
// Requires features no_core, lang_items
|
2018-03-24 20:38:48 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-24 20:38:48 +00:00
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
#![feature(no_core)]
|
|
|
|
#![feature(lang_items)]
|
|
|
|
#![no_core]
|
|
|
|
|
|
|
|
pub fn foo() -> u32 {
|
|
|
|
42
|
|
|
|
}
|
|
|
|
|
|
|
|
#[lang = "sized"]
|
|
|
|
pub trait Sized {
|
|
|
|
// Empty.
|
|
|
|
}
|
|
|
|
#[lang = "copy"]
|
|
|
|
pub trait Copy {
|
|
|
|
// Empty.
|
|
|
|
}
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-03-24 20:38:48 +00:00
|
|
|
"custom-target.json",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
{
|
|
|
|
"llvm-target": "x86_64-unknown-none-gnu",
|
|
|
|
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
|
|
|
|
"arch": "x86_64",
|
|
|
|
"target-endian": "little",
|
|
|
|
"target-pointer-width": "64",
|
|
|
|
"target-c-int-width": "32",
|
|
|
|
"os": "none",
|
|
|
|
"linker-flavor": "ld.lld"
|
|
|
|
}
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2018-03-24 20:38:48 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build --lib --target custom-target.json -v").run();
|
|
|
|
p.cargo("build --lib --target src/../custom-target.json -v")
|
|
|
|
.run();
|
2020-04-17 15:35:10 +00:00
|
|
|
|
|
|
|
// Ensure that the correct style of flag is passed to --target with doc tests.
|
|
|
|
p.cargo("test --doc --target src/../custom-target.json -v -Zdoctest-xcompile")
|
|
|
|
.masquerade_as_nightly_cargo()
|
|
|
|
.with_stderr_contains("[RUNNING] `rustdoc [..]--target [..]foo/custom-target.json[..]")
|
|
|
|
.run();
|
2018-03-24 20:38:48 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-03-24 20:38:48 +00:00
|
|
|
fn custom_target_dependency() {
|
|
|
|
if !is_nightly() {
|
2020-11-27 14:50:08 +00:00
|
|
|
// Requires features no_core, lang_items, auto_traits
|
2018-03-24 20:38:48 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-24 20:38:48 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
2018-03-24 20:38:48 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = ["author@example.com"]
|
2018-03-24 20:38:48 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = { path = "bar" }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-03-24 20:38:48 +00:00
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
#![feature(no_core)]
|
|
|
|
#![feature(lang_items)]
|
2020-11-27 14:50:08 +00:00
|
|
|
#![feature(auto_traits)]
|
2020-09-27 00:59:58 +00:00
|
|
|
#![no_core]
|
2018-03-24 20:38:48 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
extern crate bar;
|
2018-03-24 20:38:48 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
pub fn foo() -> u32 {
|
|
|
|
bar::bar()
|
|
|
|
}
|
2018-03-24 20:38:48 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
#[lang = "freeze"]
|
|
|
|
unsafe auto trait Freeze {}
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1"))
|
2018-03-24 20:38:48 +00:00
|
|
|
.file(
|
|
|
|
"bar/src/lib.rs",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
#![feature(no_core)]
|
|
|
|
#![feature(lang_items)]
|
|
|
|
#![no_core]
|
|
|
|
|
|
|
|
pub fn bar() -> u32 {
|
|
|
|
42
|
|
|
|
}
|
|
|
|
|
|
|
|
#[lang = "sized"]
|
|
|
|
pub trait Sized {
|
|
|
|
// Empty.
|
|
|
|
}
|
|
|
|
#[lang = "copy"]
|
|
|
|
pub trait Copy {
|
|
|
|
// Empty.
|
|
|
|
}
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-03-24 20:38:48 +00:00
|
|
|
"custom-target.json",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
{
|
|
|
|
"llvm-target": "x86_64-unknown-none-gnu",
|
|
|
|
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
|
|
|
|
"arch": "x86_64",
|
|
|
|
"target-endian": "little",
|
|
|
|
"target-pointer-width": "64",
|
|
|
|
"target-c-int-width": "32",
|
|
|
|
"os": "none",
|
|
|
|
"linker-flavor": "ld.lld"
|
|
|
|
}
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2018-03-24 20:38:48 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build --lib --target custom-target.json -v").run();
|
2018-03-24 20:38:48 +00:00
|
|
|
}
|
2019-09-16 07:31:20 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn custom_bin_target() {
|
|
|
|
if !is_nightly() {
|
|
|
|
// Requires features no_core, lang_items
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
#![feature(no_core)]
|
|
|
|
#![feature(lang_items)]
|
|
|
|
#![no_core]
|
|
|
|
#![no_main]
|
|
|
|
|
|
|
|
#[lang = "sized"]
|
|
|
|
pub trait Sized {
|
|
|
|
// Empty.
|
|
|
|
}
|
|
|
|
#[lang = "copy"]
|
|
|
|
pub trait Copy {
|
|
|
|
// Empty.
|
|
|
|
}
|
|
|
|
"#,
|
2019-09-16 07:31:20 +00:00
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"custom-bin-target.json",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
{
|
|
|
|
"llvm-target": "x86_64-unknown-none-gnu",
|
|
|
|
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
|
|
|
|
"arch": "x86_64",
|
|
|
|
"target-endian": "little",
|
|
|
|
"target-pointer-width": "64",
|
|
|
|
"target-c-int-width": "32",
|
|
|
|
"os": "none",
|
|
|
|
"linker-flavor": "ld.lld",
|
|
|
|
"linker": "rust-lld",
|
|
|
|
"executables": true
|
|
|
|
}
|
|
|
|
"#,
|
2019-09-16 07:31:20 +00:00
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build --target custom-bin-target.json -v").run();
|
|
|
|
}
|