WASM support, using official binaries (#341)
* chg: New build system that uses the officially distributed binaries, bumped version to 8.0.0, simplified git workflow, removed deprecated OpenGL 1.1 functionality. * chg: Modernize CI workflow, enable SourceLink - Bump workflow actions to latest majors (Node 24); drop deprecated softprops/action-gh-release@v1 - Trigger push builds on main instead of master - Create local nuget feed dir before pack (fixes NU1301) - Enable Microsoft.SourceLink.GitHub for debugging symbols (ref PR #340) * fix: centralized version data in Directory.build.props, and fixed various interop details that had incorrect function signatures * chore: updated readme * fix: version the native extract marker and chain download via DependsOnTargets The .extracted marker now includes the raylib package name, so bumping TargetRaylibTag re-extracts the new archive instead of silently keeping (and packing/copying) the previous version's files. _PrepareNativeLibrary and _StageWasmNative now depend directly on _DownloadAndExtractInternal instead of CallTarget-ing it; dependency targets run in the same project instance, so the resolved properties (RaylibPackageName etc.) propagate naturally. * fix: let the binding build for browser-wasm on both net8.0 and net10.0 The net8-era wasm workload (Microsoft.NET.Runtime.WebAssembly.Sdk 8.0.x, auto-imported for RID browser-wasm) treats every browser-wasm project as a wasm app: it forces OutputType=Exe after project evaluation (CS5001 for a classlib) and hooks its app-bundle build after Build, which errors because a library has no assemblies to bundle. Opt Raylib-cs out via DisableAutoWasmBuildApp (props time, before the workload defaults its trigger) and pin OutputType back to Library in Directory.Build.targets (evaluated after the workload props, so the assignment wins). net10's wasm SDK needs neither workaround. * chore: readme updated * chg: simplifying build logic - a simple line in the documentation should save us the code here * fix: Wrong signature of FrameBufferComplete * chore: readme update * feat: samples default to local project reference, and can optionally use the nuget package * fix: Examples.csproj runs the download task when building locally
This commit is contained in:
parent
ef98ca456a
commit
565f0912ea
27 changed files with 403 additions and 364 deletions
192
.github/workflows/build.yml
vendored
192
.github/workflows/build.yml
vendored
|
|
@ -1,4 +1,8 @@
|
||||||
name: Build
|
# This workflow will build a .NET project
|
||||||
|
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
|
||||||
|
|
||||||
|
name: .NET
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: ["main"]
|
branches: ["main"]
|
||||||
|
|
@ -7,186 +11,46 @@ on:
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- "README.md"
|
- "README.md"
|
||||||
- ".github/ISSUE_TEMPLATE/**"
|
- ".github/ISSUE_TEMPLATE/**"
|
||||||
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
|
||||||
version: ${{ steps.version.outputs.version }}
|
|
||||||
pkgversion: ${{ steps.version.outputs.pkgversion }}
|
|
||||||
steps:
|
steps:
|
||||||
- name: checkout repository
|
- uses: actions/checkout@v7
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: check raylib version
|
- name: Setup .NET
|
||||||
id: version
|
uses: actions/setup-dotnet@v5
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
echo "version=$(sed -n 's/.*<TargetRaylibTag>\(.*\)<\/TargetRaylibTag>.*/\1/p' Raylib-cs/Build.props)">> ${GITHUB_OUTPUT}
|
|
||||||
echo "pkgversion=$(sed -n 's/.*<PackageVersion>\(.*\)<\/PackageVersion>.*/\1/p' Raylib-cs/Build.props)">> ${GITHUB_OUTPUT}
|
|
||||||
|
|
||||||
build-linux:
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
needs: build
|
|
||||||
steps:
|
|
||||||
- name: checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: setup dotnet
|
|
||||||
uses: actions/setup-dotnet@v4
|
|
||||||
with:
|
with:
|
||||||
dotnet-version: |
|
dotnet-version: |
|
||||||
6.0.x
|
|
||||||
8.0.x
|
8.0.x
|
||||||
|
9.0.x
|
||||||
|
10.0.x
|
||||||
|
|
||||||
- name: setup dependencies
|
- name: Prepare local NuGet source
|
||||||
run: |
|
run: mkdir -p nuget
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install \
|
|
||||||
libasound2-dev \
|
|
||||||
libx11-dev \
|
|
||||||
libxrandr-dev \
|
|
||||||
libxi-dev \
|
|
||||||
libgl1-mesa-dev \
|
|
||||||
libglu1-mesa-dev \
|
|
||||||
libxcursor-dev \
|
|
||||||
libxinerama-dev
|
|
||||||
|
|
||||||
- name: build projects
|
- name: Create NuGet Package
|
||||||
run: dotnet build -c Release
|
|
||||||
|
|
||||||
- name: run tests
|
|
||||||
run: dotnet test Raylib-cs.Tests -c Release
|
|
||||||
|
|
||||||
- name: upload build
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: linux-x64
|
|
||||||
path: Raylib-cs.Native/bin/Release/native/raylib/libraylib.so
|
|
||||||
if-no-files-found: error
|
|
||||||
|
|
||||||
build-osx:
|
|
||||||
runs-on: macos-latest
|
|
||||||
needs: build
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
name: [arm64, x64]
|
|
||||||
include:
|
|
||||||
- name: arm64
|
|
||||||
arch: arm64
|
|
||||||
- name: x64
|
|
||||||
arch: x86_64
|
|
||||||
steps:
|
|
||||||
- name: checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: setup dotnet
|
|
||||||
uses: actions/setup-dotnet@v4
|
|
||||||
with:
|
|
||||||
dotnet-version: |
|
|
||||||
6.0.x
|
|
||||||
8.0.x
|
|
||||||
|
|
||||||
- name: build projects
|
|
||||||
run: dotnet build -c Release /p:BuildArch=${{ matrix.arch }}
|
|
||||||
|
|
||||||
- name: run tests
|
|
||||||
run: dotnet test Raylib-cs.Tests -c Release
|
|
||||||
|
|
||||||
- name: upload build
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: osx-${{ matrix.name }}
|
|
||||||
path: Raylib-cs.Native/bin/Release/native/raylib/libraylib.dylib
|
|
||||||
if-no-files-found: error
|
|
||||||
|
|
||||||
build-windows:
|
|
||||||
runs-on: windows-latest
|
|
||||||
needs: build
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
name: [x86, x64]
|
|
||||||
include:
|
|
||||||
- name: x86
|
|
||||||
arch: win32
|
|
||||||
- name: x64
|
|
||||||
arch: x64
|
|
||||||
steps:
|
|
||||||
- name: checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: setup dotnet
|
|
||||||
uses: actions/setup-dotnet@v4
|
|
||||||
with:
|
|
||||||
dotnet-version: |
|
|
||||||
6.0.x
|
|
||||||
8.0.x
|
|
||||||
|
|
||||||
- name: build projects
|
|
||||||
run: dotnet build -c Release /p:BuildArch=${{ matrix.arch }}
|
|
||||||
|
|
||||||
- name: run tests
|
|
||||||
run: dotnet test Raylib-cs.Tests -c Release
|
|
||||||
|
|
||||||
- name: upload build
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: win-${{ matrix.name }}
|
|
||||||
path: Raylib-cs.Native/bin/Release/native/raylib/Release/raylib.dll
|
|
||||||
if-no-files-found: error
|
|
||||||
|
|
||||||
build-publish:
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
needs:
|
|
||||||
- build-linux
|
|
||||||
- build-osx
|
|
||||||
- build-windows
|
|
||||||
steps:
|
|
||||||
- name: checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- uses: actions/download-artifact@v4.1.7
|
|
||||||
with:
|
|
||||||
name: linux-x64
|
|
||||||
path: Raylib-cs/runtimes/linux-x64/native
|
|
||||||
|
|
||||||
- uses: actions/download-artifact@v4.1.7
|
|
||||||
with:
|
|
||||||
name: osx-arm64
|
|
||||||
path: Raylib-cs/runtimes/osx-arm64/native
|
|
||||||
|
|
||||||
- uses: actions/download-artifact@v4.1.7
|
|
||||||
with:
|
|
||||||
name: osx-x64
|
|
||||||
path: Raylib-cs/runtimes/osx-x64/native
|
|
||||||
|
|
||||||
- uses: actions/download-artifact@v4.1.7
|
|
||||||
with:
|
|
||||||
name: win-x86
|
|
||||||
path: Raylib-cs/runtimes/win-x86/native
|
|
||||||
|
|
||||||
- uses: actions/download-artifact@v4.1.7
|
|
||||||
with:
|
|
||||||
name: win-x64
|
|
||||||
path: Raylib-cs/runtimes/win-x64/native
|
|
||||||
|
|
||||||
- name: setup dotnet
|
|
||||||
uses: actions/setup-dotnet@v4
|
|
||||||
with:
|
|
||||||
dotnet-version: |
|
|
||||||
6.0.x
|
|
||||||
8.0.x
|
|
||||||
|
|
||||||
- name: create NuGet Package
|
|
||||||
run: dotnet pack Raylib-cs -c Release --output nuget
|
run: dotnet pack Raylib-cs -c Release --output nuget
|
||||||
|
|
||||||
|
|
||||||
|
- name: Restore + Install Built Package
|
||||||
|
run: |
|
||||||
|
dotnet restore
|
||||||
|
|
||||||
|
- name: Run Tests
|
||||||
|
run: |
|
||||||
|
dotnet test --verbosity normal
|
||||||
|
|
||||||
- name: upload NuGet Package As Artifact
|
- name: upload NuGet Package As Artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
path: nuget/*
|
path: nuget/*
|
||||||
|
|
||||||
- name: upload NuGet Package As Release
|
- name: upload NuGet Package As Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v3
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
with:
|
with:
|
||||||
files: nuget/*
|
files: nuget/*
|
||||||
|
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -177,6 +177,7 @@ PublishScripts/
|
||||||
|
|
||||||
# NuGet Packages
|
# NuGet Packages
|
||||||
*.nupkg
|
*.nupkg
|
||||||
|
nuget
|
||||||
# The packages folder can be ignored because of Package Restore
|
# The packages folder can be ignored because of Package Restore
|
||||||
**/packages/*
|
**/packages/*
|
||||||
# except build/, which is used as an MSBuild target.
|
# except build/, which is used as an MSBuild target.
|
||||||
|
|
|
||||||
14
Directory.Build.props
Normal file
14
Directory.Build.props
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
<Project>
|
||||||
|
<!-- Auto-imported by every project in the repo; referenced via $(RaylibCsVersion). -->
|
||||||
|
<PropertyGroup>
|
||||||
|
<RaylibCsVersion>8.1.0</RaylibCsVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- The net8-era wasm workload treats any browser-wasm project as a wasm *app* and hooks
|
||||||
|
its app-bundle build after Build, which fails for a plain classlib. Opt the binding out
|
||||||
|
(must happen at props time, before the workload defaults WasmBuildAppAfterThisTarget).
|
||||||
|
The matching OutputType pin lives in Directory.Build.targets. -->
|
||||||
|
<PropertyGroup Condition="'$(MSBuildProjectName)' == 'Raylib-cs' And '$(RuntimeIdentifier)' == 'browser-wasm'">
|
||||||
|
<DisableAutoWasmBuildApp>true</DisableAutoWasmBuildApp>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
10
Directory.Build.targets
Normal file
10
Directory.Build.targets
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<Project>
|
||||||
|
<!-- The net8-era wasm workload (Microsoft.NET.Runtime.WebAssembly.Sdk 8.0.x, imported for
|
||||||
|
RID browser-wasm) unconditionally sets OutputType=Exe after project evaluation, which
|
||||||
|
breaks the net8.0 classlib build with CS5001. Pin it back to Library here: this file is
|
||||||
|
imported after the workload props, so the assignment wins. (net10's wasm SDK leaves
|
||||||
|
OutputType alone; Examples stays an Exe and is excluded.) -->
|
||||||
|
<PropertyGroup Condition="'$(MSBuildProjectName)' == 'Raylib-cs' And '$(RuntimeIdentifier)' == 'browser-wasm'">
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
|
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using Raylib_cs;
|
|
||||||
using static Raylib_cs.Raylib;
|
using static Raylib_cs.Raylib;
|
||||||
|
|
||||||
namespace Examples.Core;
|
namespace Examples.Core;
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,34 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
|
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<StartupObject>Examples.Program</StartupObject>
|
<StartupObject>Examples.Program</StartupObject>
|
||||||
<RunWorkingDirectory>$(MSBuildThisFileDirectory)</RunWorkingDirectory>
|
<RunWorkingDirectory>$(MSBuildThisFileDirectory)</RunWorkingDirectory>
|
||||||
<LangVersion>default</LangVersion>
|
<LangVersion>12</LangVersion>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
<IsPackable>false</IsPackable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Remove="Core/LoadingThread.cs"/>
|
<Compile Remove="Core/LoadingThread.cs"/>
|
||||||
<Compile Remove="Text/Unicode.cs"/>
|
<Compile Remove="Text/Unicode.cs"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Using Include="Raylib_cs" />
|
<Using Include="Raylib_cs"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition="'$(UseRaylibCsPackage)' != 'true'">
|
||||||
|
<ProjectReference Include="..\Raylib-cs\Raylib-cs.csproj"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- NuGet imports this from buildTransitive/ for PackageReference; ProjectReference needs it imported from source
|
||||||
|
so the native raylib library is downloaded and copied to the output. -->
|
||||||
|
<Import Project="..\Raylib-cs\Raylib-cs.targets" Condition="'$(UseRaylibCsPackage)' != 'true'"/>
|
||||||
|
|
||||||
|
<ItemGroup Condition="'$(UseRaylibCsPackage)' == 'true'">
|
||||||
|
<PackageReference Include="Raylib-cs" Version="$(RaylibCsVersion)"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="../Raylib-cs/Raylib-cs.csproj" />
|
|
||||||
<ProjectReference Include="../Raylib-cs.Native/Raylib-cs.Native.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
using Raylib_cs;
|
||||||
using static Raylib_cs.Raylib;
|
using static Raylib_cs.Raylib;
|
||||||
|
|
||||||
namespace Examples.Shapes;
|
namespace Examples.Shapes;
|
||||||
|
|
|
||||||
7
NuGet.config
Normal file
7
NuGet.config
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<packageSources>
|
||||||
|
<add key="LocalRaylibBuild" value="./nuget" />
|
||||||
|
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
|
||||||
|
</packageSources>
|
||||||
|
</configuration>
|
||||||
52
README.md
52
README.md
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# Raylib-cs
|
# Raylib-cs
|
||||||
|
|
||||||
C# bindings for raylib, a simple and easy-to-use library to learn videogames programming (www.raylib.com)
|
C# bindings for raylib, a simple and easy-to-use library to learn video games programming (www.raylib.com)
|
||||||
|
|
||||||
[](https://github.com/raylib-cs/raylib-cs/graphs/contributors)
|
[](https://github.com/raylib-cs/raylib-cs/graphs/contributors)
|
||||||
[](LICENSE)
|
[](LICENSE)
|
||||||
|
|
@ -13,17 +13,30 @@ C# bindings for raylib, a simple and easy-to-use library to learn videogames pro
|
||||||
Raylib-cs targets net8.0, net10.0 and uses the [official 6.0 release](https://github.com/raysan5/raylib/releases/tag/6.0)
|
Raylib-cs targets net8.0, net10.0 and uses the [official 6.0 release](https://github.com/raysan5/raylib/releases/tag/6.0)
|
||||||
to build the native libraries.
|
to build the native libraries.
|
||||||
|
|
||||||
|
### Version 8.1.0 of Raylib-cs supports the following runtimes:
|
||||||
|
- **browser-wasm** *(raylib-6.0_webassembly)* 🆕
|
||||||
|
- **linux-x64** *(raylib-6.0_linux_amd64)*
|
||||||
|
- **osx-arm64** *(raylib-6.0_macos)*
|
||||||
|
- **osx-x64** *(raylib-6.0_macos)*
|
||||||
|
- **win-x64** *(raylib-6.0_win64_msvc16)*
|
||||||
|
- **win-x86** *(raylib-6.0_win32_msvc16)*
|
||||||
|
|
||||||
|
The following frameworks are deprecated (fall back to Version 7.x if required):
|
||||||
|
- net6.0 (end of life)
|
||||||
|
|
||||||
|
|
||||||
## Status
|
## Status
|
||||||
|
|
||||||
Raylib-cs is passively maintained. Occasional updates may be released from time to time. Pull requests may be
|
Raylib-cs is passively maintained. Occasional updates may be released from time to time. Pull requests may be
|
||||||
accepted if they don't have a large maintainence burden.
|
accepted if they don't have a large maintenance burden.
|
||||||
|
|
||||||
## Installation - NuGet
|
## Installation - NuGet
|
||||||
|
|
||||||
This is the prefered method to get started.
|
This is the preferred method to get started.
|
||||||
|
|
||||||
1) Pick a folder in which you would like to start a raylib project. For example "MyRaylibCSProj".
|
1) Pick a folder in which you would like to start a raylib project. For example, "MyRaylibCSProj."
|
||||||
2) Then from a terminal whilst in the directory you just created run the following commands. (Please keep in mind .NET should already be installed on your system).
|
2) Then from a terminal (for example, a VSCode terminal), whilst in the directory you just created
|
||||||
|
run the following commands. (Please keep in mind .NET should already be installed on your system)
|
||||||
|
|
||||||
```
|
```
|
||||||
dotnet new console
|
dotnet new console
|
||||||
|
|
@ -34,9 +47,11 @@ dotnet add package Raylib-cs
|
||||||
|
|
||||||
[](https://www.nuget.org/packages/Raylib-cs/)
|
[](https://www.nuget.org/packages/Raylib-cs/)
|
||||||
|
|
||||||
If you need to edit Raylib-cs source then you will need to add the bindings as a project (see below).
|
If you need to edit the Raylib-cs source, then you will need to add the bindings as a project (see below).
|
||||||
|
|
||||||
Remember if you are trying to run the above commands in the terminal that you need to be *inside the intended project directory* (not just inside the solution directory) otherwise the command won't work.
|
If you are new to using NuGet (or you've forgotten) and are trying to run the above command in the command prompt,
|
||||||
|
remember that you need to be *inside the intended project directory* (not just inside the solution directory);
|
||||||
|
otherwise the command won't work.
|
||||||
|
|
||||||
## Installation - Manual
|
## Installation - Manual
|
||||||
|
|
||||||
|
|
@ -46,9 +61,28 @@ Remember if you are trying to run the above commands in the terminal that you ne
|
||||||
|
|
||||||
3. Download/build the native libraries for the platforms you want using the [official 6.0 release](https://github.com/raysan5/raylib/releases/tag/6.0). **NOTE: the MSVC version is required for Windows platforms**
|
3. Download/build the native libraries for the platforms you want using the [official 6.0 release](https://github.com/raysan5/raylib/releases/tag/6.0). **NOTE: the MSVC version is required for Windows platforms**
|
||||||
|
|
||||||
4. Add the native libraries to your project so they are in the same directory as the executable/can be found in the [search path](https://www.mono-project.com/docs/advanced/pinvoke/).
|
4. Set up the native libraries, so they are in the same directory as the executable/can be found in the [search path](https://www.mono-project.com/docs/advanced/pinvoke/).
|
||||||
|
|
||||||
6. Start coding!
|
5. Start coding!
|
||||||
|
|
||||||
|
## Building from source
|
||||||
|
|
||||||
|
The `Examples` and `Raylib-cs.Tests` projects consume the binding as a NuGet package, and the in-repo
|
||||||
|
version may not be published on nuget.org yet. Pack it once into the local feed before the first build:
|
||||||
|
|
||||||
|
```
|
||||||
|
dotnet pack Raylib-cs -c Release -o nuget
|
||||||
|
dotnet build
|
||||||
|
```
|
||||||
|
|
||||||
|
`NuGet.config` points restore at the local `./nuget` feed, so both projects pick up the freshly packed
|
||||||
|
package. If you skip the pack step on a fresh clone, restore fails with NU1301 (the `./nuget` source
|
||||||
|
doesn't exist) or NU1102 (Raylib-cs not found) — running the pack command fixes both.
|
||||||
|
|
||||||
|
When iterating on the binding itself, note that NuGet caches the extracted package by version and
|
||||||
|
ignores repacks of the same version. After repacking, delete the old package from `./nuget` and clear
|
||||||
|
the cached copy (`dotnet nuget locals global-packages --clear`, or delete
|
||||||
|
`~/.nuget/packages/raylib-cs/<version>`) before restoring again.
|
||||||
|
|
||||||
## Hello, World!
|
## Hello, World!
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
namespace Raylib_cs.Native;
|
|
||||||
|
|
||||||
internal class Native
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
@ -1,71 +0,0 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk" InitialTargets="ConfigureNative">
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
|
||||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
|
||||||
<DebugType>none</DebugType>
|
|
||||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
|
||||||
<GenerateDependencyFile>False</GenerateDependencyFile>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<Import Project="../Raylib-cs/Build.props" />
|
|
||||||
|
|
||||||
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Linux'))">
|
|
||||||
<NativeExt>so</NativeExt>
|
|
||||||
<NativePre>lib</NativePre>
|
|
||||||
<NativeArch>x64</NativeArch>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('OSX'))">
|
|
||||||
<NativeExt>dylib</NativeExt>
|
|
||||||
<NativePre>lib</NativePre>
|
|
||||||
<NativeArch Condition="$(BuildArch) == ''">x86_x64</NativeArch>
|
|
||||||
<NativeArch Condition="$(BuildArch) != ''">$(BuildArch)</NativeArch>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
|
|
||||||
<NativeExt>dll</NativeExt>
|
|
||||||
<NativePre>$(Configuration)/</NativePre>
|
|
||||||
<NativeArch Condition="$(BuildArch) == ''">x64</NativeArch>
|
|
||||||
<NativeArch Condition="$(BuildArch) != ''">$(BuildArch)</NativeArch>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('OSX')) AND $(NativeArch) == 'arm64'">
|
|
||||||
<CMakeArgs Include="-D CMAKE_OSX_ARCHITECTURES=arm64" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('OSX')) AND $(NativeArch) == 'x86_64'">
|
|
||||||
<CMakeArgs Include="-D CMAKE_OSX_ARCHITECTURES=x86_64" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup Condition="$([MSBuild]::IsOsPlatform('Windows')) AND $(NativeArch) == 'win32'">
|
|
||||||
<CMakeArgs Include="-A win32" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup Condition="$([MSBuild]::IsOsPlatform('Windows')) AND $(NativeArch) == 'x64'">
|
|
||||||
<CMakeArgs Include="-A x64" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Content Include="$(OutputPath)native/raylib/$(NativePre)raylib.$(NativeExt)" Link="%(Filename)%(Extension)" CopyToOutputDirectory="PreserveNewest" Condition="Exists('$(OutputPath)native/raylib/$(NativePre)raylib.$(NativeExt)')" />
|
|
||||||
|
|
||||||
<CMakeArgs Include="-B $(OutputPath)native" />
|
|
||||||
<CMakeArgs Include="-S $(BaseIntermediateOutputPath)raylib-$(TargetRaylibTag)" />
|
|
||||||
<CMakeArgs Include="-D CMAKE_BUILD_TYPE=$(Configuration)" />
|
|
||||||
<CMakeArgs Include="-D BUILD_SHARED_LIBS=ON" />
|
|
||||||
<CMakeArgs Include="-D BUILD_EXAMPLES=OFF" />
|
|
||||||
<CMakeArgs Include="-D CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded" />
|
|
||||||
<CMakeArgs Include="-D CMAKE_MINIMUM_REQUIRED_VERSION=3.15" />
|
|
||||||
<CMakeArgs Include="-D CMAKE_POLICY_DEFAULT_CMP0091=NEW" />
|
|
||||||
<!-- <CMakeArgs Include="-D GLFW_BUILD_WAYLAND=ON" /> -->
|
|
||||||
<!-- <CMakeArgs Include="-D GRAPHICS=GRAPHICS_API_OPENGL_43" /> -->
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<Target Name="ConfigureNative" Condition="$(SkipLocalBuild) != true">
|
|
||||||
<DownloadFile SourceUrl="https://github.com/raysan5/raylib/archive/refs/tags/$(TargetRaylibTag).zip" DestinationFolder="$(BaseIntermediateOutputPath)" DestinationFileName="raylib.zip" Condition="!Exists('$(BaseIntermediateOutputPath)raylib.zip')" />
|
|
||||||
|
|
||||||
<Unzip SourceFiles="$(BaseIntermediateOutputPath)raylib.zip" DestinationFolder="$(BaseIntermediateOutputPath)" OverwriteReadOnlyFiles="true" Condition="!Exists('$(BaseIntermediateOutputPath)raylib-$(TargetRaylibTag)')" />
|
|
||||||
|
|
||||||
<Exec Command="cmake @(CMakeArgs, ' ') $(CMakeExtraArgs)" />
|
|
||||||
<Exec Command="cmake --build $(OutputPath)native --config $(Configuration)" />
|
|
||||||
</Target>
|
|
||||||
</Project>
|
|
||||||
|
|
@ -1,18 +1,21 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net10.0</TargetFrameworks>
|
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<LangVersion>12</LangVersion>
|
<LangVersion>12</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
|
||||||
<PackageReference Include="xunit" Version="2.6.2" />
|
<PackageReference Include="xunit" Version="2.6.2"/>
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4" />
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4"/>
|
||||||
<PackageReference Include="coverlet.collector" Version="6.0.0" />
|
<PackageReference Include="coverlet.collector" Version="6.0.4">
|
||||||
</ItemGroup>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Raylib-cs\Raylib-cs.csproj" />
|
<PackageReference Include="Raylib-cs" Version="$(RaylibCsVersion)"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ public static class BlittableHelper
|
||||||
|
|
||||||
public class RaylibTests
|
public class RaylibTests
|
||||||
{
|
{
|
||||||
private unsafe void CheckType<T>() where T : unmanaged
|
private static void CheckType<T>() where T : unmanaged
|
||||||
{
|
{
|
||||||
Assert.True(BlittableHelper.IsBlittable<T>());
|
Assert.True(BlittableHelper.IsBlittable<T>());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raylib-cs.Tests", "Raylib-c
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Examples", "Examples\Examples.csproj", "{1E2A5986-3F11-457F-AF97-D0C08D0060BA}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Examples", "Examples\Examples.csproj", "{1E2A5986-3F11-457F-AF97-D0C08D0060BA}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raylib-cs.Native", "Raylib-cs.Native\Raylib-cs.Native.csproj", "{B89AA313-3675-42A3-80BC-6156913E3A27}"
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
|
@ -32,9 +30,5 @@ Global
|
||||||
{1E2A5986-3F11-457F-AF97-D0C08D0060BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{1E2A5986-3F11-457F-AF97-D0C08D0060BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{1E2A5986-3F11-457F-AF97-D0C08D0060BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{1E2A5986-3F11-457F-AF97-D0C08D0060BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{1E2A5986-3F11-457F-AF97-D0C08D0060BA}.Release|Any CPU.Build.0 = Release|Any CPU
|
{1E2A5986-3F11-457F-AF97-D0C08D0060BA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{B89AA313-3675-42A3-80BC-6156913E3A27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{B89AA313-3675-42A3-80BC-6156913E3A27}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{B89AA313-3675-42A3-80BC-6156913E3A27}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{B89AA313-3675-42A3-80BC-6156913E3A27}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
|
||||||
2
Raylib-cs.sln.DotSettings
Normal file
2
Raylib-cs.sln.DotSettings
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=macos/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetRaylibTag>6.0</TargetRaylibTag>
|
<TargetRaylibTag>6.0</TargetRaylibTag>
|
||||||
<Version>8.0.0</Version>
|
<Version>$(RaylibCsVersion)</Version>
|
||||||
<PackageVersion>8.0.0</PackageVersion>
|
<PackageVersion>$(RaylibCsVersion)</PackageVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -1,54 +1,165 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
|
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
|
||||||
<EnableDefaultItems>false</EnableDefaultItems>
|
<AssemblyName>Raylib-cs</AssemblyName>
|
||||||
<AssemblyName>Raylib-cs</AssemblyName>
|
<RootNamespace>Raylib_cs</RootNamespace>
|
||||||
<RootNamespace>Raylib_cs</RootNamespace>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<LangVersion>12</LangVersion>
|
||||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
</PropertyGroup>
|
||||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
|
||||||
<LangVersion>12</LangVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Title>Raylib-cs</Title>
|
<NoWarn>$(NoWarn);1591</NoWarn> <!-- missing XML comment on public member -->
|
||||||
<Description>C# bindings for raylib - A simple and easy-to-use library to learn videogames programming</Description>
|
</PropertyGroup>
|
||||||
<RepositoryUrl>https://github.com/raylib-cs/raylib-cs/</RepositoryUrl>
|
|
||||||
<Authors>raylib-cs</Authors>
|
|
||||||
<PackageLicenseExpression>Zlib</PackageLicenseExpression>
|
|
||||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
|
||||||
<PackageIcon>raylib-cs_64x64.png</PackageIcon>
|
|
||||||
<PackageTags>raylib csharp gamedev</PackageTags>
|
|
||||||
<PackageProjectUrl>https://www.raylib.com/</PackageProjectUrl>
|
|
||||||
<PackProject>true</PackProject>
|
|
||||||
<IncludeSymbols>true</IncludeSymbols>
|
|
||||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
|
||||||
<RepositoryType>git</RepositoryType>
|
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<PropertyGroup>
|
||||||
<None Include="logo/raylib-cs_64x64.png" Pack="true" PackagePath="" />
|
<PackageId>Raylib-cs</PackageId>
|
||||||
<None Include="../README.md" Pack="true" PackagePath="" />
|
<Description>C# bindings for raylib</Description>
|
||||||
</ItemGroup>
|
<RepositoryUrl>https://github.com/raylib-cs/raylib-cs/</RepositoryUrl>
|
||||||
|
<Authors>raylib-cs</Authors>
|
||||||
|
<PackageLicenseExpression>Zlib</PackageLicenseExpression>
|
||||||
|
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||||
|
<PackageIcon>raylib-cs_64x64.png</PackageIcon>
|
||||||
|
<PackageTags>raylib csharp gamedev</PackageTags>
|
||||||
|
|
||||||
<ItemGroup>
|
<IncludeSymbols>true</IncludeSymbols>
|
||||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
|
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||||
</ItemGroup>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<Import Project="./Build.props" />
|
<ItemGroup>
|
||||||
|
<!-- Use explicit PackagePath for these to prevent ambiguity -->
|
||||||
|
<None Include="logo/raylib-cs_64x64.png" Pack="true" PackagePath="raylib-cs_64x64.png"/>
|
||||||
|
<None Include="../README.md" Pack="true" PackagePath="README.md"/>
|
||||||
|
<None Include="Raylib-cs.targets" Pack="true" PackagePath="buildTransitive\Raylib-cs.targets"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="runtimes/**" Link="runtimes/%(RecursiveDir)/%(Filename)%(Extension)">
|
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/>
|
||||||
<PackagePath>runtimes/</PackagePath>
|
</ItemGroup>
|
||||||
<Pack>true</Pack>
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<!-- Import Build Props -->
|
||||||
<Compile Include="interop\*.cs" />
|
<Import Project="./Build.props" Condition="Exists('./Build.props')"/>
|
||||||
<Compile Include="types\*.cs" />
|
<PropertyGroup Condition="'$(TargetRaylibTag)' == ''">
|
||||||
<Compile Include="types\native\*.cs" />
|
<TargetRaylibTag>6.0</TargetRaylibTag>
|
||||||
</ItemGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<NativesRoot>$(BaseIntermediateOutputPath)natives/</NativesRoot>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Single source of truth: RID -> raylib release archive + library file.
|
||||||
|
Pkg/Ext name the upstream release asset; Lib is the download-time copy glob
|
||||||
|
(libraylib.so* catches the versioned .so); Pack is the exact file name packed
|
||||||
|
into the nupkg; PackAs renames it inside the package (wasm: libraylib.web.a -> raylib.a).
|
||||||
|
Drives PackageRids, the per-RID resolve below, and the pack file list. -->
|
||||||
|
<ItemGroup>
|
||||||
|
<RaylibRid Include="win-x64" Pkg="raylib-$(TargetRaylibTag)_win64_msvc16" Ext=".zip" Lib="raylib.dll" Pack="raylib.dll"/>
|
||||||
|
<RaylibRid Include="win-x86" Pkg="raylib-$(TargetRaylibTag)_win32_msvc16" Ext=".zip" Lib="raylib.dll" Pack="raylib.dll"/>
|
||||||
|
<RaylibRid Include="linux-x64" Pkg="raylib-$(TargetRaylibTag)_linux_amd64" Ext=".tar.gz" Lib="libraylib.so*" Pack="libraylib.so"/>
|
||||||
|
<RaylibRid Include="osx-x64" Pkg="raylib-$(TargetRaylibTag)_macos" Ext=".tar.gz" Lib="libraylib.dylib" Pack="libraylib.dylib"/>
|
||||||
|
<RaylibRid Include="osx-arm64" Pkg="raylib-$(TargetRaylibTag)_macos" Ext=".tar.gz" Lib="libraylib.dylib" Pack="libraylib.dylib"/>
|
||||||
|
<RaylibRid Include="browser-wasm" Pkg="raylib-$(TargetRaylibTag)_webassembly" Ext=".zip" Lib="libraylib.web.a" Pack="libraylib.web.a" PackAs="raylib.a"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Resolve the active RID's archive metadata from the table. Runs as a dependency
|
||||||
|
(execution phase) because properties can't read items during evaluation. -->
|
||||||
|
<Target Name="_ResolveRaylibNative">
|
||||||
|
<PropertyGroup>
|
||||||
|
<RaylibPackageName>@(RaylibRid->WithMetadataValue('Identity','$(RuntimeIdentifier)')->'%(Pkg)')</RaylibPackageName>
|
||||||
|
<ArchiveExt>@(RaylibRid->WithMetadataValue('Identity','$(RuntimeIdentifier)')->'%(Ext)')</ArchiveExt>
|
||||||
|
<LibPattern>@(RaylibRid->WithMetadataValue('Identity','$(RuntimeIdentifier)')->'%(Lib)')</LibPattern>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<!-- ================================================================== -->
|
||||||
|
<!-- TARGET: PACKING -->
|
||||||
|
<!-- ================================================================== -->
|
||||||
|
<Target Name="PrepareNativesForPack" BeforeTargets="_GetPackageFiles">
|
||||||
|
<MSBuild Projects="$(MSBuildThisFileFullPath)"
|
||||||
|
Targets="_DownloadAndExtractInternal"
|
||||||
|
Properties="RuntimeIdentifier=%(RaylibRid.Identity);TargetFramework=$(TargetFramework);TargetRaylibTag=$(TargetRaylibTag)"
|
||||||
|
BuildInParallel="false"/>
|
||||||
|
|
||||||
|
<!-- Direct injection into _PackageFiles, derived from the RID table.
|
||||||
|
RIDs without PackAs keep their file name in runtimes/<rid>/native/;
|
||||||
|
RIDs with PackAs (wasm) are renamed via an explicit file path. -->
|
||||||
|
<ItemGroup>
|
||||||
|
<_PackageFiles Include="@(RaylibRid->'$(NativesRoot)%(Identity)/%(Pkg)/lib/%(Pack)')"
|
||||||
|
Condition="'%(RaylibRid.PackAs)' == ''">
|
||||||
|
<PackagePath>runtimes/%(RaylibRid.Identity)/native/</PackagePath>
|
||||||
|
<BuildAction>None</BuildAction>
|
||||||
|
</_PackageFiles>
|
||||||
|
<_PackageFiles Include="@(RaylibRid->'$(NativesRoot)%(Identity)/%(Pkg)/lib/%(Pack)')"
|
||||||
|
Condition="'%(RaylibRid.PackAs)' != ''">
|
||||||
|
<PackagePath>runtimes/%(RaylibRid.Identity)/native/%(RaylibRid.PackAs)</PackagePath>
|
||||||
|
<BuildAction>None</BuildAction>
|
||||||
|
</_PackageFiles>
|
||||||
|
</ItemGroup>
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<!-- ================================================================== -->
|
||||||
|
<!-- TARGET: LOCAL DEVELOPMENT -->
|
||||||
|
<!-- ================================================================== -->
|
||||||
|
|
||||||
|
<!-- Resolve and download the native library for a given RID (used by ProjectReference consumers). -->
|
||||||
|
<Target Name="_PrepareNativeLibrary" DependsOnTargets="_DownloadAndExtractInternal" Outputs="@(_RaylibNativeLibraryItem)">
|
||||||
|
<PropertyGroup>
|
||||||
|
<_RaylibNativesDir>$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)/$(NativesRoot)'))</_RaylibNativesDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<_NativeCandidate Include="$(_RaylibNativesDir)$(RuntimeIdentifier)/**/$(LibPattern)"/>
|
||||||
|
<_RaylibNativeLibraryItem Include="@(_NativeCandidate)"/>
|
||||||
|
</ItemGroup>
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<!-- Stage libraylib.web.a as raylib.a for wasm linking (pinvoke module name must match LibraryImport). -->
|
||||||
|
<Target Name="_StageWasmNative" DependsOnTargets="_DownloadAndExtractInternal"
|
||||||
|
Condition="'$(RuntimeIdentifier)' == 'browser-wasm'">
|
||||||
|
<PropertyGroup>
|
||||||
|
<_WasmNativeSrc>$(NativesRoot)browser-wasm/$(RaylibPackageName)/lib/libraylib.web.a</_WasmNativeSrc>
|
||||||
|
<_WasmNativeDst>$(MSBuildThisFileDirectory)obj/browser-wasm/raylib.a</_WasmNativeDst>
|
||||||
|
</PropertyGroup>
|
||||||
|
<MakeDir Directories="$(MSBuildThisFileDirectory)obj/browser-wasm"/>
|
||||||
|
<Copy SourceFiles="$(_WasmNativeSrc)" DestinationFiles="$(_WasmNativeDst)" SkipUnchangedFiles="true"/>
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<!-- ================================================================== -->
|
||||||
|
<!-- WORKER: DOWNLOADER -->
|
||||||
|
<!-- ================================================================== -->
|
||||||
|
|
||||||
|
<!-- Resolves the archive metadata first (properties can't read items at eval time, so the
|
||||||
|
RID -> package mapping must be applied here in the execution phase via DependsOnTargets).
|
||||||
|
Tasks are guarded on RaylibPackageName so an unknown RID is a no-op. -->
|
||||||
|
<Target Name="_DownloadAndExtractInternal" DependsOnTargets="_ResolveRaylibNative">
|
||||||
|
<PropertyGroup>
|
||||||
|
<_WorkDir>$(NativesRoot)$(RuntimeIdentifier)/</_WorkDir>
|
||||||
|
<_ArchiveFile>$(_WorkDir)$(RaylibPackageName)$(ArchiveExt)</_ArchiveFile>
|
||||||
|
<!-- Marker includes the package name so bumping TargetRaylibTag re-extracts
|
||||||
|
instead of silently keeping the old version's files. -->
|
||||||
|
<_ExtractMarker>$(_WorkDir)$(RaylibPackageName).extracted</_ExtractMarker>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Message Text="Downloading raylib $(TargetRaylibTag) native for $(RuntimeIdentifier)"
|
||||||
|
Importance="normal" Condition="'$(RaylibPackageName)' != ''"/>
|
||||||
|
|
||||||
|
<MakeDir Directories="$(_WorkDir)" Condition="'$(RaylibPackageName)' != ''"/>
|
||||||
|
|
||||||
|
<DownloadFile
|
||||||
|
SourceUrl="https://github.com/raysan5/raylib/releases/download/$(TargetRaylibTag)/$(RaylibPackageName)$(ArchiveExt)"
|
||||||
|
DestinationFolder="$(_WorkDir)"
|
||||||
|
DestinationFileName="$(RaylibPackageName)$(ArchiveExt)"
|
||||||
|
Condition="'$(RaylibPackageName)' != '' AND !Exists('$(_ArchiveFile)')"
|
||||||
|
Retries="3"/>
|
||||||
|
|
||||||
|
<Unzip SourceFiles="$(_ArchiveFile)"
|
||||||
|
DestinationFolder="$(_WorkDir)"
|
||||||
|
OverwriteReadOnlyFiles="true"
|
||||||
|
Condition="'$(ArchiveExt)' == '.zip' AND !Exists('$(_ExtractMarker)')"/>
|
||||||
|
|
||||||
|
<Exec Command="tar -xzf "$(RaylibPackageName)$(ArchiveExt)""
|
||||||
|
WorkingDirectory="$(_WorkDir)"
|
||||||
|
Condition="'$(ArchiveExt)' == '.tar.gz' AND !Exists('$(_ExtractMarker)')"/>
|
||||||
|
|
||||||
|
<Touch Files="$(_ExtractMarker)" AlwaysCreate="true" Condition="'$(RaylibPackageName)' != ''"/>
|
||||||
|
</Target>
|
||||||
|
</Project>
|
||||||
54
Raylib-cs/Raylib-cs.targets
Normal file
54
Raylib-cs/Raylib-cs.targets
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<!-- Default raylib release tag for consumers (Package/ProjectReference) that don't import Build.props. -->
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetRaylibTag Condition="'$(TargetRaylibTag)' == ''">6.0</TargetRaylibTag>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'browser-wasm'">
|
||||||
|
<EmccFlags>$(EmccFlags) -sUSE_GLFW=3</EmccFlags>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- NuGet layout: runtimes/browser-wasm/native/raylib.a -->
|
||||||
|
<ItemGroup Condition="'$(RuntimeIdentifier)' == 'browser-wasm' And Exists('$(MSBuildThisFileDirectory)..\runtimes\browser-wasm\native\raylib.a')">
|
||||||
|
<NativeFileReference Include="$(MSBuildThisFileDirectory)..\runtimes\browser-wasm\native\raylib.a"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- ProjectReference / local build: stage via Raylib-cs.csproj -->
|
||||||
|
<Target Name="_StageRaylibWasmNative"
|
||||||
|
BeforeTargets="_PrepareForBrowserWasmBuildNative"
|
||||||
|
Condition="'$(RuntimeIdentifier)' == 'browser-wasm' And !Exists('$(MSBuildThisFileDirectory)..\runtimes\browser-wasm\native\raylib.a')">
|
||||||
|
<MSBuild Projects="$(MSBuildThisFileDirectory)Raylib-cs.csproj"
|
||||||
|
Targets="_StageWasmNative"
|
||||||
|
Properties="RuntimeIdentifier=browser-wasm;TargetFramework=$(TargetFramework);TargetRaylibTag=$(TargetRaylibTag)"/>
|
||||||
|
<ItemGroup>
|
||||||
|
<NativeFileReference Include="$(MSBuildThisFileDirectory)obj\browser-wasm\raylib.a"/>
|
||||||
|
</ItemGroup>
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<!-- ProjectReference: copy raylib next to the app (NuGet does this automatically for PackageReference).
|
||||||
|
Guarded on the sibling csproj existing: present for ProjectReference (targets imported from source),
|
||||||
|
absent for PackageReference (targets shipped alone in buildTransitive/). -->
|
||||||
|
<Target Name="_CopyRaylibNativeToConsumerOutput"
|
||||||
|
AfterTargets="Build"
|
||||||
|
Condition="'$(RuntimeIdentifier)' != 'browser-wasm' And '$(MSBuildProjectName)' != 'Raylib-cs' And Exists('$(MSBuildThisFileDirectory)Raylib-cs.csproj')">
|
||||||
|
<PropertyGroup>
|
||||||
|
<!-- Use the explicit RID if set, else the host RID the SDK resolves (covers osx-arm64). -->
|
||||||
|
<_RaylibNativeRid Condition="'$(_RaylibNativeRid)' == ''">$(RuntimeIdentifier)</_RaylibNativeRid>
|
||||||
|
<_RaylibNativeRid Condition="'$(_RaylibNativeRid)' == ''">$(NETCoreSdkPortableRuntimeIdentifier)</_RaylibNativeRid>
|
||||||
|
<_RaylibNativeOutputDir>$(OutputPath)runtimes\$(_RaylibNativeRid)\native\</_RaylibNativeOutputDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<MSBuild Projects="$(MSBuildThisFileDirectory)Raylib-cs.csproj"
|
||||||
|
Targets="_PrepareNativeLibrary"
|
||||||
|
Properties="RuntimeIdentifier=$(_RaylibNativeRid);TargetFramework=$(TargetFramework);TargetRaylibTag=$(TargetRaylibTag)">
|
||||||
|
<Output TaskParameter="TargetOutputs" ItemName="_RaylibNativeLibrary"/>
|
||||||
|
</MSBuild>
|
||||||
|
<MakeDir Directories="$(_RaylibNativeOutputDir)"/>
|
||||||
|
<Copy SourceFiles="@(_RaylibNativeLibrary)"
|
||||||
|
DestinationFolder="$(_RaylibNativeOutputDir)"
|
||||||
|
SkipUnchangedFiles="true"/>
|
||||||
|
<!-- Also copy to the app root so NativeLibrary.TryLoad("raylib") succeeds. -->
|
||||||
|
<Copy SourceFiles="@(_RaylibNativeLibrary)"
|
||||||
|
DestinationFolder="$(OutputPath)"
|
||||||
|
SkipUnchangedFiles="true"/>
|
||||||
|
</Target>
|
||||||
|
</Project>
|
||||||
|
|
@ -26,7 +26,14 @@ public static unsafe partial class Raylib
|
||||||
|
|
||||||
static Raylib()
|
static Raylib()
|
||||||
{
|
{
|
||||||
NativeLibrary.SetDllImportResolver(Assembly.GetExecutingAssembly(), ResolveDllImport);
|
// On WebAssembly (browser) the native library is statically linked into the main
|
||||||
|
// module, and P/Invokes are resolved by the runtime's built-in static-linking table.
|
||||||
|
// A custom resolver would override that and fail (there is no library to load), so we
|
||||||
|
// only install it on platforms where raylib is a separate dynamic library.
|
||||||
|
if (!OperatingSystem.IsBrowser())
|
||||||
|
{
|
||||||
|
NativeLibrary.SetDllImportResolver(Assembly.GetExecutingAssembly(), ResolveDllImport);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IntPtr ResolveDllImport(string libraryName, Assembly assembly, DllImportSearchPath? searchPath)
|
public static IntPtr ResolveDllImport(string libraryName, Assembly assembly, DllImportSearchPath? searchPath)
|
||||||
|
|
|
||||||
|
|
@ -298,19 +298,6 @@ public static unsafe partial class Rlgl
|
||||||
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
|
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
|
||||||
public static partial void DisableVertexAttribute(uint index);
|
public static partial void DisableVertexAttribute(uint index);
|
||||||
|
|
||||||
/// <summary>Enable attribute state pointer<br/>
|
|
||||||
/// NOTE: Only available for GRAPHICS_API_OPENGL_11</summary>
|
|
||||||
[LibraryImport(NativeLibName, EntryPoint = "rlEnableStatePointer")]
|
|
||||||
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
|
|
||||||
public static partial void EnableStatePointer(int vertexAttribType, void* buffer);
|
|
||||||
|
|
||||||
/// <summary>Disable attribute state pointer<br/>
|
|
||||||
/// NOTE: Only available for GRAPHICS_API_OPENGL_11</summary>
|
|
||||||
[LibraryImport(NativeLibName, EntryPoint = "rlDisableStatePointer")]
|
|
||||||
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
|
|
||||||
public static partial void DisableStatePointer(int vertexAttribType);
|
|
||||||
|
|
||||||
|
|
||||||
// Textures state
|
// Textures state
|
||||||
|
|
||||||
/// <summary>Select and active a texture slot</summary>
|
/// <summary>Select and active a texture slot</summary>
|
||||||
|
|
@ -757,7 +744,7 @@ public static unsafe partial class Rlgl
|
||||||
/// <summary>Load depth texture/renderbuffer (to be attached to fbo)</summary>
|
/// <summary>Load depth texture/renderbuffer (to be attached to fbo)</summary>
|
||||||
[LibraryImport(NativeLibName, EntryPoint = "rlLoadTextureDepth")]
|
[LibraryImport(NativeLibName, EntryPoint = "rlLoadTextureDepth")]
|
||||||
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
|
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
|
||||||
public static partial uint LoadTextureDepth(int width, int height, CBool useRenderBuffer);
|
public static partial uint LoadTextureDepth(int width, int height, int useRenderBuffer);
|
||||||
|
|
||||||
/// <summary>Load texture cubemap data</summary>
|
/// <summary>Load texture cubemap data</summary>
|
||||||
[LibraryImport(NativeLibName, EntryPoint = "rlLoadTextureCubemap")]
|
[LibraryImport(NativeLibName, EntryPoint = "rlLoadTextureCubemap")]
|
||||||
|
|
@ -826,8 +813,8 @@ public static unsafe partial class Rlgl
|
||||||
public static partial void FramebufferAttach(
|
public static partial void FramebufferAttach(
|
||||||
uint fboId,
|
uint fboId,
|
||||||
uint texId,
|
uint texId,
|
||||||
FramebufferAttachType attachType,
|
int attachType,
|
||||||
FramebufferAttachTextureType texType,
|
int texType,
|
||||||
int mipLevel
|
int mipLevel
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
|
|
||||||
|
|
@ -186,6 +186,14 @@ public static unsafe partial class Raylib
|
||||||
/// <summary>Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR)</summary>
|
/// <summary>Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR)</summary>
|
||||||
public static void TraceLog(TraceLogLevel logLevel, string text)
|
public static void TraceLog(TraceLogLevel logLevel, string text)
|
||||||
{
|
{
|
||||||
|
// raylib's TraceLog is variadic (const char *text, ...). WebAssembly cannot invoke
|
||||||
|
// variadic C functions from managed code (traps with "function signature mismatch").
|
||||||
|
if (OperatingSystem.IsBrowser())
|
||||||
|
{
|
||||||
|
Console.WriteLine(text);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
using Utf8Buffer str1 = text.ToUtf8Buffer();
|
using Utf8Buffer str1 = text.ToUtf8Buffer();
|
||||||
TraceLog(logLevel, str1.AsPointer());
|
TraceLog(logLevel, str1.AsPointer());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,19 @@ namespace Raylib_cs;
|
||||||
|
|
||||||
public static unsafe partial class Rlgl
|
public static unsafe partial class Rlgl
|
||||||
{
|
{
|
||||||
|
/// <summary>Load depth texture/renderbuffer (to be attached to fbo)</summary>
|
||||||
|
public static uint LoadTextureDepth(int width, int height, bool useRenderBuffer) =>
|
||||||
|
LoadTextureDepth(width, height, useRenderBuffer ? 1 : 0);
|
||||||
|
|
||||||
|
/// <summary>Attach texture/renderbuffer to a framebuffer</summary>
|
||||||
|
public static void FramebufferAttach(
|
||||||
|
uint fboId,
|
||||||
|
uint texId,
|
||||||
|
FramebufferAttachType attachType,
|
||||||
|
FramebufferAttachTextureType texType,
|
||||||
|
int mipLevel
|
||||||
|
) => FramebufferAttach(fboId, texId, (int)attachType, (int)texType, mipLevel);
|
||||||
|
|
||||||
/// <summary>Set shader value matrices</summary>
|
/// <summary>Set shader value matrices</summary>
|
||||||
public static void SetUniformMatrices(int locIndex, Matrix4x4[] mat)
|
public static void SetUniformMatrices(int locIndex, Matrix4x4[] mat)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue