Skip to content

Commit 2650fdb

Browse files
committed
Added the gen_probackup_project.pl script for project generation
1 parent 059d384 commit 2650fdb

File tree

1 file changed

+190
-0
lines changed

1 file changed

+190
-0
lines changed

gen_probackup_project.pl

+190
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
# -*-perl-*- hey - emacs - this is a perl file
2+
BEGIN{
3+
use Cwd;
4+
use File::Basename;
5+
6+
my $pgsrc="";
7+
if (@ARGV==1)
8+
{
9+
$pgsrc = shift @ARGV;
10+
if($pgsrc == "--help"){
11+
print STDERR "Usage $0 pg-source-dir \n";
12+
print STDERR "Like this: \n";
13+
print STDERR "$0 C:/PgProject/postgresql.10dev/postgrespro \n";
14+
print STDERR "May be need input this before: \n";
15+
print STDERR "CALL \"C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\vcvarsall\" amd64\n";
16+
exit 1;
17+
}
18+
}
19+
else
20+
{
21+
use Cwd qw(abs_path);
22+
my $path = dirname(abs_path($0));
23+
chdir($path);
24+
chdir("../..");
25+
$pgsrc = cwd();
26+
}
27+
28+
chdir("$pgsrc/src/tools/msvc");
29+
push(@INC, "$pgsrc/src/tools/msvc");
30+
chdir("../../..") if (-d "../msvc" && -d "../../../src");
31+
32+
}
33+
34+
use Win32;
35+
use Carp;
36+
use strict;
37+
use warnings;
38+
39+
40+
use Project;
41+
use Solution;
42+
use File::Copy;
43+
use Config;
44+
use VSObjectFactory;
45+
use List::Util qw(first);
46+
47+
use Exporter;
48+
our (@ISA, @EXPORT_OK);
49+
@ISA = qw(Exporter);
50+
@EXPORT_OK = qw(Mkvcbuild);
51+
52+
my $solution;
53+
my $libpgport;
54+
my $libpgcommon;
55+
my $libpgfeutils;
56+
my $postgres;
57+
my $libpq;
58+
my @unlink_on_exit;
59+
60+
61+
use lib "src/tools/msvc";
62+
63+
use Mkvcbuild;
64+
65+
# if (-e "src/tools/msvc/buildenv.pl")
66+
# {
67+
# do "src/tools/msvc/buildenv.pl";
68+
# }
69+
# elsif (-e "./buildenv.pl")
70+
# {
71+
# do "./buildenv.pl";
72+
# }
73+
74+
# set up the project
75+
our $config;
76+
do "config_default.pl";
77+
do "config.pl" if (-f "src/tools/msvc/config.pl");
78+
79+
# my $vcver = Mkvcbuild::mkvcbuild($config);
80+
my $vcver = build_pgprobackup($config);
81+
82+
# check what sort of build we are doing
83+
84+
my $bconf = $ENV{CONFIG} || "Release";
85+
my $msbflags = $ENV{MSBFLAGS} || "";
86+
my $buildwhat = $ARGV[1] || "";
87+
if (uc($ARGV[0]) eq 'DEBUG')
88+
{
89+
$bconf = "Debug";
90+
}
91+
elsif (uc($ARGV[0]) ne "RELEASE")
92+
{
93+
$buildwhat = $ARGV[0] || "";
94+
}
95+
96+
# ... and do it
97+
system("msbuild pg_probackup.vcxproj /verbosity:normal $msbflags /p:Configuration=$bconf" );
98+
99+
100+
# report status
101+
102+
my $status = $? >> 8;
103+
104+
exit $status;
105+
106+
107+
108+
sub build_pgprobackup
109+
{
110+
our $config = shift;
111+
112+
chdir('../../..') if (-d '../msvc' && -d '../../../src');
113+
die 'Must run from root or msvc directory'
114+
unless (-d 'src/tools/msvc' && -d 'src');
115+
116+
# my $vsVersion = DetermineVisualStudioVersion();
117+
my $vsVersion = '12.00';
118+
119+
$solution = CreateSolution($vsVersion, $config);
120+
121+
$libpq = $solution->AddProject('libpq', 'dll', 'interfaces',
122+
'src/interfaces/libpq');
123+
$libpgfeutils = $solution->AddProject('libpgfeutils', 'lib', 'misc');
124+
$libpgcommon = $solution->AddProject('libpgcommon', 'lib', 'misc');
125+
$libpgport = $solution->AddProject('libpgport', 'lib', 'misc');
126+
127+
#vvs test
128+
my $probackup =
129+
$solution->AddProject('pg_probackup', 'exe', 'pg_probackup'); #, 'contrib/pg_probackup'
130+
$probackup->AddFiles(
131+
'contrib/pg_probackup/src',
132+
'archive.c',
133+
'backup.c',
134+
'catalog.c',
135+
'configure.c',
136+
'data.c',
137+
'delete.c',
138+
'dir.c',
139+
'fetch.c',
140+
'help.c',
141+
'init.c',
142+
'parsexlog.c',
143+
'pg_probackup.c',
144+
'restore.c',
145+
'show.c',
146+
'status.c',
147+
'util.c',
148+
'validate.c'
149+
);
150+
$probackup->AddFiles(
151+
'contrib/pg_probackup/src/utils',
152+
'json.c',
153+
'logger.c',
154+
'parray.c',
155+
'pgut.c',
156+
'thread.c'
157+
);
158+
$probackup->AddFile('src/backend/access/transam/xlogreader.c');
159+
$probackup->AddFiles(
160+
'src/bin/pg_basebackup',
161+
'receivelog.c',
162+
'streamutil.c'
163+
);
164+
165+
if (-e 'src/bin/pg_basebackup/walmethods.c')
166+
{
167+
$probackup->AddFile('src/bin/pg_basebackup/walmethods.c');
168+
}
169+
170+
$probackup->AddFile('src/bin/pg_rewind/datapagemap.c');
171+
172+
$probackup->AddFile('src/interfaces/libpq/pthread-win32.c');
173+
174+
$probackup->AddIncludeDir('src/bin/pg_basebackup');
175+
$probackup->AddIncludeDir('src/bin/pg_rewind');
176+
$probackup->AddIncludeDir('src/interfaces/libpq');
177+
$probackup->AddIncludeDir('src');
178+
$probackup->AddIncludeDir('src/port');
179+
180+
$probackup->AddIncludeDir('contrib/pg_probackup');
181+
$probackup->AddIncludeDir('contrib/pg_probackup/src');
182+
$probackup->AddIncludeDir('contrib/pg_probackup/src/utils');
183+
184+
$probackup->AddReference($libpq, $libpgfeutils, $libpgcommon, $libpgport);
185+
$probackup->AddLibrary('ws2_32.lib');
186+
187+
$probackup->Save();
188+
return $solution->{vcver};
189+
190+
}

0 commit comments

Comments
 (0)