forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
auto merge of rust-lang#11077 : alexcrichton/rust/crate-id, r=cmr
Right now the --crate-id and related flags are all process *after* the entire crate is parsed. This is less than desirable when used with makefiles because it means that just to learn the output name of the crate you have to parse the entire crate (unnecessary). This commit changes the behavior to lift the handling of these flags much sooner in the compilation process. This allows us to not have to parse the entire crate and only have to worry about parsing the crate attributes themselves. The related methods have all been updated to take an array of attributes rather than a crate. Additionally, this ceases duplication of the "what output are we producing" logic in order to correctly handle things in the case of --test. Finally, this adds tests for all of this functionality to ensure that it does not regress.
- Loading branch information
Showing
10 changed files
with
127 additions
and
67 deletions.
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
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
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
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,10 @@ | ||
-include ../tools.mk | ||
|
||
all: | ||
[ `$(RUSTC) --crate-id crate.rs` = "foo#0.9" ] | ||
[ `$(RUSTC) --crate-name crate.rs` = "foo" ] | ||
[ `$(RUSTC) --crate-file-name crate.rs` = "foo" ] | ||
[ `$(RUSTC) --crate-file-name --lib --test crate.rs` = "foo" ] | ||
[ `$(RUSTC) --crate-file-name --test lib.rs` = "mylib" ] | ||
$(RUSTC) --crate-file-name lib.rs | ||
$(RUSTC) --crate-file-name rlib.rs |
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,7 @@ | ||
#[crate_id = "foo#0.9"]; | ||
|
||
// Querying about the crate metadata should *not* parse the entire crate, it | ||
// only needs the crate attributes (which are guaranteed to be at the top) be | ||
// sure that if we have an error like a missing module that we can still query | ||
// about the crate id. | ||
mod error; |
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,2 @@ | ||
#[crate_id = "mylib"]; | ||
#[crate_type = "lib"]; |
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,2 @@ | ||
#[crate_id = "mylib"]; | ||
#[crate_type = "rlib"]; |