Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WGPU native libs #1348

Merged
merged 4 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions .github/workflows/wgpu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: WGPU
on:
push:
branches-ignore:
- "ci/*"
- "develop/*"
- "main"
paths:
- "build/submodules/wgpu-native"
- "build/nuke/Build.Native.cs"
- ".github/workflows/wgpu.yml"
jobs:
Build:
strategy:
fail-fast: false
matrix:
env:
- os: ubuntu-latest
name: Linux
nuke_invoke: ./build.sh
extras: |
sudo apt-get update
sudo apt-get install -y gcc-multilib
- os: windows-latest
name: Windows
nuke_invoke: ./build.cmd
extras: ""
- os: macos-latest
name: Darwin
nuke_invoke: ./build.sh
extras: ""
name: ${{ matrix.env.name }} Build
runs-on: ${{ matrix.env.os }}
steps:
- uses: dtolnay/rust-toolchain@nightly
if: runner.os == 'Windows'
with:
toolchain: nightly-x86_64-pc-windows-msvc

- uses: dtolnay/rust-toolchain@nightly
if: runner.os == 'Linux'
with:
toolchain: nightly-x86_64-unknown-linux-gnu

- uses: dtolnay/rust-toolchain@nightly
if: runner.os == 'macOS'
with:
toolchain: nightly-x86_64-apple-darwin

- name: Add targets
if: runner.os == 'Windows'
run: |
rustup target add i686-pc-windows-msvc
rustup target add aarch64-pc-windows-msvc

- name: Add targets
if: runner.os == 'Linux'
run: |
rustup target add i686-unknown-linux-gnu

- name: Add targets
if: runner.os == 'macOS'
run: |
rustup target add aarch64-apple-darwin

- uses: actions/checkout@v2
with:
token: ${{ secrets.PUSHABLE_GITHUB_TOKEN }}
- name: Checkout submodules, configure git
run: |
git -c submodule.third_party/git-hooks.update=none submodule update --init --recursive build/submodules/wgpu-native
git config --local user.email "9011267+dotnet-bot@users.noreply.github.com"
git config --local user.name "The Silk.NET Automaton"
- name: Extra prerequisites
run: |
echo running extras
${{ matrix.env.extras }}
- name: Setup .NET 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.201
- name: Setup .NET 7.0.102
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.0.102
- name: Build WGPU
run: ${{ matrix.env.nuke_invoke }} Wgpu
env:
PUSHABLE_GITHUB_TOKEN: ${{ secrets.PUSHABLE_GITHUB_TOKEN }}

15 changes: 15 additions & 0 deletions Silk.NET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Direct3D11.Extensi
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.DirectComposition", "src\Microsoft\Silk.NET.DirectComposition\Silk.NET.DirectComposition.csproj", "{8773396C-5EDF-498C-97D7-1D2728CB969B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.WebGPU.Native.WGPU", "src\Native\Silk.NET.WebGPU.Native.WGPU\Silk.NET.WebGPU.Native.WGPU.csproj", "{4031A5EB-820B-478D-A656-85C93210054E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -3389,6 +3391,18 @@ Global
{8773396C-5EDF-498C-97D7-1D2728CB969B}.Release|x64.Build.0 = Release|Any CPU
{8773396C-5EDF-498C-97D7-1D2728CB969B}.Release|x86.ActiveCfg = Release|Any CPU
{8773396C-5EDF-498C-97D7-1D2728CB969B}.Release|x86.Build.0 = Release|Any CPU
{4031A5EB-820B-478D-A656-85C93210054E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4031A5EB-820B-478D-A656-85C93210054E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4031A5EB-820B-478D-A656-85C93210054E}.Debug|x64.ActiveCfg = Debug|Any CPU
{4031A5EB-820B-478D-A656-85C93210054E}.Debug|x64.Build.0 = Debug|Any CPU
{4031A5EB-820B-478D-A656-85C93210054E}.Debug|x86.ActiveCfg = Debug|Any CPU
{4031A5EB-820B-478D-A656-85C93210054E}.Debug|x86.Build.0 = Debug|Any CPU
{4031A5EB-820B-478D-A656-85C93210054E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4031A5EB-820B-478D-A656-85C93210054E}.Release|Any CPU.Build.0 = Release|Any CPU
{4031A5EB-820B-478D-A656-85C93210054E}.Release|x64.ActiveCfg = Release|Any CPU
{4031A5EB-820B-478D-A656-85C93210054E}.Release|x64.Build.0 = Release|Any CPU
{4031A5EB-820B-478D-A656-85C93210054E}.Release|x86.ActiveCfg = Release|Any CPU
{4031A5EB-820B-478D-A656-85C93210054E}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -3661,6 +3675,7 @@ Global
{58FECE86-7530-4E6F-BA61-512BE44DEA83} = {F2CF5D32-4B41-425E-B229-8FFC48F88063}
{82626916-C5F3-46E7-B0EC-1D38191450C7} = {58FECE86-7530-4E6F-BA61-512BE44DEA83}
{8773396C-5EDF-498C-97D7-1D2728CB969B} = {F2CF5D32-4B41-425E-B229-8FFC48F88063}
{4031A5EB-820B-478D-A656-85C93210054E} = {72E7FA64-5B1E-477D-BD30-63B7F206B3C4}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F5273D7F-3334-48DF-94E3-41AE6816CD4D}
Expand Down
53 changes: 53 additions & 0 deletions build/nuke/Build.Native.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,59 @@ string AndroidHome
)
);


AbsolutePath WgpuPath => RootDirectory / "build" / "submodules" / "wgpu-native";

Target Wgpu => CommonTarget
(
x => x.Before(Compile)
.After(Clean)
.Executes
(
() =>
{
var runtimes = RootDirectory / "src" / "Native" / "Silk.NET.WebGPU.Native.WGPU" / "runtimes";

var target = WgpuPath / "target";
EnsureCleanDirectory(target);

if(OperatingSystem.IsWindows())
{
//Compile Windows libraries
InheritedShell("cargo build --release --target=i686-pc-windows-msvc", WgpuPath).AssertZeroExitCode();
InheritedShell("cargo build --release --target=x86_64-pc-windows-msvc", WgpuPath).AssertZeroExitCode();
InheritedShell("cargo build --release --target=aarch64-pc-windows-msvc", WgpuPath).AssertZeroExitCode();

CopyFile(target / "i686-pc-windows-msvc" / "release" / "wgpu_native.dll", runtimes / "win-x86" / "native" / "wgpu_native.dll", FileExistsPolicy.Overwrite);
CopyFile(target / "x86_64-pc-windows-msvc" / "release" / "wgpu_native.dll", runtimes / "win-x64" / "native" / "wgpu_native.dll", FileExistsPolicy.Overwrite);
CopyFile(target / "aarch64-pc-windows-msvc" / "release" / "wgpu_native.dll", runtimes / "win-arm64" / "native" / "wgpu_native.dll", FileExistsPolicy.Overwrite);
}

if(OperatingSystem.IsLinux())
{
//Compile Linux libraries
InheritedShell("cargo build --release --target=i686-unknown-linux-gnu", WgpuPath).AssertZeroExitCode();
InheritedShell("cargo build --release --target=x86_64-unknown-linux-gnu", WgpuPath).AssertZeroExitCode();

CopyFile(target / "i686-unknown-linux-gnu" / "release" / "libwgpu_native.so", runtimes / "linux-x86" / "native" / "libwgpu_native.so", FileExistsPolicy.Overwrite);
CopyFile(target / "x86_64-unknown-linux-gnu" / "release" / "libwgpu_native.so", runtimes / "linux-x64" / "native" / "libwgpu_native.so", FileExistsPolicy.Overwrite);
}

if(OperatingSystem.IsMacOS())
{
//Compile MacOS libraries
InheritedShell("cargo build --release --target=aarch64-apple-darwin", WgpuPath).AssertZeroExitCode();
InheritedShell("cargo build --release --target=x86_64-apple-darwin", WgpuPath).AssertZeroExitCode();

CopyFile(target / "x86_64-apple-darwin" / "release" / "libwgpu_native.dylib", runtimes / "osx-x64" / "native" / "libwgpu_native.dylib", FileExistsPolicy.Overwrite);
CopyFile(target / "aarch64-apple-darwin" / "release" / "libwgpu_native.dylib", runtimes / "osx-arm64" / "native" / "libwgpu_native.dylib", FileExistsPolicy.Overwrite);
}

PrUpdatedNativeBinary("Wgpu");
}
)
);

AbsolutePath GLFWPath => RootDirectory / "build" / "submodules" / "GLFW";

Target GLFW => CommonTarget
Expand Down
2 changes: 1 addition & 1 deletion build/submodules/wgpu-native
1 change: 1 addition & 0 deletions src/Native/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ compatibility with the rest of your solution:
- Silk.NET.Assimp.Native: BSD-3-Clause
- Silk.NET.SDL.Native and Silk.NET.GLFW.Native: Zlib
- Silk.NET.OpenAL.Soft.Native: LGPL-2.0-or-later
- Silk.NET.WebGPU.Native.WGPU: MIT/Apache-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<SilkNativePackage>true</SilkNativePackage>
</PropertyGroup>

<Import Project="..\..\..\build\props\common.props" />

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net4.6.1</TargetFrameworks>
<PackageId>Silk.NET.WebGPU.Native.WGPU</PackageId>
<Authors>.NET Foundation and Contributors</Authors>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/dotnet/Silk.NET</PackageProjectUrl>
<Description>Multi-platform native library for WGPU.</Description>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/gfx-rs/wgpu-native</RepositoryUrl>
<IncludeBuildOutput>false</IncludeBuildOutput>
<IncludeContentInPack>true</IncludeContentInPack>
</PropertyGroup>

<ItemGroup>
<Content Include="build\net461\$(PackageId).props" PackagePath="build\net461\$(PackageId).props" />
<Content Include="runtimes\linux-x86\native\libwgpu_native.so" PackagePath="runtimes\linux-x86\native\libwgpu_native.so" />
<Content Include="runtimes\linux-x64\native\libwgpu_native.so" PackagePath="runtimes\linux-x64\native\libwgpu_native.so" />
<Content Include="runtimes\osx-x64\native\libwgpu_native.dylib" PackagePath="runtimes\osx-x64\native\libwgpu_native.dylib" />
<Content Include="runtimes\osx-arm64\native\libwgpu_native.dylib" PackagePath="runtimes\osx-arm64\native\libwgpu_native.dylib" />
<Content Include="runtimes\win-x86\native\wgpu_native.dll" PackagePath="runtimes\win-x86\native\wgpu_native.dll" />
<Content Include="runtimes\win-x64\native\wgpu_native.dll" PackagePath="runtimes\win-x64\native\wgpu_native.dll" />
<Content Include="runtimes\win-arm64\native\wgpu_native.dll" PackagePath="runtimes\win-arm64\native\wgpu_native.dll" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_Ultz_NativePackages_SDL_IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</_Ultz_NativePackages_SDL_IsWindows>
Beyley marked this conversation as resolved.
Show resolved Hide resolved
<_Ultz_NativePackages_SDL_IsMacOS Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</_Ultz_NativePackages_SDL_IsMacOS>
<_Ultz_NativePackages_SDL_IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</_Ultz_NativePackages_SDL_IsLinux>

<_Ultz_NativePackages_SDL_NativeRuntime Condition=" '$(_Ultz_NativePackages_SDL_NativeRuntime)' == '' And '$(_Ultz_NativePackages_SDL_IsMacOS)' == 'true' And ('$(Prefer32Bit)' == 'false' Or '$(PlatformTarget)' == 'x64')">osx-x64</_Ultz_NativePackages_SDL_NativeRuntime>
<_Ultz_NativePackages_SDL_NativeRuntime Condition=" '$(_Ultz_NativePackages_SDL_NativeRuntime)' == '' And '$(_Ultz_NativePackages_SDL_IsLinux)' == 'true' And ('$(Prefer32Bit)' == 'false' Or '$(PlatformTarget)' == 'x64')">linux-x64</_Ultz_NativePackages_SDL_NativeRuntime>
<_Ultz_NativePackages_SDL_NativeRuntime Condition=" '$(_Ultz_NativePackages_SDL_NativeRuntime)' == '' And '$(_Ultz_NativePackages_SDL_IsWindows)' == 'true' And ('$(Prefer32Bit)' == 'true' Or '$(PlatformTarget)' == 'x86')">win-x86</_Ultz_NativePackages_SDL_NativeRuntime>
<_Ultz_NativePackages_SDL_NativeRuntime Condition=" '$(_Ultz_NativePackages_SDL_NativeRuntime)' == '' And '$(_Ultz_NativePackages_SDL_IsWindows)' == 'true' And ('$(Prefer32Bit)' == 'false' Or '$(PlatformTarget)' == 'x64')">win-x64</_Ultz_NativePackages_SDL_NativeRuntime>
<_Ultz_NativePackages_SDL_NativeRuntime Condition=" '$(_Ultz_NativePackages_SDL_NativeRuntime)' == '' And '$(_Ultz_NativePackages_SDL_IsWindows)' == 'true' And '$(PlatformTarget)' == 'arm64'">win-arm64</_Ultz_NativePackages_SDL_NativeRuntime>

<_Ultz_NativePackages_SDL_NativeLibName Condition="'$(_Ultz_NativePackages_SDL_NativeRuntime)' == 'win-x86'">wgpu_native.dll</_Ultz_NativePackages_SDL_NativeLibName>
<_Ultz_NativePackages_SDL_NativeLibName Condition="'$(_Ultz_NativePackages_SDL_NativeRuntime)' == 'win-x64'">wgpu_native.dll</_Ultz_NativePackages_SDL_NativeLibName>
<_Ultz_NativePackages_SDL_NativeLibName Condition="'$(_Ultz_NativePackages_SDL_NativeRuntime)' == 'win-arm64'">wgpu_native.dll</_Ultz_NativePackages_SDL_NativeLibName>
<_Ultz_NativePackages_SDL_NativeLibName Condition="'$(_Ultz_NativePackages_SDL_NativeRuntime)' == 'osx-x64'">libwgpu_native.dylib</_Ultz_NativePackages_SDL_NativeLibName>
<_Ultz_NativePackages_SDL_NativeLibName Condition="'$(_Ultz_NativePackages_SDL_NativeRuntime)' == 'osx-arm64'">libwgpu_native.dylib</_Ultz_NativePackages_SDL_NativeLibName>
<_Ultz_NativePackages_SDL_NativeLibName Condition="'$(_Ultz_NativePackages_SDL_NativeRuntime)' == 'linux-x86'">libwgpu_native.so</_Ultz_NativePackages_SDL_NativeLibName>
<_Ultz_NativePackages_SDL_NativeLibName Condition="'$(_Ultz_NativePackages_SDL_NativeRuntime)' == 'linux-x64'">libwgpu_native.so</_Ultz_NativePackages_SDL_NativeLibName>
</PropertyGroup>
<ItemGroup>
<Content Condition="'$(_Ultz_NativePackages_SDL_NativeRuntime)' != ''" Include="$(MSBuildThisFileDirectory)..\..\runtimes\$(_Ultz_NativePackages_SDL_NativeRuntime)\native\$(_Ultz_NativePackages_SDL_NativeLibName)">
<Link>%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
</ItemGroup>
</Project>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.