Skip to content
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

Running this script as a pre build event causes recompilation of whole codebase #29

Open
PolarGoose opened this issue Nov 14, 2019 · 1 comment
Assignees

Comments

@PolarGoose
Copy link

PolarGoose commented Nov 14, 2019

Brief
Even if a file already contains right copyright header, the 'licenseheaders.py' script overrides file with the same content making build system treat this file as "changed" and recompile it again.

Details
Suppose we have a C++ codebase where all files already have right copyright headers. After we apply a 'licenseheaders.py' script, the C++ build system will treat all C++ files as "changed" even if there were no changes introduced, which will lead to recompilation of whole code base.
Because of that it is not practical to use the 'licenseheaders.py' script as a prebuild event.

Possible solution
The algorithm to ensure that the script touches files only when it is needed:

  1. Write output to the temporary file
  2. If temporary file is different from the original (it means that the copyright header has been updated) replace the original file with the temporary one
@johann-petrak johann-petrak self-assigned this Nov 15, 2019
@johann-petrak
Copy link
Owner

johann-petrak commented Nov 15, 2019

Good point, thanks for reporting!
(Never thought of this getting used as a prebuild-task :D )
It should be possible to do this without writing to a temporary file and comparing, as long as we assume that all files processed will fit into memory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants