-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.pl
executable file
·80 lines (69 loc) · 1.43 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
#!/usr/bin/perl
use warnings;
use strict;
use Getopt::Long;
use Cwd;
use File::Path qw (rmtree mkpath);
my ($target, @configs);
GetOptions("target=s"=>\$target, "configs=s"=>\@configs);
@configs = split(/,/,join(',',@configs));
sub BuildLinux ($);
if (not $target)
{
if ($^O eq "darwin")
{
$target = "mac";
}
elsif ($^O eq "MSWin32")
{
$target = "win32";
}
}
if ($target eq "mac")
{
BuildMac();
}
elsif ($target eq "win32")
{
BuildWin32();
}
elsif ($target eq "linux32")
{
BuildLinux ($target);
}
elsif ($target eq "linux64")
{
BuildLinux ($target);
}
else
{
die ("Unknown platform");
}
sub BuildMac
{
system ("rm", "-rf", "Build");
system("make" , "-f", "Makefile.osx", "all") && die ("Failed to build version control plugins");
}
sub BuildWin32
{
rmtree("Build");
system("msbuilder.cmd", "VersionControl.sln", "P4Plugin", "Win32") && die ("Failed to build PerforcePlugin.exe");
}
sub BuildLinux ($)
{
my $platform = shift;
my $cflags = '-O3 -fPIC -fexceptions -fvisibility=hidden -DLINUX';
my $cxxflags = "$cflags -Wno-ctor-dtor-private";
my $ldflags = '';
if ($platform eq 'linux32') {
$cflags = "$cflags -m32";
$cxxflags = "$cxxflags -m32";
$ldflags = '-m32';
}
$ENV{'CFLAGS'} = $cflags;
$ENV{'CXXFLAGS'} = $cxxflags;
$ENV{'LDFLAGS'} = $ldflags;
$ENV{'PLATFORM'} = $platform;
system ('make', '-f', 'Makefile.gnu', 'clean');
system ('make', '-f', 'Makefile.gnu') && die ("Failed to build $platform");
}