Skip to content

Commit

Permalink
Merge branch 'main' into UNC-245-Android-Support
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanL8 committed Feb 9, 2024
2 parents b54eaba + 099fadb commit 9f94875
Show file tree
Hide file tree
Showing 89 changed files with 2,525 additions and 1,782 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/llvm-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ jobs:
fail-fast: false
matrix:
config:
- { os: windows-2022, platform: x86, vs: "Program Files/Microsoft Visual Studio/2022" }
- { os: windows-2022, platform: x64, vs: "Program Files/Microsoft Visual Studio/2022" }
- { os: windows-2022, platform: x64, configuration : Debug, vs: "Program Files/Microsoft Visual Studio/2022" }
- { os: windows-2022, platform: x64, configuration : RelWithDebInfo, vs: "Program Files/Microsoft Visual Studio/2022" }

runs-on: ${{ matrix.config.os }}

Expand All @@ -19,6 +19,7 @@ jobs:
CXX: ${{ matrix.config.cxx }}
VS_VERSION: ${{ matrix.config.vs }}
PLATFORM: ${{ matrix.config.platform }}
CONFIGURATION: ${{ matrix.config.configuration }}
ACTIONS_ALLOW_UNSECURE_COMMANDS: true

steps:
Expand Down Expand Up @@ -51,16 +52,16 @@ jobs:

- name: Build LLVM
shell: bash
run: build/build.sh build_llvm -platform $PLATFORM
run: build/build.sh build_llvm -platform $PLATFORM -configuration $CONFIGURATION
working-directory: C:\CppSharp

- name: Package LLVM
shell: bash
run: build/build.sh package_llvm -platform $PLATFORM
run: build/build.sh package_llvm -platform $PLATFORM -configuration $CONFIGURATION
working-directory: C:\CppSharp

- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
name: llvm
path: C:\CppSharp\build\llvm\llvm-*-*.*
path: C:\CppSharp\build\llvm\llvm-*-*.*
10 changes: 8 additions & 2 deletions .github/workflows/llvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ jobs:
matrix:
config:
- { os: ubuntu-22.04, platform: x64, cxx: g++-11, cc: gcc-11 }
- { os: ubuntu-22.04, platform: arm64, cxx: g++-11, cc: gcc-11 }
- { os: macos-11, platform: x64, cxx: clang++, cc: clang }
- { os: macos-12, platform: x64, cxx: clang++, cc: clang }
- { os: macos-12, platform: arm64, cxx: clang++, cc: clang }

runs-on: ${{ matrix.config.os }}

Expand All @@ -22,9 +24,13 @@ jobs:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: lukka/get-cmake@latest

- name: Install cross compilers
if: startsWith(matrix.config.os, 'ubuntu') && startsWith(matrix.config.platform, 'arm64')
run: sudo apt install -y g++-aarch64-linux-gnu gcc-aarch64-linux-gnu

- name: Clone LLVM
shell: bash
run: build/build.sh clone_llvm
Expand All @@ -41,4 +47,4 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: llvm
path: build/llvm/llvm-*-*.*
path: build/llvm/llvm-*-*.*
10 changes: 5 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
DOTNET_CLI_TELEMETRY_OPTOUT: true

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: '0'

Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
shell: bash
run: build/build.sh prepack -platform $PLATFORM

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: intermediate
path: |
Expand All @@ -82,14 +82,14 @@ jobs:
DOTNET_CLI_TELEMETRY_OPTOUT: true

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: '0'

- name: Set version
run: nbgv cloud --all-vars

- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: intermediate

Expand All @@ -102,7 +102,7 @@ jobs:
run: build/build.sh pack

- name: Upload package
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: CppSharp.nupkg
path: |
Expand Down
113 changes: 57 additions & 56 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,57 +1,58 @@
<Project>
<Import Project="build/config.props" />

<PropertyGroup>
<RootDir>$(MSBuildThisFileDirectory)</RootDir>
<Platforms>x86;x64</Platforms>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryUrl>https://github.com/mono/CppSharp</RepositoryUrl>
<RepositoryCommit>$(GITHUB_SHA)</RepositoryCommit>
<Authors>João Matos, Dimitar Dobrev, Jose Torres</Authors>
<Copyright>João Matos, Dimitar Dobrev</Copyright>
<Version>$(NBGV_Version)</Version>
<AssemblyVersion>$(NBGV_AssemblyVersion)</AssemblyVersion>
<AssemblyFileVersion>$(NBGV_AssemblyFileVersion)</AssemblyFileVersion>
<AssemblyInformationalVersion>$(NBGV_AssemblyInformationalVersion)</AssemblyInformationalVersion>
<IsPackable>false</IsPackable>
<BuildDir>$(RootDir)build\</BuildDir>
<ObjDir>$(BuildDir)obj\</ObjDir>
<GenDir>$(BuildDir)gen\</GenDir>
<SrcDir>$(RootDir)src\</SrcDir>
<GlobalTargetFramework>$(TargetFramework)</GlobalTargetFramework>
<BaseIntermediateOutputPath>$(ObjDir)$(MSBuildProjectName)\</BaseIntermediateOutputPath>
<BaseOutputPath>$(RootDir)bin\</BaseOutputPath>
<OutputPath>$(BaseOutputPath)$(Configuration)_$(PlatformTarget)\</OutputPath>
<ActionDir>$(BuildDir)$(PremakeAction)\</ActionDir>
<NativeProjectsDir>$(ActionDir)projects\</NativeProjectsDir>
<PackageDir>$(RootDir)artifacts\package\</PackageDir>
<TargetDir>$(OutputPath)</TargetDir>
<LangVersion>9.0</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>
<RID Condition="$(IsWindows)">win</RID>
<RID Condition="$(IsLinux)">linux</RID>
<RID Condition="$(IsMacOSX)">osx</RID>
<RID>$(RID)-$(PlatformTarget)</RID>
</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>

<Target Name="prepack" DependsOnTargets="Build" Condition="'$(IsPackable)' == 'true' AND '$(Platform)' == 'x64'">
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(PackageDir)runtimes\$(RID)\lib\$(GlobalTargetFramework)" />
</Target>
<Project>
<Import Project="build/config.props" />

<PropertyGroup>
<RootDir>$(MSBuildThisFileDirectory)</RootDir>
<Platforms>x86;x64</Platforms>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryUrl>https://github.com/mono/CppSharp</RepositoryUrl>
<RepositoryCommit>$(GITHUB_SHA)</RepositoryCommit>
<Authors>João Matos, Dimitar Dobrev, Jose Torres</Authors>
<Copyright>João Matos, Dimitar Dobrev</Copyright>
<Version>$(NBGV_Version)</Version>
<AssemblyVersion>$(NBGV_AssemblyVersion)</AssemblyVersion>
<AssemblyFileVersion>$(NBGV_AssemblyFileVersion)</AssemblyFileVersion>
<AssemblyInformationalVersion>$(NBGV_AssemblyInformationalVersion)</AssemblyInformationalVersion>
<IsPackable>false</IsPackable>
<BuildDir>$(RootDir)build\</BuildDir>
<ObjDir>$(BuildDir)obj\</ObjDir>
<GenDir>$(BuildDir)gen\</GenDir>
<SrcDir>$(RootDir)src\</SrcDir>
<GlobalTargetFramework>$(TargetFramework)</GlobalTargetFramework>
<BaseIntermediateOutputPath>$(ObjDir)$(MSBuildProjectName)\</BaseIntermediateOutputPath>
<BaseOutputPath>$(RootDir)bin\</BaseOutputPath>
<OutputPath>$(BaseOutputPath)$(Configuration)_$(PlatformTarget)\</OutputPath>
<ActionDir>$(BuildDir)$(PremakeAction)\</ActionDir>
<NativeProjectsDir>$(ActionDir)projects\</NativeProjectsDir>
<PackageDir>$(RootDir)artifacts\package\</PackageDir>
<TargetDir>$(OutputPath)</TargetDir>
<LangVersion>10.0</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>
<RID Condition="$(IsWindows)">win</RID>
<RID Condition="$(IsLinux)">linux</RID>
<RID Condition="$(IsMacOSX)">osx</RID>
<RID>$(RID)-$(PlatformTarget)</RID>
</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>

<Target Name="prepack" DependsOnTargets="Build" Condition="'$(IsPackable)' == 'true' AND '$(Platform)' == 'x64'">
<Copy SourceFiles="$(TargetDir)$(TargetFileName)" DestinationFolder="$(PackageDir)ref\$(GlobalTargetFramework)" Condition="'$(ProduceReferenceAssembly)' == 'true' AND '$(RID)' == 'win-x64'" />
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(PackageDir)runtimes\$(RID)\lib\$(GlobalTargetFramework)" />
</Target>
</Project>
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,11 @@ Please see the following resources for more information:

## Community

Feel free to open up issues on Github for any problems you find.
Feel free to open up issues on GitHub for any problems you find.

## Support

For building wrappers and priority support please write to &#99;&#112;&#112;&#115;&#104;&#97;&#114;&#112;&#64;&#112;&#114;&#111;&#116;&#111;&#110;&#109;&#97;&#105;&#108;&#46;&#99;&#111;&#109;.
Alternatively, you may post bounties at https://www.bountysource.com/.
If you need commercial support feel free to open a discussion or issue for discussion.

## Users

Expand Down Expand Up @@ -109,4 +108,6 @@ CppSharp is used by the following projects:

[GLFW3.NET](https://github.com/realvictorprm/GLFW3.NET)

[DearImguiSharp](https://github.com/Sewer56/DearImguiSharp)

Please feel free to send us a pull request adding your own projects to the list above.
5 changes: 5 additions & 0 deletions build/Helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ newoption {
allowed = {
{ "x86", "x86 32-bits" },
{ "x64", "x64 64-bits" },
{ "arm64","ARM64 64-bits" },
}
}

Expand Down Expand Up @@ -251,11 +252,15 @@ function AddPlatformSpecificFiles(folder, filename)
filter { "toolset:msc*", "architecture:x86" }
files { path.join(folder, "i686-pc-win32-msvc", filename) }
elseif os.istarget("macosx") then
filter { "architecture:arm64" }
files { path.join(folder, "arm64-apple-darwin12.4.0", filename) }
filter { "architecture:x86_64" }
files { path.join(folder, "x86_64-apple-darwin12.4.0", filename) }
filter {"architecture:x86" }
files { path.join(folder, "i686-apple-darwin12.4.0", filename) }
elseif os.istarget("linux") then
filter { "architecture:arm64" }
files { path.join(folder, "arm64-linux-gnu" .. (UseCxx11ABI() and "-cxx11abi" or ""), filename) }
filter { "architecture:x86_64" }
files { path.join(folder, "x86_64-linux-gnu" .. (UseCxx11ABI() and "-cxx11abi" or ""), filename) }
else
Expand Down
6 changes: 6 additions & 0 deletions build/LLVM.lua
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ function SetupLLVMLibs()
"LLVMX86CodeGen",
"LLVMX86Desc",
"LLVMX86Info",
"LLVMAArch64AsmParser",
"LLVMAArch64CodeGen",
"LLVMAArch64Desc",
"LLVMAArch64Disassembler",
"LLVMAArch64Info",
"LLVMAArch64Utils",
"LLVMipo",
"LLVMInstrumentation",
"LLVMVectorize",
Expand Down
36 changes: 35 additions & 1 deletion build/llvm/LLVM.lua
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ function cmake(gen, conf, builddir, options)
.. ' -DLLVM_ENABLE_ZSTD=false'
.. ' -DLLVM_INCLUDE_DOCS=false'
.. ' -DLLVM_INCLUDE_EXAMPLES=false'
.. ' -DLLVM_TARGETS_TO_BUILD="X86"'
.. ' -DLLVM_TARGETS_TO_BUILD="X86;AArch64"'
.. ' -DLLVM_TOOL_BUGPOINT_BUILD=false'
.. ' -DLLVM_TOOL_BUGPOINT_PASSES_BUILD=false'
.. ' -DLLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD=false'
Expand Down Expand Up @@ -438,10 +438,44 @@ function build_llvm(llvm_build)
local options = os.ishost("macosx") and
"-DLLVM_ENABLE_LIBCXX=true" or ""
local is32bits = target_architecture() == "x86"
local targetIsArm64 = target_architecture() == "arm64"

if is32bits then
options = options .. (is32bits and " -DLLVM_BUILD_32_BITS=true" or "")
end

if targetIsArm64 then
if os.host() == "linux" then
local host_arch = unix_host_architecture()
if host_arch ~= "aarch64" then
options = options .. ""
.. ' -DCMAKE_SYSTEM_NAME=Linux'
.. ' -DCMAKE_SYSTEM_PROCESSOR=aarch64'
.. ' -DCMAKE_C_COMPILER=/usr/bin/aarch64-linux-gnu-gcc'
.. ' -DCMAKE_CXX_COMPILER=/usr/bin/aarch64-linux-gnu-g++'
.. ' -DCMAKE_ASM_COMPILER=/usr/bin/aarch64-linux-gnu-as'
.. ' -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER'
.. ' -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY'
.. ' -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY'
.. ' -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY'
.. ' ' .. options
end
end
if os.host() == "macosx" then
local host_arch = unix_host_architecture()
if host_arch ~= "arm64" then
options = options .. ""
.. ' -DCMAKE_SYSTEM_NAME=Darwin'
.. ' -DCMAKE_SYSTEM_PROCESSOR=arm64'
.. ' -DCMAKE_C_COMPILER_TARGET=arm64-apple-darwin21.6.0'
.. ' -DCMAKE_CXX_COMPILER_TARGET=arm64-apple-darwin21.6.0'
.. ' -DCMAKE_ASM_COMPILER_TARGET=arm64-apple-darwin21.6.0'
.. ' ' .. options
end
end
end


cmake("Ninja", conf, llvm_build, options)
ninja('"' .. llvm_build .. '"')
ninja('"' .. llvm_build .. '"', "clang-headers")
Expand Down
7 changes: 6 additions & 1 deletion build/scripts/Utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ function download(url, file, try)
return res, code
end

function unix_host_architecture()
result, errorCode = os.outputof("uname -m")
return result
end

--
-- Allows copying directories.
-- It uses the premake patterns (**=recursive match, *=file match)
Expand Down Expand Up @@ -202,4 +207,4 @@ function os.rmfiles(src_dir, filter)
print( "Error: " .. counter .. "/" .. #matches .. " files removed.")
return nil
end
end
end
2 changes: 2 additions & 0 deletions examples/SDL/SDL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public void Preprocess(Driver driver, ASTContext ctx)

ctx.IgnoreEnumWithMatchingItem("SDL_ENOMEM");
ctx.IgnoreFunctionWithName("SDL_Error");

ctx.SetFunctionParameterUsage("SDL_PollEvent", 1, ParameterUsage.Out);
}

public void Postprocess(Driver driver, ASTContext ctx)
Expand Down
3 changes: 2 additions & 1 deletion src/AST/ASTContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ public enum CppAbi
Itanium,
Microsoft,
ARM,
AArch64,
iOS,
iOS64,
AppleARM64,
WebAssembly
}

Expand Down
6 changes: 6 additions & 0 deletions src/AST/Template.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@ public override string ToString()
/// </summary>
public class ClassTemplatePartialSpecialization : ClassTemplateSpecialization
{
public readonly List<Declaration> Parameters;

public ClassTemplatePartialSpecialization()
{
Parameters = new List<Declaration>();
}
}

/// <summary>
Expand Down
Loading

0 comments on commit 9f94875

Please sign in to comment.