File: compilingplr.md

package info (click to toggle)
plr 1%3A8.4.8-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 1,172 kB
  • sloc: ansic: 4,742; sql: 629; sh: 357; makefile: 78; perl: 20
file content (115 lines) | stat: -rw-r--r-- 3,580 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
Copyright (c) 2003

I successfully did the following recently in order to build 64 bit PL/R
on Windows 10:

----------------
dumpbin /exports R.dll > R.dump.csv

Note that I used the csv extension so OpenOffice would import the file
into a spreadsheet conveniently.

Edit R.dump.csv to produce a one column file of symbols called R.def.

cat R.dump.csv | tr -s ' ' | cut -d ' ' -f 5 > R.def

Add the following two lines to the top of the file:
 LIBRARY R
 
 EXPORTS

Then run the following using R.def

 lib /def:R.def /out:R.lib

move R.lib to the bin dir of R

run build from postgres/src/tools/msvc
run install <dir> to install postgresql
initdb to create the cluster
start postgres using pg_ctl -D data -l logfile start_

vcregress plcheck will run the tests

I had to edit the test sql to comment out the loading of plr.sql to get the test to pass

Very important do make sure that your path points to the right location

IF YOU INSTALLED R IN Program Files\R\R... the PATH MUST HAVE C:\Program Files\R\R<version>\bin\x64 
	or C:\Program Files\R\R<version>\bin\i386

msvc.diff

```diff
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index fe905d3..97200bb 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -46,7 +46,7 @@ my @contrib_excludes = (
 	'ltree_plpython',  'pgcrypto',
 	'sepgsql',         'brin',
 	'test_extensions', 'test_pg_dump',
-	'snapshot_too_old');
+	'snapshot_too_old','plr');
 
 # Set of variables for frontend modules
 my $frontend_defines = { 'initdb' => 'FRONTEND' };
@@ -453,6 +453,15 @@ sub mkvcbuild
 	$pgcrypto->AddLibrary('ws2_32.lib');
 	my $mf = Project::read_file('contrib/pgcrypto/Makefile');
 	GenerateContribSqlFiles('pgcrypto', $mf);
+ 	my $plr = $solution->AddProject('plr','dll','plr');
+     	$plr->AddFiles(
+       	  'src\pl\plr','plr.c','pg_conversion.c','pg_backend_support.c','pg_userfuncs.c','pg_rsupport.c'
+     	);
+     	$plr->AddReference($postgres);
+     	$plr->AddLibrary('C:\Program Files\R\R-3.3.1\bin\R.lib');
+     	$plr->AddIncludeDir('C:\Program Files\R\R-3.3.1\include');
+     	my $mfplr = Project::read_file('src/pl/plr/Makefile');
+     	GenerateContribSqlFiles('plr', $mfplr);
 
 	foreach my $subdir ('contrib', 'src/test/modules')
 	{
@@ -822,14 +831,14 @@ sub GenerateContribSqlFiles
 
 			if (Solution::IsNewer("contrib/$n/$out", "contrib/$n/$in"))
 			{
-				print "Building $out from $in (contrib/$n)...\n";
-				my $cont = Project::read_file("contrib/$n/$in");
+				print "Building $out from $in (src/pl/$n)...\n";
+				my $cont = Project::read_file("src/pl/$n/$in");
 				my $dn   = $out;
 				$dn   =~ s/\.sql$//;
 				$cont =~ s/MODULE_PATHNAME/\$libdir\/$dn/g;
 				my $o;
-				open($o, ">contrib/$n/$out")
-				  || croak "Could not write to contrib/$n/$d";
+				open($o, ">src/pl/$n/$out")
+				  || croak "Could not write to src/pl/$n/$d";
 				print $o $cont;
 				close($o);
 			}
diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
index b4f9464..9593d36 100644
--- a/src/tools/msvc/vcregress.pl
+++ b/src/tools/msvc/vcregress.pl
@@ -222,7 +222,7 @@ sub plcheck
 {
 	chdir "../../pl";
 
-	foreach my $pl (glob("*"))
+	foreach my $pl (glob("plr"))
 	{
 		next unless -d "$pl/sql" && -d "$pl/expected";
 		my $lang = $pl eq 'tcl' ? 'pltcl' : $pl;
@@ -260,6 +260,7 @@ sub plcheck
 			"../../../$Config/pg_regress/pg_regress",
 			"--bindir=../../../$Config/psql",
 			"--dbname=pl_regression", @lang_args, @tests);
+		print join(" ", @args) . "\n";
 		system(@args);
 		my $status = $? >> 8;
 		exit $status if $status;
```