add support for linux build

This commit is contained in:
Juraj Michalek
2014-04-19 20:57:36 +02:00
parent 2cdbccf10e
commit 57d35a9fd0
5 changed files with 28 additions and 8 deletions

View File

@@ -9,7 +9,7 @@ sources {
include "**/*.c"
}
exportedHeaders {
srcDir "../build/SDL2-2.0.3/include"
srcDir "../build/include"
}
}
}
@@ -20,7 +20,9 @@ executables {
binaries.all {
if (toolChain in VisualCpp) {
cCompiler.args "/MD"
linker.args "/SUBSYSTEM:CONSOLE", "/LIBPATH:../build/SDL2-2.0.3/lib/x86/", "SDL2main.lib", "SDL2.lib"
linker.args "/SUBSYSTEM:CONSOLE", "/LIBPATH:../build/lib/", "SDL2main.lib", "SDL2.lib"
} else if (toolChain in Gcc) {
linker.args "-lSDL2"
}
}
}

View File

@@ -1,6 +1,6 @@
// SDL2 example - initialize and quit
#include "SDL.h"
#include "SDL2/SDL.h"
int main(int argc, char** argv){
SDL_Init(SDL_INIT_EVERYTHING);

View File

@@ -5,11 +5,10 @@ sources {
main {
c {
source {
// Include just source, avoid including *.swp and other helper files
include "**/*.c"
}
exportedHeaders {
srcDir "../build/SDL2-2.0.3/include"
srcDir "../build/include"
}
}
}
@@ -20,7 +19,9 @@ executables {
binaries.all {
if (toolChain in VisualCpp) {
cCompiler.args "/MD"
linker.args "/SUBSYSTEM:CONSOLE", "/LIBPATH:../build/SDL2-2.0.3/lib/x86/", "SDL2main.lib", "SDL2.lib"
linker.args "/SUBSYSTEM:CONSOLE", "/LIBPATH:../build/lib/", "SDL2main.lib", "SDL2.lib"
} else if (toolChain in Gcc) {
linker.args "-lSDL2"
}
}
}

View File

@@ -2,7 +2,7 @@
//
#include <stdio.h>
#include "SDL.h"
#include "SDL2/SDL.h"
int main(int argc, char* argv[]) {
SDL_Window *win = NULL;

View File

@@ -1,3 +1,5 @@
apply plugin: 'c'
buildscript {
repositories {
mavenCentral()
@@ -22,10 +24,25 @@ task extractSdl(type: Copy) {
into 'build/'
}
task copySdlLib(type: Copy) {
from 'build/SDL2-2.0.3/lib/x86'
into 'build/lib/'
}
task copySdlInclude(type: Copy) {
description = "Copy SDL2 include to location compatible with Linux builds."
from "build/SDL2/include"
into "build/include/SDL2"
}
task prepare {
description = "Prepare build environment for SDL2"
}
extractSdl.dependsOn downloadSdl
prepare.dependsOn extractSdl
copySdlLib.dependsOn extractSdl
copySdlInclude.dependsOn extractSdl
prepare.dependsOn copySdlInclude
prepare.dependsOn copySdlLib