-
Notifications
You must be signed in to change notification settings - Fork 55
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
First-class support for conditional compilation #1323
Comments
I think perhaps a pretty low-hanging fruit would be to just add an extra run command flag |
We already have configurable variables. I would be inclined to handle this by having a module in the standard library that provides a configurable variable that is automatically set to true or false depending on whether it's a debug or release build. WDYT @sameerajayasoma |
Isn't this the same thing that we discussed earlier where a config value could be statically set (say from a file or a parameter)? |
Yea exactly what i mentioned earlier. It wouldn't be conditional builts but is easier to implement and gives already a lot of the usability benefits |
I think this is already possible: https://ballerina.io/learn/provide-values-to-configurable-variables/ The difference is i would like that ballerina sets this config value automatically without me having to set or unset it. |
There is a discussion on this topic in Discord initiated by @DaAlbrecht and that thread has more details. https://discord.com/channels/957996897782616114/1301578394944798750/1301578394944798750 |
The workaround that doesn't require any changes right now is to define a configurable variable (say DEBUG) and configure it via the command line. I believe @DaAlbrecht is already doing this. I believe this approach is good enough for now. configurable boolean DEBUG = false; bal run -- -CDEBUG=true I am thinking for a bit more first-class conditional compilation solution that would even work for nBallerina as well. Here are some requirements:
|
Description:
Having conditional compilations in Ballerina (Debug / Release Build) would be pretty helpful or at least setting Debug / Release Flags automatically.
This would allow the user just to check if the Debug flag is set and use this to instrument their applications with extra debug logic without needing to set this flag themselves.
Inspiration from Rust:
cfg: checks https://doc.rust-lang.org/rust-by-example/attribute/cfg.html#cfg
This allows for a nice syntax like
Suggested Labels:
enhancement, langlib, design/usability
The text was updated successfully, but these errors were encountered: