Browse Source

Initial support for building under .NET Core.

pull/1153/head
Joao Matos 7 years ago committed by João Matos
parent
commit
c3629a2aad
  1. 32
      build/Helpers.lua
  2. 51
      build/Tests.lua
  3. 3
      src/AST/premake5.lua
  4. 12
      src/CLI/premake5.lua
  5. 8
      src/Core/premake5.lua
  6. 2
      src/CppParser/Bindings/premake5.lua
  7. 4
      src/CppParser/ParserGen/premake5.lua
  8. 2
      src/CppParser/premake5.lua
  9. 21
      src/Generator.Tests/premake5.lua
  10. 18
      src/Generator/premake5.lua
  11. 5
      src/Parser/premake5.lua
  12. 3
      src/Runtime/premake5.lua

32
build/Helpers.lua

@ -6,6 +6,7 @@ newoption { @@ -6,6 +6,7 @@ newoption {
allowed = {
{ "x86", "x86 32-bits" },
{ "x64", "x64 64-bits" },
{ "AnyCPU", "Any CPU (.NET)" },
}
}
@ -23,6 +24,10 @@ function is_64_bits_mono_runtime() @@ -23,6 +24,10 @@ function is_64_bits_mono_runtime()
end
function target_architecture()
if _ACTION == "netcore" then
return "AnyCPU"
end
-- Default to 32-bit on Windows and Mono architecture otherwise.
if explicit_target_architecture ~= nil then
return explicit_target_architecture
@ -50,8 +55,14 @@ if _ARGS[1] then @@ -50,8 +55,14 @@ if _ARGS[1] then
builddir = path.getabsolute("./" .. _ARGS[1]);
end
objsdir = path.join(builddir, "obj", "%{cfg.buildcfg}_%{cfg.platform}");
libdir = path.join(builddir, "lib", "%{cfg.buildcfg}_%{cfg.platform}");
if _ACTION ~= "netcore" then
objsdir = path.join(builddir, "obj", "%{cfg.buildcfg}_%{cfg.platform}");
libdir = path.join(builddir, "lib", "%{cfg.buildcfg}_%{cfg.platform}");
else
objsdir = path.join(builddir, "obj", "%{cfg.buildcfg}");
libdir = path.join(builddir, "lib", "%{cfg.buildcfg}");
end
gendir = path.join(builddir, "gen");
msvc_buildflags = { "/wd4267" }
@ -121,11 +132,14 @@ function SetupManagedProject() @@ -121,11 +132,14 @@ function SetupManagedProject()
dotnetframework "4.6"
if not os.istarget("macosx") then
filter { "action:vs*" }
filter { "action:vs* or netcore" }
location "."
filter {}
end
filter { "action:netcore" }
dotnetframework "netstandard2.0"
filter { "action:vs2013" }
dotnetframework "4.5"
@ -197,3 +211,15 @@ function UseCxx11ABI() @@ -197,3 +211,15 @@ function UseCxx11ABI()
end
return false
end
function EnableNativeProjects()
if _ACTION == "netcore" then
return false
end
if string.starts(_ACTION, "vs") and not os.ishost("windows") then
return false
end
return true
end

51
build/Tests.lua

@ -55,8 +55,6 @@ function SetupTestGeneratorProject(name, depends) @@ -55,8 +55,6 @@ function SetupTestGeneratorProject(name, depends)
dependson { name .. ".Native" }
linktable = {
"System",
"System.Core",
"CppSharp",
"CppSharp.AST",
"CppSharp.Generator",
@ -71,6 +69,16 @@ function SetupTestGeneratorProject(name, depends) @@ -71,6 +69,16 @@ function SetupTestGeneratorProject(name, depends)
links(linktable)
SetupParser()
filter { "action:netcore" }
dotnetframework "netcoreapp2.0"
filter { "action:not netcore" }
links
{
"System",
"System.Core"
}
end
local function get_mono_exe()
@ -82,6 +90,9 @@ local function get_mono_exe() @@ -82,6 +90,9 @@ local function get_mono_exe()
end
function SetupTestGeneratorBuildEvent(name)
if _ACTION == "netcore" then
return
end
local monoExe = get_mono_exe()
local runtimeExe = os.ishost("windows") and "" or monoExe .. " --debug "
if string.starts(action, "vs") then
@ -94,7 +105,7 @@ function SetupTestGeneratorBuildEvent(name) @@ -94,7 +105,7 @@ function SetupTestGeneratorBuildEvent(name)
end
function SetupTestNativeProject(name, depends)
if string.starts(action, "vs") and not os.ishost("windows") then
if not EnableNativeProjects() then
return
end
@ -114,17 +125,29 @@ function SetupTestNativeProject(name, depends) @@ -114,17 +125,29 @@ function SetupTestNativeProject(name, depends)
end
function LinkNUnit()
libdirs
{
depsdir .. "/NUnit",
depsdir .. "/NSubstitute"
}
local c = filter()
links
{
"nunit.framework",
"NSubstitute"
}
filter { "action:not netcore"}
libdirs
{
depsdir .. "/NUnit",
depsdir .. "/NSubstitute"
}
links
{
"nunit.framework",
"NSubstitute"
}
filter { "action:netcore"}
nuget
{
"NUnit:3.11.0",
"NSubstitute:4.0.0-rc1"
}
filter(c)
end
function SetupTestProjectsCSharp(name, depends, extraFiles, suffix)
@ -170,7 +193,7 @@ function SetupTestProjectsCSharp(name, depends, extraFiles, suffix) @@ -170,7 +193,7 @@ function SetupTestProjectsCSharp(name, depends, extraFiles, suffix)
end
function SetupTestProjectsCLI(name, extraFiles, suffix)
if not os.ishost("windows") then
if (not os.ishost("windows")) or (_ACTION == "netcore") then
return
end

3
src/AST/premake5.lua

@ -8,4 +8,5 @@ project "CppSharp.AST" @@ -8,4 +8,5 @@ project "CppSharp.AST"
files { "*.cs" }
vpaths { ["*"] = "*" }
links { "System", "System.Core" }
filter { "action:not netcore"}
links { "System", "System.Core" }

12
src/CLI/premake5.lua

@ -10,8 +10,6 @@ project "CppSharp.CLI" @@ -10,8 +10,6 @@ project "CppSharp.CLI"
links
{
"System",
"System.Core",
"CppSharp",
"CppSharp.AST",
"CppSharp.Generator",
@ -19,3 +17,13 @@ project "CppSharp.CLI" @@ -19,3 +17,13 @@ project "CppSharp.CLI"
}
SetupParser()
filter { "action:not netcore"}
links
{
"System",
"System.Core"
}
filter { "action:netcore" }
dotnetframework "netcoreapp2.0"

8
src/Core/premake5.lua

@ -11,7 +11,11 @@ project "CppSharp" @@ -11,7 +11,11 @@ project "CppSharp"
links
{
"System",
"System.Core",
depsdir .. "/vs2017/Microsoft.VisualStudio.Setup.Configuration.Interop"
}
filter { "action:netcore" }
nuget { "Microsoft.Win32.Registry:4.5.0" }
filter { "action:not netcore"}
links { "System", "System.Core" }

2
src/CppParser/Bindings/premake5.lua

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
include ("CSharp")
if string.starts(action, "vs") and os.ishost("windows") then
if EnableNativeProjects() and os.ishost("windows") then
include ("CLI")

4
src/CppParser/ParserGen/premake5.lua

@ -14,7 +14,9 @@ project "CppSharp.Parser.Gen" @@ -14,7 +14,9 @@ project "CppSharp.Parser.Gen"
"CppSharp.AST",
"CppSharp.Generator",
"CppSharp.Parser",
"System.Core"
}
SetupParser()
filter { "action:not netcore"}
links { "System.Core" }

2
src/CppParser/premake5.lua

@ -6,7 +6,7 @@ clang_msvc_flags = @@ -6,7 +6,7 @@ clang_msvc_flags =
"/wd4141", -- 'inline' : used more than once
}
if not (string.starts(action, "vs") and not os.ishost("windows")) then
if EnableNativeProjects() then
project "CppSharp.CppParser"

