forked from TASEmulators/fceux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.pl
executable file
·170 lines (149 loc) · 4.08 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
#!/usr/bin/perl
use strict;
use File::Basename;
#use File::Spec;
#
# Global Variables
#
my $platform = "";
my $fceuVersionMajor = 1;
my $fceuVersionMinor = 0;
my $fceuVersionPatch = 0;
foreach my $arg (@ARGV)
{
#print $arg, "\n";
if ($platform eq "")
{
$platform = $arg;
}
}
my $dirname = dirname(__FILE__);
my $projRoot = "$dirname/..";
my $ReleaseBuild=0;
my $ReleaseVersion="";
#print "PATH: $ENV{PATH}\n";
#print "Dir $dirname\n";
#
($fceuVersionMajor, $fceuVersionMinor, $fceuVersionPatch) = getVersion();
($ReleaseBuild, $ReleaseVersion) = isReleaseBuild();
if ($ReleaseBuild)
{
$ENV{FCEU_RELEASE_VERSION} = $ReleaseVersion;
}
if ($platform eq "win32")
{
build_win32();
}
elsif ($platform eq "win64")
{
build_win64();
}
elsif ($platform eq "win64-QtSDL")
{
build_win64_QtSDL();
}
elsif ($platform eq "linux")
{
build_ubuntu_linux();
}
elsif ($platform eq "macOS")
{
build_macOS();
}
#--------------------------------------------------------------------------------------------
# Build win32 version
#--------------------------------------------------------------------------------------------
sub build_win32
{
chdir("$projRoot");
my $ret = system("cmd.exe /c pipelines\\\\win32_build.bat");
if ($ret != 0){ die "Build Errors Detected\n";}
}
#--------------------------------------------------------------------------------------------
# Build win64 version
#--------------------------------------------------------------------------------------------
sub build_win64
{
chdir("$projRoot");
my $ret = system("cmd.exe /c pipelines\\\\win64_build.bat");
if ($ret != 0){ die "Build Errors Detected\n";}
}
#--------------------------------------------------------------------------------------------
# Build win64-Qt/SDL version
#--------------------------------------------------------------------------------------------
sub build_win64_QtSDL
{
chdir("$projRoot");
my $ret = system("cmd.exe /c pipelines\\\\qwin64_build.bat");
if ($ret != 0){ die "Build Errors Detected\n";}
}
#--------------------------------------------------------------------------------------------
# Build Ubuntu Linux version
#--------------------------------------------------------------------------------------------
sub build_ubuntu_linux
{
chdir("$projRoot");
my $ret = system("./pipelines/linux_build.sh");
if ($ret != 0){ die "Build Errors Detected\n";}
}
#--------------------------------------------------------------------------------------------
# Build MacOSX version
#--------------------------------------------------------------------------------------------
sub build_macOS
{
chdir("$projRoot");
my $ret = system("./pipelines/macOS_build.sh");
if ($ret != 0){ die "Build Errors Detected\n";}
}
#--------------------------------------------------------------------------------------------
# Search src/version.h and retrieve version numbers
#--------------------------------------------------------------------------------------------
sub getVersion
{
my $versionHeader = "$projRoot/src/version.h";
my $line;
my $major = 1;
my $minor = 0;
my $patch = 0;
open INFILE, "$versionHeader" or die "Error: Could not open file: $versionHeader\n";
while ($line = <INFILE>)
{
#print $line;
if ($line =~ m/\s*#define\s+FCEU_VERSION_MAJOR\s+(\d+)/)
{
$major = $1;
}
elsif ($line =~ m/\s*#define\s+FCEU_VERSION_MINOR\s+(\d+)/)
{
$minor = $1;
}
elsif ($line =~ m/\s*#define\s+FCEU_VERSION_PATCH\s+(\d+)/)
{
$patch = $1;
}
}
close(INFILE);
return ( $major, $minor, $patch );
}
#--------------------------------------------------------------------------------------------
# Returns whether this is a release build and returns the version if detected
#--------------------------------------------------------------------------------------------
sub isReleaseBuild
{
my $isRelease = 0;
my $tagVersion = "";
if (defined($ENV{APPVEYOR_REPO_TAG_NAME}))
{
if ($ENV{APPVEYOR_REPO_TAG_NAME} =~ m/fceux-(\d+\.\d+\.\d+)/)
{
$tagVersion = $1;
$isRelease = 1;
}
elsif ($ENV{APPVEYOR_REPO_TAG_NAME} =~ m/(\d+\.\d+\.\d+)/)
{
$tagVersion = $1;
$isRelease = 1;
}
}
return ($isRelease, $tagVersion);
}