Actually fix Linux build

At least on Debian, arch returns amd64 on Linux.  The moment I saw that
I realized that 32 bit wintel systems running Linux are going to return
everything from i386 to i686 at least.  Let's be proative about that if
we can.  :)

There's probably a plugin or module that does this behind the scenes,
but this is still much cleaner than what we had before.
This commit is contained in:
T. Joseph Carter 2017-11-18 02:21:21 -08:00
parent 9a88c1264f
commit 6e426d0b9c
1 changed files with 15 additions and 5 deletions

View File

@ -9,15 +9,25 @@ apply plugin: 'application'
mainClassName = 'com.webcodepro.applecommander.ui.AppleCommander'
// Configure build for each supported platform
def os = System.getProperty("os.name").toLowerCase()
def arch = System.getProperty("os.arch")
ext {
os = System.getProperty("os.name").toLowerCase()
arch = System.getProperty("os.arch").toLowerCase()
// First let's sanitize arch
if (arch.contains("amd64")) {
swtArch = "x86_64"
} else if (arch.matches("i[3-6]86]")) {
swtArch = "x86"
} else {
swtArch = arch
}
if (os.contains("windows")) {
swtGUI = "win32.win32.$arch"
swtGUI = "win32.win32.$swtArch"
} else if (os.contains("mac os x")) {
swtGUI = "cocoa.macosx.$arch"
swtGUI = "cocoa.macosx.$swtArch"
} else if (os.contains("linux")) {
swtGUI = "gtk.linux.$arch"
swtGUI = "gtk.linux.$swtArch"
} else {
throw new GradleException("Don't know how to build for this platform:\n" +
" os = \"$os\"\n" +