Thread: msvc, build and install with cygwin in the PATH

msvc, build and install with cygwin in the PATH

From
Hannes Eder
Date:
With a small modification to src/tools/msvc/Install.pm (see attached
patch) it's possible for me to build with msvc and install postgres on a
Windows xp box and leave cygwin in the PATH. Since I use cygwin
frequently it's usfull for me to have it in the PATH.

This might not work on Win9x platforms. But is that platform supported
for development anyway?

Hannes.


Index: src/tools/msvc/Install.pm
===================================================================
--- src/tools/msvc/Install.pm    (revision 44)
+++ src/tools/msvc/Install.pm    (working copy)
@@ -110,7 +110,7 @@
 
     my $subdirs = $norecurse?'':'/s';
     print "Copying $what" unless ($silent);
-    open($D, "dir /b $subdirs $spec |") || croak "Could not list $spec\n";
+    open($D, "cmd /c dir /b $subdirs $spec |") || croak "Could not list $spec\n";
     while (<$D>)
     {
         chomp;
@@ -375,7 +375,7 @@
 
     print "Installing NLS files...";
     EnsureDirectories($target, "share/locale");
-    open($D,"dir /b /s nls.mk|") || croak "Could not list nls.mk\n";
+    open($D,"cmd /c dir /b /s nls.mk|") || croak "Could not list nls.mk\n";
     while (<$D>)
     {
         chomp;

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

From
Andrew Dunstan
Date:

Hannes Eder wrote:
> -    open($D, "dir /b $subdirs $spec |") || croak "Could not list $spec\n";
> +    open($D, "cmd /c dir /b $subdirs $spec |") || croak "Could not list $spec\n";
>
>

What the heck are we doing here anyway? We should be doing this a la
Perl - calling out to "dir /b" is surely not the best way to do this. If
we need to recurse we should use File::Find.

cheers

andrew

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

From
Hannes Eder
Date:
Andrew Dunstan schrieb:
> Hannes Eder wrote:
>> -    open($D, "dir /b $subdirs $spec |") || croak "Could not list
>> $spec\n";
>> +    open($D, "cmd /c dir /b $subdirs $spec |") || croak "Could not
>> list $spec\n";
>>
>
> What the heck are we doing here anyway? We should be doing this a la
> Perl - calling out to "dir /b" is surely not the best way to do this.
> If we need to recurse we should use File::Find.
I think since the code in src/tools/msvc is specific to MSVC and
therefor, at least currently, specific to Windows. Calling out to "dir
/b /s" or "cmd /c dir /b /s" works on WinNT and higher. On Win9x/ME
command.com should be called instead of cmd.exe. In order to be more
portable maybe we should use the environment variable COMSPEC, which
should always point to an appropriate command processor.

Is it worth doing this the "Perl-way" and using File::Find? If so, I can
work an a patch for that.

Hannes.


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

From
Magnus Hagander
Date:
On Wed, May 30, 2007 at 12:09:05PM +0200, Hannes Eder wrote:
> Andrew Dunstan schrieb:
> >Hannes Eder wrote:
> >>-    open($D, "dir /b $subdirs $spec |") || croak "Could not list
> >>$spec\n";
> >>+    open($D, "cmd /c dir /b $subdirs $spec |") || croak "Could not
> >>list $spec\n";
> >>
> >
> >What the heck are we doing here anyway? We should be doing this a la
> >Perl - calling out to "dir /b" is surely not the best way to do this.
> >If we need to recurse we should use File::Find.
> I think since the code in src/tools/msvc is specific to MSVC and
> therefor, at least currently, specific to Windows. Calling out to "dir
> /b /s" or "cmd /c dir /b /s" works on WinNT and higher. On Win9x/ME
> command.com should be called instead of cmd.exe. In order to be more
> portable maybe we should use the environment variable COMSPEC, which
> should always point to an appropriate command processor.

We only support NT based OSes anyway, so I don't see COMSPEC as being a
problem. The reason it is the way it is is because that part was originally
just a .bat-file and I just copy/pasted the commands...

Are you actually *running* the script from inside cygwin? How else does it
pick up the wrong command processor?


> 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.

//Magnus


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

From
Hannes Eder
Date:
Magnus Hagander schrieb:
> Are you actually *running* the script from inside cygwin? How else does it
> pick up the wrong command processor?
>
I run the script within cmd.exe, but cygwin´s /usr/bin directory is in
my PATH, therefor cygwin dir executable is in the PATH (/usr/bin/dir).
Instead of running cmd.exe´s "dir" command, cygwin´s /usr/bin/dir is
invoked, when calling

open($D, "dir /b $subdirs $spec |") || croak "Could not list $spec\n";

but they do not work in the same way.

So my original patch just solves the issue to run
src/tools/msvc/install.(bat¦pl¦pm) while leaving the cygwin´s /usr/bin
in the PATH.
>> 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.
>
Time permitting I´ll provide a patch.

Hannes.

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

From
Magnus Hagander
Date:
On Wed, May 30, 2007 at 01:56:24PM +0200, Hannes Eder wrote:
> Magnus Hagander schrieb:
> >Are you actually *running* the script from inside cygwin? How else does it
> >pick up the wrong command processor?
> >
> I run the script within cmd.exe, but cygwin´s /usr/bin directory is in
> my PATH, therefor cygwin dir executable is in the PATH (/usr/bin/dir).
> Instead of running cmd.exe´s "dir" command, cygwin´s /usr/bin/dir is
> invoked, when calling

They actually *put* that in there? Wow. That's yet another reason never to
let cygwni touch your global path :-)

> >>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.
> >
> Time permitting I´ll provide a patch.

Thanks.

//Magnus


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

From
Hannes Eder
Date:
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";
  }


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

