-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for absolute target.json paths #5228
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
use cargotest::is_nightly; | ||
use cargotest::support::{execs, project}; | ||
use hamcrest::assert_that; | ||
|
||
#[test] | ||
fn custom_target_minimal() { | ||
if !is_nightly() { | ||
return; | ||
} | ||
let p = project("foo") | ||
.file( | ||
"Cargo.toml", | ||
r#" | ||
[package] | ||
|
||
name = "foo" | ||
version = "0.0.1" | ||
authors = ["author@example.com"] | ||
"#, | ||
) | ||
.file( | ||
"src/lib.rs", | ||
r#" | ||
#![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. | ||
} | ||
"#, | ||
) | ||
.file( | ||
"custom-target.json", | ||
r#" | ||
{ | ||
"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" | ||
} | ||
"#, | ||
) | ||
.build(); | ||
|
||
assert_that( | ||
p.cargo("build") | ||
.arg("--lib") | ||
.arg("--target") | ||
.arg("custom-target.json") | ||
.arg("-v"), | ||
execs().with_status(0), | ||
); | ||
assert_that( | ||
p.cargo("build") | ||
.arg("--lib") | ||
.arg("--target") | ||
.arg("src/../custom-target.json") | ||
.arg("-v"), | ||
execs().with_status(0), | ||
); | ||
} | ||
|
||
#[test] | ||
fn custom_target_dependency() { | ||
if !is_nightly() { | ||
return; | ||
} | ||
let p = project("foo") | ||
.file( | ||
"Cargo.toml", | ||
r#" | ||
[package] | ||
|
||
name = "foo" | ||
version = "0.0.1" | ||
authors = ["author@example.com"] | ||
|
||
[dependencies] | ||
bar = { path = "bar" } | ||
"#, | ||
) | ||
.file( | ||
"src/lib.rs", | ||
r#" | ||
#![feature(no_core)] | ||
#![feature(lang_items)] | ||
#![feature(optin_builtin_traits)] | ||
#![no_core] | ||
|
||
extern crate bar; | ||
|
||
pub fn foo() -> u32 { | ||
bar::bar() | ||
} | ||
|
||
#[lang = "freeze"] | ||
unsafe auto trait Freeze {} | ||
"#, | ||
) | ||
.file( | ||
"bar/Cargo.toml", | ||
r#" | ||
[package] | ||
|
||
name = "bar" | ||
version = "0.0.1" | ||
authors = ["author@example.com"] | ||
"#, | ||
) | ||
.file( | ||
"bar/src/lib.rs", | ||
r#" | ||
#![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. | ||
} | ||
"#, | ||
) | ||
.file( | ||
"custom-target.json", | ||
r#" | ||
{ | ||
"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" | ||
} | ||
"#, | ||
) | ||
.build(); | ||
|
||
assert_that( | ||
p.cargo("build") | ||
.arg("--lib") | ||
.arg("--target") | ||
.arg("custom-target.json") | ||
.arg("-v"), | ||
execs().with_status(0), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this clause required here? Ideally there'd only be one location where we'd deal with json targets and currently it's split across two locations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure which other location you mean. The
Layout::new
implementation?The motivation for putting it here is that we canonicalize the path that is passed to
rustc
, to avoid the issue that the path becomes invalid due to the cwd changes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sure I didn't look too too closely before, I was mostly just thinking that we should have one location where we recognize
.json
targets instead of two, but the most recent version only has one so that sounds good to me!