Commit 854adb83 authored by Peter Eisentraut's avatar Peter Eisentraut

Replace backslashes by forward slashes in MSVC build code

This makes it possible to run some stages of these build scripts on
non-Windows systems.  That way, we can more easily test whether file
moves or makefile changes might break the MSVC build.

Peter Eisentraut and Michael Paquier
parent 410cbfd6
...@@ -127,7 +127,7 @@ EOF ...@@ -127,7 +127,7 @@ EOF
foreach my $fileNameWithPath (sort keys %{ $self->{files} }) foreach my $fileNameWithPath (sort keys %{ $self->{files} })
{ {
confess "Bad format filename '$fileNameWithPath'\n" confess "Bad format filename '$fileNameWithPath'\n"
unless ($fileNameWithPath =~ /^(.*)\\([^\\]+)\.(c|cpp|y|l|rc)$/); unless ($fileNameWithPath =~ m!^(.*)/([^/]+)\.(c|cpp|y|l|rc)$!);
my $dir = $1; my $dir = $1;
my $fileName = $2; my $fileName = $2;
if ($fileNameWithPath =~ /\.y$/ or $fileNameWithPath =~ /\.l$/) if ($fileNameWithPath =~ /\.y$/ or $fileNameWithPath =~ /\.l$/)
......
This diff is collapsed.
...@@ -52,20 +52,19 @@ sub AddFiles ...@@ -52,20 +52,19 @@ sub AddFiles
while (my $f = shift) while (my $f = shift)
{ {
$self->{files}->{ $dir . "\\" . $f } = 1; $self->{files}->{ $dir . "/" . $f } = 1;
} }
} }
sub ReplaceFile sub ReplaceFile
{ {
my ($self, $filename, $newname) = @_; my ($self, $filename, $newname) = @_;
my $re = "\\\\$filename\$"; my $re = "\\/$filename\$";
foreach my $file (keys %{ $self->{files} }) foreach my $file (keys %{ $self->{files} })
{ {
# Match complete filename # Match complete filename
if ($filename =~ /\\/) if ($filename =~ m!/!)
{ {
if ($file eq $filename) if ($file eq $filename)
{ {
...@@ -77,7 +76,7 @@ sub ReplaceFile ...@@ -77,7 +76,7 @@ sub ReplaceFile
elsif ($file =~ m/($re)/) elsif ($file =~ m/($re)/)
{ {
delete $self->{files}{$file}; delete $self->{files}{$file};
$self->{files}{"$newname\\$filename"} = 1; $self->{files}{"$newname/$filename"} = 1;
return; return;
} }
} }
...@@ -105,7 +104,7 @@ sub RelocateFiles ...@@ -105,7 +104,7 @@ sub RelocateFiles
if ($r) if ($r)
{ {
$self->RemoveFile($f); $self->RemoveFile($f);
$self->AddFile($targetdir . '\\' . basename($f)); $self->AddFile($targetdir . '/' . basename($f));
} }
} }
} }
...@@ -118,7 +117,7 @@ sub AddReference ...@@ -118,7 +117,7 @@ sub AddReference
{ {
push @{ $self->{references} }, $ref; push @{ $self->{references} }, $ref;
$self->AddLibrary( $self->AddLibrary(
"__CFGNAME__\\" . $ref->{name} . "\\" . $ref->{name} . ".lib"); "__CFGNAME__/" . $ref->{name} . "/" . $ref->{name} . ".lib");
} }
} }
...@@ -169,8 +168,8 @@ sub FullExportDLL ...@@ -169,8 +168,8 @@ sub FullExportDLL
my ($self, $libname) = @_; my ($self, $libname) = @_;
$self->{builddef} = 1; $self->{builddef} = 1;
$self->{def} = ".\\__CFGNAME__\\$self->{name}\\$self->{name}.def"; $self->{def} = "./__CFGNAME__/$self->{name}/$self->{name}.def";
$self->{implib} = "__CFGNAME__\\$self->{name}\\$libname"; $self->{implib} = "__CFGNAME__/$self->{name}/$libname";
} }
sub UseDef sub UseDef
...@@ -194,9 +193,9 @@ sub AddDir ...@@ -194,9 +193,9 @@ sub AddDir
if $subdir eq "\$(top_builddir)/src/timezone" if $subdir eq "\$(top_builddir)/src/timezone"
; #special case for non-standard include ; #special case for non-standard include
next next
if $reldir . "\\" . $subdir eq "src\\backend\\port\\darwin"; if $reldir . "/" . $subdir eq "src/backend/port/darwin";
$self->AddDir($reldir . "\\" . $subdir); $self->AddDir($reldir . "/" . $subdir);
} }
} }
while ($mf =~ m{^(?:EXTRA_)?OBJS[^=]*=\s*(.*)$}m) while ($mf =~ m{^(?:EXTRA_)?OBJS[^=]*=\s*(.*)$}m)
...@@ -243,13 +242,11 @@ sub AddDir ...@@ -243,13 +242,11 @@ sub AddDir
if ($f =~ /^\$\(top_builddir\)\/(.*)/) if ($f =~ /^\$\(top_builddir\)\/(.*)/)
{ {
$f = $1; $f = $1;
$f =~ s/\//\\/g;
$self->{files}->{$f} = 1; $self->{files}->{$f} = 1;
} }
else else
{ {
$f =~ s/\//\\/g; $self->{files}->{"$reldir/$f"} = 1;
$self->{files}->{"$reldir\\$f"} = 1;
} }
} }
$mf =~ s{OBJS[^=]*=\s*(.*)$}{}m; $mf =~ s{OBJS[^=]*=\s*(.*)$}{}m;
...@@ -264,7 +261,6 @@ sub AddDir ...@@ -264,7 +261,6 @@ sub AddDir
my $match = $1; my $match = $1;
my $top = $2; my $top = $2;
my $target = $3; my $target = $3;
$target =~ s{/}{\\}g;
my @pieces = split /\s+/, $match; my @pieces = split /\s+/, $match;
foreach my $fn (@pieces) foreach my $fn (@pieces)
{ {
...@@ -274,7 +270,7 @@ sub AddDir ...@@ -274,7 +270,7 @@ sub AddDir
} }
elsif ($top eq "(backend_src)") elsif ($top eq "(backend_src)")
{ {
eval { $self->ReplaceFile($fn, "src\\backend\\$target") }; eval { $self->ReplaceFile($fn, "src/backend/$target") };
} }
else else
{ {
...@@ -310,12 +306,12 @@ sub AddResourceFile ...@@ -310,12 +306,12 @@ sub AddResourceFile
localtime(time); localtime(time);
my $d = sprintf("%02d%03d", ($year - 100), $yday); my $d = sprintf("%02d%03d", ($year - 100), $yday);
if (Solution::IsNewer("$dir\\win32ver.rc", 'src\port\win32ver.rc')) if (Solution::IsNewer("$dir/win32ver.rc", 'src/port/win32ver.rc'))
{ {
print "Generating win32ver.rc for $dir\n"; print "Generating win32ver.rc for $dir\n";
open(I, 'src\port\win32ver.rc') open(I, 'src/port/win32ver.rc')
|| confess "Could not open win32ver.rc"; || confess "Could not open win32ver.rc";
open(O, ">$dir\\win32ver.rc") open(O, ">$dir/win32ver.rc")
|| confess "Could not write win32ver.rc"; || confess "Could not write win32ver.rc";
my $icostr = $ico ? "IDI_ICON ICON \"src/port/$ico.ico\"" : ""; my $icostr = $ico ? "IDI_ICON ICON \"src/port/$ico.ico\"" : "";
while (<I>) while (<I>)
...@@ -332,7 +328,7 @@ sub AddResourceFile ...@@ -332,7 +328,7 @@ sub AddResourceFile
} }
close(O); close(O);
close(I); close(I);
$self->AddFile("$dir\\win32ver.rc"); $self->AddFile("$dir/win32ver.rc");
} }
sub DisableLinkerWarnings sub DisableLinkerWarnings
...@@ -415,9 +411,9 @@ sub read_makefile ...@@ -415,9 +411,9 @@ sub read_makefile
my $t = $/; my $t = $/;
undef $/; undef $/;
open($F, "$reldir\\GNUmakefile") open($F, "$reldir/GNUmakefile")
|| open($F, "$reldir\\Makefile") || open($F, "$reldir/Makefile")
|| croak "Could not open $reldir\\Makefile\n"; || confess "Could not open $reldir/Makefile\n";
my $txt = <$F>; my $txt = <$F>;
close($F); close($F);
$/ = $t; $/ = $t;
......
...@@ -87,15 +87,15 @@ sub DeterminePlatform ...@@ -87,15 +87,15 @@ sub DeterminePlatform
sub IsNewer sub IsNewer
{ {
my ($newfile, $oldfile) = @_; my ($newfile, $oldfile) = @_;
if ( $oldfile ne 'src\tools\msvc\config.pl' if ( $oldfile ne 'src/tools/msvc/config.pl'
&& $oldfile ne 'src\tools\msvc\config_default.pl') && $oldfile ne 'src/tools/msvc/config_default.pl')
{ {
return 1 return 1
if (-f 'src\tools\msvc\config.pl') if (-f 'src/tools/msvc/config.pl')
&& IsNewer($newfile, 'src\tools\msvc\config.pl'); && IsNewer($newfile, 'src/tools/msvc/config.pl');
return 1 return 1
if (-f 'src\tools\msvc\config_default.pl') if (-f 'src/tools/msvc/config_default.pl')
&& IsNewer($newfile, 'src\tools\msvc\config_default.pl'); && IsNewer($newfile, 'src/tools/msvc/config_default.pl');
} }
return 1 if (!(-e $newfile)); return 1 if (!(-e $newfile));
my @nstat = stat($newfile); my @nstat = stat($newfile);
...@@ -144,20 +144,20 @@ sub GenerateFiles ...@@ -144,20 +144,20 @@ sub GenerateFiles
if ($self->{strver} eq '' || $self->{numver} eq ''); if ($self->{strver} eq '' || $self->{numver} eq '');
if (IsNewer( if (IsNewer(
"src\\include\\pg_config_os.h", "src\\include\\port\\win32.h")) "src/include/pg_config_os.h", "src/include/port/win32.h"))
{ {
print "Copying pg_config_os.h...\n"; print "Copying pg_config_os.h...\n";
copyFile("src\\include\\port\\win32.h", copyFile("src/include/port/win32.h",
"src\\include\\pg_config_os.h"); "src/include/pg_config_os.h");
} }
if (IsNewer( if (IsNewer(
"src\\include\\pg_config.h", "src\\include\\pg_config.h.win32")) "src/include/pg_config.h", "src/include/pg_config.h.win32"))
{ {
print "Generating pg_config.h...\n"; print "Generating pg_config.h...\n";
open(I, "src\\include\\pg_config.h.win32") open(I, "src/include/pg_config.h.win32")
|| confess "Could not open pg_config.h.win32\n"; || confess "Could not open pg_config.h.win32\n";
open(O, ">src\\include\\pg_config.h") open(O, ">src/include/pg_config.h")
|| confess "Could not write to pg_config.h\n"; || confess "Could not write to pg_config.h\n";
my $extraver = $self->{options}->{extraver}; my $extraver = $self->{options}->{extraver};
$extraver = '' unless defined $extraver; $extraver = '' unless defined $extraver;
...@@ -245,111 +245,111 @@ sub GenerateFiles ...@@ -245,111 +245,111 @@ sub GenerateFiles
} }
if (IsNewer( if (IsNewer(
"src\\include\\pg_config_ext.h", "src/include/pg_config_ext.h",
"src\\include\\pg_config_ext.h.win32")) "src/include/pg_config_ext.h.win32"))
{ {
print "Copying pg_config_ext.h...\n"; print "Copying pg_config_ext.h...\n";
copyFile( copyFile(
"src\\include\\pg_config_ext.h.win32", "src/include/pg_config_ext.h.win32",
"src\\include\\pg_config_ext.h"); "src/include/pg_config_ext.h");
} }
$self->GenerateDefFile( $self->GenerateDefFile(
"src\\interfaces\\libpq\\libpqdll.def", "src/interfaces/libpq/libpqdll.def",
"src\\interfaces\\libpq\\exports.txt", "src/interfaces/libpq/exports.txt",
"LIBPQ"); "LIBPQ");
$self->GenerateDefFile( $self->GenerateDefFile(
"src\\interfaces\\ecpg\\ecpglib\\ecpglib.def", "src/interfaces/ecpg/ecpglib/ecpglib.def",
"src\\interfaces\\ecpg\\ecpglib\\exports.txt", "src/interfaces/ecpg/ecpglib/exports.txt",
"LIBECPG"); "LIBECPG");
$self->GenerateDefFile( $self->GenerateDefFile(
"src\\interfaces\\ecpg\\compatlib\\compatlib.def", "src/interfaces/ecpg/compatlib/compatlib.def",
"src\\interfaces\\ecpg\\compatlib\\exports.txt", "src/interfaces/ecpg/compatlib/exports.txt",
"LIBECPG_COMPAT"); "LIBECPG_COMPAT");
$self->GenerateDefFile( $self->GenerateDefFile(
"src\\interfaces\\ecpg\\pgtypeslib\\pgtypeslib.def", "src/interfaces/ecpg/pgtypeslib/pgtypeslib.def",
"src\\interfaces\\ecpg\\pgtypeslib\\exports.txt", "src/interfaces/ecpg/pgtypeslib/exports.txt",
"LIBPGTYPES"); "LIBPGTYPES");
if (IsNewer( if (IsNewer(
'src\backend\utils\fmgrtab.c', 'src\include\catalog\pg_proc.h')) 'src/backend/utils/fmgrtab.c', 'src/include/catalog/pg_proc.h'))
{ {
print "Generating fmgrtab.c and fmgroids.h...\n"; print "Generating fmgrtab.c and fmgroids.h...\n";
chdir('src\backend\utils'); chdir('src/backend/utils');
system( system(
"perl -I ../catalog Gen_fmgrtab.pl ../../../src/include/catalog/pg_proc.h"); "perl -I ../catalog Gen_fmgrtab.pl ../../../src/include/catalog/pg_proc.h");
chdir('..\..\..'); chdir('../../..');
} }
if (IsNewer( if (IsNewer(
'src\include\utils\fmgroids.h', 'src/include/utils/fmgroids.h',
'src\backend\utils\fmgroids.h')) 'src/backend/utils/fmgroids.h'))
{ {
copyFile('src\backend\utils\fmgroids.h', copyFile('src/backend/utils/fmgroids.h',
'src\include\utils\fmgroids.h'); 'src/include/utils/fmgroids.h');
} }
if (IsNewer('src\include\utils\probes.h', 'src\backend\utils\probes.d')) if (IsNewer('src/include/utils/probes.h', 'src/backend/utils/probes.d'))
{ {
print "Generating probes.h...\n"; print "Generating probes.h...\n";
system( system(
'psed -f src\backend\utils\Gen_dummy_probes.sed src\backend\utils\probes.d > src\include\utils\probes.h' 'psed -f src/backend/utils/Gen_dummy_probes.sed src/backend/utils/probes.d > src/include/utils/probes.h'
); );
} }
if ($self->{options}->{python} if ($self->{options}->{python}
&& IsNewer( && IsNewer(
'src\pl\plpython\spiexceptions.h', 'src/pl/plpython/spiexceptions.h',
'src\include\backend\errcodes.txt')) 'src/include/backend/errcodes.txt'))
{ {
print "Generating spiexceptions.h...\n"; print "Generating spiexceptions.h...\n";
system( system(
'perl src\pl\plpython\generate-spiexceptions.pl src\backend\utils\errcodes.txt > src\pl\plpython\spiexceptions.h' 'perl src/pl/plpython/generate-spiexceptions.pl src/backend/utils/errcodes.txt > src/pl/plpython/spiexceptions.h'
); );
} }
if (IsNewer( if (IsNewer(
'src\include\utils\errcodes.h', 'src/include/utils/errcodes.h',
'src\backend\utils\errcodes.txt')) 'src/backend/utils/errcodes.txt'))
{ {
print "Generating errcodes.h...\n"; print "Generating errcodes.h...\n";
system( system(
'perl src\backend\utils\generate-errcodes.pl src\backend\utils\errcodes.txt > src\backend\utils\errcodes.h' 'perl src/backend/utils/generate-errcodes.pl src/backend/utils/errcodes.txt > src/backend/utils/errcodes.h'
); );
copyFile('src\backend\utils\errcodes.h', copyFile('src/backend/utils/errcodes.h',
'src\include\utils\errcodes.h'); 'src/include/utils/errcodes.h');
} }
if (IsNewer( if (IsNewer(
'src\pl\plpgsql\src\plerrcodes.h', 'src/pl/plpgsql/src/plerrcodes.h',
'src\backend\utils\errcodes.txt')) 'src/backend/utils/errcodes.txt'))
{ {
print "Generating plerrcodes.h...\n"; print "Generating plerrcodes.h...\n";
system( system(
'perl src\pl\plpgsql\src\generate-plerrcodes.pl src\backend\utils\errcodes.txt > src\pl\plpgsql\src\plerrcodes.h' 'perl src/pl/plpgsql/src/generate-plerrcodes.pl src/backend/utils/errcodes.txt > src/pl/plpgsql/src/plerrcodes.h'
); );
} }
if (IsNewer( if (IsNewer(
'src\backend\utils\sort\qsort_tuple.c', 'src/backend/utils/sort/qsort_tuple.c',
'src\backend\utils\sort\gen_qsort_tuple.pl')) 'src/backend/utils/sort/gen_qsort_tuple.pl'))
{ {
print "Generating qsort_tuple.c...\n"; print "Generating qsort_tuple.c...\n";
system( system(
'perl src\backend\utils\sort\gen_qsort_tuple.pl > src\backend\utils\sort\qsort_tuple.c' 'perl src/backend/utils/sort/gen_qsort_tuple.pl > src/backend/utils/sort/qsort_tuple.c'
); );
} }
if (IsNewer( if (IsNewer(
'src\interfaces\libpq\libpq.rc', 'src/interfaces/libpq/libpq.rc',
'src\interfaces\libpq\libpq.rc.in')) 'src/interfaces/libpq/libpq.rc.in'))
{ {
print "Generating libpq.rc...\n"; print "Generating libpq.rc...\n";
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
localtime(time); localtime(time);
my $d = ($year - 100) . "$yday"; my $d = ($year - 100) . "$yday";
open(I, '<', 'src\interfaces\libpq\libpq.rc.in') open(I, '<', 'src/interfaces/libpq/libpq.rc.in')
|| confess "Could not open libpq.rc.in"; || confess "Could not open libpq.rc.in";
open(O, '>', 'src\interfaces\libpq\libpq.rc') open(O, '>', 'src/interfaces/libpq/libpq.rc')
|| confess "Could not open libpq.rc"; || confess "Could not open libpq.rc";
while (<I>) while (<I>)
{ {
...@@ -360,30 +360,30 @@ sub GenerateFiles ...@@ -360,30 +360,30 @@ sub GenerateFiles
close(O); close(O);
} }
if (IsNewer('src\bin\psql\sql_help.h', 'src\bin\psql\create_help.pl')) if (IsNewer('src/bin/psql/sql_help.h', 'src/bin/psql/create_help.pl'))
{ {
print "Generating sql_help.h...\n"; print "Generating sql_help.h...\n";
chdir('src\bin\psql'); chdir('src/bin/psql');
system("perl create_help.pl ../../../doc/src/sgml/ref sql_help"); system("perl create_help.pl ../../../doc/src/sgml/ref sql_help");
chdir('..\..\..'); chdir('../../..');
} }
if (IsNewer( if (IsNewer(
'src\interfaces\ecpg\preproc\preproc.y', 'src/interfaces/ecpg/preproc/preproc.y',
'src\backend\parser\gram.y')) 'src/backend/parser/gram.y'))
{ {
print "Generating preproc.y...\n"; print "Generating preproc.y...\n";
chdir('src\interfaces\ecpg\preproc'); chdir('src/interfaces/ecpg/preproc');
system('perl parse.pl < ..\..\..\backend\parser\gram.y > preproc.y'); system('perl parse.pl < ../../../backend/parser/gram.y > preproc.y');
chdir('..\..\..\..'); chdir('../../../..');
} }
if (IsNewer( if (IsNewer(
'src\interfaces\ecpg\include\ecpg_config.h', 'src/interfaces/ecpg/include/ecpg_config.h',
'src\interfaces\ecpg\include\ecpg_config.h.in')) 'src/interfaces/ecpg/include/ecpg_config.h.in'))
{ {
print "Generating ecpg_config.h...\n"; print "Generating ecpg_config.h...\n";
open(O, '>', 'src\interfaces\ecpg\include\ecpg_config.h') open(O, '>', 'src/interfaces/ecpg/include/ecpg_config.h')
|| confess "Could not open ecpg_config.h"; || confess "Could not open ecpg_config.h";
print O <<EOF; print O <<EOF;
#if (_MSC_VER > 1200) #if (_MSC_VER > 1200)
...@@ -396,10 +396,10 @@ EOF ...@@ -396,10 +396,10 @@ EOF
close(O); close(O);
} }
unless (-f "src\\port\\pg_config_paths.h") unless (-f "src/port/pg_config_paths.h")
{ {
print "Generating pg_config_paths.h...\n"; print "Generating pg_config_paths.h...\n";
open(O, '>', 'src\port\pg_config_paths.h') open(O, '>', 'src/port/pg_config_paths.h')
|| confess "Could not open pg_config_paths.h"; || confess "Could not open pg_config_paths.h";
print O <<EOF; print O <<EOF;
#define PGBINDIR "/bin" #define PGBINDIR "/bin"
...@@ -418,7 +418,7 @@ EOF ...@@ -418,7 +418,7 @@ EOF
close(O); close(O);
} }
my $mf = Project::read_file('src\backend\catalog\Makefile'); my $mf = Project::read_file('src/backend/catalog/Makefile');
$mf =~ s{\\\r?\n}{}g; $mf =~ s{\\\r?\n}{}g;
$mf =~ /^POSTGRES_BKI_SRCS\s*:?=[^,]+,(.*)\)$/gm $mf =~ /^POSTGRES_BKI_SRCS\s*:?=[^,]+,(.*)\)$/gm
|| croak "Could not find POSTGRES_BKI_SRCS in Makefile\n"; || croak "Could not find POSTGRES_BKI_SRCS in Makefile\n";
...@@ -431,15 +431,15 @@ EOF ...@@ -431,15 +431,15 @@ EOF
"src/include/catalog/$bki")) "src/include/catalog/$bki"))
{ {
print "Generating postgres.bki and schemapg.h...\n"; print "Generating postgres.bki and schemapg.h...\n";
chdir('src\backend\catalog'); chdir('src/backend/catalog');
my $bki_srcs = join(' ../../../src/include/catalog/', @allbki); my $bki_srcs = join(' ../../../src/include/catalog/', @allbki);
system( system(
"perl genbki.pl -I../../../src/include/catalog --set-version=$self->{majorver} $bki_srcs" "perl genbki.pl -I../../../src/include/catalog --set-version=$self->{majorver} $bki_srcs"
); );
chdir('..\..\..'); chdir('../../..');
copyFile( copyFile(
'src\backend\catalog\schemapg.h', 'src/backend/catalog/schemapg.h',
'src\include\catalog\schemapg.h'); 'src/include/catalog/schemapg.h');
last; last;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment