Skip to content

Commit 43a41a9

Browse files
committed
Pull dev
2 parents cd866cb + a2d070e commit 43a41a9

File tree

113 files changed

+21809
-5544
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+21809
-5544
lines changed

.github/workflows/publish-site.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Website Build
2+
on:
3+
push:
4+
branches:
5+
- 'develop/3.0'
6+
pull_request:
7+
permissions:
8+
contents: read
9+
pages: write
10+
id-token: write
11+
12+
jobs:
13+
Build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Build Website
18+
run: |
19+
git submodule update --init eng/submodules/silk.net-2.x
20+
cd eng/submodules/silk.net-2.x
21+
git fetch --all
22+
cd ../../..
23+
./build.sh website
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
- name: Upload artifact
27+
if: ${{ github.repository == 'dotnet/Silk.NET' && github.ref == 'refs/heads/develop/3.0' }}
28+
uses: actions/upload-pages-artifact@v3
29+
with:
30+
path: "artifacts/docs/Silk.NET"
31+
Deploy:
32+
if: ${{ github.repository == 'dotnet/Silk.NET' && github.ref == 'refs/heads/develop/3.0' }}
33+
environment:
34+
name: github-pages
35+
url: ${{ steps.deployment.outputs.page_url }}
36+
runs-on: ubuntu-latest
37+
needs: Build
38+
steps:
39+
- name: Deploy to GitHub Pages
40+
id: deployment
41+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,13 @@ src/**/build/
473473
# Silk.NET Build System
474474
*.gen.sln
475475
*.gen.txt
476+
excluded-platforms.txt
477+
478+
# Silk.NET Website Generation Output
479+
#/docs/
480+
src/Website/Silk.NET.Statiq/temp
481+
src/Website/Silk.NET.Statiq/cache
482+
.nuke/temp
476483

477484
# SilkTouch configs
478485
!eng/silktouch/**/*.rsp

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@
1010
[submodule "eng/submodules/sdl"]
1111
path = eng/submodules/sdl
1212
url = https://github.com/libsdl-org/SDL
13+
[submodule "eng/submodules/silk.net-2.x"]
14+
path = eng/submodules/silk.net-2.x
15+
url = https://github.com/dotnet/Silk.NET

