diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-06-29 17:04:23 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-06-30 13:15:11 +0200 |
commit | 108fb2f1973f1919a4dece8c0b1624923aedd8af (patch) | |
tree | 45421080ed56335cf7576391ebf4a5269f93861e /bin | |
parent | 18eb51b8139f214a92d532d435366f0c0d2d15e6 (diff) |
syncqt: Make sure to update forwarding headers if they are stale
Previously syncqt did not write content to forwarding headers if they
already existed in the target location, regardless of the contents of
the forwarding header.
This is different from syncqt's behavior when it actually copies
the headers to the target location, instead of creating a forwarding
header that includes another header.
Fix syncqt to read existing forwarding header content, and update the
content in case if it's different from the newly generated content.
This should fix the following non-prefix build case: running syncqt
from a different source + build directory would not update the
forwarding headers in the qtbase build dir.
Change-Id: Ia0a1665a36ce54f1c487101d9a7532fc0aa40c89
Reviewed-by: Brett Stottlemyer <bstottle@ford.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/syncqt.pl | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/bin/syncqt.pl b/bin/syncqt.pl index 7ede34cf1d..c472ab5a12 100755 --- a/bin/syncqt.pl +++ b/bin/syncqt.pl @@ -423,14 +423,31 @@ sub syncHeader { normalizePath(\$header); return copyFile($lib, $iheader, $header) if($copy); - unless(-e $header) { - my $header_dir = dirname($header); + my $header_dir = dirname($header); + my $iheader_out = fixPaths($iheader, $header_dir); + my $new_forwarding_header_content = "#include \"$iheader_out\"\n"; + + # By default, create / update the forwarding header if it does + # not exist. + my $forwarding_header_exists = (-e $header ? 1 : 0); + my $update_forwarding_header = !$forwarding_header_exists; + + # If remove_stale option is on, make sure to overwrite the + # forwarding header contents if the file already exists and its + # content is different from what we will generate. + if ($remove_stale) { + my $existing_forwarding_header_content = fileContents($header); + my $header_content_is_different = + $new_forwarding_header_content ne $existing_forwarding_header_content; + $update_forwarding_header ||= $header_content_is_different; + } + + if ($update_forwarding_header) { make_path($header_dir, $lib, $verbose_level); #write it - my $iheader_out = fixPaths($iheader, $header_dir); open(HEADER, ">$header") || die "Could not open $header for writing: $!\n"; - print HEADER "#include \"$iheader_out\"\n"; + print HEADER "$new_forwarding_header_content"; close HEADER; if(defined($ts)) { utime(time, $ts, $header) or die "$iheader, $header"; |