Can I change my rust target settings to see code for another platform?

Answered

I am working on a rust crate that targets multiple platforms, however I would like to tell CLion that I am developing for the Android target so that code wrapped in `#[cfg(target_os = "android")]` is not dimmed-out.  Is this possible with CLion?

I build for Android using a python script, so I don't expect CLion to handle the cross-compilation, it's just for editing purposes.

0
2 comments
Official comment

The plugin takes into account Cargo config file during retrieving `cfg` options. So if you provide android target in the config, the plugin will evaluate `#[cfg(target_os = "android")]` to `true`. Something like


`.cargo/config.toml`

[build]
target = "aarch64-linux-android"

Thank you, that’s useful to know.

0

Please sign in to leave a comment.