mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-27 14:04:56 +01:00
Allow custom link_section
attributes for late resources
This commit makes RTIC aware of user-provided `link_section` attributes, letting user override default section mapping.
This commit is contained in:
parent
981fa1fb30
commit
c6fd3cdd0a
2 changed files with 17 additions and 3 deletions
|
@ -27,8 +27,15 @@ pub fn codegen(
|
||||||
let mangled_name = util::static_local_resource_ident(name);
|
let mangled_name = util::static_local_resource_ident(name);
|
||||||
|
|
||||||
let attrs = &res.attrs;
|
let attrs = &res.attrs;
|
||||||
|
|
||||||
// late resources in `util::link_section_uninit`
|
// late resources in `util::link_section_uninit`
|
||||||
let section = util::link_section_uninit();
|
// unless user specifies custom link section
|
||||||
|
let section = if attrs.iter().any(|attr| attr.path.is_ident("link_section")) {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Some(util::link_section_uninit())
|
||||||
|
};
|
||||||
|
|
||||||
// For future use
|
// For future use
|
||||||
// let doc = format!(" RTIC internal: {}:{}", file!(), line!());
|
// let doc = format!(" RTIC internal: {}:{}", file!(), line!());
|
||||||
|
|
|
@ -23,10 +23,17 @@ pub fn codegen(
|
||||||
let ty = &res.ty;
|
let ty = &res.ty;
|
||||||
let mangled_name = &util::static_shared_resource_ident(name);
|
let mangled_name = &util::static_shared_resource_ident(name);
|
||||||
|
|
||||||
// late resources in `util::link_section_uninit`
|
|
||||||
let section = util::link_section_uninit();
|
|
||||||
let attrs = &res.attrs;
|
let attrs = &res.attrs;
|
||||||
|
|
||||||
|
// late resources in `util::link_section_uninit`
|
||||||
|
// unless user specifies custom link section
|
||||||
|
let section = if attrs.iter().any(|attr| attr.path.is_ident("link_section")) {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Some(util::link_section_uninit())
|
||||||
|
};
|
||||||
|
|
||||||
// For future use
|
// For future use
|
||||||
// let doc = format!(" RTIC internal: {}:{}", file!(), line!());
|
// let doc = format!(" RTIC internal: {}:{}", file!(), line!());
|
||||||
mod_app.push(quote!(
|
mod_app.push(quote!(
|
||||||
|
|
Loading…
Reference in a new issue