Browse Source

Updated build scripts with OS X fixes and added some building documentation.

pull/146/merge
Joao Matos 12 years ago
parent
commit
b19cd1042e
  1. 11
      build/Helpers.lua
  2. 20
      build/Tests.lua
  3. 12
      build/premake4.lua
  4. 20
      docs/GettingStarted.md
  5. 4
      examples/SDL/SDL.cs
  6. 5
      src/AST/AST.lua
  7. 3
      src/Core/Parser/ASTConverter.cs
  8. 7
      src/Core/premake4.lua
  9. 10
      src/CppParser/Bindings/premake4.lua
  10. 2
      src/Generator/Generator.lua
  11. 2
      src/Runtime/Runtime.lua

11
build/Helpers.lua

@ -30,7 +30,7 @@ end @@ -30,7 +30,7 @@ end
function SetupNativeProject()
location (path.join(builddir, "projects"))
c = configuration "Debug"
local c = configuration "Debug"
defines { "DEBUG" }
configuration "Release"
@ -57,6 +57,15 @@ function SetupNativeProject() @@ -57,6 +57,15 @@ function SetupNativeProject()
configuration(c)
end
function SetupManagedProject()
location (path.join(builddir, "projects"))
local c = configuration "vs*"
location "."
configuration(c)
end
function IncludeDir(dir)
local deps = os.matchdirs(dir .. "/*")

20
build/Tests.lua

@ -7,12 +7,9 @@ function SetupExampleProject() @@ -7,12 +7,9 @@ function SetupExampleProject()
files { "**.cs", "./*.lua" }
links { "CppSharp.AST", "CppSharp.Generator" }
SetupParser()
location (path.join(builddir, "projects"))
configuration "vs*"
location "."
SetupManagedProject()
SetupParser()
end
function SetupTestProject(name, file, lib)
@ -38,10 +35,7 @@ function SetupManagedTestProject() @@ -38,10 +35,7 @@ function SetupManagedTestProject()
kind "SharedLib"
language "C#"
flags { "Unsafe" }
local c = configuration "vs*"
location "."
configuration(c)
SetupManagedProject()
end
function SetupTestGeneratorProject(name)
@ -63,8 +57,12 @@ function SetupTestGeneratorProject(name) @@ -63,8 +57,12 @@ function SetupTestGeneratorProject(name)
end
function SetupTestGeneratorBuildEvent(name)
local exePath = SafePath("$(TargetDir)" .. name .. ".Gen.exe")
prebuildcommands { exePath }
local exePath = SafePath("%{cfg.buildtarget.directory}/" .. name .. ".Gen.exe")
if string.starts(action, "vs") then
prebuildcommands { exePath }
else
prebuildcommands { "mono " .. exePath }
end
end
function SetupTestNativeProject(name)

12
build/premake4.lua

@ -31,7 +31,11 @@ function SetupCLIParser() @@ -31,7 +31,11 @@ function SetupCLIParser()
end
function SetupCSharpParser()
links { "CppSharp.Parser.CSharp" }
links
{
"CppSharp.Parser.CSharp",
"CppSharp.Runtime"
}
end
function SetupParser()
@ -66,11 +70,15 @@ solution "CppSharp" @@ -66,11 +70,15 @@ solution "CppSharp"
configuration {}
if string.starts(action, "vs") then
group "Examples"
IncludeExamples()
group "Tests"
IncludeTests()
IncludeTests()
end
group "Libraries"
include (srcdir .. "/Core")

20
docs/GettingStarted.md

@ -20,7 +20,25 @@ source first. @@ -20,7 +20,25 @@ source first.
Building in *Release* is recommended because else the Clang parser will be
excruciatingly slow.
Last updated to LLVM/Clang revision: `r194603`
Last updated to LLVM/Clang revision: `r198449`
## Compiling on Mac OS X (experimental)
Requirements: Clang revision >= 198625
1. Clone CppSharp to `<CppSharp>`
2. Clone LLVM to `<CppSharp>\deps\llvm`
3. Clone Clang to `<CppSharp>\deps\llvm\tools\clang` (see:
[http://clang.llvm.org/get_started.html](http://clang.llvm.org/get_started.html))
4. Run CMake in `<CppSharp>\deps\llvm` and compile solution in *RelWithDebInfo* mode
The following CMake variables should be enabled:
- LLVM_ENABLE_CXX11 (enables C++11 support)
- LLVM_ENABLE_LIBCXX (enables libc++ standard library support)
- LLVM_BUILD_32_BITS for 32-bit builds (defaults to 64-bit)
5. Run `premake5 gmake` in <CppSharp>\build
6. Build generated makefiles:
- 32-bit builds: `config=release_x32 make`
- 64-bit builds: `config=release_x64 make`
## Generating bindings

4
examples/SDL/SDL.cs

@ -10,7 +10,11 @@ namespace CppSharp @@ -10,7 +10,11 @@ namespace CppSharp
var options = driver.Options;
options.LibraryName = "SDL";
options.Headers.Add("SDL.h");
#if OLD_PARSER
options.IncludeDirs.Add("../../../examples/SDL/SDL-2.0/include");
#else
options.addIncludeDirs("../../../examples/SDL/SDL-2.0/include");
#endif
options.OutputDir = "SDL";
}

5
src/AST/AST.lua

@ -3,8 +3,7 @@ project "CppSharp.AST" @@ -3,8 +3,7 @@ project "CppSharp.AST"
kind "SharedLib"
language "C#"
configuration "vs*"
location "."
SetupManagedProject()
files { "*.cs" }
links { "System", "System.Core" }
links { "System", "System.Core" }

3
src/Core/Parser/ASTConverter.cs

@ -155,8 +155,7 @@ namespace CppSharp @@ -155,8 +155,7 @@ namespace CppSharp
_decl.PreprocessedEntities.Add(_entity);
}
_decl.OriginalPtr = decl.OriginalPtr;
//_decl.OriginalPtr = decl.OriginalPtr;
}
AST.PreprocessedEntity VisitPreprocessedEntity(Parser.AST.PreprocessedEntity entity)

7
src/Core/premake4.lua

@ -2,6 +2,9 @@ project "CppSharp" @@ -2,6 +2,9 @@ project "CppSharp"
kind "SharedLib"
language "C#"
flags { "Unsafe"}
SetupManagedProject()
files { "**.cs" }
links
@ -9,9 +12,7 @@ project "CppSharp" @@ -9,9 +12,7 @@ project "CppSharp"
"System",
"System.Core",
"CppSharp.AST",
"CppSharp.Runtime"
}
SetupParser()
configuration "vs*"
location "."

10
src/CppParser/Bindings/premake4.lua

@ -2,7 +2,7 @@ project "CppSharp.Parser.Gen" @@ -2,7 +2,7 @@ project "CppSharp.Parser.Gen"
kind "ConsoleApp"
language "C#"
location "."
SetupManagedProject()
debugdir "."
files { "ParserGen.cs", "*.lua" }
@ -14,7 +14,7 @@ project "CppSharp.Parser.CSharp" @@ -14,7 +14,7 @@ project "CppSharp.Parser.CSharp"
kind "SharedLib"
language "C#"
location "."
SetupManagedProject()
dependson { "CppSharp.CppParser" }
flags { common_flags, "Unsafe" }
@ -27,7 +27,7 @@ project "CppSharp.Parser.CSharp" @@ -27,7 +27,7 @@ project "CppSharp.Parser.CSharp"
links { "CppSharp.Runtime" }
configuration "vs*"
if string.starts(action, "vs") then
project "CppSharp.Parser.CLI"
@ -55,4 +55,6 @@ configuration "vs*" @@ -55,4 +55,6 @@ configuration "vs*"
includedirs { "../../../include/", "../../../src/CppParser/" }
configuration "*"
links { "CppSharp.CppParser" }
links { "CppSharp.CppParser" }
end

2
src/Generator/Generator.lua

@ -4,6 +4,8 @@ project "CppSharp.Generator" @@ -4,6 +4,8 @@ project "CppSharp.Generator"
language "C#"
location "."
SetupManagedProject()
files { "**.cs", "**verbs.txt" }
excludes { "Filter.cs" }

2
src/Runtime/Runtime.lua

@ -4,6 +4,8 @@ project "CppSharp.Runtime" @@ -4,6 +4,8 @@ project "CppSharp.Runtime"
language "C#"
flags { "Unsafe" }
SetupManagedProject()
files { "**.cs" }
links { "System" }

Loading…
Cancel
Save