Browse Source

Improved SDL sample with clone scripts and directory scanning.

pull/621/merge
João Matos 10 years ago
parent
commit
d02192ed66
  1. 23
      examples/SDL/SDL.cs
  2. 21
      examples/SDL/SDL.lua
  3. 3
      examples/SDL/premake4.lua

23
examples/SDL/SDL.cs

@ -1,5 +1,7 @@ @@ -1,5 +1,7 @@
using CppSharp.AST;
using CppSharp.Passes;
using System;
using System.IO;
namespace CppSharp
{
@ -10,7 +12,8 @@ namespace CppSharp @@ -10,7 +12,8 @@ namespace CppSharp
var options = driver.Options;
options.LibraryName = "SDL";
options.Headers.Add("SDL.h");
options.addIncludeDirs("../../../examples/SDL/SDL-2.0/include");
var sdlPath = Path.Combine(GetExamplesDirectory("SDL"), "SDL-2.0/include");
options.addIncludeDirs(sdlPath);
options.OutputDir = "SDL";
}
@ -64,6 +67,24 @@ namespace CppSharp @@ -64,6 +67,24 @@ namespace CppSharp
ctx.SetNameOfEnumWithName("LOG_CATEGORY", "LogCategory");
}
public static string GetExamplesDirectory(string name)
{
var directory = Directory.GetParent(Directory.GetCurrentDirectory());
while (directory != null)
{
var path = Path.Combine(directory.FullName, "examples", name);
if (Directory.Exists(path))
return path;
directory = directory.Parent;
}
throw new Exception(string.Format(
"Examples directory for project '{0}' was not found", name));
}
static class Program
{
public static void Main(string[] args)

21
examples/SDL/SDL.lua

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
package.path = package.path .. "../build/?.lua;../../build/scripts/?.lua"
require "Helpers"
require "Utils"
function clone_sdl()
local sdl = path.getabsolute(examplesdir .. "/SDL/SDL-2.0")
local repo = "https://github.com/spurious/SDL-mirror.git"
if os.isdir(sdl) and not os.isdir(sdl .. "/.git") then
error("SDL directory is not a git repository.")
end
if not os.isdir(sdl) then
git.clone(sdl, repo)
end
end
if _ACTION == "clone_sdl" then
clone_sdl()
os.exit()
end

3
examples/SDL/premake4.lua

@ -46,5 +46,4 @@ project "SDL.Tests" @@ -46,5 +46,4 @@ project "SDL.Tests"
libdir .. "/SDL/SDL_video.cs",
"*.lua"
}
end
end

Loading…
Cancel
Save