forked from postgrespro/pg_probackup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_probackup_project.pl
230 lines (191 loc) · 4.87 KB
/
gen_probackup_project.pl
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# -*-perl-*- hey - emacs - this is a perl file
# my $currpath = cwd();
our $pgsrc;
our $currpath;
BEGIN {
# path to the pg_probackup dir
$currpath = File::Basename::dirname(Cwd::abs_path($0));
use Cwd;
use File::Basename;
if (($#ARGV+1)==1)
{
$pgsrc = shift @ARGV;
if($pgsrc eq "--help"){
print STDERR "Usage $0 pg-source-dir \n";
print STDERR "Like this: \n";
print STDERR "$0 C:/PgProject/postgresql.10dev/postgrespro \n";
print STDERR "May be need input this before: \n";
print STDERR "CALL \"C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\vcvarsall\" amd64\n";
exit 1;
}
}
else
{
use Cwd qw(abs_path);
my $path = dirname(abs_path($0));
chdir($path);
chdir("../..");
$pgsrc = cwd();
$currpath = "contrib/pg_probackup";
}
chdir("$pgsrc/src/tools/msvc");
push(@INC, "$pgsrc/src/tools/msvc");
chdir("../../..") if (-d "../msvc" && -d "../../../src");
}
use Win32;
use Carp;
use strict;
use warnings;
use Project;
use Solution;
use File::Copy;
use Config;
use VSObjectFactory;
use List::Util qw(first);
use Exporter;
our (@ISA, @EXPORT_OK);
@ISA = qw(Exporter);
@EXPORT_OK = qw(Mkvcbuild);
my $solution;
my $libpgport;
my $libpgcommon;
my $libpgfeutils;
my $postgres;
my $libpq;
my @unlink_on_exit;
if (-d "src/fe_utils")
{
$libpgfeutils = 1;
}
else
{
$libpgfeutils = 0;
}
use lib "src/tools/msvc";
use Mkvcbuild;
# if (-e "src/tools/msvc/buildenv.pl")
# {
# do "src/tools/msvc/buildenv.pl";
# }
# elsif (-e "./buildenv.pl")
# {
# do "./buildenv.pl";
# }
# set up the project
our $config;
do "config_default.pl";
do "config.pl" if (-f "src/tools/msvc/config.pl");
# my $vcver = Mkvcbuild::mkvcbuild($config);
my $vcver = build_pgprobackup($config);
# check what sort of build we are doing
my $bconf = $ENV{CONFIG} || "Release";
my $msbflags = $ENV{MSBFLAGS} || "";
my $buildwhat = $ARGV[1] || "";
# if (uc($ARGV[0]) eq 'DEBUG')
# {
# $bconf = "Debug";
# }
# elsif (uc($ARGV[0]) ne "RELEASE")
# {
# $buildwhat = $ARGV[0] || "";
# }
# printf "currpath=$currpath";
# exit(0);
# ... and do it
system("msbuild pg_probackup.vcxproj /verbosity:normal $msbflags /p:Configuration=$bconf" );
# report status
my $status = $? >> 8;
printf("Status: $status\n");
printf("Output file built in the folder $pgsrc/$bconf/pg_probackup\n");
exit $status;
sub build_pgprobackup
{
our $config = shift;
chdir('../../..') if (-d '../msvc' && -d '../../../src');
die 'Must run from root or msvc directory'
unless (-d 'src/tools/msvc' && -d 'src');
# my $vsVersion = DetermineVisualStudioVersion();
my $vsVersion = '12.00';
$solution = CreateSolution($vsVersion, $config);
$libpq = $solution->AddProject('libpq', 'dll', 'interfaces',
'src/interfaces/libpq');
if ($libpgfeutils)
{
$libpgfeutils = $solution->AddProject('libpgfeutils', 'lib', 'misc');
}
$libpgcommon = $solution->AddProject('libpgcommon', 'lib', 'misc');
$libpgport = $solution->AddProject('libpgport', 'lib', 'misc');
#vvs test
my $probackup =
$solution->AddProject("pg_probackup", 'exe', "pg_probackup"); #, 'contrib/pg_probackup'
$probackup->AddDefine('FRONTEND');
$probackup->AddFiles(
"$currpath/src",
'archive.c',
'backup.c',
'catalog.c',
'configure.c',
'data.c',
'delete.c',
'dir.c',
'fetch.c',
'help.c',
'init.c',
'merge.c',
'parsexlog.c',
'pg_probackup.c',
'restore.c',
'show.c',
'stream.c',
'util.c',
'validate.c',
'checkdb.c',
'ptrack.c'
);
$probackup->AddFiles(
"$currpath/src/utils",
'configuration.c',
'file.c',
'remote.c',
'json.c',
'logger.c',
'parray.c',
'pgut.c',
'thread.c',
'remote.c'
);
$probackup->AddFile("$pgsrc/src/backend/access/transam/xlogreader.c");
$probackup->AddFile("$pgsrc/src/backend/utils/hash/pg_crc.c");
$probackup->AddFiles(
"$pgsrc/src/bin/pg_basebackup",
'receivelog.c',
'streamutil.c'
);
if (-e "$pgsrc/src/bin/pg_basebackup/walmethods.c")
{
$probackup->AddFile("$pgsrc/src/bin/pg_basebackup/walmethods.c");
}
$probackup->AddFile("$pgsrc/src/bin/pg_rewind/datapagemap.c");
$probackup->AddFile("$pgsrc/src/interfaces/libpq/pthread-win32.c");
$probackup->AddFile("$pgsrc/src/timezone/strftime.c");
$probackup->AddIncludeDir("$pgsrc/src/bin/pg_basebackup");
$probackup->AddIncludeDir("$pgsrc/src/bin/pg_rewind");
$probackup->AddIncludeDir("$pgsrc/src/interfaces/libpq");
$probackup->AddIncludeDir("$pgsrc/src");
$probackup->AddIncludeDir("$pgsrc/src/port");
$probackup->AddIncludeDir("$pgsrc/src/include/portability");
$probackup->AddIncludeDir("$currpath");
$probackup->AddIncludeDir("$currpath/src");
$probackup->AddIncludeDir("$currpath/src/utils");
if ($libpgfeutils)
{
$probackup->AddReference($libpq, $libpgfeutils, $libpgcommon, $libpgport);
}
else
{
$probackup->AddReference($libpq, $libpgcommon, $libpgport);
}
$probackup->AddLibrary('ws2_32.lib');
$probackup->Save();
return $solution->{vcver};
}