Rantanen / intercom

Object based cross-language FFI for Rust
MIT License
63 stars 7 forks source link

Use crate name as `[com_library]` name #3

Closed Rantanen closed 6 years ago

Rantanen commented 6 years ago

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: