syncqt: Fix to work correctly when the line endings are LF in Win-msys

In Windows-msys syncqt.pl expects CRLF line endings, and does not
work correctly with LF. syncqt.pl was fixed to be line-ending-agnostic.

Task-number: QTBUG-77192
Change-Id: Ie8029238bdd580bcf042ede0d0f64d5f01488406
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Terunao HIROTA 2019-08-08 11:57:08 +09:00
parent 2959bdc656
commit b03ee91ebf

View File

@ -79,9 +79,6 @@ normalizePath(\$out_basedir);
our $build_basedir; our $build_basedir;
our $basedir; our $basedir;
# Make sure we use Windows line endings for chomp and friends on Windows.
$INPUT_RECORD_SEPARATOR = "\r\n" if ($^O eq "msys");
# will be defined based on the modules sync.profile # will be defined based on the modules sync.profile
our (%modules, %moduleheaders, @allmoduleheadersprivate, %classnames, %deprecatedheaders); our (%modules, %moduleheaders, @allmoduleheadersprivate, %classnames, %deprecatedheaders);
our (@qpa_headers, @private_headers); our (@qpa_headers, @private_headers);
@ -182,10 +179,10 @@ sub shouldMasterInclude {
my ($iheader) = @_; my ($iheader) = @_;
return 0 if (basename($iheader) =~ /_/); return 0 if (basename($iheader) =~ /_/);
return 0 if (basename($iheader) =~ /qconfig/); return 0 if (basename($iheader) =~ /qconfig/);
local $/ = "\x0a";
if (open(F, "<$iheader")) { if (open(F, "<$iheader")) {
while (<F>) { while (<F>) {
chomp; s/\x0d?\x0a//;
chop if /\r$/;
return 0 if (/^\#pragma qt_no_master_include$/); return 0 if (/^\#pragma qt_no_master_include$/);
} }
close(F); close(F);
@ -215,11 +212,11 @@ sub classNames {
my $ihdrbase = basename($iheader); my $ihdrbase = basename($iheader);
my $parsable = ""; my $parsable = "";
local $/ = "\x0a";
if(open(F, "<$iheader")) { if(open(F, "<$iheader")) {
while(<F>) { while(<F>) {
s/\x0d?\x0a//;
my $line = $_; my $line = $_;
chomp $line;
chop $line if ($line =~ /\r$/);
if($line =~ /^\#/) { if($line =~ /^\#/) {
$$clean = 0 if ($line =~ m/^#pragma qt_sync_skip_header_check/); $$clean = 0 if ($line =~ m/^#pragma qt_sync_skip_header_check/);
return @ret if($line =~ m/^#pragma qt_sync_stop_processing/); return @ret if($line =~ m/^#pragma qt_sync_stop_processing/);
@ -336,6 +333,7 @@ sub check_header {
$header_skip_qt_begin_namespace_test = 1 if ($ignore_for_qt_begin_namespace_check{$header}); $header_skip_qt_begin_namespace_test = 1 if ($ignore_for_qt_begin_namespace_check{$header});
} }
local $/ = "\x0a";
open(F, "<$iheader") or return; open(F, "<$iheader") or return;
my $qt_begin_namespace_found = 0; my $qt_begin_namespace_found = 0;
my $qt_end_namespace_found = 0; my $qt_end_namespace_found = 0;
@ -344,7 +342,7 @@ sub check_header {
my $stop_processing = 0; my $stop_processing = 0;
my $we_mean_it = 0; my $we_mean_it = 0;
while ($line = <F>) { while ($line = <F>) {
chomp $line; $line =~ s/\x0d?\x0a//;
my $output_line = 1; my $output_line = 1;
if ($line =~ /^ *\# *pragma (qt_no_included_check|qt_sync_stop_processing)/) { if ($line =~ /^ *\# *pragma (qt_no_included_check|qt_sync_stop_processing)/) {
$stop_processing = 1; $stop_processing = 1;
@ -965,9 +963,10 @@ foreach my $lib (@modules_to_sync) {
#push @files, "$out_basedir/include/Qt/$t" if(-e "$out_basedir/include/Qt/$t"); #push @files, "$out_basedir/include/Qt/$t" if(-e "$out_basedir/include/Qt/$t");
foreach my $file (@files) { foreach my $file (@files) {
my $remove_file = 0; my $remove_file = 0;
local $/ = "\x0a";
if(open(F, "<$file")) { if(open(F, "<$file")) {
while(my $line = <F>) { while(my $line = <F>) {
chomp $line; $line =~ s/\x0d?\x0a//;
if($line =~ /^\#include \"([^\"]*)\"$/) { if($line =~ /^\#include \"([^\"]*)\"$/) {
my $include = $1; my $include = $1;
$include = $subdir . "/" . $include unless(substr($include, 0, 1) eq "/"); $include = $subdir . "/" . $include unless(substr($include, 0, 1) eq "/");