-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Ability to conditionally compile from a workspace #11742
Comments
In the meanwhile, you can use empty |
Definitely looks like #5220 might apply 😄
Could you expand on this a little? Is it possible to specify an alternate source path on libs per-target? |
Take Lines 68 to 75 in 0c33172
In general, you could have several Rust source files. Import them respectively with corresponding
And the code may look like this: // lib.rs
#[cfg(windows)]
use windows::my_function;
#[cfg(not(windows))]
use this_is_not_windows::my_function; |
Going to close this as it is a duplicate of #5220. Let us know if it is wrong. Thank you! |
We can't do that because Windows doesn't have PAM or Nsswitch or equivalents. So on Windows we'd be compiling empty DLL's for no reason. We'd rather see a way to cfg target platforms at the workspace level so we don't even consider the pam/nsswitch modules at all on windows. And vice versa, we don't want the windows specific code considered when we are on unix. So I think while the "lib.rs" hack with cfg works, it's a thin cover up of the real problem which is the ability to have workspace members targeted based on platform. |
Hi there,
We have recently been having an issue where we can't easily select components for compilation from a workspace based on target_family. We have a generic server binary that can run on all platforms, and two platform/target specific tools for unix vs windows.
What we would like is a way to say:
However, we can't find a way to do this effectively, and even within the tools, we can't do target conditional compilation for libs or bins. This means we are left trying to do cfg based on target family inside the libs and binaries instead which feels a bit messy to us. The alternate is to "de-workspace" our project, but then we lose valuable maintenance features like workspace specified dependencies.
I think it would be a significant improvement for rust/cargo to support such conditional compilation rules in workspaces.
The text was updated successfully, but these errors were encountered: