Re: [HACKERS] msvc, build and install with cygwin in the PATH

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Hannes Eder <Hannes(at)HannesEder(dot)net>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [HACKERS] msvc, build and install with cygwin in the PATH
Date: 2007-07-17 02:45:46
Message-ID: 200707170245.l6H2jkE07624@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches


Magnus, what is your reaction to this patch?

---------------------------------------------------------------------------

Hannes Eder wrote:
> Magnus Hagander wrote:
> >Hannes Eder wrote:
> >> Is it worth doing this the "Perl-way" and using File::Find? If so, I
> can
> >> work an a patch for that.
> >>
> > It's certainly cleaner that way, but I don't find it a major issue.
> But I'd
> > rather see that fix than the other one.
>
> Here we go. See attached patch. Your comments are welcome.
>
> Hannes.
>

> *** ..\pgsql-cvshead\src\tools\msvc\Install.pm Mo Mai 14 16:36:10 2007
> --- src\tools\msvc\Install.pm Mi Jun 6 20:39:47 2007
> ***************
> *** 10,15 ****
> --- 10,18 ----
> use Carp;
> use File::Basename;
> use File::Copy;
> + use File::Find;
> + use File::Glob;
> + use File::Spec;
>
> use Exporter;
> our (@ISA,@EXPORT_OK);
> ***************
> *** 99,104 ****
> --- 102,142 ----
> print "\n";
> }
>
> + sub FindFiles
> + {
> + my $spec = shift;
> + my $nonrecursive = shift;
> + my $pat = basename($spec);
> + my $dir = dirname($spec);
> +
> + if ($dir eq '') { $dir = '.'; }
> +
> + -d $dir || croak "Could not list directory $dir: $!\n";
> +
> + if ($nonrecursive)
> + {
> + return glob($spec);
> + }
> +
> + # borrowed from File::DosGlob
> + # escape regex metachars but not glob chars
> + $pat =~ s:([].+^\-\${}[|]):\\$1:g;
> + # and convert DOS-style wildcards to regex
> + $pat =~ s/\*/.*/g;
> + $pat =~ s/\?/.?/g;
> +
> + $pat = '^' . $pat . '\z';
> +
> + my @res;
> + find(
> + {
> + wanted => sub { /$pat/s && push (@res, File::Spec->canonpath($File::Find::name)); }
> + },
> + $dir
> + );
> + return @res;
> + }
> +
> sub CopySetOfFiles
> {
> my $what = shift;
> ***************
> *** 106,126 ****
> my $target = shift;
> my $silent = shift;
> my $norecurse = shift;
> - my $D;
>
> - my $subdirs = $norecurse?'':'/s';
> print "Copying $what" unless ($silent);
> ! open($D, "dir /b $subdirs $spec |") || croak "Could not list $spec\n";
> ! while (<$D>)
> {
> - chomp;
> next if /regress/; # Skip temporary install in regression subdir
> ! my $tgt = $target . basename($_);
> print ".";
> ! my $src = $norecurse?(dirname($spec) . '/' . $_):$_;
> ! copy($src, $tgt) || croak "Could not copy $src: $!\n";
> }
> ! close($D);
> print "\n";
> }
>
> --- 144,161 ----
> my $target = shift;
> my $silent = shift;
> my $norecurse = shift;
>
> print "Copying $what" unless ($silent);
> !
> ! foreach (FindFiles($spec, $norecurse))
> {
> next if /regress/; # Skip temporary install in regression subdir
> ! my $src = $_;
> ! my $tgt = $target . basename($src);
> print ".";
> ! copy($src, $tgt) || croak "Could not copy $src to $tgt: $!\n";
> }
> !
> print "\n";
> }
>
> ***************
> *** 371,395 ****
> {
> my $target = shift;
> my $nlspath = shift;
> - my $D;
>
> print "Installing NLS files...";
> EnsureDirectories($target, "share/locale");
> ! open($D,"dir /b /s nls.mk|") || croak "Could not list nls.mk\n";
> ! while (<$D>)
> {
> - chomp;
> s/nls.mk/po/;
> my $dir = $_;
> next unless ($dir =~ /([^\\]+)\\po$/);
> my $prgm = $1;
> $prgm = 'postgres' if ($prgm eq 'backend');
> - my $E;
> - open($E,"dir /b $dir\\*.po|") || croak "Could not list contents of $_\n";
>
> ! while (<$E>)
> {
> - chomp;
> my $lang;
> next unless /^(.*)\.po/;
> $lang = $1;
> --- 406,425 ----
> {
> my $target = shift;
> my $nlspath = shift;
>
> print "Installing NLS files...";
> EnsureDirectories($target, "share/locale");
> !
> ! foreach (FindFiles("nls.mk"))
> {
> s/nls.mk/po/;
> my $dir = $_;
> next unless ($dir =~ /([^\\]+)\\po$/);
> my $prgm = $1;
> $prgm = 'postgres' if ($prgm eq 'backend');
>
> ! foreach (FindFiles("$dir\\*.po", 1))
> {
> my $lang;
> next unless /^(.*)\.po/;
> $lang = $1;
> ***************
> *** 401,409 ****
> && croak("Could not run msgfmt on $dir\\$_");
> print ".";
> }
> - close($E);
> }
> ! close($D);
> print "\n";
> }
>
> --- 431,438 ----
> && croak("Could not run msgfmt on $dir\\$_");
> print ".";
> }
> }
> !
> print "\n";
> }
>

>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Shruthi A 2007-07-17 04:32:07 Re: Altering a plan
Previous Message Tom Lane 2007-07-17 01:56:58 Re: IsTransactionState() is being used incorrectly

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2007-07-17 04:11:59 Re: Patch for recent PITR bug
Previous Message Bruce Momjian 2007-07-17 02:31:16 Re: WIP: script binaries renaming