Currently #[com_library] attribute requires the type library name as the first parameter. It is strongly recommended that this library name matches the crate name - so strongly that it makes no sense for those two to differ.
It would be better to drop that parameter completely and just use the crate itself as the library name.
There is a slight issue with this though. We need a way to find out the name of the crate using the attributes. The usual way to find the crate name programmatically is to use the env variables with the env! macro, which inspects these at compile time.
When it comes to attribute expansions, if we used the env! macro, we'd end up with the intercom-attributes crate name. However as the crate compilation is runtime for attribute expansions, we should be able to use the env variables as is through the std::env module.
This same issue applies to #1.
Tasks:
Read the crate name during com_library attribute expansion.
Convert the name from library_name to LibraryName for COM capitalization purposes. This conversion is already done in intercom-utils for IDL generation. The conversion should be moved to intercom-common/utils.rs so we can share the code.
Ensure intercom-utils handles the new com_library attribute.
Currently
#[com_library]
attribute requires the type library name as the first parameter. It is strongly recommended that this library name matches the crate name - so strongly that it makes no sense for those two to differ.It would be better to drop that parameter completely and just use the crate itself as the library name.
There is a slight issue with this though. We need a way to find out the name of the crate using the attributes. The usual way to find the crate name programmatically is to use the env variables with the
env!
macro, which inspects these at compile time.When it comes to attribute expansions, if we used the
env!
macro, we'd end up with theintercom-attributes
crate name. However as the crate compilation is runtime for attribute expansions, we should be able to use the env variables as is through thestd::env
module.This same issue applies to #1.
Tasks:
com_library
attribute expansion.library_name
toLibraryName
for COM capitalization purposes. This conversion is already done inintercom-utils
for IDL generation. The conversion should be moved tointercom-common/utils.rs
so we can share the code.intercom-utils
handles the newcom_library
attribute.