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