-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.pl
executable file
·171 lines (150 loc) · 3.84 KB
/
build.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
#!/usr/bin/perl
use warnings;
use strict;
use Getopt::Long;
use Cwd;
use File::Path qw (rmtree mkpath);
use lib 'Test';
use VCSTest;
use File::Find;
use File::Basename;
my ($testoption,$test, $target, $clean, @configs, $filter);
GetOptions("test"=>\$test, "testoption=s"=>\$testoption, "filter=s"=>\$filter,
"target=s"=>\$target, "configs=s"=>\@configs, "clean"=>\$clean);
@configs = split(/,/,join(',',@configs));
sub BuildLinux ($);
sub TestLinux ($);
$testoption = "nonverbose" unless ($testoption);
if ($clean)
{
rmtree("Debug");
rmtree("Release");
rmtree("Build");
find(\&wanted, "./");
sub wanted
{
my($filename, $dirs, $suffix) = fileparse($File::Find::name, qr/\.[^.]*/);
if (($suffix eq ".o") or ($suffix eq ".obj"))
{
print "delete $File::Find::name","\n";
unlink($_);
}
}
unlink("PerforcePlugin");
exit 0;
}
if (not $target)
{
if ($^O eq "darwin")
{
$target = "mac";
}
elsif ($^O eq "MSWin32")
{
$target = "win32";
}
elsif ($^O eq "linux")
{
$target = "linux64";
}
}
$ENV{'TARGET'} = $target;
if ($target eq "mac")
{
unless ($test)
{
BuildMac();
}
else
{
TestMac();
}
}
elsif ($target eq "win32")
{
unless ($test)
{
BuildWin32();
}
else
{
TestWin32();
}
}
elsif ($target eq "linux64")
{
unless ($test)
{
BuildLinux ($target);
}
else
{
TestLinux ($target);
}
}
else
{
die ("Unknown platform");
}
sub TestPerforce()
{
IntegrationTest("Plugin", "localhost:1667", $testoption, $filter);
IntegrationTest("Plugin", "ssl:localhost:1667", $testoption, $filter);
IntegrationTest("Perforce/Common", "localhost:1667", $testoption, $filter);
IntegrationTest("Perforce/Common", "ssl:localhost:1667", $testoption, $filter);
IntegrationTest("Perforce/BaseIPv4", "tcp4:localhost:1667", $testoption, $filter);
IntegrationTest("Perforce/SecureBaseIPv4", "ssl4:localhost:1667", $testoption, $filter);
IntegrationTest("Perforce/SquareBracketIPv4", "tcp4:[localhost]:1667", $testoption, $filter);
# Only works if DNS routes via IPv6
# IntegrationTest("Perforce/BaseIPv6", "tcp6:[localhost]:1667", $testoption, $filter);
# Does not work in new version of Perforce server
# IntegrationTest("Perforce/SquareBracketIPv6", "tcp6:[::1]:1667", $testoption, $filter);
# IntegrationTest("Perforce/SecureSquareBracketIPv6", "ssl6:[::1]:1667", $testoption, $filter);
IntegrationTest("Perforce/MultiFactorAuthentication", "localhost:1667", $testoption, $filter);
}
sub BuildMac
{
rmtree("Build");
system("make" , "-f", "Makefile.osx", "all") && die ("Failed to build version control plugins");
}
sub TestMac
{
$ENV{'P4DEXEC'} = "PerforceBinaries/OSX/p4d";
$ENV{'P4EXEC'} = "PerforceBinaries/OSX/p4";
$ENV{'P4PLUGIN'} = "Build/OSXx64/PerforcePlugin";
$ENV{'TESTSERVER'} = "Build/OSXx64/TestServer";
# Teamcity artifacts looses their file attributes on transfer
chmod 0755, glob("Build/OSXx64/*");
TestPerforce();
}
sub BuildWin32
{
rmtree("Build");
system("msbuilder.cmd", "/t:P4Plugin") && die ("Failed to build PerforcePlugin.exe");
system("msbuilder.cmd", "/t:TestServer") && die ("Failed to build TestServer.exe");
}
sub TestWin32
{
$ENV{'P4DEXEC'} = 'PerforceBinaries\Win_x64\p4d.exe';
$ENV{'P4EXEC'} = 'PerforceBinaries\Win_x64\p4.exe';
$ENV{'P4PLUGIN'} = 'Build\Win32\PerforcePlugin.exe';
$ENV{'TESTSERVER'} = 'Build\Win32\TestServer.exe';
TestPerforce();
}
sub BuildLinux ($)
{
my $platform = shift;
system ('make', '-f', 'Makefile.gnu', 'clean');
system ('make', '-f', 'Makefile.gnu') && die ("Failed to build $platform");
}
sub TestLinux ($)
{
my $platform = shift;
$ENV{'P4DEXEC'} = "PerforceBinaries/linux64/p4d";
$ENV{'P4EXEC'} = "PerforceBinaries/linux64/p4";
$ENV{'P4PLUGIN'} = "Build/linux64/PerforcePlugin";
$ENV{'TESTSERVER'} = "Build/linux64/TestServer";
# Teamcity artifacts looses their file attributes on transfer
chmod 0755, glob("Build/linux64/*");
TestPerforce();
}