From
Bruce Momjian
Date:
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@momjian.us>          http://momjian.us
  EnterpriseDB                               http://www.enterprisedb.com

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

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

From
Magnus Hagander
Date:
I used to have a different patch from Andrew that did part of this, and
more, and conflicted rather badly with it. However, I never got around
to applying that one, and I can't seem to find it anymore.

Andrew -do you recall if you had all this in yours, and is it still
something you want in, or should we just go with this one?

//Magnus

Bruce Momjian wrote:
> 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
>


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

From
Andrew Dunstan
Date:
I am fighting some fires in my day job.

My pesonal TODO list for pg up to beta is:

. fix chunking muddle (see recent emails)
. complete CSV logs patch
. harden MSVC builds

I'll get to this when I can.  I can dig up the patch I did if you want
it again.

cheers

andrew


Magnus Hagander wrote:
> I used to have a different patch from Andrew that did part of this, and
> more, and conflicted rather badly with it. However, I never got around
> to applying that one, and I can't seem to find it anymore.
>
> Andrew -do you recall if you had all this in yours, and is it still
> something you want in, or should we just go with this one?
>
> //Magnus
>
> Bruce Momjian wrote:
>
>> 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
>>>
>
>

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

From
Hannes Eder
Date:
Magnus Hagander schrieb:
> I used to have a different patch from Andrew that did part of this, and
> more, and conflicted rather badly with it. However, I never got around
> to applying that one, and I can't seem to find it anymore.
>
> Andrew -do you recall if you had all this in yours, and is it still
> something you want in, or should we just go with this one?
>
Do you want my to submit a patch against HEAD again?

-Hannes



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

From
Andrew Dunstan
Date:

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.
>
>

I have committed a fix that is somewhat similar to this. The Install.pm
module needs some love, but that will have to wait till the next cycle.

cheers

andrew

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

From
Magnus Hagander
Date:
Andrew Dunstan wrote:
> 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.
>>
>>
>
> I have committed a fix that is somewhat similar to this. The Install.pm
> module needs some love, but that will have to wait till the next cycle.

Thanks, Andrew!

//Magnus


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

From
Tom Lane
Date:
Magnus Hagander <magnus@hagander.net> writes:
> Andrew Dunstan wrote:
>> I have committed a fix that is somewhat similar to this. The Install.pm
>> module needs some love, but that will have to wait till the next cycle.

> Thanks, Andrew!

Guys, would you comment on whether this patch closes all the open issues
that Bruce has listed for the MSVC port on his "pending patches" page?
Specifically, the half-dozen messages with "MSVC" in their subjects at
http://momjian.us/cgi-bin/pgpatches
        regards, tom lane


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

From
Magnus Hagander
Date:
Tom Lane wrote:
> Magnus Hagander <magnus@hagander.net> writes:
>> Andrew Dunstan wrote:
>>> I have committed a fix that is somewhat similar to this. The Install.pm
>>> module needs some love, but that will have to wait till the next cycle.
> 
>> Thanks, Andrew!
> 
> Guys, would you comment on whether this patch closes all the open issues
> that Bruce has listed for the MSVC port on his "pending patches" page?
> Specifically, the half-dozen messages with "MSVC" in their subjects at
> http://momjian.us/cgi-bin/pgpatches

