OutpostUniverse / OP2Utility

C++ library for working with Outpost 2 related files and tasks.
MIT License
4 stars 0 forks source link

Enable Warnings as Errors #175

Open DanRStevens opened 6 years ago

DanRStevens commented 6 years ago

We can potentially enable warnings as errors. This could make sense for the CI builds, as it would report warnings as build failures, and force us to look at the logs.


Technical:

For MSVC there are two relevant settings to enable to treat warnings as errors. There is the /WX compiler flag, and the /WX linker flag.

For Clang and g++, the "-Werror" flag will promote warnings to errors.


As for the ramifications, when warnings are promoted to errors, it can prevent output of object files (.o), and halt the build process. Or rather, it can halt later build processes that depend on the current output. The CI servers should continue trying to compile non-dependent items, resulting in maximum possible error message generation. For Windows, I believe this is the default behaviour. For Linux, we run make -k to not immediately abort the build before reporting failure.

Failing to produce object files means library and executable files also won't be produced by the later stages. This means the test executable will not be built, and so unit tests will not run.


It would still be possible to merge branches, even with failing CI tests. They would just complain loudly as we did it.

It might be possible to modify the build scripts such that reporting of warnings as errors is delayed until after unit tests run. That would still allow for maximum reporting, and we could see if the warnings have any impact on later build stages. This would require a bit more investigation though.

Brett208 commented 6 years ago

Would what you are proposing be implemented in the actual MSVC project file that I develop with (OP2Utility.vcxproj)? If it doesn't affect this copy it would be more palatable as I could still work locally without stopping compilations whenever a warning is encountered.

DanRStevens commented 6 years ago

There is most likely a way to do this only on the CI build servers. For MSVC, I think there was a way to write changes to the project file before compiling. I haven't read up on the details. Failing that, there might be a way to pass a custom build parameter which could enable warnings as errors.

For the Linux makefile, I could probably get something working with the knowledge I already have, using an environment variable.