diff --git a/build/Helpers.lua b/build/Helpers.lua index b0e36743..77dc1e7b 100644 --- a/build/Helpers.lua +++ b/build/Helpers.lua @@ -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() 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 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() 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" @@ -196,4 +210,16 @@ function UseCxx11ABI() return true end return false -end \ No newline at end of file +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 diff --git a/build/Tests.lua b/build/Tests.lua index 7fdf8042..87387ad8 100644 --- a/build/Tests.lua +++ b/build/Tests.lua @@ -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) 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() 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) 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) end function LinkNUnit() - libdirs - { - depsdir .. "/NUnit", - depsdir .. "/NSubstitute" - } + local c = filter() + + filter { "action:not netcore"} + libdirs + { + depsdir .. "/NUnit", + depsdir .. "/NSubstitute" + } - links - { - "nunit.framework", - "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) end function SetupTestProjectsCLI(name, extraFiles, suffix) - if not os.ishost("windows") then + if (not os.ishost("windows")) or (_ACTION == "netcore") then return end diff --git a/src/AST/premake5.lua b/src/AST/premake5.lua index 491ba385..217face8 100644 --- a/src/AST/premake5.lua +++ b/src/AST/premake5.lua @@ -8,4 +8,5 @@ project "CppSharp.AST" files { "*.cs" } vpaths { ["*"] = "*" } - links { "System", "System.Core" } + filter { "action:not netcore"} + links { "System", "System.Core" } diff --git a/src/CLI/premake5.lua b/src/CLI/premake5.lua index 0bf6f8d1..277a9995 100644 --- a/src/CLI/premake5.lua +++ b/src/CLI/premake5.lua @@ -10,8 +10,6 @@ project "CppSharp.CLI" links { - "System", - "System.Core", "CppSharp", "CppSharp.AST", "CppSharp.Generator", @@ -19,3 +17,13 @@ project "CppSharp.CLI" } SetupParser() + + filter { "action:not netcore"} + links + { + "System", + "System.Core" + } + + filter { "action:netcore" } + dotnetframework "netcoreapp2.0" diff --git a/src/Core/premake5.lua b/src/Core/premake5.lua index 003d8835..0c3cc9d7 100644 --- a/src/Core/premake5.lua +++ b/src/Core/premake5.lua @@ -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" } diff --git a/src/CppParser/Bindings/premake5.lua b/src/CppParser/Bindings/premake5.lua index 9253981a..aeef75ef 100644 --- a/src/CppParser/Bindings/premake5.lua +++ b/src/CppParser/Bindings/premake5.lua @@ -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") diff --git a/src/CppParser/ParserGen/premake5.lua b/src/CppParser/ParserGen/premake5.lua index 62891c39..9e201033 100644 --- a/src/CppParser/ParserGen/premake5.lua +++ b/src/CppParser/ParserGen/premake5.lua @@ -14,7 +14,9 @@ project "CppSharp.Parser.Gen" "CppSharp.AST", "CppSharp.Generator", "CppSharp.Parser", - "System.Core" } - SetupParser() \ No newline at end of file + SetupParser() + + filter { "action:not netcore"} + links { "System.Core" } diff --git a/src/CppParser/premake5.lua b/src/CppParser/premake5.lua index 19ce8970..2c0f918c 100644 --- a/src/CppParser/premake5.lua +++ b/src/CppParser/premake5.lua @@ -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" diff --git a/src/Generator.Tests/premake5.lua b/src/Generator.Tests/premake5.lua index 548e492b..506900af 100644 --- a/src/Generator.Tests/premake5.lua +++ b/src/Generator.Tests/premake5.lua @@ -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" + } diff --git a/src/Generator/premake5.lua b/src/Generator/premake5.lua index a7b6d17f..56da57db 100644 --- a/src/Generator/premake5.lua +++ b/src/Generator/premake5.lua @@ -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" 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" diff --git a/src/Parser/premake5.lua b/src/Parser/premake5.lua index 7af098ef..732d0b60 100644 --- a/src/Parser/premake5.lua +++ b/src/Parser/premake5.lua @@ -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" } diff --git a/src/Runtime/premake5.lua b/src/Runtime/premake5.lua index f9b0da2c..2fa0ba66 100644 --- a/src/Runtime/premake5.lua +++ b/src/Runtime/premake5.lua @@ -8,7 +8,8 @@ project "CppSharp.Runtime" files { "**.cs" } vpaths { ["*"] = "*" } - links { "System" } + filter { "action:not netcore"} + links { "System" } filter { "action:vs*" } defines { "MSVC" }