-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathbuild.pl
More file actions
executable file
·207 lines (180 loc) · 5.53 KB
/
build.pl
File metadata and controls
executable file
·207 lines (180 loc) · 5.53 KB
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
#!/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
{
# Need to test both architectures if possible
TestMacX64();
TestMacArm64();
}
}
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()
{
my $failed = 0;
$failed += IntegrationTest("1-7", "Plugin", "localhost:1667", $testoption, $filter);
$failed += IntegrationTest("2-7", "Plugin", "ssl:localhost:1667", $testoption, $filter);
$failed += IntegrationTest("3-7", "Perforce/Common", "localhost:1667", $testoption, $filter);
$failed += IntegrationTest("4-7", "Perforce/Common", "ssl:localhost:1667", $testoption, $filter);
$failed += IntegrationTest("5-7", "Perforce/BaseIPv4", "tcp4:localhost:1667", $testoption, $filter);
$failed += IntegrationTest("6-7", "Perforce/SecureBaseIPv4", "ssl4:localhost:1667", $testoption, $filter);
$failed += IntegrationTest("7-7", "Perforce/SquareBracketIPv4", "tcp4:[localhost]:1667", $testoption, $filter);
# Only works locally, not in CI
# $failed += IntegrationTest("8-7", "Perforce/MultiFactorAuthentication", "localhost:1667", $testoption, $filter);
# Only works if DNS routes via IPv6
# $failed += IntegrationTest("9-7", "Perforce/BaseIPv6", "tcp6:[localhost]:1667", $testoption, $filter);
# Does not work in new version of Perforce server
# $failed += IntegrationTest("10-7", "Perforce/SquareBracketIPv6", "tcp6:[::1]:1667", $testoption, $filter);
# $failed += IntegrationTest("11-7", "Perforce/SecureSquareBracketIPv6", "ssl6:[::1]:1667", $testoption, $filter);
if ($failed > 0)
{
print "\nFAILURE $failed Perforce Integrations Test(s) failed!\n\n";
exit 1;
}
else
{
print "\nSUCCESS: All Perforce Integrations Tests passed\n\n";
}
}
sub BuildMac
{
rmtree("Build");
system("make", "-f", "Makefile.osx", "clean-objs") && die ("Failed to clean build artifacts");
$ENV{'BUILD_TARGET'} = "P4PluginX64";
system("make", "-f", "Makefile.osx", "all") && die ("Failed to build macOS x64 version control plugin");
# In between architectures clean up object files so they are not reused.
system("make", "-f", "Makefile.osx", "clean-objs") && die ("Failed to clean build artifacts");
$ENV{'BUILD_TARGET'} = "P4PluginArm64";
system("make", "-f", "Makefile.osx", "all") && die ("Failed to build macOS arm64 version control plugin");
system("mkdir -p Build/OSX");
system("lipo", "-create", "Build/OSXarm64/PerforcePlugin", "Build/OSXx64/PerforcePlugin", "-output", "Build/OSX/PerforcePlugin") && die ("Failed to create a universal macOS build version control plugin");
system("lipo", "-create", "Build/OSXarm64/TestServer", "Build/OSXx64/TestServer", "-output", "Build/OSX/TestServer") && die ("Failed to create a universal macOS test server");
}
sub TestMacX64
{
$ENV{'P4DEXEC'} = "PerforceBinaries/OSX/x86_64/p4d";
$ENV{'P4EXEC'} = "PerforceBinaries/OSX/x86_64/p4";
$ENV{'P4PLUGIN'} = "Build/OSX/PerforcePlugin";
$ENV{'TESTSERVER'} = "Build/OSX/TestServer";
# Teamcity artifacts looses their file attributes on transfer
chmod 0755, glob("Build/OSX/*");
TestPerforce();
}
sub TestMacArm64
{
$ENV{'P4DEXEC'} = "PerforceBinaries/OSX/arm64/p4d";
$ENV{'P4EXEC'} = "PerforceBinaries/OSX/arm64/p4";
$ENV{'P4PLUGIN'} = "Build/OSX/PerforcePlugin";
$ENV{'TESTSERVER'} = "Build/OSX/TestServer";
# Teamcity artifacts looses their file attributes on transfer
chmod 0755, glob("Build/OSX/*");
TestPerforce();
}
sub BuildWin32
{
rmtree("Build");
system("msbuilder.cmd", "VersionControl.sln", "P4Plugin", "Win32") && die ("Failed to build PerforcePlugin.exe");
system("msbuilder.cmd", "VersionControl.sln", "TestServer", "Win32") && 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 ($)
{
system ('make', '-f', 'Makefile.gnu', 'clean');
system ('make', '-f', 'Makefile.gnu') && die ("Failed to build PerforcePlugin for linux64");
}
sub TestLinux ($)
{
$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();
}