mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
Build test-macros in a build script
This commit is contained in:
parent
5f592f4f58
commit
05b3a4bc93
9 changed files with 133 additions and 75 deletions
|
@ -7,35 +7,8 @@ use proc_macro_api::ListMacrosTask;
|
|||
use std::str::FromStr;
|
||||
|
||||
pub mod fixtures {
|
||||
use cargo_metadata::Message;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
|
||||
// Use current project metadata to get the proc-macro dylib path
|
||||
pub fn proc_macro_test_dylib_path() -> std::path::PathBuf {
|
||||
let name = "proc_macro_test";
|
||||
let version = "0.0.0";
|
||||
let command = Command::new(toolchain::cargo())
|
||||
.args(&["check", "--tests", "--message-format", "json"])
|
||||
.output()
|
||||
.unwrap()
|
||||
.stdout;
|
||||
|
||||
for message in Message::parse_stream(command.as_slice()) {
|
||||
match message.unwrap() {
|
||||
Message::CompilerArtifact(artifact) => {
|
||||
if artifact.target.kind.contains(&"proc-macro".to_string()) {
|
||||
let repr = format!("{} {}", name, version);
|
||||
if artifact.package_id.repr.starts_with(&repr) {
|
||||
return PathBuf::from(&artifact.filenames[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => (), // Unknown message
|
||||
}
|
||||
}
|
||||
|
||||
panic!("No proc-macro dylib for {} found!", name);
|
||||
proc_macro_test::PROC_MACRO_TEST_LOCATION.into()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue