Browse Source

Only use premake for native projects and improve c# projects.

pull/1537/head
josetr 5 years ago
parent
commit
1926e69435
  1. 2
      .gitignore
  2. 30
      Directory.Build.props
  3. 38
      build/Helpers.lua
  4. 83
      build/Tests.lua
  5. 2
      build/build.sh
  6. 38
      build/premake/premake.extensions.lua
  7. 11
      build/premake/premake.fixes.lua
  8. 8
      build/premake5.lua
  9. 6
      src/AST/CppSharp.AST.csproj
  10. 7
      src/AST/premake5.lua
  11. 9
      src/CLI/CppSharp.CLI.csproj
  12. 9
      src/CLI/premake5.lua
  13. 11
      src/Core/CppSharp.csproj
  14. 12
      src/Core/premake5.lua
  15. 23
      src/CppParser/Bindings/CSharp/CppSharp.Parser.CSharp.csproj
  16. 15
      src/CppParser/Bindings/CSharp/premake5.lua
  17. 9
      src/CppParser/Bootstrap/CppSharp.Parser.Bootstrap.csproj
  18. 10
      src/CppParser/Bootstrap/premake5.lua
  19. 9
      src/CppParser/ParserGen/CppSharp.Parser.Gen.csproj
  20. 10
      src/CppParser/ParserGen/premake5.lua
  21. 15
      src/Generator.Tests/CppSharp.Generator.Tests.csproj
  22. 21
      src/Generator.Tests/premake5.lua
  23. 14
      src/Generator/CppSharp.Generator.csproj
  24. 21
      src/Generator/premake5.lua
  25. 18
      src/Parser/CppSharp.Parser.csproj
  26. 21
      src/Parser/premake5.lua
  27. 7
      src/Runtime/CppSharp.Runtime.csproj
  28. 12
      src/Runtime/premake5.lua
  29. 1
      tests/CLI/CLI.Gen.csproj
  30. 1
      tests/CLI/CLI.Tests.CLI.csproj
  31. 1
      tests/CSharp/CSharp.CSharp.csproj
  32. 1
      tests/CSharp/CSharp.Gen.csproj
  33. 1
      tests/CSharp/CSharp.Tests.CSharp.csproj
  34. 1
      tests/Common/Common.CSharp.csproj
  35. 1
      tests/Common/Common.Gen.csproj
  36. 1
      tests/Common/Common.Tests.CLI.csproj
  37. 1
      tests/Common/Common.Tests.CSharp.csproj
  38. 7
      tests/Directory.Build.props
  39. 1
      tests/Encodings/Encodings.CSharp.csproj
  40. 1
      tests/Encodings/Encodings.Gen.csproj
  41. 1
      tests/Encodings/Encodings.Tests.CSharp.csproj
  42. 11
      tests/NamespacesBase/NamespacesBase.CSharp.csproj
  43. 12
      tests/NamespacesBase/premake4.lua
  44. 14
      tests/NamespacesDerived/NamespacesDerived.CSharp.csproj
  45. 1
      tests/NamespacesDerived/NamespacesDerived.Gen.csproj
  46. 1
      tests/NamespacesDerived/NamespacesDerived.Tests.CSharp.csproj
  47. 1
      tests/StandardLib/StandardLib.Gen.csproj
  48. 1
      tests/StandardLib/StandardLib.Tests.CLI.csproj
  49. 23
      tests/Test.Bindings.props
  50. 20
      tests/Test.Common.props
  51. 31
      tests/Test.Generator.props
  52. 20
      tests/Test.props
  53. 1
      tests/VTables/VTables.CSharp.csproj
  54. 1
      tests/VTables/VTables.Gen.csproj
  55. 1
      tests/VTables/VTables.Tests.CSharp.csproj

2
.gitignore vendored

@ -26,7 +26,6 @@ src/generator/generator
*.filters *.filters
*.sln *.sln
*.metagen *.metagen
*.csproj
*.ilk *.ilk
*.manifest *.manifest
*.tmp *.tmp
@ -43,6 +42,7 @@ src/generator/generator
/build/vs20* /build/vs20*
/build/gmake /build/gmake
/build/headers /build/headers
/build/config.props
/build/premake/premake5* /build/premake/premake5*
/build/gen /build/gen
/deps/llvm /deps/llvm

30
Directory.Build.props

@ -1,10 +1,36 @@
<Project> <Project>
<Import Project="build/config.props" />
<PropertyGroup> <PropertyGroup>
<RootDir>$(MSBuildThisFileDirectory)</RootDir> <RootDir>$(MSBuildThisFileDirectory)</RootDir>
<Platforms>x86;x64</Platforms> <Platforms>x86;x64</Platforms>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<BaseIntermediateOutputPath>$(RootDir)build\obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath> <BuildDir>$(RootDir)build\</BuildDir>
<TargetDir Condition="$(Configuration) != ''">$(RootDir)bin\$(Configuration)_$(Platform)</TargetDir> <ObjDir>$(BuildDir)obj\</ObjDir>
<GenDir>$(BuildDir)gen\</GenDir>
<SrcDir>$(RootDir)src\</SrcDir>
<BaseIntermediateOutputPath>$(ObjDir)$(MSBuildProjectName)\</BaseIntermediateOutputPath>
<BaseOutputPath>$(RootDir)bin\</BaseOutputPath>
<OutputPath>$(BaseOutputPath)$(Configuration)_$(PlatformTarget)\</OutputPath>
<ActionDir>$(BuildDir)$(PremakeAction)\</ActionDir>
<NativeProjectsDir>$(ActionDir)projects\</NativeProjectsDir>
<TargetDir>$(OutputPath)</TargetDir>
<LangVersion>7.3</LangVersion> <LangVersion>7.3</LangVersion>
<WarningLevel>4</WarningLevel>
<DotNetCmd>dotnet</DotNetCmd>
<GeneratorFileExtension>dll</GeneratorFileExtension>
<DotNetCmd Condition="'$(PlatformTarget)' == 'x86' AND Exists('$(MSBuildProgramFiles32)\dotnet\dotnet.exe')">"$(MSBuildProgramFiles32)\dotnet\dotnet.exe"</DotNetCmd>
<DotNetCmd Condition="'$(PlatformTarget)' == 'x64' AND Exists('$(ProgramW6432)\dotnet\dotnet.exe')">"$(ProgramW6432)\dotnet\dotnet.exe"</DotNetCmd>
</PropertyGroup>
<PropertyGroup Condition="'$(CPPSHARP_RELEASE)' != 'true'">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(DotNetCmd)' == 'dotnet' AND $(IsWindows)">
<GeneratorFileExtension>exe</GeneratorFileExtension>
<DotNetCmd></DotNetCmd>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

38
build/Helpers.lua

@ -56,6 +56,7 @@ msvc_cpp_defines = { }
default_gcc_version = "9.0.0" default_gcc_version = "9.0.0"
generate_build_config = true generate_build_config = true
premake.path = premake.path .. ";" .. path.join(builddir, "modules") premake.path = premake.path .. ";" .. path.join(builddir, "modules")
targetframework = "netcoreapp3.1"
function string.starts(str, start) function string.starts(str, start)
if str == nil then return end if str == nil then return end
@ -73,6 +74,10 @@ end
function SetupNativeProject() function SetupNativeProject()
location (path.join(actionbuilddir, "projects")) location (path.join(actionbuilddir, "projects"))
files { "*.lua" } files { "*.lua" }
if os.getenv("CPPSHARP_RELEASE") == "true" then
symbols "off"
end
filter { "configurations:Debug" } filter { "configurations:Debug" }
defines { "DEBUG" } defines { "DEBUG" }
@ -118,11 +123,17 @@ function SetupNativeProject()
end end
function SetupManagedProject() function SetupManagedProject()
kind "SharedLib"
language "C#" language "C#"
location "." location "."
filter {} filter {}
end end
function SetupExternalManagedProject(name)
externalproject (name)
SetupManagedProject()
end
function IncludeDir(dir) function IncludeDir(dir)
local deps = os.matchdirs(dir .. "/*") local deps = os.matchdirs(dir .. "/*")
@ -230,3 +241,30 @@ function AddPlatformSpecificFiles(folder, filename)
print "Unknown architecture" print "Unknown architecture"
end end
end end
function WriteConfigForMSBuild()
local file = io.open("config.props", "w+")
function writeProperty(name, value)
file:write(" <" .. name .. ">" .. (value ~= nil and value or "") .. "</" .. name .. ">\n")
end
function writeBooleanProperty(name, value)
writeProperty(name, value and "true" or "false")
end
file:write("<!-- GENERATED FILE -->\n")
file:write("<Project>\n")
file:write(" <PropertyGroup>\n")
writeProperty("PlatformTarget", target_architecture())
writeProperty("TargetFramework", targetframework)
writeProperty("Configuration", _OPTIONS["configuration"])
writeBooleanProperty("IsWindows", os.istarget("windows"))
writeBooleanProperty("IsLinux", os.istarget("linux"))
writeBooleanProperty("IsMacOSX", os.istarget("macosx"))
writeBooleanProperty("CI", os.getenv("CI") == "true")
writeBooleanProperty("GenerateBuildConfig", generate_build_config == true)
writeBooleanProperty("UseCXX11ABI", UseCxx11ABI())
writeProperty("PremakeAction", _ACTION)
file:write(" </PropertyGroup>\n")
file:write("</Project>")
file:close()
end

83
build/Tests.lua

@ -40,32 +40,15 @@ function SetupManagedTestProject()
files { "*.lua" } files { "*.lua" }
end end
function SetupTestGeneratorProject(name, depends) function SetupExternalManagedTestProject(name)
if not EnabledManagedProjects() then externalproject (name)
return SetupManagedTestProject()
end
project(name .. ".Gen")
SetupManagedTestProject()
kind "ConsoleApp"
enabledefaultnoneitems "false"
files { name .. ".cs" }
dependson { name .. ".Native" }
links { "CppSharp.Generator.Tests" }
if depends ~= nil then
links { depends .. ".Gen" }
end
local command = os.ishost("windows") and "type nul >" or "touch"
postbuildcommands { command .. " " .. SafePath(path.join(objsdir, name .. ".Native", "timestamp.cs")) }
postbuildcommands { command .. " " .. SafePath(path.join(objsdir, name .. ".Native", "timestamp.cpp")) }
end end
function SetupTestGeneratorBuildEvent(name) function SetupTestGeneratorProject(name, depends)
local cmd = os.ishost("windows") and "" or "dotnet " if EnabledManagedProjects() then
local ext = os.ishost("windows") and "exe" or "dll" SetupExternalManagedTestProject(name .. ".Gen")
prebuildcommands { cmd .. SafePath(path.join("%{cfg.buildtarget.directory}", name .. ".Gen." .. ext)) } end
end end
function SetupTestNativeProject(name, depends) function SetupTestNativeProject(name, depends)
@ -86,10 +69,6 @@ function SetupTestNativeProject(name, depends)
if depends ~= nil then if depends ~= nil then
links { depends .. ".Native" } links { depends .. ".Native" }
end end
local command = os.ishost("windows") and "type nul >" or "touch"
postbuildcommands { command .. " " .. SafePath(path.join(objsdir, name .. ".Native", "timestamp.cs")) }
postbuildcommands { command .. " " .. SafePath(path.join(objsdir, name .. ".Native", "timestamp.cpp")) }
end end
function SetupTestProjectsCSharp(name, depends, extraFiles, suffix) function SetupTestProjectsCSharp(name, depends, extraFiles, suffix)
@ -103,35 +82,9 @@ function SetupTestProjectsCSharp(name, depends, extraFiles, suffix)
nm = name nm = name
str = "Std" str = "Std"
end end
project(name .. ".CSharp")
SetupManagedTestProject() SetupExternalManagedTestProject(name .. ".CSharp")
SetupExternalManagedTestProject(name .. ".Tests.CSharp")
dependson { name .. ".Gen", name .. ".Native", "CppSharp.Generator" }
SetupTestGeneratorBuildEvent(name)
enabledefaultnoneitems "false"
files
{
path.join(gendir, name, nm .. ".cs"),
path.join(gendir, name, str .. ".cs"),
path.join(objsdir, name .. ".Native", "timestamp.cs")
}
links { "CppSharp.Runtime" }
if depends ~= nil then
links { depends .. ".CSharp" }
end
project(name .. ".Tests.CSharp")
SetupManagedTestProject()
enabledefaultnoneitems "false"
files { name .. ".Tests.cs" }
links { name .. ".CSharp", "CppSharp.Generator.Tests", "CppSharp.Runtime" }
nuget { "Microsoft.NET.Test.Sdk:16.8.0" }
dependson { name .. ".Native" }
end end
function SetupTestProjectsCLI(name, extraFiles, suffix) function SetupTestProjectsCLI(name, extraFiles, suffix)
@ -142,14 +95,11 @@ function SetupTestProjectsCLI(name, extraFiles, suffix)
project(name .. ".CLI") project(name .. ".CLI")
SetupNativeProject() SetupNativeProject()
enabledefaultcompileitems "false"
enabledefaultnoneitems "false"
kind "SharedLib" kind "SharedLib"
language "C++" language "C++"
clr "NetCore" clr "NetCore"
dependson { name .. ".Gen", name .. ".Native", "CppSharp.Generator" } dependson { name .. ".Gen" }
SetupTestGeneratorBuildEvent(name)
if (suffix ~= nil) then if (suffix ~= nil) then
nm = name .. suffix nm = name .. suffix
@ -174,16 +124,9 @@ function SetupTestProjectsCLI(name, extraFiles, suffix)
includedirs { path.join(testsdir, name), incdir } includedirs { path.join(testsdir, name), incdir }
links { name .. ".Native" } links { name .. ".Native" }
files { path.join(objsdir, name .. ".Native", "timestamp.cpp") } files { path.join(objsdir, name .. ".Native") }
project(name .. ".Tests.CLI")
SetupManagedTestProject()
enabledefaultnoneitems "false"
files { name .. ".Tests.cs" }
links { name .. ".CLI", "CppSharp.Generator.Tests" } SetupExternalManagedTestProject(name .. ".Tests.CLI")
dependson { name .. ".Native" }
nuget { "Microsoft.NET.Test.Sdk:16.8.0" }
end end
function IncludeExamples() function IncludeExamples()

2
build/build.sh

@ -140,7 +140,7 @@ find_msbuild()
if [ -x "$(command -v MSBuild.exe)" ]; then if [ -x "$(command -v MSBuild.exe)" ]; then
msbuild="MSBuild.exe" msbuild="MSBuild.exe"
else else
msbuild="msbuild" msbuild="dotnet msbuild"
fi fi
} }

38
build/premake/premake.extensions.lua

@ -4,44 +4,16 @@ premake.api.register {
kind = "list:string", kind = "list:string",
} }
premake.api.register {
name = "removecompilefiles",
scope = "project",
kind = "list:string",
}
premake.api.register {
name = "enabledefaultnoneitems",
scope = "project",
kind = "boolean",
}
premake.override(premake.vstudio.dotnetbase.netcore, "enableDefaultCompileItems", function(base, cfg)
base(cfg);
if cfg.enabledefaultnoneitems ~= nil then
premake.w('<EnableDefaultNoneItems>%s</EnableDefaultNoneItems>', iif(cfg.enabledefaultnoneitems, "true", "false"))
end
end)
premake.override(premake.vstudio.dotnetbase, "files", function(base, prj)
base(prj);
if prj.removecompilefiles ~= nil then
for _, file in ipairs(prj.removecompilefiles) do
premake.w("<Compile Remove=\"%s\" />", file)
end
end
end)
-- https://github.com/premake/premake-core/issues/1061#issuecomment-441417853 -- https://github.com/premake/premake-core/issues/1061#issuecomment-441417853
premake.override(premake.vstudio.sln2005, "projects", function(base, wks) premake.override(premake.vstudio.sln2005, "projects", function(base, wks)
if wks.workspacefiles and #wks.workspacefiles > 0 then if wks.workspacefiles and #wks.workspacefiles > 0 then
premake.push('Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{' .. os.uuid("Solution Items:"..wks.name) .. '}"') premake.push('Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{' .. os.uuid("Solution Items:"..wks.name) .. '}"')
premake.push("ProjectSection(SolutionItems) = preProject") premake.push("ProjectSection(SolutionItems) = preProject")
for _, file in ipairs(wks.workspacefiles) do for _, pattern in ipairs(wks.workspacefiles) do
file = path.rebase(file, ".", wks.location) local matches = os.matchfiles(pattern)
premake.w(file.." = "..file) for _, file in ipairs(matches) do
premake.w(file.." = "..file)
end
end end
premake.pop("EndProjectSection") premake.pop("EndProjectSection")
premake.pop("EndProject") premake.pop("EndProject")

11
build/premake/premake.fixes.lua

@ -10,14 +10,3 @@ premake.override(premake.vstudio.vc2010, "targetFramework", function(oldfn, prj)
oldfn(prj) oldfn(prj)
end end
end) end)
-- https://github.com/premake/premake-core/issues/1549
premake.override(premake.vstudio.cs2005.elements, "projectProperties", function(base, cfg)
local calls = base(cfg);
table.insert(calls, function(cfg)
if cfg.clr == "Unsafe" then
premake.w('<AllowUnsafeBlocks>true</AllowUnsafeBlocks>')
end
end)
return calls;
end)

8
build/premake5.lua

@ -8,10 +8,9 @@ include "Helpers.lua"
include "LLVM.lua" include "LLVM.lua"
workspace "CppSharp" workspace "CppSharp"
configurations { _OPTIONS["configuration"] } configurations { _OPTIONS["configuration"] }
platforms { target_architecture() } platforms { target_architecture() }
dotnetframework "netcoreapp3.1" dotnetframework (targetframework)
enabledefaultcompileitems "true" enabledefaultcompileitems "true"
characterset "Unicode" characterset "Unicode"
symbols "On" symbols "On"
@ -35,6 +34,11 @@ workspace "CppSharp"
end end
end end
workspacefiles(path.join(builddir, "premake5.lua"))
workspacefiles(path.join(builddir, "*.sh"))
workspacefiles(path.join(rootdir, "tests/Test*.props"))
WriteConfigForMSBuild()
group "Libraries" group "Libraries"
if EnableNativeProjects() then if EnableNativeProjects() then
include (srcdir .. "/CppParser") include (srcdir .. "/CppParser")

6
src/AST/CppSharp.AST.csproj

@ -0,0 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
</Project>

7
src/AST/premake5.lua

@ -1,6 +1 @@
project "CppSharp.AST" SetupExternalManagedProject("CppSharp.AST")
kind "SharedLib"
language "C#"
SetupManagedProject()

9
src/CLI/CppSharp.CLI.csproj

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Generator\CppSharp.Generator.csproj" />
</ItemGroup>
</Project>

9
src/CLI/premake5.lua

@ -1,8 +1 @@
project "CppSharp.CLI" SetupExternalManagedProject("CppSharp.CLI")
SetupManagedProject()
kind "ConsoleApp"
language "C#"
links { "CppSharp.Generator" }

11
src/Core/CppSharp.csproj

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Win32.Registry" Version="4.7.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Setup.Configuration.Interop" Version="2.3.2262-g94fae01e" PrivateAssets="All" />
</ItemGroup>
</Project>

12
src/Core/premake5.lua

@ -1,11 +1 @@
project "CppSharp" SetupExternalManagedProject("CppSharp")
SetupManagedProject()
kind "SharedLib"
language "C#"
nuget {
"Microsoft.Win32.Registry:4.7.0",
"Microsoft.VisualStudio.Setup.Configuration.Interop:2.3.2262-g94fae01e"
}

23
src/CppParser/Bindings/CSharp/CppSharp.Parser.CSharp.csproj

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<EnableDefaultNoneItems>false</EnableDefaultNoneItems>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PlatformParserFolder Condition="$(IsWindows) AND $(PlatformTarget) == x64">x86_64-pc-win32-msvc</PlatformParserFolder>
<PlatformParserFolder Condition="$(IsLinux) AND $(PlatformTarget) == x64 AND $(UseCXX11ABI)">x86_64-linux-gnu-cxx11abi</PlatformParserFolder>
<PlatformParserFolder Condition="$(IsLinux) AND $(PlatformTarget) == x64 AND !$(UseCXX11ABI)">x86_64-linux-gnu</PlatformParserFolder>
<PlatformParserFolder Condition="$(IsMacOSX) AND $(PlatformTarget) == x64">x86_64-apple-darwin12.4.0</PlatformParserFolder>
<PlatformParserFolder Condition="$(IsWindows) AND $(PlatformTarget) == x86">i686-pc-win32-msvc</PlatformParserFolder>
<PlatformParserFolder Condition="$(IsMacOSX) AND $(PlatformTarget) == x86">i686-apple-darwin12.4.0</PlatformParserFolder>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(PlatformParserFolder)\*.cs" />
<None Include="$(PlatformParserFolder)\*.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Runtime\CppSharp.Runtime.csproj" />
<ProjectReference Include="$(NativeProjectsDir)CppSharp.CppParser.vcxproj" ReferenceOutputAssembly="false" Condition="$(IsWindows)" />
</ItemGroup>
</Project>

15
src/CppParser/Bindings/CSharp/premake5.lua

@ -2,19 +2,6 @@ if not EnabledManagedProjects() then
return return
end end
project "CppSharp.Parser.CSharp" SetupExternalManagedProject("CppSharp.Parser.CSharp")
SetupManagedProject()
kind "SharedLib"
language "C#"
clr "Unsafe"
enabledefaultcompileitems "false"
enabledefaultnoneitems "false"
dependson { "CppSharp.CppParser" }
links { "CppSharp.Runtime" }
AddPlatformSpecificFiles("", "**.cs")
AddPlatformSpecificFiles("", "**.cpp")
CppSharpParserBindings = "CppSharp.Parser.CSharp" CppSharpParserBindings = "CppSharp.Parser.CSharp"

9
src/CppParser/Bootstrap/CppSharp.Parser.Bootstrap.csproj

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Generator\CppSharp.Generator.csproj" />
</ItemGroup>
</Project>

10
src/CppParser/Bootstrap/premake5.lua

@ -1,9 +1 @@
project "CppSharp.Parser.Bootstrap" SetupExternalManagedProject("CppSharp.Parser.Bootstrap")
SetupManagedProject()
kind "ConsoleApp"
language "C#"
debugdir "."
links { "CppSharp.Generator" }

9
src/CppParser/ParserGen/CppSharp.Parser.Gen.csproj

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Generator\CppSharp.Generator.csproj" />
</ItemGroup>
</Project>

10
src/CppParser/ParserGen/premake5.lua

@ -1,9 +1 @@
project "CppSharp.Parser.Gen" SetupExternalManagedProject("CppSharp.Parser.Gen")
SetupManagedProject()
kind "ConsoleApp"
language "C#"
debugdir "."
links { "CppSharp.Generator" }

15
src/Generator.Tests/CppSharp.Generator.Tests.csproj

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<None Include="..\..\tests\Native\AST.h" LinkBase="tests\Native" />
<None Include="..\..\tests\Native\ASTExtensions.h" LinkBase="tests\Native" />
<None Include="..\..\tests\Native\Passes.h" LinkBase="tests\Native" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Generator\CppSharp.Generator.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
</ItemGroup>
</Project>

21
src/Generator.Tests/premake5.lua

@ -1,20 +1 @@
project "CppSharp.Generator.Tests" SetupExternalManagedProject("CppSharp.Generator.Tests")
kind "SharedLib"
SetupManagedProject()
files { testsdir .. "/Native/AST.h", testsdir .. "/Native/ASTExtensions.h", testsdir .. "/Native/Passes.h" }
filter "files:**.h"
buildaction "None"
filter {}
links { "CppSharp.Generator" }
nuget
{
"System.CodeDom:4.7.0",
"Microsoft.CSharp:4.7.0",
"Microsoft.NET.Test.Sdk:16.8.0",
"NUnit:3.11.0",
"NUnit3TestAdapter:3.17.0",
}

14
src/Generator/CppSharp.Generator.csproj

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<EmbeddedResource Include="Passes\verbs.txt" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Parser\CppSharp.Parser.csproj" />
<ProjectReference Include="$(NativeProjectsDir)Std-symbols.vcxproj" ReferenceOutputAssembly="false" Condition="$(IsWindows)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.CodeDom" Version="4.7.0" PrivateAssets="All"/>
</ItemGroup>
</Project>

21
src/Generator/premake5.lua

@ -1,20 +1 @@
project "CppSharp.Generator" SetupExternalManagedProject("CppSharp.Generator")
SetupManagedProject()
kind "SharedLib"
language "C#"
dependson { "Std-symbols" }
links { "CppSharp.Parser" }
nuget
{
"System.CodeDom:4.7.0",
"Microsoft.CSharp:4.7.0"
}
files { "**verbs.txt" }
filter { 'files:**verbs.txt' }
buildaction "Embed"
filter {}

18
src/Parser/CppSharp.Parser.csproj

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup Condition="$(GenerateBuildConfig)">
<Compile Include="$(ActionDir)BuildConfig.cs" LinkBase="build" />
<Compile Remove="BuildConfig.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Core\CppSharp.csproj" />
<ProjectReference Include="..\AST\CppSharp.AST.csproj" />
<ProjectReference Include="..\Runtime\CppSharp.Runtime.csproj" />
<ProjectReference Include="..\CppParser\Bindings\CSharp\CppSharp.Parser.CSharp.csproj" Condition="!$(IsWindows) OR $(CI)" />
<ProjectReference Include="$(NativeProjectsDir)\CppSharp.Parser.CLI.vcxproj" Condition="$(IsWindows) AND !$(CI)" />
</ItemGroup>
</Project>

21
src/Parser/premake5.lua

@ -15,23 +15,4 @@ if generate_build_config == true and _ACTION then
GenerateBuildConfig() GenerateBuildConfig()
end end
project "CppSharp.Parser" SetupExternalManagedProject("CppSharp.Parser")
SetupManagedProject()
kind "SharedLib"
language "C#"
clr "Unsafe"
if generate_build_config == true then
files { buildconfig }
removecompilefiles { "BuildConfig.cs" }
end
links
{
"CppSharp",
"CppSharp.AST",
"CppSharp.Runtime",
CppSharpParserBindings
}

7
src/Runtime/CppSharp.Runtime.csproj

@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFramework>netstandard2.0</TargetFramework>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
</Project>

12
src/Runtime/premake5.lua

@ -1,12 +1,2 @@
project "CppSharp.Runtime" SetupExternalManagedProject("CppSharp.Runtime")
SetupManagedProject()
kind "SharedLib"
clr "Unsafe"
filter { "toolset:msc*" }
defines { "MSVC" }
filter { "system:macosx" }
defines { "LIBCXX" }

1
tests/CLI/CLI.Gen.csproj

@ -0,0 +1 @@
<Project Sdk="Microsoft.NET.Sdk" />

1
tests/CLI/CLI.Tests.CLI.csproj

@ -0,0 +1 @@
<Project Sdk="Microsoft.NET.Sdk" />

1
tests/CSharp/CSharp.CSharp.csproj

@ -0,0 +1 @@
<Project Sdk="Microsoft.NET.Sdk" />

1
tests/CSharp/CSharp.Gen.csproj

@ -0,0 +1 @@
<Project Sdk="Microsoft.NET.Sdk" />

1
tests/CSharp/CSharp.Tests.CSharp.csproj

@ -0,0 +1 @@
<Project Sdk="Microsoft.NET.Sdk" />

1
tests/Common/Common.CSharp.csproj

@ -0,0 +1 @@
<Project Sdk="Microsoft.NET.Sdk" />

1
tests/Common/Common.Gen.csproj

@ -0,0 +1 @@
<Project Sdk="Microsoft.NET.Sdk" />

1
tests/Common/Common.Tests.CLI.csproj

@ -0,0 +1 @@
<Project Sdk="Microsoft.NET.Sdk" />

1
tests/Common/Common.Tests.CSharp.csproj

@ -0,0 +1 @@
<Project Sdk="Microsoft.NET.Sdk" />

7
tests/Directory.Build.props

@ -0,0 +1,7 @@
<Project>
<Import Project="../Directory.Build.props" />
<Import Project="Test.Common.props" />
<Import Project="Test.Generator.props" Condition="$(IsTestGenerator)" />
<Import Project="Test.Bindings.props" Condition="$(IsTestBindings)" />
<Import Project="Test.props" Condition="$(IsTest)" />
</Project>

1
tests/Encodings/Encodings.CSharp.csproj

@ -0,0 +1 @@
<Project Sdk="Microsoft.NET.Sdk" />

1
tests/Encodings/Encodings.Gen.csproj

@ -0,0 +1 @@
<Project Sdk="Microsoft.NET.Sdk" />

1
tests/Encodings/Encodings.Tests.CSharp.csproj

@ -0,0 +1 @@
<Project Sdk="Microsoft.NET.Sdk" />

11
tests/NamespacesBase/NamespacesBase.CSharp.csproj

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TestGeneratorName>NamespacesDerived.Gen</TestGeneratorName>
<TestGeneratorProjectDir>$(MSBuildProjectDirectory)\..\NamespacesDerived\</TestGeneratorProjectDir>
<EnableGeneratorCompileItems>false</EnableGeneratorCompileItems>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(GenDir)NamespacesDerived\NamespacesBase.cs" />
</ItemGroup>
</Project>

12
tests/NamespacesBase/premake4.lua

@ -3,17 +3,7 @@ function SetupWrapper(name)
return return
end end
project(name .. ".CSharp") SetupExternalManagedTestProject(name .. ".CSharp")
SetupManagedTestProject()
dependson { name .. ".Native", "NamespacesDerived.Gen" }
links { "CppSharp.Runtime" }
SetupTestGeneratorBuildEvent("NamespacesDerived")
files
{
path.join(gendir, "NamespacesDerived", name .. ".cs"),
}
end end
group "Tests/Namespaces" group "Tests/Namespaces"

14
tests/NamespacesDerived/NamespacesDerived.CSharp.csproj

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<EnableGeneratorCompileItems>false</EnableGeneratorCompileItems>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(GenDir)NamespacesDerived\NamespacesDerived.cs" />
<Compile Include="$(GenDir)NamespacesDerived\Std.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NamespacesBase\NamespacesBase.CSharp.csproj" />
</ItemGroup>
</Project>

1
tests/NamespacesDerived/NamespacesDerived.Gen.csproj

@ -0,0 +1 @@
<Project Sdk="Microsoft.NET.Sdk" />

1
tests/NamespacesDerived/NamespacesDerived.Tests.CSharp.csproj

@ -0,0 +1 @@
<Project Sdk="Microsoft.NET.Sdk" />

1
tests/StandardLib/StandardLib.Gen.csproj

@ -0,0 +1 @@
<Project Sdk="Microsoft.NET.Sdk" />

1
tests/StandardLib/StandardLib.Tests.CLI.csproj

@ -0,0 +1 @@
<Project Sdk="Microsoft.NET.Sdk" />

23
tests/Test.Bindings.props

@ -0,0 +1,23 @@
<Project>
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<EnableGeneratorCompileItems>true</EnableGeneratorCompileItems>
</PropertyGroup>
<ItemGroup>
<GeneratedCSharpFiles Include="$(GenDir)$(TestName)\*.cs"></GeneratedCSharpFiles>
<Compile Include="@(GeneratedCSharpFiles)" Condition="$(EnableGeneratorCompileItems)"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(TestGeneratorProjectDir)$(TestGeneratorName).csproj" ReferenceOutputAssembly="false" />
<ProjectReference Include="$(SrcDir)Runtime\CppSharp.Runtime.csproj" />
</ItemGroup>
<Target Name="AddGeneratedCompileItems" BeforeTargets="BeforeCompile">
<ItemGroup Condition="$(EnableGeneratorCompileItems)">
<Compile Remove="@(GeneratedCSharpFiles)" />
<Compile Include="$(GenDir)$(TestName)\*.cs" />
</ItemGroup>
</Target>
</Project>

20
tests/Test.Common.props

@ -0,0 +1,20 @@
<Project>
<PropertyGroup>
<EnableGeneratorCompileItems>true</EnableGeneratorCompileItems>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<EnableDefaultNoneItems>false</EnableDefaultNoneItems>
<IsTestBindings>false</IsTestBindings>
<IsTestGenerator>false</IsTestGenerator>
<IsTest>false</IsTest>
<IsTest Condition="$(MSBuildProjectName.Contains('.Tests'))">true</IsTest>
<IsTestGenerator Condition="$(MSBuildProjectName.EndsWith('.Gen'))">true</IsTestGenerator>
<IsTestBindings Condition="!$(IsTest) AND ($(MSBuildProjectName.EndsWith('.CSharp')) OR $(MSBuildProjectName.EndsWith('.CLI')))">true</IsTestBindings>
<TestName>$(MSBuildProjectName.Substring(0, $(MSBuildProjectName.IndexOf('.'))))</TestName>
<TestGeneratorName>$(TestName).Gen</TestGeneratorName>
<OutputType Condition="$(IsTestGenerator)">Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<None Include="premake4.lua" />
</ItemGroup>
</Project>

31
tests/Test.Generator.props

@ -0,0 +1,31 @@
<Project>
<PropertyGroup>
<GeneratorOutput>$(BaseIntermediateOutputPath)$(TestName).Bindings.timestamp</GeneratorOutput>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(TestName).Gen.cs" />
<Compile Include="$(SrcDir)Generator.Tests\GeneratorTest.cs" Visible="false" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(NativeProjectsDir)$(TestName).Native.vcxproj" ReferenceOutputAssembly="false" Condition="$(IsWindows)" />
<ProjectReference Include="$(SrcDir)Generator\CppSharp.Generator.csproj" />
</ItemGroup>
<ItemGroup>
<GeneratorInputs Include="*.h" />
<GeneratorInputs Include="$(TestName).Gen.cs" />
<UpToDateCheckInput Include="@(GeneratorInputs)" Set="Bindings" />
<UpToDateCheckBuilt Include="$(GeneratorOutput)" Set="Bindings" />
</ItemGroup>
<Target Name="GenerateBindings" Inputs="@(GeneratorInputs)" Outputs="$(GeneratorOutput)" AfterTargets="AfterBuild">
<Exec command='$(DotNetCmd) "$(OutputPath)$(TestGeneratorName).$(GeneratorFileExtension)"' />
<Touch Files="$(GeneratorOutput)" AlwaysCreate="true" />
<ItemGroup>
<FileWrites Include="$(GeneratorOutput)"/>
</ItemGroup>
</Target>
</Project>

20
tests/Test.props

@ -0,0 +1,20 @@
<Project>
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(TestName).Tests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(SrcDir)Generator.Tests\CppSharp.Generator.Tests.csproj" />
<ProjectReference Include="$(TestName).CSharp.csproj" Condition="$(MSBuildProjectName.EndsWith('CSharp'))" />
<ProjectReference Include="$(NativeProjectsDir)$(TestName).Native.vcxproj" Condition="$(IsWindows)" ReferenceOutputAssembly="false" />
<ProjectReference Include="$(NativeProjectsDir)$(TestName).CLI.vcxproj" Condition="$(MSBuildProjectName.EndsWith('CLI')) AND $(IsWindows)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
</ItemGroup>
</Project>

1
tests/VTables/VTables.CSharp.csproj

@ -0,0 +1 @@
<Project Sdk="Microsoft.NET.Sdk" />

1
tests/VTables/VTables.Gen.csproj

@ -0,0 +1 @@
<Project Sdk="Microsoft.NET.Sdk" />

1
tests/VTables/VTables.Tests.CSharp.csproj

@ -0,0 +1 @@
<Project Sdk="Microsoft.NET.Sdk" />
Loading…
Cancel
Save