-
-
Notifications
You must be signed in to change notification settings - Fork 78
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
Support reflecting CXXFLAGS
and LDFLAGS
environment variables
#1030
Conversation
Added support for environment variables `CXXFLAGS` and `LDFLAGS` while generating makefile.
Why would you prefer to do this instead of my idea? |
Firstly, the most important reason is, as far as I know, many build systems that are widely used made use of those environment variables ( Also sometimes I would like to temporarily change the flags frequently to quickly see the result and adjust my flags in the config after I'm confident about the result. I personally prefer setting the environment variables to edit the config file over and over again because it's convenient to just add an environment variable in the command line, and I don't need to repeatly edit and save a file just for something experimental (in my personal opinion). Another reason (may be too personal) is that, if I downloaded a project that I don't own and I want to build it with my preferred toolchain, for instance I want to build with Homebrew ruby instead of the default ruby provided by macOS (but the project's config doesn't contain flags for Homebrew ruby), it's just convenient to just set an environment variable instead of editing config file, because if I changed the project config file and next time I want to upgrade the repository, I still need to revert the change, pull the repository and change it again. It may fail the compilation or even have different behavior after the compilation but since those environment variables were set by me, it means I know the risks and I'll take them. By the way, (not very seriously though) we supported To conclude I think the most important reason is to keep the behavior consistent as build systems that are widely used, and it will be also super convenient for some users to quickly edit the flags just for experimental uses (especially command-line nerds like me, yeah). About the potential risks it may bring, like compilation error or different behavior etc., since the system won't set those environment variables automatically (and it means they are set only by user) I think user would and should take the risks, and once user set the environment variable (even globally) they usually knows what they're doing (and hoping the build system uses those variables). |
P.S.: I do think your idea is great and should be used on most projects, but I think the support of environment flags still should be implemented as well for the consistency with other widely-used build systems and some advanced user may require it to work |
Thanks for the clarification, I'll review your PR when I get a chance. Please also make the PR title clearer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for working on this. This is a good start; I left some comments. Also, please address the clang-tidy error.
Cleaned up code and did some change according to the reviewer's comment, also fix some bugs in edge cases
CXXFLAGS
and LDFLAGS
CXXFLAGS
and LDFLAGS
for consistency with other build system
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this looks great. Thanks for your work. Let's tweak more details.
Renamed `ignoreXXX` variables to more meaningful and self-explanatory one. Changed code structure of `parseEnvFlags` to make it more compact. Made test cases more general.
All review comments are resolved in the latest commit. By the way I enabled workflow on the fork repo so I could run poac tidy and see the results to prevent me from making dumb mistakes. For some strange reasons (that I don't know) Another thing about tidy is after I committed my latest change, assertEq(argsEscapeMixed.size(), 5);
~^~ is a magic constant and tell me to consider replacing it with a named constant (but tbh we really need a named constant like After digging deeper in the project I found a file |
Thanks!
This problem was due to the previous
Using a named constant here makes no sense, so let's use
Currently, they are used only by |
Suppress `clang-tidy` errors (`cppcoreguidelines-avoid-magic-numbers`,`readability-magic-numbers`) in `testParseEnvFlags` on the statements that checks for the size, because these errors don't make sense in this situation.
Thanks, will have a look when I get the time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. After tweaking small things, ok for main. Thanks.
CXXFLAGS
and LDFLAGS
for consistency with other build systemCXXFLAGS
and LDFLAGS
environment variables
Fixed typo in comments and added test cases for double backslashes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your time to work on this!
Added support for environment variables
CXXFLAGS
andLDFLAGS
while generating makefile.See #923.