-
Notifications
You must be signed in to change notification settings - Fork 244
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
Compile examples and spirv-std on stable #340
Conversation
#[spirv(block)] | ||
#[derive(Copy, Clone)] | ||
#[allow(unused_attributes)] | ||
#[spirv(block)] |
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.
any reason for this, or just formatting?
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.
You can't put proc macros bellow derives.
let end = item_str[start..item_str.len()].find(")]"); | ||
item_str.replace_range(start..start + end.unwrap() + 2, ""); | ||
} | ||
TokenStream::from_str(item_str.as_str()).unwrap() |
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.
the quadratic reparse time here makes me sad, but, I'll leave this up to @eddyb if they think this is OK since they know more about proc macros than me
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.
"quadratic reparse time" makes me sound really smart. 👍
while let Some(start) = item_str.find("#[spirv(") { | ||
let end = item_str[start..item_str.len()].find(")]"); | ||
item_str.replace_range(start..start + end.unwrap() + 2, ""); | ||
} | ||
TokenStream::from_str(item_str.as_str()).unwrap() |
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.
Can you implement this by looking for [...]
groups instead (preceded by #
), in the TokenStream
? Using strings feels very error-prone.
Ideally you could/would use syn
but that seems like it would be a lot more work.
use proc_macro::TokenStream; | ||
use std::str::FromStr; | ||
|
||
#[cfg(not(target_arch = "spirv"))] |
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.
This won't do anything, I don't think, Cargo will only ever compile this for the host.
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 think it did compile it unless I put the crate behind a [target.dependency] thing
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.
Yep your right doesn't get compiled.
@@ -0,0 +1,16 @@ | |||
#![cfg_attr(target_arch = "spirv", feature(register_attr), register_attr(spirv))] |
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 don't think this does anything?
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.
Why not? It only registers the spriv attribute on spirv architecture.
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 your right 👍
spirv-attrib
This would be a huge step forward for ark integration.