-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add simple proc-macro loading test case
commit-id:e457ae12
- Loading branch information
Showing
7 changed files
with
178 additions
and
0 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,13 @@ | ||
[package] | ||
name = "proc-macro-stub" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[lib] | ||
crate-type = ["rlib", "cdylib"] | ||
|
||
[dependencies] | ||
scarb-proc-macro-interface = { path = "../../../utils/scarb-proc-macro-interface"} | ||
|
||
[workspace] |
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,6 @@ | ||
[package] | ||
name = "proc_macro_stub" | ||
version = "0.1.0" | ||
edition = "2023_11" | ||
|
||
[cairo-plugin] |
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,11 @@ | ||
use scarb_proc_macro_interface::shared::{FfiProcMacroResult, FfiTokenStream}; | ||
|
||
/// Proc macro stub. | ||
/// | ||
/// # Safety | ||
/// Note that token stream deserialization may fail. | ||
#[no_mangle] | ||
pub unsafe extern "C" fn expand(token_stream: FfiTokenStream) -> FfiProcMacroResult { | ||
let _code = unsafe { token_stream.to_string() }; | ||
FfiProcMacroResult::Leave | ||
} |
Binary file added
BIN
+355 KB
scarb/fixtures/proc-macro-stub/target/release/libproc_macro_stub.dylib
Binary file not shown.
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,35 @@ | ||
use assert_fs::TempDir; | ||
use scarb_test_support::command::Scarb; | ||
use scarb_test_support::project_builder::{Dep, DepBuilder, ProjectBuilder}; | ||
use std::fs; | ||
use std::path::PathBuf; | ||
|
||
#[test] | ||
fn compile_simple() { | ||
let proc_macro_stub_path = | ||
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("fixtures/proc-macro-stub/"); | ||
let t = TempDir::new().unwrap(); | ||
ProjectBuilder::start() | ||
.name("hello") | ||
.dep( | ||
"proc_macro_stub", | ||
Dep.path(proc_macro_stub_path.as_path().to_string_lossy().to_string()), | ||
) | ||
.build(&t); | ||
|
||
let res = Scarb::quick_snapbox() | ||
.arg("build") | ||
.current_dir(&t) | ||
.output() | ||
.unwrap(); | ||
// .assert() | ||
// .success(); | ||
dbg!(res); | ||
dbg!(fs::read_dir(proc_macro_stub_path.join("target/release")) | ||
.unwrap() | ||
.into_iter() | ||
.map(|p| p.unwrap().path().to_string_lossy().to_string()) | ||
.collect::<Vec<_>>()); | ||
|
||
panic!("Fail"); | ||
} |