Skip to content

Commit

Permalink
Pull dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Perksey committed Jan 27, 2025
2 parents cd866cb + a2d070e commit 43a41a9
Show file tree
Hide file tree
Showing 113 changed files with 21,809 additions and 5,544 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/publish-site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Website Build
on:
push:
branches:
- 'develop/3.0'
pull_request:
permissions:
contents: read
pages: write
id-token: write

jobs:
Build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build Website
run: |
git submodule update --init eng/submodules/silk.net-2.x
cd eng/submodules/silk.net-2.x
git fetch --all
cd ../../..
./build.sh website
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifact
if: ${{ github.repository == 'dotnet/Silk.NET' && github.ref == 'refs/heads/develop/3.0' }}
uses: actions/upload-pages-artifact@v3
with:
path: "artifacts/docs/Silk.NET"
Deploy:
if: ${{ github.repository == 'dotnet/Silk.NET' && github.ref == 'refs/heads/develop/3.0' }}
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: Build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,13 @@ src/**/build/
# Silk.NET Build System
*.gen.sln
*.gen.txt
excluded-platforms.txt

# Silk.NET Website Generation Output
#/docs/
src/Website/Silk.NET.Statiq/temp
src/Website/Silk.NET.Statiq/cache
.nuke/temp

# SilkTouch configs
!eng/silktouch/**/*.rsp
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "eng/submodules/sdl"]
path = eng/submodules/sdl
url = https://github.com/libsdl-org/SDL
[submodule "eng/submodules/silk.net-2.x"]
path = eng/submodules/silk.net-2.x
url = https://github.com/dotnet/Silk.NET
15 changes: 14 additions & 1 deletion .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@
"Clean",
"Compile",
"DeclareApi",
"DisablePlatforms",
"FinishRelease",
"Pack",
"Prerequisites",
"PushToNuGet",
"RegenerateBindings",
"ShipApi",
"SignPackages"
"SignPackages",
"Website"
]
},
"Verbosity": {
Expand Down Expand Up @@ -166,13 +168,24 @@
"type": "string",
"description": "NuGet username"
},
"Platforms": {
"type": "array",
"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",
"items": {
"type": "string"
}
},
"SilkTouchAdditionalArgs": {
"type": "array",
"description": "Additional arguments to prepend to SilkTouch invocations",
"items": {
"type": "string"
}
},
"SkipContributorsScrape": {
"type": "boolean",
"description": "If enabled, skips scraping the contributors for the authors.yml file of the blog"
},
"Solution": {
"type": "string",
"description": "Path to a solution file that is automatically loaded"
Expand Down
11 changes: 11 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,15 @@
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>

<PropertyGroup>
<SilkExcludedPlatforms />
<SilkExcludedPlatforms Condition="Exists('$(MSBuildThisFileDirectory)excluded-platforms.txt')">$([System.IO.File]::ReadAllText("$(MSBuildThisFileDirectory)excluded-platforms.txt"))</SilkExcludedPlatforms>
<SilkExcludedPlatforms Condition="$([MSBuild]::IsOSPlatform('Linux'))">$(SilkExcludedPlatforms) ios tvos mac maccatalyst</SilkExcludedPlatforms>
<SilkAndroidDisabled Condition="$(SilkExcludedPlatforms.Contains('android'))">true</SilkAndroidDisabled>
<SilkiOSDisabled Condition="$(SilkExcludedPlatforms.Contains('ios'))">true</SilkiOSDisabled>
<SilkTvOSDisabled Condition="$(SilkExcludedPlatforms.Contains('tvos'))">true</SilkTvOSDisabled>
<SilkMacDisabled Condition="$(SilkExcludedPlatforms.Contains('mac'))">true</SilkMacDisabled>
<SilkMacCatalystDisabled Condition="$(SilkExcludedPlatforms.Contains('maccatalyst'))">true</SilkMacCatalystDisabled>
</PropertyGroup>
</Project>
12 changes: 11 additions & 1 deletion Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
<Error Text="Native packages should have a version.txt file! Read documentation/for-contributors/build-system.md for more info."
Condition="'$(SilkNativePackage)' == 'true' and !Exists('$(SilkVersionTxtPath)')" />
<ItemGroup Condition="'$(SilkNativePackage)' == 'true'">
<None Include="$(MSBuildProjectDirectory)/runtimes/**/*" Pack="true" PackagePath="runtimes" />
<None Include="$(MSBuildProjectDirectory)/runtimes/**/*" Pack="true" PackagePath="runtimes" KeepMetadata="Link;CopyToOutputDirectory" CopyToOutputDirectory="PreserveNewest" />
<!-- bundled in the aar instead -->
<None Remove="$(MSBuildProjectDirectory)/runtimes/android*/**/*" Condition="'$(SilkNativeHasAndroidJars)' == 'true'" />
</ItemGroup>
Expand Down Expand Up @@ -260,4 +260,14 @@
Condition="'$(IncludeBuildOutput)' == 'false'" />
</ItemGroup>
</Target>

<!-- This is a bodge to make native packages feel like they're working when in repo i.e. with ProjectReferences -->
<Target Name="SilkProjectReferenceNatives" AfterTargets="GetCopyToOutputDirectoryItems" Condition="'$(RuntimeIdentifier)' != ''">
<ItemGroup>
<SilkThisRidItems Include="@(AllItemsFullPathWithTargetPath)"
Condition="$([System.String]::Copy('%(TargetPath)').Contains('$(RuntimeIdentifier)')) or $([System.String]::Copy('%(TargetPath)').Contains('$(RuntimeIdentifier.Split('-')[0])'))"
TargetPath="$([System.String]::Copy('%(Filename)%(Extension)'))" />
</ItemGroup>
<Copy SourceFiles="@(SilkThisRidItems)" DestinationFiles="@(SilkThisRidItems->'$(OutDir)%(TargetPath)')" />
</Target>
</Project>
65 changes: 65 additions & 0 deletions docs/for-contributors/README.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
title: "Overview"
---

import DocCardList from '@theme/DocCardList';
import { useCurrentSidebarCategory } from '@docusaurus/theme-common';

# The Silk.NET Contributors Guide

Welcome to the Silk.NET project! We're so glad you want to help us create the best native interoperation experience that
.NET has ever seen.

This contributors guide covers many topics about Silk.NET's internals in great detail to help anyone pick up any part of
the codebase and hit the ground running.

## Table of Contents

- [Getting Started (you are here!)](#getting-started)
- [Contribution Process](../CONTRIBUTING.md)
- [Build System](build-system.md)

## Getting Started

### Prerequisites

To get started, first clone Silk.NET using `git clone https://github.com/dotnet/Silk.NET --depth 1`. Your development
environment will need the latest production-ready .NET SDK, so make sure you've installed that from
[get.dot.net](https://get.dot.net). We also recommend installing NUKE using `dotnet tool install -g NUKE.GlobalTool` to
enable our auxiliary build commands/utilities, but this is optional and in fact can be accessed using the
`./build.sh`/`.\build.cmd`/`.\build.ps1` scripts in place of `nuke` in usages in this guide without installing the tool.

If you'd like to build and/or work with the mobile support in Silk.NET, you'll need to install the workloads using
`dotnet workload restore`. It is highly likely you need to prefix this with `sudo` on macOS and Linux. In addition,
you'll need to install the Android SDK with API 34 and API 35 support to ensure a successful build. Furthermore, on
macOS you will need Xcode installed with the iOS platform installed. Alternatively, if you don't want to work with our
mobile support, you can disable it for your local builds using `nuke disable-platforms --platforms android ios` for
example. The acceptable values for `--platforms` are any valid platform identifiers (i.e. right-hand side of the `-` of
a `TargetFramework`, without platform version information).

We automatically disable iOS support on Linux, as these workloads are only available on Windows and macOS. For more
information about the NUKE utilities, consult the [Build System](build-system.md) documentation or use `nuke --help`.

### Building from Source

Assuming you've got the prerequisites installed, `dotnet build`! Or `dotnet pack` to produce all the NuPkgs in
`artifacts/pkg`.

To learn more about the build system, see the [Build System](build-system.md) documentation. It is intentionally
designed to be as compatible as possible with the regular `dotnet build` system such that you can use the built-in
utilities of your favourite IDE.

### Regenerating Bindings

You can regenerate bindings using NUKE with `nuke regenerate-bindings`, but this isn't recommended. A full regeneration
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
create loads of unrelated changes in your working tree. Instead, it is preferred to run SilkTouch manually using a
command like
`dotnet run --project sources/SilkTouch/SilkTouch/Silk.NET.SilkTouch.csproj -c Release -- generator.json -s Job1 -s Job2 ...`
where the values for the `-s` arguments are replaced with the job names (the keys of the `Jobs` dictionary in
`generator.json` e.g. `SDL`, `OpenGL`, etc).

For more information on SilkTocuh arguments, consult the [SilkTouch User Guide](../silktouch) or use
`dotnet run --project sources/SilkTouch/SilkTouch/Silk.NET.SilkTouch.csproj -- --help`.

<DocCardList items={useCurrentSidebarCategory().items.filter((e) => e.label != "Overview")} />
24 changes: 24 additions & 0 deletions docs/for-contributors/build-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ library itself that are provided by a auxiliary build system implemented using t

## MSBuild Usage

### Target Frameworks

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

### Package READMEs

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

Obviously, the native packages only work when consumed as a NuGet. However, we have a "best effort" attempt to copy the
appropriate native binary to the output directory for projects that `ProjectReference` a native binary, whether directly
or transitively. To make this work however, projects must include this:
```xml
<Project>
<PropertyGroup>
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == ''">$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
</PropertyGroup>
</Project>
```

This logic is defined in the `SilkProjectReferenceNatives` target in `Directory.Build.targets`.

We currently have not explored doing this for static linking (i.e. iOS) builds.

## Native Build Workflow

As mentioned previously, we build all of our native binaries in CI to ensure they come from a trusted source and also to
Expand Down
77 changes: 77 additions & 0 deletions docs/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
title: "Welcome"
id: "index"
description: 'Get Started with Silk.NET'
slug: '/'
---

import DocCardList from '@theme/DocCardList';
import { useDocsSidebar } from '@docusaurus/plugin-content-docs/client'

# Welcome to Silk.NET!

## Getting Started

To get started, install the relevant NuGet packages. They all start with `Silk.NET`, and the next inner namespace after
that indicates the binding or High-Level Utility (HLU, e.g. Windowing or Input) that package belongs. Here' some example
commands to install such NuGet packages:

```bash
dotnet add package Silk.NET.Assimp
dotnet add package Silk.NET.Input
dotnet add package Silk.NET.Maths
dotnet add package Silk.NET.Direct2D
dotnet add package Silk.NET.Direct3D.Compilers
dotnet add package Silk.NET.Direct3D9
dotnet add package Silk.NET.Direct3D11
dotnet add package Silk.NET.Direct3D12
dotnet add package Silk.NET.DirectComposition
dotnet add package Silk.NET.DirectStorage
dotnet add package Silk.NET.DXGI
dotnet add package Silk.NET.DXVA
dotnet add package Silk.NET.XAudio
dotnet add package Silk.NET.XInput
dotnet add package Silk.NET.OpenAL
dotnet add package Silk.NET.OpenCL
dotnet add package Silk.NET.OpenGL
dotnet add package Silk.NET.OpenGL.Legacy
dotnet add package Silk.NET.OpenGLES
dotnet add package Silk.NET.OpenXR
dotnet add package Silk.NET.Shaderc
dotnet add package Silk.NET.SPIRV.Cross
dotnet add package Silk.NET.SPIRV.Reflect
dotnet add package Silk.NET.Vulkan
dotnet add package Silk.NET.WebGPU
dotnet add package Silk.NET.Windowing
```

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
API that has universal compatibility on most platforms. It is succeeded by Vulkan, but there is a large jump in
difficulty thereafter. Alternatively, if you only care about Microsoft platforms, try Direct3D 11! Note that the same
caveat for Vulkan vs OpenGL applies to Direct3D 12 vs Direct3D 11.

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
bindings and High-Level Utilities (HLUs). You can install that as follows:

```bash
dotnet add package Silk.NET
```

As always, we're happy to help in our Discord server with whatever questions you have, no matter how far along you are!

## Find Documentation

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
(other than our High-Level Utilities) map 1:1 directly into a native API signature that should be easily searchable by
its API name (e.g. `glGetString` becomes `GL.GetString` in Silk.NET). Note that these rules are not consistent and it is expected
that you have at least some familiarity with how the native API is structured.

Of course, there are some bindings for which we have our own introductory documentation for, which presents a good
jumping-off point for new users to Silk.NET - regardless of whether you've used the native API before (e.g. with C/C++)
or you've never seen anything about it before! To that end, you can find our own documentation indexed below or
throughout this site.

<DocCardList items={useDocsSidebar().items.filter((e) => e.label != "Welcome")} />

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
[our Discord server](https://discord.gg/DTHHXRt).
Loading

0 comments on commit 43a41a9

Please sign in to comment.