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

Touch *.in outputs only if output actually changed #30

Closed
tangentsoft opened this issue Oct 9, 2017 · 2 comments
Closed

Touch *.in outputs only if output actually changed #30

tangentsoft opened this issue Oct 9, 2017 · 2 comments

Comments

@tangentsoft
Copy link
Contributor

tangentsoft commented Oct 9, 2017

Currently, the output of any *.in file is rewritten every time the configure script runs, which means if the Makefile has dependencies on any of the output files, those dependents get rebuilt even though nothing will change afterward.

I propose that the piece of autosetup that writes these files out change so that:

  1. It writes the output of substituting variables into foo.in to foo.in.tmp instead of to foo.
  2. If foo doesn't exist yet, rename foo.in.tmp to foo.
  3. If the file size of foo is the same as foo.in.tmp, do a byte-by-byte comparison: if they are the same, then remove foo.in.tmp, else continue to case 4.
  4. Remove foo and rename foo.in.tmp to foo: the file contents differ.

I'm willing to do this myself, and I'm just about annoyed enough by the needless rebuilds to do it soon, but I thought I'd file it in case you wanted to tackle it yourself. I'll be more than happy to just pull the result into my package. :)

EDIT: It would also be nice if the Created foo from foo.in message output by autosetup would change to Updated foo from foo.in in case 4 above and to Left foo alone; unchanged in the "then" branch of case 3 above.

@msteveb
Copy link
Owner

msteveb commented Oct 9, 2017

Actually I was surprised it didn't already work this way. Try the following minor patch.

diff --git a/lib/system.tcl b/lib/system.tcl
index e792151..a753340 100644
--- a/lib/system.tcl
+++ b/lib/system.tcl
@@ -222,9 +222,9 @@ proc make-template {template {out {}}} {
                }
                lappend result $line
        }
-       writefile $out [string map $mapping [join $result \n]]\n
-
-       msg-result "Created [relative-path $out] from [relative-path $template]"
+       write-if-changed $out [string map $mapping [join $result \n]]\n {
+               msg-result "Created [relative-path $out] from [relative-path $template]"
+       }
 }

 # build/host tuples and cross-compilation prefix

@tangentsoft
Copy link
Contributor Author

Verified, thank you!

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