@@ -46,7 +46,11 @@ my $contrib_extraincludes =
46
46
my $contrib_extrasource = {
47
47
' cube' => [ ' contrib/cube/cubescan.l' , ' contrib/cube/cubeparse.y' ],
48
48
' seg' => [ ' contrib/seg/segscan.l' , ' contrib/seg/segparse.y' ], };
49
- my @contrib_excludes = (' pgcrypto' , ' commit_ts' , ' intagg' , ' sepgsql' );
49
+ my @contrib_excludes = (
50
+ ' commit_ts' , ' hstore_plperl' ,
51
+ ' hstore_plpython' , ' intagg' ,
52
+ ' ltree_plpython' , ' pgcrypto' ,
53
+ ' sepgsql' );
50
54
51
55
# Set of variables for frontend modules
52
56
my $frontend_defines = { ' initdb' => ' FRONTEND' };
@@ -176,119 +180,6 @@ sub mkvcbuild
176
180
$plpgsql -> AddFiles(' src/pl/plpgsql/src' , ' pl_gram.y' );
177
181
$plpgsql -> AddReference($postgres );
178
182
179
- if ($solution -> {options }-> {perl })
180
- {
181
- my $plperlsrc = " src/pl/plperl/" ;
182
- my $plperl =
183
- $solution -> AddProject(' plperl' , ' dll' , ' PLs' , ' src/pl/plperl' );
184
- $plperl -> AddIncludeDir($solution -> {options }-> {perl } . ' /lib/CORE' );
185
- $plperl -> AddDefine(' PLPERL_HAVE_UID_GID' );
186
- foreach my $xs (' SPI.xs' , ' Util.xs' )
187
- {
188
- (my $xsc = $xs ) =~ s /\. xs/ .c/ ;
189
- if (Solution::IsNewer(" $plperlsrc$xsc " , " $plperlsrc$xs " ))
190
- {
191
- my $xsubppdir = first { -e " $_ /ExtUtils/xsubpp" } @INC ;
192
- print " Building $plperlsrc$xsc ...\n " ;
193
- system ( $solution -> {options }-> {perl }
194
- . ' /bin/perl '
195
- . " $xsubppdir /ExtUtils/xsubpp -typemap "
196
- . $solution -> {options }-> {perl }
197
- . ' /lib/ExtUtils/typemap '
198
- . " $plperlsrc$xs "
199
- . " >$plperlsrc$xsc " );
200
- if ((!(-f " $plperlsrc$xsc " )) || -z " $plperlsrc$xsc " )
201
- {
202
- unlink (" $plperlsrc$xsc " ); # if zero size
203
- die " Failed to create $xsc .\n " ;
204
- }
205
- }
206
- }
207
- if (Solution::IsNewer(
208
- ' src/pl/plperl/perlchunks.h' ,
209
- ' src/pl/plperl/plc_perlboot.pl' )
210
- || Solution::IsNewer(
211
- ' src/pl/plperl/perlchunks.h' ,
212
- ' src/pl/plperl/plc_trusted.pl' ))
213
- {
214
- print ' Building src/pl/plperl/perlchunks.h ...' . " \n " ;
215
- my $basedir = getcwd;
216
- chdir ' src/pl/plperl' ;
217
- system ( $solution -> {options }-> {perl }
218
- . ' /bin/perl '
219
- . ' text2macro.pl '
220
- . ' --strip="^(\#.*|\s*)$$" '
221
- . ' plc_perlboot.pl plc_trusted.pl '
222
- . ' >perlchunks.h' );
223
- chdir $basedir ;
224
- if ((!(-f ' src/pl/plperl/perlchunks.h' ))
225
- || -z ' src/pl/plperl/perlchunks.h' )
226
- {
227
- unlink (' src/pl/plperl/perlchunks.h' ); # if zero size
228
- die ' Failed to create perlchunks.h' . " \n " ;
229
- }
230
- }
231
- if (Solution::IsNewer(
232
- ' src/pl/plperl/plperl_opmask.h' ,
233
- ' src/pl/plperl/plperl_opmask.pl' ))
234
- {
235
- print ' Building src/pl/plperl/plperl_opmask.h ...' . " \n " ;
236
- my $basedir = getcwd;
237
- chdir ' src/pl/plperl' ;
238
- system ( $solution -> {options }-> {perl }
239
- . ' /bin/perl '
240
- . ' plperl_opmask.pl '
241
- . ' plperl_opmask.h' );
242
- chdir $basedir ;
243
- if ((!(-f ' src/pl/plperl/plperl_opmask.h' ))
244
- || -z ' src/pl/plperl/plperl_opmask.h' )
245
- {
246
- unlink (' src/pl/plperl/plperl_opmask.h' ); # if zero size
247
- die ' Failed to create plperl_opmask.h' . " \n " ;
248
- }
249
- }
250
- $plperl -> AddReference($postgres );
251
- my @perl_libs =
252
- grep { / perl\d +.lib$ / }
253
- glob ($solution -> {options }-> {perl } . ' \lib\CORE\perl*.lib' );
254
- if (@perl_libs == 1)
255
- {
256
- $plperl -> AddLibrary($perl_libs [0]);
257
- }
258
- else
259
- {
260
- die " could not identify perl library version" ;
261
- }
262
- }
263
-
264
- if ($solution -> {options }-> {python })
265
- {
266
-
267
- # Attempt to get python version and location.
268
- # Assume python.exe in specified dir.
269
- open (P,
270
- $solution -> {options }-> {python }
271
- . " \\ python -c \" import sys;print(sys.prefix);print(str(sys.version_info[0])+str(sys.version_info[1]))\" |"
272
- ) || die " Could not query for python version!\n " ;
273
- my $pyprefix = <P>;
274
- chomp ($pyprefix );
275
- my $pyver = <P>;
276
- chomp ($pyver );
277
- close (P);
278
-
279
- # Sometimes (always?) if python is not present, the execution
280
- # appears to work, but gives no data...
281
- die " Failed to query python for version information\n "
282
- if (!(defined ($pyprefix ) && defined ($pyver )));
283
-
284
- my $pymajorver = substr ($pyver , 0, 1);
285
- my $plpython = $solution -> AddProject(' plpython' . $pymajorver ,
286
- ' dll' , ' PLs' , ' src/pl/plpython' );
287
- $plpython -> AddIncludeDir($pyprefix . ' /include' );
288
- $plpython -> AddLibrary($pyprefix . " /Libs/python$pyver .lib" );
289
- $plpython -> AddReference($postgres );
290
- }
291
-
292
183
if ($solution -> {options }-> {tcl })
293
184
{
294
185
my $pltcl =
@@ -571,6 +462,138 @@ sub mkvcbuild
571
462
closedir ($D );
572
463
}
573
464
465
+ # Build Perl and Python modules after contrib/ modules to satisfy some
466
+ # dependencies with transform contrib modules, like hstore_plpython
467
+ # ltree_plpython and hstore_plperl.
468
+ if ($solution -> {options }-> {python })
469
+ {
470
+ # Attempt to get python version and location.
471
+ # Assume python.exe in specified dir.
472
+ my $pythonprog = " import sys;print(sys.prefix);" .
473
+ " print(str(sys.version_info[0])+str(sys.version_info[1]))" ;
474
+ my $prefixcmd = $solution -> {options }-> {python }
475
+ . " \\ python -c \" $pythonprog \" " ;
476
+ my $pyout = ` $prefixcmd ` ;
477
+ die " Could not query for python version!\n " if $? ;
478
+ my ($pyprefix ,$pyver ) = split (/ \r ?\n / ,$pyout );
479
+
480
+ # Sometimes (always?) if python is not present, the execution
481
+ # appears to work, but gives no data...
482
+ die " Failed to query python for version information\n "
483
+ if (!(defined ($pyprefix ) && defined ($pyver )));
484
+
485
+ my $pymajorver = substr ($pyver , 0, 1);
486
+ my $plpython = $solution -> AddProject(' plpython' . $pymajorver ,
487
+ ' dll' , ' PLs' , ' src/pl/plpython' );
488
+ $plpython -> AddIncludeDir($pyprefix . ' /include' );
489
+ $plpython -> AddLibrary($pyprefix . " /Libs/python$pyver .lib" );
490
+ $plpython -> AddReference($postgres );
491
+
492
+ # Add transform modules dependent on plpython
493
+ AddTransformModule(' hstore_plpython' . $pymajorver ,
494
+ ' contrib/hstore_plpython' ,
495
+ ' plpython' . $pymajorver ,
496
+ ' src/pl/plpython' , ' hstore' ,
497
+ ' contrib/hstore' );
498
+ AddTransformModule(' ltree_plpython' . $pymajorver ,
499
+ ' contrib/ltree_plpython' ,
500
+ ' plpython' . $pymajorver ,
501
+ ' src/pl/plpython' , ' ltree' ,
502
+ ' contrib/ltree' );
503
+ }
504
+
505
+ if ($solution -> {options }-> {perl })
506
+ {
507
+ my $plperlsrc = " src/pl/plperl/" ;
508
+ my $plperl =
509
+ $solution -> AddProject(' plperl' , ' dll' , ' PLs' , ' src/pl/plperl' );
510
+ $plperl -> AddIncludeDir($solution -> {options }-> {perl } . ' /lib/CORE' );
511
+ $plperl -> AddDefine(' PLPERL_HAVE_UID_GID' );
512
+ foreach my $xs (' SPI.xs' , ' Util.xs' )
513
+ {
514
+ (my $xsc = $xs ) =~ s /\. xs/ .c/ ;
515
+ if (Solution::IsNewer(" $plperlsrc$xsc " , " $plperlsrc$xs " ))
516
+ {
517
+ my $xsubppdir = first { -e " $_ /ExtUtils/xsubpp" } @INC ;
518
+ print " Building $plperlsrc$xsc ...\n " ;
519
+ system ( $solution -> {options }-> {perl }
520
+ . ' /bin/perl '
521
+ . " $xsubppdir /ExtUtils/xsubpp -typemap "
522
+ . $solution -> {options }-> {perl }
523
+ . ' /lib/ExtUtils/typemap '
524
+ . " $plperlsrc$xs "
525
+ . " >$plperlsrc$xsc " );
526
+ if ((!(-f " $plperlsrc$xsc " )) || -z " $plperlsrc$xsc " )
527
+ {
528
+ unlink (" $plperlsrc$xsc " ); # if zero size
529
+ die " Failed to create $xsc .\n " ;
530
+ }
531
+ }
532
+ }
533
+ if (Solution::IsNewer(
534
+ ' src/pl/plperl/perlchunks.h' ,
535
+ ' src/pl/plperl/plc_perlboot.pl' )
536
+ || Solution::IsNewer(
537
+ ' src/pl/plperl/perlchunks.h' ,
538
+ ' src/pl/plperl/plc_trusted.pl' ))
539
+ {
540
+ print ' Building src/pl/plperl/perlchunks.h ...' . " \n " ;
541
+ my $basedir = getcwd;
542
+ chdir ' src/pl/plperl' ;
543
+ system ( $solution -> {options }-> {perl }
544
+ . ' /bin/perl '
545
+ . ' text2macro.pl '
546
+ . ' --strip="^(\#.*|\s*)$$" '
547
+ . ' plc_perlboot.pl plc_trusted.pl '
548
+ . ' >perlchunks.h' );
549
+ chdir $basedir ;
550
+ if ((!(-f ' src/pl/plperl/perlchunks.h' ))
551
+ || -z ' src/pl/plperl/perlchunks.h' )
552
+ {
553
+ unlink (' src/pl/plperl/perlchunks.h' ); # if zero size
554
+ die ' Failed to create perlchunks.h' . " \n " ;
555
+ }
556
+ }
557
+ if (Solution::IsNewer(
558
+ ' src/pl/plperl/plperl_opmask.h' ,
559
+ ' src/pl/plperl/plperl_opmask.pl' ))
560
+ {
561
+ print ' Building src/pl/plperl/plperl_opmask.h ...' . " \n " ;
562
+ my $basedir = getcwd;
563
+ chdir ' src/pl/plperl' ;
564
+ system ( $solution -> {options }-> {perl }
565
+ . ' /bin/perl '
566
+ . ' plperl_opmask.pl '
567
+ . ' plperl_opmask.h' );
568
+ chdir $basedir ;
569
+ if ((!(-f ' src/pl/plperl/plperl_opmask.h' ))
570
+ || -z ' src/pl/plperl/plperl_opmask.h' )
571
+ {
572
+ unlink (' src/pl/plperl/plperl_opmask.h' ); # if zero size
573
+ die ' Failed to create plperl_opmask.h' . " \n " ;
574
+ }
575
+ }
576
+ $plperl -> AddReference($postgres );
577
+ my @perl_libs =
578
+ grep { / perl\d +.lib$ / }
579
+ glob ($solution -> {options }-> {perl } . ' \lib\CORE\perl*.lib' );
580
+ if (@perl_libs == 1)
581
+ {
582
+ $plperl -> AddLibrary($perl_libs [0]);
583
+ }
584
+ else
585
+ {
586
+ die " could not identify perl library version" ;
587
+ }
588
+
589
+ # Add transform module dependent on plperl
590
+ my $hstore_plperl =
591
+ AddTransformModule(' hstore_plperl' , ' contrib/hstore_plperl' ,
592
+ ' plperl' , ' src/pl/plperl' ,
593
+ ' hstore' , ' contrib/hstore' );
594
+ $hstore_plperl -> AddDefine(' PLPERL_HAVE_UID_GID' );
595
+ }
596
+
574
597
$mf =
575
598
Project::read_file(' src/backend/utils/mb/conversion_procs/Makefile' );
576
599
$mf =~ s {\\\r ?\n } {} g ;
@@ -680,6 +703,68 @@ sub AddSimpleFrontend
680
703
return $p ;
681
704
}
682
705
706
+ # Add a simple transform module
707
+ sub AddTransformModule
708
+ {
709
+ my $n = shift ;
710
+ my $n_src = shift ;
711
+ my $pl_proj_name = shift ;
712
+ my $pl_src = shift ;
713
+ my $transform_name = shift ;
714
+ my $transform_src = shift ;
715
+
716
+ my $transform_proj = undef ;
717
+ foreach my $proj (@{ $solution -> {projects }-> {' contrib' } })
718
+ {
719
+ if ($proj -> {name } eq $transform_name )
720
+ {
721
+ $transform_proj = $proj ;
722
+ last ;
723
+ }
724
+ }
725
+ die " could not find base module $transform_name for transform module $n "
726
+ if (!defined ($transform_proj ));
727
+
728
+ my $pl_proj = undef ;
729
+ foreach my $proj (@{ $solution -> {projects }-> {' PLs' } })
730
+ {
731
+ if ($proj -> {name } eq $pl_proj_name )
732
+ {
733
+ $pl_proj = $proj ;
734
+ last ;
735
+ }
736
+ }
737
+ die " could not find PL $pl_proj_name for transform module $n "
738
+ if (!defined ($pl_proj ));
739
+
740
+ my $p = $solution -> AddProject($n , ' dll' , ' contrib' , $n_src );
741
+ for my $file (glob (" $n_src /*.c" ))
742
+ {
743
+ $p -> AddFile($file );
744
+ }
745
+ $p -> AddReference($postgres );
746
+
747
+ # Add PL dependencies
748
+ $p -> AddIncludeDir($pl_src );
749
+ $p -> AddReference($pl_proj );
750
+ $p -> AddIncludeDir($pl_proj -> {includes });
751
+ foreach my $pl_lib (@{$pl_proj -> {libraries }})
752
+ {
753
+ $p -> AddLibrary($pl_lib );
754
+ }
755
+
756
+ # Add base module dependencies
757
+ $p -> AddIncludeDir($transform_src );
758
+ $p -> AddIncludeDir($transform_proj -> {includes });
759
+ foreach my $trans_lib (@{$transform_proj -> {libraries }})
760
+ {
761
+ $p -> AddLibrary($trans_lib );
762
+ }
763
+ $p -> AddReference($transform_proj );
764
+
765
+ return $p ;
766
+ }
767
+
683
768
# Add a simple contrib project
684
769
sub AddContrib
685
770
{
0 commit comments