It should, but it'd be good if Hannes can confirm that.

Or - it should fix all except
http://momjian.us/mhonarc/patches/msg00310.html.

//Magnus



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

From
Andrew Dunstan
Date:

Tom Lane wrote:
> Magnus Hagander <magnus@hagander.net> writes:
>   
>> Andrew Dunstan wrote:
>>     
>>> I have committed a fix that is somewhat similar to this. The Install.pm
>>> module needs some love, but that will have to wait till the next cycle.
>>>       
>
>   
>> Thanks, Andrew!
>>     
>
> Guys, would you comment on whether this patch closes all the open issues
> that Bruce has listed for the MSVC port on his "pending patches" page?
> Specifically, the half-dozen messages with "MSVC" in their subjects at
> http://momjian.us/cgi-bin/pgpatches
>
>   

All but "WIP - MSVC build script replacements". I was intending to 
commit the two new perl files today, which will make adapting the 
buildfarm easier, but given how close we are to beta hold off on 
changing the .bat files to make them pure wrappers till the new dev cycle.

cheers

andrew


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

From
Hannes Eder
Date:
Magnus Hagander schrieb:
> Tom Lane wrote:
>
>> Magnus Hagander <magnus@hagander.net> writes:
>>
>>> Andrew Dunstan wrote:
>>>
>>>> I have committed a fix that is somewhat similar to this. The Install.pm
>>>> module needs some love, but that will have to wait till the next cycle.
>>>>
>>> Thanks, Andrew!
>>>
>> Guys, would you comment on whether this patch closes all the open issues
>> that Bruce has listed for the MSVC port on his "pending patches" page?
>> Specifically, the half-dozen messages with "MSVC" in their subjects at
>> http://momjian.us/cgi-bin/pgpatches
>>
>
> It should, but it'd be good if Hannes can confirm that.
>
>
I found two issues:

(a) use the current dir "." instead of "../.." for the *.sample files,
since there are the chdir's to ../../.. resp. to ../../../.. in line 28
resp. 29. Using ../.. would traverse a too large part of the directory
structure.

(b) a <http://www.dict.cc/englisch-deutsch/superfluous.html>superfluous
\ for the "Dictionaries sample files"

see attached diff.

besides from that it works well in my configuration and it solves the
intial issue with cygwin's dir in PATH. Thank you.

-Hannes

*** ../pgsql-cvshead/src/tools/msvc/Install.pm    Sun Sep 23 20:27:59 2007
--- src/tools/msvc/Install.pm    Sun Sep 23 21:24:13 2007
***************
*** 50,56 ****
                                      push(@$sample_files, $File::Find::name);
                              }
                    },
!                      "../.." );
      CopySetOfFiles('config files', $sample_files , $target . '/share/');
      CopyFiles(
          'Import libraries',
--- 50,56 ----
                                      push(@$sample_files, $File::Find::name);
                              }
                    },
!                      "." );
      CopySetOfFiles('config files', $sample_files , $target . '/share/');
      CopyFiles(
          'Import libraries',
***************
*** 81,87 ****
                     [ glob ("src\\backend\\snowball\\stopwords\\*.stop") ],
                     $target . '/share/tsearch_data/');
      CopySetOfFiles('Dictionaries sample files',
!                    [ glob ("src\\backend\\tsearch\\\*_sample.*" ) ],
                     $target . '/share/tsearch_data/');
      CopyContribFiles($config,$target);
      CopyIncludeFiles($target);
--- 81,87 ----
                     [ glob ("src\\backend\\snowball\\stopwords\\*.stop") ],
                     $target . '/share/tsearch_data/');
      CopySetOfFiles('Dictionaries sample files',
!                    [ glob ("src\\backend\\tsearch\\*_sample.*" ) ],
                     $target . '/share/tsearch_data/');
      CopyContribFiles($config,$target);
      CopyIncludeFiles($target);

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

From
Andrew Dunstan
Date:

Hannes Eder wrote:
>
> (a) use the current dir "." instead of "../.." for the *.sample files, 
> since there are the chdir's to ../../.. resp. to ../../../.. in line 
> 28 resp. 29. Using ../.. would traverse a too large part of the 
> directory structure.

Actually, it should be restricted more, to src. I adjusted this and the 
other recursive search accordingly.
>
> (b) a 
> <http://www.dict.cc/englisch-deutsch/superfluous.html>superfluous \ 
> for the "Dictionaries sample files"
>
>

Oops.

Fixes applied.

cheers

andrew