.nuke/build.schema.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@
2727
"Clean",
2828
"Compile",
2929
"DeclareApi",
30+
"DisablePlatforms",
3031
"FinishRelease",
3132
"Pack",
3233
"Prerequisites",
3334
"PushToNuGet",
3435
"RegenerateBindings",
3536
"ShipApi",
36-
"SignPackages"
37+
"SignPackages",
38+
"Website"
3739
]
3840
},
3941
"Verbosity": {
@@ -166,13 +168,24 @@
166168
"type": "string",
167169
"description": "NuGet username"
168170
},
171+
"Platforms": {
172+
"type": "array",
173+
"description": "A list of platforms that DisablePlatforms should exclude from MSBuild usages, both inside and outside of NUKE. This can be reset by running DisablePlatforms with no platforms, or by deleting the excluded-platforms.txt file",
174+
"items": {
175+
"type": "string"
176+
}
177+
},
169178
"SilkTouchAdditionalArgs": {
170179
"type": "array",
171180
"description": "Additional arguments to prepend to SilkTouch invocations",
172181
"items": {
173182
"type": "string"
174183
}
175184
},
185+
"SkipContributorsScrape": {
186+
"type": "boolean",
187+
"description": "If enabled, skips scraping the contributors for the authors.yml file of the blog"
188+
},
176189
"Solution": {
177190
"type": "string",
178191
"description": "Path to a solution file that is automatically loaded"

Directory.Build.props

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,15 @@
7777
<IncludeSymbols>true</IncludeSymbols>
7878
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
7979
</PropertyGroup>
80+
81+
<PropertyGroup>
82+
<SilkExcludedPlatforms />
83+
<SilkExcludedPlatforms Condition="Exists('$(MSBuildThisFileDirectory)excluded-platforms.txt')">$([System.IO.File]::ReadAllText("$(MSBuildThisFileDirectory)excluded-platforms.txt"))</SilkExcludedPlatforms>
84+
<SilkExcludedPlatforms Condition="$([MSBuild]::IsOSPlatform('Linux'))">$(SilkExcludedPlatforms) ios tvos mac maccatalyst</SilkExcludedPlatforms>
85+
<SilkAndroidDisabled Condition="$(SilkExcludedPlatforms.Contains('android'))">true</SilkAndroidDisabled>
86+
<SilkiOSDisabled Condition="$(SilkExcludedPlatforms.Contains('ios'))">true</SilkiOSDisabled>
87+
<SilkTvOSDisabled Condition="$(SilkExcludedPlatforms.Contains('tvos'))">true</SilkTvOSDisabled>
88+
<SilkMacDisabled Condition="$(SilkExcludedPlatforms.Contains('mac'))">true</SilkMacDisabled>
89+
<SilkMacCatalystDisabled Condition="$(SilkExcludedPlatforms.Contains('maccatalyst'))">true</SilkMacCatalystDisabled>
90+
</PropertyGroup>
8091
</Project>

Directory.Build.targets

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@
201201
<Error Text="Native packages should have a version.txt file! Read documentation/for-contributors/build-system.md for more info."
202202
Condition="'$(SilkNativePackage)' == 'true' and !Exists('$(SilkVersionTxtPath)')" />
203203
<ItemGroup Condition="'$(SilkNativePackage)' == 'true'">
204-
<None Include="$(MSBuildProjectDirectory)/runtimes/**/*" Pack="true" PackagePath="runtimes" />
204+
<None Include="$(MSBuildProjectDirectory)/runtimes/**/*" Pack="true" PackagePath="runtimes" KeepMetadata="Link;CopyToOutputDirectory" CopyToOutputDirectory="PreserveNewest" />
205205
<!-- bundled in the aar instead -->
206206
<None Remove="$(MSBuildProjectDirectory)/runtimes/android*/**/*" Condition="'$(SilkNativeHasAndroidJars)' == 'true'" />
207207
</ItemGroup>
@@ -260,4 +260,14 @@
260260
Condition="'$(IncludeBuildOutput)' == 'false'" />
261261
</ItemGroup>
262262
</Target>
263+
264+
<!-- This is a bodge to make native packages feel like they're working when in repo i.e. with ProjectReferences -->
265+
<Target Name="SilkProjectReferenceNatives" AfterTargets="GetCopyToOutputDirectoryItems" Condition="'$(RuntimeIdentifier)' != ''">
266+
<ItemGroup>
267+
<SilkThisRidItems Include="@(AllItemsFullPathWithTargetPath)"
268+
Condition="$([System.String]::Copy('%(TargetPath)').Contains('$(RuntimeIdentifier)')) or $([System.String]::Copy('%(TargetPath)').Contains('$(RuntimeIdentifier.Split('-')[0])'))"
269+
TargetPath="$([System.String]::Copy('%(Filename)%(Extension)'))" />
270+
</ItemGroup>
271+
<Copy SourceFiles="@(SilkThisRidItems)" DestinationFiles="@(SilkThisRidItems->'$(OutDir)%(TargetPath)')" />
272+
</Target>
263273
</Project>

docs/for-contributors/README.mdx

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
title: "Overview"
3+
---
4+
5+
import DocCardList from '@theme/DocCardList';
6+
import { useCurrentSidebarCategory } from '@docusaurus/theme-common';
7+
8+
# The Silk.NET Contributors Guide
9+
10+
Welcome to the Silk.NET project! We're so glad you want to help us create the best native interoperation experience that
11+
.NET has ever seen.
12+
13+
This contributors guide covers many topics about Silk.NET's internals in great detail to help anyone pick up any part of
14+
the codebase and hit the ground running.
15+
16+
## Table of Contents
17+
18+
- [Getting Started (you are here!)](#getting-started)
19+
- [Contribution Process](../CONTRIBUTING.md)
20+
- [Build System](build-system.md)
21+
22+
## Getting Started
23+
24+
### Prerequisites
25+
26+
To get started, first clone Silk.NET using `git clone https://github.com/dotnet/Silk.NET --depth 1`. Your development
27+
environment will need the latest production-ready .NET SDK, so make sure you've installed that from
28+
[get.dot.net](https://get.dot.net). We also recommend installing NUKE using `dotnet tool install -g NUKE.GlobalTool` to
29+
enable our auxiliary build commands/utilities, but this is optional and in fact can be accessed using the
30+
`./build.sh`/`.\build.cmd`/`.\build.ps1` scripts in place of `nuke` in usages in this guide without installing the tool.
31+
32+
If you'd like to build and/or work with the mobile support in Silk.NET, you'll need to install the workloads using
33+
`dotnet workload restore`. It is highly likely you need to prefix this with `sudo` on macOS and Linux. In addition,
34+
you'll need to install the Android SDK with API 34 and API 35 support to ensure a successful build. Furthermore, on
35+
macOS you will need Xcode installed with the iOS platform installed. Alternatively, if you don't want to work with our
36+
mobile support, you can disable it for your local builds using `nuke disable-platforms --platforms android ios` for
37+
example. The acceptable values for `--platforms` are any valid platform identifiers (i.e. right-hand side of the `-` of
38+
a `TargetFramework`, without platform version information).
39+
40+
We automatically disable iOS support on Linux, as these workloads are only available on Windows and macOS. For more
41+
information about the NUKE utilities, consult the [Build System](build-system.md) documentation or use `nuke --help`.
42+
43+
### Building from Source
44+
45+
Assuming you've got the prerequisites installed, `dotnet build`! Or `dotnet pack` to produce all the NuPkgs in
46+
`artifacts/pkg`.
47+
48+
To learn more about the build system, see the [Build System](build-system.md) documentation. It is intentionally
49+
designed to be as compatible as possible with the regular `dotnet build` system such that you can use the built-in
50+
utilities of your favourite IDE.
51+
52+
### Regenerating Bindings
53+
54+
You can regenerate bindings using NUKE with `nuke regenerate-bindings`, but this isn't recommended. A full regeneration
55+
of Silk.NET takes a long time and has the potential to touch the vast majority of the files that make up Silk.NET and/or
56+
create loads of unrelated changes in your working tree. Instead, it is preferred to run SilkTouch manually using a
57+
command like
58+
`dotnet run --project sources/SilkTouch/SilkTouch/Silk.NET.SilkTouch.csproj -c Release -- generator.json -s Job1 -s Job2 ...`
59+
where the values for the `-s` arguments are replaced with the job names (the keys of the `Jobs` dictionary in
60+
`generator.json` e.g. `SDL`, `OpenGL`, etc).
61+
62+
For more information on SilkTocuh arguments, consult the [SilkTouch User Guide](../silktouch) or use
63+
`dotnet run --project sources/SilkTouch/SilkTouch/Silk.NET.SilkTouch.csproj -- --help`.
64+
65+
<DocCardList items={useCurrentSidebarCategory().items.filter((e) => e.label != "Overview")} />

docs/for-contributors/build-system.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ library itself that are provided by a auxiliary build system implemented using t
66

77
## MSBuild Usage
88

9+
### Target Frameworks
10+
11+
It is our goal to always target the latest LTS .NET release, and optionally multi-targeting to the next non-LTS version
12+
thereafter. We also make use of the mobile frameworks e.g. `net8.0-android`, `net8.0-ios`, but these shall always be
13+
guarded using properties such as `SilkAndroidDisabled`, `SilkiOSDisabled` etc which are set in `Directory.Build.props`,
14+
which in turn check whether a file named `excluded-platforms.txt` exists and contains the target platform identifier.
15+
This can be quickly modified by using the NUKE target `nuke disable-platforms`, which just writes to this file the
16+
values provided for `--platforms`.
17+
918
### Package READMEs
1019

1120
NuGet has recently added functionality to include a "README" rendered from Markdown on the front page of a package in
@@ -160,6 +169,21 @@ automatically, however in some cases there are specific linker flags required wh
160169
The `.targets` injected can be seen at `eng/native/nuget/NativeNuGetPackage.targets` with the `TO_BE_REPLACED`
161170
placeholders replaced in `Directory.Build.targets`.
162171

172+
Obviously, the native packages only work when consumed as a NuGet. However, we have a "best effort" attempt to copy the
173+
appropriate native binary to the output directory for projects that `ProjectReference` a native binary, whether directly
174+
or transitively. To make this work however, projects must include this:
175+
```xml
176+
<Project>
177+
<PropertyGroup>
178+
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == ''">$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
179+
</PropertyGroup>
180+
</Project>
181+
```
182+
183+
This logic is defined in the `SilkProjectReferenceNatives` target in `Directory.Build.targets`.
184+
185+
We currently have not explored doing this for static linking (i.e. iOS) builds.
186+
163187
## Native Build Workflow
164188

165189
As mentioned previously, we build all of our native binaries in CI to ensure they come from a trusted source and also to

docs/index.mdx

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
title: "Welcome"
3+
id: "index"
4+
description: 'Get Started with Silk.NET'
5+
slug: '/'
6+
---
7+
8+
import DocCardList from '@theme/DocCardList';
9+
import { useDocsSidebar } from '@docusaurus/plugin-content-docs/client'
10+
11+
# Welcome to Silk.NET!
12+
13+
## Getting Started
14+
15+
To get started, install the relevant NuGet packages. They all start with `Silk.NET`, and the next inner namespace after
16+
that indicates the binding or High-Level Utility (HLU, e.g. Windowing or Input) that package belongs. Here' some example
17+
commands to install such NuGet packages:
18+
19+
```bash
20+
dotnet add package Silk.NET.Assimp
21+
dotnet add package Silk.NET.Input
22+
dotnet add package Silk.NET.Maths
23+
dotnet add package Silk.NET.Direct2D
24+
dotnet add package Silk.NET.Direct3D.Compilers
25+
dotnet add package Silk.NET.Direct3D9
26+
dotnet add package Silk.NET.Direct3D11
27+
dotnet add package Silk.NET.Direct3D12
28+
dotnet add package Silk.NET.DirectComposition
29+
dotnet add package Silk.NET.DirectStorage
30+
dotnet add package Silk.NET.DXGI
31+
dotnet add package Silk.NET.DXVA
32+
dotnet add package Silk.NET.XAudio
33+
dotnet add package Silk.NET.XInput
34+
dotnet add package Silk.NET.OpenAL
35+
dotnet add package Silk.NET.OpenCL
36+
dotnet add package Silk.NET.OpenGL
37+
dotnet add package Silk.NET.OpenGL.Legacy
38+
dotnet add package Silk.NET.OpenGLES
39+
dotnet add package Silk.NET.OpenXR
40+
dotnet add package Silk.NET.Shaderc
41+
dotnet add package Silk.NET.SPIRV.Cross
42+
dotnet add package Silk.NET.SPIRV.Reflect
43+
dotnet add package Silk.NET.Vulkan
44+
dotnet add package Silk.NET.WebGPU
45+
dotnet add package Silk.NET.Windowing
46+
```
47+
48+
If you don't know which API you'd like to start with, try OpenGL if you'd like to draw graphics - it's an old but tested
49+
API that has universal compatibility on most platforms. It is succeeded by Vulkan, but there is a large jump in
50+
difficulty thereafter. Alternatively, if you only care about Microsoft platforms, try Direct3D 11! Note that the same
51+
caveat for Vulkan vs OpenGL applies to Direct3D 12 vs Direct3D 11.
52+
53+
If you can't decide on one for now, we maintain a "metapackage" that pulls in most of Silk.NET's core packages from all
54+
bindings and High-Level Utilities (HLUs). You can install that as follows:
55+
56+
```bash
57+
dotnet add package Silk.NET
58+
```
59+
60+
As always, we're happy to help in our Discord server with whatever questions you have, no matter how far along you are!
61+
62+
## Find Documentation
63+
64+
Now that you've pulled in the APIs you would like to use, it's time to find documentation to follow. Most Silk.NET APIs
65+
(other than our High-Level Utilities) map 1:1 directly into a native API signature that should be easily searchable by
66+
its API name (e.g. `glGetString` becomes `GL.GetString` in Silk.NET). Note that these rules are not consistent and it is expected
67+
that you have at least some familiarity with how the native API is structured.
68+
69+
Of course, there are some bindings for which we have our own introductory documentation for, which presents a good
70+
jumping-off point for new users to Silk.NET - regardless of whether you've used the native API before (e.g. with C/C++)
71+
or you've never seen anything about it before! To that end, you can find our own documentation indexed below or
72+
throughout this site.
73+
74+
<DocCardList items={useDocsSidebar().items.filter((e) => e.label != "Welcome")} />
75+
76+
Have fun! We always look forward to seeing what people can create with Silk.NET and would love to hear how you get on in
77+
[our Discord server](https://discord.gg/DTHHXRt).

0 commit comments

Comments
 (0)