mirror of
https://github.com/ysoftdevs/cpp-examples.git
synced 2026-01-11 14:30:32 +01:00
use gradle to build example
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
// sdl2-sample.cpp : SDL2 example - initialize and quit
|
||||
//
|
||||
|
||||
#include <tchar.h>
|
||||
#include "SDL.h"
|
||||
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
{
|
||||
SDL_Init(SDL_INIT_EVERYTHING);
|
||||
SDL_Quit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
28
sdl/01-sdl2-init/build.gradle
Normal file
28
sdl/01-sdl2-init/build.gradle
Normal file
@@ -0,0 +1,28 @@
|
||||
apply plugin: 'c'
|
||||
apply plugin: 'visual-studio'
|
||||
|
||||
sources {
|
||||
main {
|
||||
c {
|
||||
source {
|
||||
// Include just source, avoid including *.swp and other helper files
|
||||
include "**/*.c"
|
||||
}
|
||||
exportedHeaders {
|
||||
srcDir "../build/SDL2-2.0.3/include"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
executables {
|
||||
main {
|
||||
binaries.all {
|
||||
if (toolChain in VisualCpp) {
|
||||
linker.args "/machine:X86", "/SUBSYSTEM:WINDOWS", "../build/SDL2-2.0.3/lib/x86/SDL2.lib"
|
||||
//linker.args "/SUBSYSTEM:WINDOWS", "/LIBPATH:../build/SDL2-2.0.3/lib/x86/", "SDL2.lib"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
11
sdl/01-sdl2-init/src/main/c/sdl-init.c
Normal file
11
sdl/01-sdl2-init/src/main/c/sdl-init.c
Normal file
@@ -0,0 +1,11 @@
|
||||
// sdl2-sample.cpp : SDL2 example - initialize and quit
|
||||
//
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
SDL_Init(SDL_INIT_EVERYTHING);
|
||||
SDL_Quit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
Write-Host("Downloading library")
|
||||
$workingPath = (Get-Location).path
|
||||
$clnt = new-object System.Net.WebClient
|
||||
$url = "http://libsdl.org/release/SDL2-devel-2.0.1-VC.zip"
|
||||
$file = $workingPath + "\SDL2-devel-2.0.1-VC.zip"
|
||||
$clnt.DownloadFile($url,$file)
|
||||
|
||||
Write-Host("Unzip the file to local directory")
|
||||
$shell_app=new-object -com shell.application
|
||||
$zip_file = $shell_app.namespace($file)
|
||||
$destination = $shell_app.namespace($workingPath)
|
||||
$destination.Copyhere($zip_file.items())
|
||||
|
||||
Write-Host("Done")
|
||||
31
sdl/build.gradle
Normal file
31
sdl/build.gradle
Normal file
@@ -0,0 +1,31 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'de.undercouch:gradle-download-task:1.0'
|
||||
}
|
||||
}
|
||||
|
||||
import de.undercouch.gradle.tasks.download.Download
|
||||
|
||||
|
||||
task downloadSdl(type: Download) {
|
||||
description = "Download SDL2 library ZIP file."
|
||||
src 'http://libsdl.org/release/SDL2-devel-2.0.3-VC.zip'
|
||||
dest 'build/sdl2.zip'
|
||||
}
|
||||
|
||||
task extractSdl(type: Copy) {
|
||||
description = "Unpack SDL2 library"
|
||||
from zipTree('build/sdl2.zip')
|
||||
into 'build/'
|
||||
}
|
||||
|
||||
task prepare {
|
||||
description = "Prepare build environment for SDL2"
|
||||
}
|
||||
|
||||
|
||||
extractSdl.dependsOn downloadSdl
|
||||
prepare.dependsOn extractSdl
|
||||
Reference in New Issue
Block a user