|
| 1 | +#!/usr/bin/perl |
| 2 | + |
| 3 | +use strict; |
| 4 | +use File::Basename; |
| 5 | +#use File::Spec; |
| 6 | + |
| 7 | +# |
| 8 | +# Global Variables |
| 9 | +# |
| 10 | +my $platform = ""; |
| 11 | +my $fceuVersionMajor = 1; |
| 12 | +my $fceuVersionMinor = 0; |
| 13 | +my $fceuVersionPatch = 0; |
| 14 | + |
| 15 | +foreach my $arg (@ARGV) |
| 16 | +{ |
| 17 | + #print $arg, "\n"; |
| 18 | + |
| 19 | + if ($platform eq "") |
| 20 | + { |
| 21 | + $platform = $arg; |
| 22 | + } |
| 23 | +} |
| 24 | + |
| 25 | +my $dirname = dirname(__FILE__); |
| 26 | +my $projRoot = "$dirname/.."; |
| 27 | +my $ReleaseBuild=0; |
| 28 | +my $ReleaseVersion=""; |
| 29 | + |
| 30 | +#print "PATH: $ENV{PATH}\n"; |
| 31 | +#print "Dir $dirname\n"; |
| 32 | +# |
| 33 | +($fceuVersionMajor, $fceuVersionMinor, $fceuVersionPatch) = getVersion(); |
| 34 | + |
| 35 | +($ReleaseBuild, $ReleaseVersion) = isReleaseBuild(); |
| 36 | + |
| 37 | +if ($ReleaseBuild) |
| 38 | +{ |
| 39 | + $ENV{FCEU_RELEASE_VERSION} = $ReleaseVersion; |
| 40 | +} |
| 41 | + |
| 42 | +if ($platform eq "win32") |
| 43 | +{ |
| 44 | + build_win32(); |
| 45 | +} |
| 46 | +elsif ($platform eq "win64") |
| 47 | +{ |
| 48 | + build_win64(); |
| 49 | +} |
| 50 | +elsif ($platform eq "win64-QtSDL") |
| 51 | +{ |
| 52 | + build_win64_QtSDL(); |
| 53 | +} |
| 54 | +elsif ($platform eq "linux") |
| 55 | +{ |
| 56 | + build_ubuntu_linux(); |
| 57 | +} |
| 58 | +elsif ($platform eq "macOS") |
| 59 | +{ |
| 60 | + build_macOS(); |
| 61 | +} |
| 62 | +#-------------------------------------------------------------------------------------------- |
| 63 | +# Build win32 version |
| 64 | +#-------------------------------------------------------------------------------------------- |
| 65 | +sub build_win32 |
| 66 | +{ |
| 67 | + chdir("$projRoot"); |
| 68 | + |
| 69 | + my $ret = system("cmd.exe /c pipelines\\\\win32_build.bat"); |
| 70 | + |
| 71 | + if ($ret != 0){ die "Build Errors Detected\n";} |
| 72 | +} |
| 73 | +#-------------------------------------------------------------------------------------------- |
| 74 | +# Build win64 version |
| 75 | +#-------------------------------------------------------------------------------------------- |
| 76 | +sub build_win64 |
| 77 | +{ |
| 78 | + chdir("$projRoot"); |
| 79 | + |
| 80 | + my $ret = system("cmd.exe /c pipelines\\\\win64_build.bat"); |
| 81 | + |
| 82 | + if ($ret != 0){ die "Build Errors Detected\n";} |
| 83 | +} |
| 84 | +#-------------------------------------------------------------------------------------------- |
| 85 | +# Build win64-Qt/SDL version |
| 86 | +#-------------------------------------------------------------------------------------------- |
| 87 | +sub build_win64_QtSDL |
| 88 | +{ |
| 89 | + chdir("$projRoot"); |
| 90 | + |
| 91 | + my $ret = system("cmd.exe /c pipelines\\\\qwin64_build.bat"); |
| 92 | + |
| 93 | + if ($ret != 0){ die "Build Errors Detected\n";} |
| 94 | +} |
| 95 | +#-------------------------------------------------------------------------------------------- |
| 96 | +# Build Ubuntu Linux version |
| 97 | +#-------------------------------------------------------------------------------------------- |
| 98 | +sub build_ubuntu_linux |
| 99 | +{ |
| 100 | + chdir("$projRoot"); |
| 101 | + |
| 102 | + my $ret = system("./pipelines/linux_build.sh"); |
| 103 | + |
| 104 | + if ($ret != 0){ die "Build Errors Detected\n";} |
| 105 | +} |
| 106 | +#-------------------------------------------------------------------------------------------- |
| 107 | +# Build MacOSX version |
| 108 | +#-------------------------------------------------------------------------------------------- |
| 109 | +sub build_macOS |
| 110 | +{ |
| 111 | + chdir("$projRoot"); |
| 112 | + |
| 113 | + my $ret = system("./pipelines/macOS_build.sh"); |
| 114 | + |
| 115 | + if ($ret != 0){ die "Build Errors Detected\n";} |
| 116 | +} |
| 117 | +#-------------------------------------------------------------------------------------------- |
| 118 | +# Search src/version.h and retrieve version numbers |
| 119 | +#-------------------------------------------------------------------------------------------- |
| 120 | +sub getVersion |
| 121 | +{ |
| 122 | + my $versionHeader = "$projRoot/src/version.h"; |
| 123 | + my $line; |
| 124 | + my $major = 1; |
| 125 | + my $minor = 0; |
| 126 | + my $patch = 0; |
| 127 | + open INFILE, "$versionHeader" or die "Error: Could not open file: $versionHeader\n"; |
| 128 | + while ($line = <INFILE>) |
| 129 | + { |
| 130 | + #print $line; |
| 131 | + if ($line =~ m/\s*#define\s+FCEU_VERSION_MAJOR\s+(\d+)/) |
| 132 | + { |
| 133 | + $major = $1; |
| 134 | + } |
| 135 | + elsif ($line =~ m/\s*#define\s+FCEU_VERSION_MINOR\s+(\d+)/) |
| 136 | + { |
| 137 | + $minor = $1; |
| 138 | + } |
| 139 | + elsif ($line =~ m/\s*#define\s+FCEU_VERSION_PATCH\s+(\d+)/) |
| 140 | + { |
| 141 | + $patch = $1; |
| 142 | + } |
| 143 | + } |
| 144 | + close(INFILE); |
| 145 | + |
| 146 | + return ( $major, $minor, $patch ); |
| 147 | +} |
| 148 | +#-------------------------------------------------------------------------------------------- |
| 149 | +# Returns whether this is a release build and returns the version if detected |
| 150 | +#-------------------------------------------------------------------------------------------- |
| 151 | +sub isReleaseBuild |
| 152 | +{ |
| 153 | + my $isRelease = 0; |
| 154 | + my $tagVersion = ""; |
| 155 | + |
| 156 | + if (defined($ENV{APPVEYOR_REPO_TAG_NAME})) |
| 157 | + { |
| 158 | + if ($ENV{APPVEYOR_REPO_TAG_NAME} =~ m/fceux-(\d+\.\d+\.\d+)/) |
| 159 | + { |
| 160 | + $tagVersion = $1; |
| 161 | + $isRelease = 1; |
| 162 | + } |
| 163 | + elsif ($ENV{APPVEYOR_REPO_TAG_NAME} =~ m/(\d+\.\d+\.\d+)/) |
| 164 | + { |
| 165 | + $tagVersion = $1; |
| 166 | + $isRelease = 1; |
| 167 | + } |
| 168 | + } |
| 169 | + return ($isRelease, $tagVersion); |
| 170 | +} |
0 commit comments