21
src/Generator.Tests/premake5.lua

@ -21,12 +21,25 @@ project "CppSharp.Generator.Tests" @@ -21,12 +21,25 @@ project "CppSharp.Generator.Tests"
links
{
"System",
"System.Core",
"CppSharp",
"CppSharp.AST",
"CppSharp.Generator",
"CppSharp.Parser",
"nunit.framework",
"NSubstitute"
}
filter { "action:netcore"}
nuget
{
"NUnit:3.11.0",
"NSubstitute:4.0.0-rc1"
}
filter { "action:not netcore"}
links
{
"System",
"System.Core",
"Microsoft.CSharp",
"nunit.framework",
"NSubstitute"
}

18
src/Generator/premake5.lua

@ -13,9 +13,6 @@ project "CppSharp.Generator" @@ -13,9 +13,6 @@ project "CppSharp.Generator"
links
{
"System",
"System.Core",
"Microsoft.CSharp",
"CppSharp",
"CppSharp.AST",
"CppSharp.Parser"
@ -23,6 +20,21 @@ project "CppSharp.Generator" @@ -23,6 +20,21 @@ project "CppSharp.Generator"
SetupParser()
filter { "action:netcore"}
nuget
{
"System.CodeDom:4.5.0",
"Microsoft.CSharp:4.5.0"
}
filter { "action:not netcore"}
links
{
"System",
"System.Core",
"Microsoft.CSharp"
}
filter { 'files:**verbs.txt' }
buildaction "Embed"

5
src/Parser/premake5.lua

@ -36,11 +36,12 @@ project "CppSharp.Parser" @@ -36,11 +36,12 @@ project "CppSharp.Parser"
links
{
"System",
"System.Core",
"CppSharp",
"CppSharp.AST",
"CppSharp.Runtime"
}
SetupParser()
filter { "action:not netcore"}
links { "System", "System.Core" }

3
src/Runtime/premake5.lua

@ -8,7 +8,8 @@ project "CppSharp.Runtime" @@ -8,7 +8,8 @@ project "CppSharp.Runtime"
files { "**.cs" }
vpaths { ["*"] = "*" }
links { "System" }
filter { "action:not netcore"}
links { "System" }
filter { "action:vs*" }
defines { "MSVC" }

Loading…
Cancel
Save