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

[3.0] Windowing Rewrite #2278

Draft
wants to merge 152 commits into
base: develop/3.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
7e32758
Initial group codegen
Perksey Apr 6, 2024
e53716f
Fix some trimming oddities
Perksey Apr 6, 2024
67ed5ae
Fix HintTargetPGI and others similarly situated
Perksey Apr 6, 2024
678dc6e
Base typing and namespacing
Perksey Apr 7, 2024
52e401a
Cast enum members, fix stray semicolons, Silk.NET.OpenGL builds again
Perksey Apr 8, 2024
5219292
Group and bool transformations
Perksey Apr 21, 2024
710fa56
Fix erroneous cast order
Perksey Apr 23, 2024
ea85042
Add Delete(singular) overloads (ArrayParameterOverloader)
Perksey Apr 23, 2024
4376388
Add SAL object model & Khronos length metadata parsing
Perksey May 3, 2024
3214433
ArrayParameterTransformer w/ tests
Perksey May 10, 2024
220afd0
Integrate ArrayParameterTransformer
Perksey May 10, 2024
7eec321
Merge branch 'develop/3.0' into feature/opengl-codegen
Perksey May 15, 2024
4450085
Support SupportedApiProfileAttribute generation with metadata
Perksey May 21, 2024
d523e37
PrettifyNames conflict resolution now actually works
Perksey May 21, 2024
90da556
Fix casting transformation ambiguity bugs
Perksey May 23, 2024
4f85362
Fix metadata retrieval for reserved identifiers
Perksey May 23, 2024
110a782
Merge branch 'feature/opengl-codegen' of https://github.com/dotnet/Si…
Perksey May 23, 2024
24343a8
Fix unit tests
Perksey May 23, 2024
ba1f9c4
Fixup for all caps names
Perksey May 24, 2024
37637f5
Fix naive trimming bug
Perksey May 24, 2024
5eca8c3
More self-review comments
Perksey May 24, 2024
e2ff544
SDL bindings
Perksey May 31, 2024
9f36ade
Merge attempt 2
Perksey May 31, 2024
261ddd8
Merge branch 'feature/sdl-bindings' of https://github.com/dotnet/Silk…
Perksey May 31, 2024
6298422
Fix naming regression
Perksey May 31, 2024
58561c8
Prettify & extract the nested _e__{Union,Struct,FixedBuffer} structs
Perksey Jun 3, 2024
8d7af55
Function pointer generation
Perksey Jun 6, 2024
0fb7e09
Add a second pass to name delegates based on usage!
Perksey Jun 6, 2024
384453b
Fixes from self-review
Perksey Jun 9, 2024
56af8e1
Windowing 3.0 Iteration 1 with Dependency Injection - scrapped
Perksey Jul 22, 2024
8bfba2b
WIP Windowing 3.0 for real this time
Perksey Aug 31, 2024
e01289e
Some more work
Perksey Sep 6, 2024
a76c488
Rejig the repo structure
Perksey Sep 7, 2024
9cf86ba
Save progress, as I am deleting the progress
Perksey Sep 12, 2024
f61ccce
Create a Roslyn compilation & workspace
Perksey Oct 2, 2024
570c24c
Merge branch 'feature/silktouch-3.0-fit-for-future' into HEAD
Perksey Oct 2, 2024
851f85b
Bugfixes, generation runs with renaming but is slow and outputs wrong
Perksey Oct 2, 2024
05a0f69
Some more bugfixes
Perksey Oct 2, 2024
79af236
Fix mods not saving outputs, unnecessary subdirs, filenames, and othe…
Perksey Oct 3, 2024
663f520
Add IResponseFileMod, fix EntryPoint not in DllImport, and other fixe…
Perksey Oct 3, 2024
59f6fe8
Delete some stray files
Perksey Oct 3, 2024
116d08e
Minor nits
Perksey Oct 3, 2024
1ba1315
Initial commit of the SymbolFinder rename experiment
Perksey Oct 5, 2024
938d8a9
This is the new renamer
Perksey Oct 6, 2024
789d244
Fix ctors and dtors, stop using `using static`s
Perksey Oct 6, 2024
e31c725
Regenerate bindings
Perksey Oct 6, 2024
e6f2cf3
Use public Roslyn APIs and parallelise
Perksey Oct 7, 2024
d86a14c
Sync with #2288
Perksey Oct 7, 2024
a041dfb
Merge branch 'develop/3.0' of https://github.com/dotnet/Silk.NET into…
Perksey Oct 11, 2024
129d495
Fix buidl
Perksey Oct 11, 2024
5224e0b
Add ISurfaceProvider
Perksey Oct 13, 2024
bd91c25
Add a write-up on the PAL HLU concepts/status for the future
Perksey Oct 16, 2024
2295ce6
Remove the hosting API
Perksey Oct 16, 2024
0e760e6
Start on a more clean sheet and conservative implementation
Perksey Nov 13, 2024
40ce1a2
Separate files
Perksey Nov 13, 2024
df88e68
Lay out impl, add new APIs from proposal
Perksey Nov 14, 2024
b18eebc
Add a Utf8String helper type, and transform string constants to use it
Perksey Nov 15, 2024
a7c35a0
Move bakery functionality into a mod separate from SupportedApiProfiles
Perksey Nov 16, 2024
5606e93
Rename GetTypeDeclaration to BakeMember
Perksey Nov 17, 2024
fbc0edd
Cache the result of function pointer loading
Perksey Nov 17, 2024
9d1ba99
Merge branch 'develop/3.0' into feature/misc-improv-3.0
Perksey Nov 18, 2024
f6f625f
Fix vulnerability?
Perksey Nov 18, 2024
74ddf75
Merge branch 'feature/misc-improv-3.0' of https://github.com/dotnet/S…
Perksey Nov 18, 2024
ed097fb
Merge branch 'feature/misc-improv-3.0' into feature/windowing-3.0
Perksey Nov 18, 2024
19a29a8
Recognise some #define enums, improve pfn type gen, update SDL, more …
Perksey Nov 21, 2024
202b315
Update ClangSharp (with no changes!!!!1111!1!!!111 :tada:)
Perksey Nov 21, 2024
df2ba9e
Commit cache files too
Perksey Nov 21, 2024
4fadfd8
Merge branch 'feature/misc-improv-3.0' into feature/windowing-3.0
Perksey Nov 21, 2024
67619a3
Add SDL_gpu (and other missing headers such as SDL_vulkan)
Perksey Nov 21, 2024
689ed33
Check-in rsp changes, add namespace for windowing, add SDL_main bindings
Perksey Nov 21, 2024
910fc7c
Work on more of the implementation
Perksey Dec 2, 2024
0bd60d8
Add SDL_stdinc bindings (for SDL_free...)
Perksey Dec 2, 2024
34aa1c0
Triangle with Silk.NET.Windowing 3.0
Perksey Dec 5, 2024
bd202f6
Implement all APIs
Perksey Dec 7, 2024
782f384
Wire up all relevant events
Perksey Dec 7, 2024
0c43395
Sweep a macOS deficiency under the rug
Perksey Dec 7, 2024
19b3f80
Apply initial configuration, surprisingly little code...
Perksey Dec 8, 2024
d82c775
Initial work on native build workflow
Perksey Dec 20, 2024
d202213
Stop using YAML for GITHUB_OUTPUT
Perksey Dec 21, 2024
4a48a70
Add GH_TOKEN env var to stage2
Perksey Dec 21, 2024
4324a39
Use an action for comment writing instead
Perksey Dec 21, 2024
a4f65f0
Fix permissions, try to fix expr issue
Perksey Dec 21, 2024
8dbb8a4
Same again
Perksey Dec 21, 2024
6ad84f0
Fix PR comment location
Perksey Dec 21, 2024
ecb5b94
Replace the comment rather than append to it
Perksey Dec 21, 2024
eafcc9d
Start of native build job
Perksey Dec 21, 2024
775be50
Attempt to fix matrix
Perksey Dec 21, 2024
cdd18d3
Add a job name, fix build script permissions issues
Perksey Dec 21, 2024
1fcbfe4
Add OSX build for SDL
Perksey Dec 21, 2024
88148c5
Start of commit job
Perksey Dec 21, 2024
3612345
Add missing checkout
Perksey Dec 21, 2024
5a17532
Use official action to checkout PR
Perksey Dec 21, 2024
40d0a32
Fix permissions issues
Perksey Dec 21, 2024
22af898
Update native binaries for bc824234847be3635913331b0f6fca1c7fc3c982
dotnet-bot Dec 21, 2024
063df43
Start of linux-x64 SDL build
Perksey Dec 21, 2024
ac52bbb
Sudo for apt
Perksey Dec 21, 2024
4710f9a
apt-get update
Perksey Dec 21, 2024
609bb99
Checkout submodule
Perksey Dec 21, 2024
ece2459
Fix path error
Perksey Dec 21, 2024
092d3be
Update native binaries for ece24590373710ff14b68c30800d7091f1a65d9a
dotnet-bot Dec 21, 2024
8573423
Add linux-arm and linux-arm64
Perksey Dec 21, 2024
3e3df2c
Use glibc 2.34 on linux-arm for Y2038 support
Perksey Dec 21, 2024
92b5bf4
Update native binaries for 3e3df2ca0b8424b3805d53db44fda1ccb976c387
dotnet-bot Dec 21, 2024
68abcc9
Add win-arm, win-arm64, win-x64
Perksey Dec 21, 2024
f46df63
Fix dir structure
Perksey Dec 21, 2024
8577e7b
Attempt to keep win-arm support, may be on the chopping block though
Perksey Dec 21, 2024
934ec01
Fix batch script error
Perksey Dec 21, 2024
7bb3e4d
Use curl instead of wget?
Perksey Dec 21, 2024
7919b67
Fix winsdk install?
Perksey Dec 21, 2024
0815e4c
Remove 32-bit Windows on Arm support
Perksey Dec 21, 2024
230123d
Use a Microsoft Developer Command Prompt
Perksey Dec 21, 2024
dc58874
Fix vcvarsall path
Perksey Dec 21, 2024
601bb66
Use Ninja - libsdl-org/SDL##11487
Perksey Dec 21, 2024
ec88886
Update native binaries for 601bb669523a67cd2f7650b2df01a3f3c935b10c
dotnet-bot Dec 21, 2024
aa29dc3
Fix artifact download path
Perksey Dec 21, 2024
4630438
Fix the fix
Perksey Dec 24, 2024
cf89f08
Update native binaries for 4630438977fe234017171daa18258b989c222bff
dotnet-bot Dec 24, 2024
b20e415
Add iOS and tvOS for SDL
Perksey Dec 24, 2024
7e827f8
Merge branch 'feature/natives-3.0' of https://github.com/dotnet/Silk.…
Perksey Dec 24, 2024
45f36d0
Fix file permissions
Perksey Dec 24, 2024
dde8e23
Update native binaries for 45f36d05463ee8dd7462ecb904d519253348f475
dotnet-bot Dec 24, 2024
1071026
Add Android build for SDL
Perksey Dec 27, 2024
e006e0a
Apparently sdkmanager is not in PATH
Perksey Dec 27, 2024
cd73ccb
Install Python 3.11
Perksey Dec 27, 2024
d7d3c69
Install Ninja
Perksey Dec 27, 2024
addb3da
Update native binaries for d7d3c696e56cfc8862c3e7ed8f09c3e7b375a7ae
dotnet-bot Dec 27, 2024
cb3e44c
Try to ungitignore the Android jar
Perksey Dec 27, 2024
f79ad90
Merge branch 'feature/natives-3.0' of https://github.com/dotnet/Silk.…
Perksey Dec 27, 2024
2243bfe
Update native binaries for f79ad90e3b32074ddf8f22056cea149303f0acb2
dotnet-bot Dec 27, 2024
b26f378
Add an easy update script
Perksey Dec 27, 2024
917d412
Merge branch 'feature/natives-3.0' of https://github.com/dotnet/Silk.…
Perksey Dec 27, 2024
8cf95c2
Include org.libsdl.app bindings with the aar, working package now
Perksey Dec 28, 2024
48221ff
Update native binaries for 8cf95c218c6070c2a47b9b2b833a49e03b04656f
dotnet-bot Dec 28, 2024
4a47ce0
Some cleanup, and add docs
Perksey Dec 28, 2024
c5bdec1
Merge branch 'feature/natives-3.0' of https://github.com/dotnet/Silk.…
Perksey Dec 28, 2024
ceca47d
Fix build
Perksey Dec 28, 2024
186f907
Install workloads in test too
Perksey Dec 28, 2024
de163dc
Update native binaries for 186f9079270c7481a62a6076d2f0ba9a63e7f1ef
dotnet-bot Dec 28, 2024
b85b05d
Fix build (not ideally)
Perksey Dec 28, 2024
44b9933
Merge branch 'feature/natives-3.0' of https://github.com/dotnet/Silk.…
Perksey Dec 28, 2024
7a761c7
Update native binaries for 44b99335a2a9a09df42feeb3f829808c99896e09
dotnet-bot Dec 28, 2024
496aed4
Dummy commit to run Test/Build again
Perksey Dec 28, 2024
eccb9a6
Merge branch 'feature/natives-3.0' of https://github.com/dotnet/Silk.…
Perksey Dec 28, 2024
3976598
Merge branch 'feature/natives-3.0' into feature/windowing-3.0
Perksey Dec 28, 2024
e61e2f8
Remove old code
Perksey Dec 28, 2024
f2e9a93
Fix it
Perksey Dec 28, 2024
eb1a920
Stop downloading previews?
Perksey Dec 28, 2024
cee9fe4
Add dependency to native package for SDL
Perksey Dec 28, 2024
ab30f75
Fix build
Perksey Dec 28, 2024
3beeabc
Only duplicate the VersionSuffix for natives
Perksey Dec 28, 2024
2140d38
Merge branch 'feature/natives-3.0' into feature/windowing-3.0
Perksey Dec 28, 2024
7fe88dd
Add SilkActivity
Perksey Dec 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
30 changes: 30 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*.sln text eol=lf
*.targets text eol=lf
*.yml text eol=lf
*.hlsl text eof=lf

###############################################################################
# Set explicit file behavior to:
Expand Down Expand Up @@ -53,6 +54,35 @@
*.7z binary
*.ttf binary
*.stout binary
*.p7s binary
*.sample binary
*.nupkg binary
*.exe binary
*.idx binary
*.pack binary
*.spv binary
*.lib binary
*.dylib binary
*.so binary
*.dll binary
*.xcscheme binary
*.xcworkspacedata binary
*.pdf binary
*.pfx binary
*.metal binary
*.jar binary
*.apk binary
*.aar binary
*.aidl binary
*.flata binary
*.metallib binary
*.items binary
*.stamp binary
*.icns binary
*.mdb binary
*.pdb binary
*.bmp binary
*.dat binary

# Verify
*.verified.txt text eol=lf working-tree-encoding=UTF-8
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: '9.0.x'
dotnet-quality: 'preview'
#dotnet-quality: 'preview'
- name: Install Workloads
run: dotnet workload restore
- name: Pack
# TODO decide whether we want experimental builds to use Debug or Release - using Release for now...
run: >-
Expand Down Expand Up @@ -68,8 +70,10 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
dotnet-quality: 'preview'
dotnet-version: '9.0.x'
#dotnet-quality: 'preview'
- name: Install Workloads
run: dotnet workload restore
- name: Restore
run: dotnet restore --runtime ${{ matrix.rid }}
- name: Test
Expand Down
102 changes: 102 additions & 0 deletions .github/workflows/native.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Native Builds
on:
pull_request:
types: [opened, edited, synchronize]
permissions:
pull-requests: write
contents: write
env:
# A space-separated list of paths to native libraries to build.
NATIVE_LIBRARY_PATHS: "sources/SDL/Native"
# A space-separated list of submodule paths for each native library path. Use _ if a submodule is not used - this must
# match the number of spaces in NATIVE_LIBRARY_PATHS.
NATIVE_LIBRARY_SUBMODULE_PATHS: "eng/submodules/sdl"
# A space-separated list of shorthands to the native library paths that will build the native library for each native
# library path. This must match the number of spaces in NATIVE_LIBRARY_PATHS. If a shorthand builds multiple native
# binary paths, these will be deduplicated.
NATIVE_LIBRARY_SHORTHANDS: "SDL"
jobs:
prerequisites:
name: PR Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- id: parse
name: Determine which native libraries the user has asked to build, and where to look for changes.
run: ./workflow-stage1.sh
working-directory: eng/native/buildsystem
env:
PR_COMMENT: ${{ github.event.pull_request.body }}
- uses: dorny/paths-filter@v3
id: filter
name: Determine which natives need to be rebuilt.
with:
filters: ${{ steps.parse.outputs.workflow_filters }}
- name: Find a warning message from a previous run, if applicable.
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.number }}
comment-author: "github-actions[bot]"
body-includes: "Some of the native library builds modified in this PR were not referenced in the PR description."
- id: strat
name: Create the matrix strategy for the native builds.
run: ./workflow-stage2.sh
working-directory: eng/native/buildsystem
env:
NATIVE_LIBRARY_APPLICABLE_SHORTHANDS: ${{ join(fromJSON(steps.filter.outputs.changes), ' ') }}
NATIVE_LIBRARY_USER_REFERENCED_SHORTHANDS: ${{ steps.parse.outputs.targets_referenced }}
PR_EXISTING_NOTICE_ID: ${{ steps.fc.outputs.comment-id }}
- name: Write a comment if needed.
if: ${{ steps.strat.outputs.comment_to_write }}
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.number }}
body: ${{ steps.strat.outputs.comment_to_write }}
edit-mode: replace
outputs:
matrix_strategy: ${{ steps.strat.outputs.matrix_strategy }}
targets_referenced: ${{ steps.parse.outputs.targets_referenced }}
build:
needs: [prerequisites]
strategy:
matrix:
flat: ${{ fromJSON(needs.prerequisites.outputs.matrix_strategy) }}
runs-on: ${{ (startsWith(matrix.flat.runtime, 'osx') || startsWith(matrix.flat.runtime, 'ios') || startsWith(matrix.flat.runtime, 'tvos')) && 'macos-latest' || startsWith(matrix.flat.runtime, 'win') && 'windows-latest' || 'ubuntu-latest' }}
name: ${{ matrix.flat.target }} / ${{ matrix.flat.runtime }}
steps:
- uses: actions/checkout@v3
- run: |
echo "https://github.com/actions/upload-artifact/issues/174" > .workaround-${{ matrix.flat.target }}-${{ matrix.flat.runtime }}.txt
${{ format('.{0}{1}', startsWith(matrix.flat.runtime, 'win') && '\' || '/', matrix.flat.exec) }}
working-directory: ${{ matrix.flat.dir }}
- uses: actions/upload-artifact@v4
with:
name: natives-${{ matrix.flat.target }}-${{ matrix.flat.runtime }}
path: |
./.workaround-*.txt
./${{ matrix.flat.dir }}/runtimes/${{ format('{0}{1}', matrix.flat.runtime, !contains(matrix.flat.runtime, '-') && '*' || '') }}/**/*
./${{ matrix.flat.dir }}/lib/*${{ matrix.flat.runtime }}*/**/*
./${{ matrix.flat.dir }}/*${{ matrix.flat.runtime }}*/**/*
commit:
name: Commit Binaries
needs: [prerequisites, build]
runs-on: ubuntu-latest
if: ${{ needs.prerequisites.outputs.targets_referenced }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Download All Artifacts
uses: actions/download-artifact@v4
with:
pattern: natives-*
merge-multiple: true
- name: Commit Artifacts
run: |
git config --local user.email "[email protected]"
git config --local user.name "The Silk.NET Automaton"
git add .
git commit -m "Update native binaries for $(git rev-parse HEAD)"
git push
14 changes: 9 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,6 @@ src/**/build/
*.gen.sln
*.gen.txt

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

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

Expand All @@ -489,3 +484,12 @@ src/Website/Silk.NET.Statiq/cache

# Verify
*.received.*

# Native Binaries
!**/runtimes/*/native/*.dylib
!**/runtimes/*/native/*.so
!**/runtimes/*/native/*.dll
!**/lib/**/*.aar
build/
!eng/build/
.workaround*
5 changes: 5 additions & 0 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"Clean",
"Compile",
"DeclareApi",
"FinishRelease",
"Pack",
"Prerequisites",
"PushToNuGet",
Expand Down Expand Up @@ -134,6 +135,10 @@
"Release"
]
},
"DiscordWebhook": {
"type": "string",
"description": "Discord release announcement webhook"
},
"MsbuildProperties": {
"type": "array",
"description": "Extra properties passed to MSBuild commands",
Expand Down
Binary file removed .silktouch/0afb5dc84012c2fa.stout
Binary file not shown.
Binary file added .silktouch/91c9aa14a031651f.stout
Binary file not shown.
Binary file modified .silktouch/c8c046b328b09d23.stout
Binary file not shown.
5 changes: 4 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
Expand Down Expand Up @@ -64,10 +65,12 @@
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<VersionDependsOn>SilkShippingControl;$(VersionDependsOn)</VersionDependsOn>
<PackageVersionDependsOn>SilkShippingControl;$(PackageVersionDependsOn)</PackageVersionDependsOn>
<TargetsForTfmSpecificContentInPackage>SilkNativePackaging;$(TargetsForTfmSpecificContentInPackage)</TargetsForTfmSpecificContentInPackage>
<GenerateNuspecDependsOn>SilkShippingControl;$(GenerateNuspecDependsOn)</GenerateNuspecDependsOn>
</PropertyGroup>

<!-- SourceLink -->
<PropertyGroup Condition="'$(SilkSourceLinkExempt)' == ''">
<PropertyGroup Condition="'$(SilkSourceLinkExempt)' == '' and '$(SilkNativePackage)' != 'true' and '$(SilkMetapackage)' != 'true'">
<DebugType>portable</DebugType>
<EmbedAllSources>true</EmbedAllSources>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
Expand Down
88 changes: 81 additions & 7 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,25 @@
</UsingTask>

<Target Name="SilkShippingControl" BeforeTargets="BeforeBuild">
<!-- Non-C# packages (i.e. metapackages, natives) -->
<PropertyGroup Condition="'$(SilkNativePackage)' == 'true' or '$(SilkMetapackage)' == 'true'">
<IncludeBuildOutput Condition="'$(SilkNativeHasAndroidJars)' != 'true'">false</IncludeBuildOutput>
<IncludeBuildOutput Condition="'$(TargetFramework)' != ''">false</IncludeBuildOutput>
<IncludeBuildOutput Condition="'$(SilkNativeHasAndroidJars)' == 'true' and $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">true</IncludeBuildOutput>
<NoWarn>NU5128;1591;$(NoWarn)</NoWarn>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
</PropertyGroup>

<!-- Public API -->
<PropertyGroup Condition="'$(SilkTrackPublicAPI)' != 'true' or '$(TargetFramework)' == ''">
<SilkTrackPublicAPI>false</SilkTrackPublicAPI>
</PropertyGroup>
<ItemGroup Condition="'$(SilkTrackPublicAPI)' == 'true'">
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" PrivateAssets="All" />
</ItemGroup>
<ItemGroup Condition="'$(SilkSourceLinkExempt)' == ''">

<!-- SourceLink -->
<ItemGroup Condition="'$(SilkSourceLinkExempt)' == '' and '$(SilkNativePackage)' != 'true' and '$(SilkMetapackage)' != 'true'">
<PackageReference Include="DotNet.ReproducibleBuilds" PrivateAssets="All"/>
<PackageReference Include="DotNet.ReproducibleBuilds.Isolated" PrivateAssets="All"/>
</ItemGroup>
Expand All @@ -161,6 +172,7 @@
<WriteLinesToFile File="PublicAPI/$(TargetFramework)/PublicAPI.Unshipped.txt"
Lines="@(SilkNewPublicAPILines)"
Condition="'$(SilkTrackPublicAPI)' == 'true' and !Exists('PublicAPI/$(TargetFramework)/PublicAPI.Unshipped.txt')" />

<!-- Versioning -->
<PropertyGroup>
<SilkChangelog>$([System.IO.File]::ReadAllText("$(MSBuildThisFileDirectory)docs/CHANGELOG.md"))</SilkChangelog>
Expand All @@ -171,19 +183,81 @@
<Output PropertyName="SilkReleaseNotes" TaskParameter="SilkReleaseNotes" />
</SilkGetVersionInfoTask>
<PropertyGroup>
<SilkOriginalVersionSuffix>$(VersionSuffix)</SilkOriginalVersionSuffix>
<Version>$(SilkVersion)</Version>
<VersionSuffix Condition="'$(VersionSuffix)' == ''">$(SilkVersionSuffix)</VersionSuffix>
<PackageReleaseNotes>$(SilkReleaseNotes)</PackageReleaseNotes>
<PackageVersion Condition="'$(VersionSuffix)' == ''">$(SilkVersion)</PackageVersion>
<PackageVersion Condition="'$(VersionSuffix)' != ''">$(SilkVersion)-$(VersionSuffix)</PackageVersion>
</PropertyGroup>
<!-- Trimming -->

<!-- Native Packaging -->
<PropertyGroup>
<IsTrimmable Condition="'$(SilkTrimmingExempt)' == ''">true</IsTrimmable>
<EnableTrimAnalyzer Condition="'$(SilkTrimmingExempt)' == ''">true</EnableTrimAnalyzer>
<EnableAotAnalyzer Condition="'$(SilkTrimmingExempt)' == ''">true</EnableAotAnalyzer>
<EnableSingleFileAnalyzer Condition="'$(SilkTrimmingExempt)' == ''">true</EnableSingleFileAnalyzer>
<TrimMode Condition="'$(SilkTrimmingExempt)' == ''">full</TrimMode>
<SilkVersionTxtPath>$(MSBuildProjectDirectory)/version.txt</SilkVersionTxtPath>
<PackageVersion Condition="Exists('$(SilkVersionTxtPath)')">$([System.IO.File]::ReadAllText("$(SilkVersionTxtPath)").Trim())</PackageVersion>
<PackageVersion Condition="'$(SilkOriginalVersionSuffix)' != '' and Exists('$(SilkVersionTxtPath)') and $(PackageVersion.Contains('-'))">$(PackageVersion)$(SilkOriginalVersionSuffix)</PackageVersion>
<PackageVersion Condition="'$(SilkOriginalVersionSuffix)' != '' and Exists('$(SilkVersionTxtPath)') and !$(PackageVersion.Contains('-'))">$(PackageVersion)-$(SilkOriginalVersionSuffix)</PackageVersion>
</PropertyGroup>
<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" />
<!-- bundled in the aar instead -->
<None Remove="$(MSBuildProjectDirectory)/runtimes/android*/**/*" Condition="'$(SilkNativeHasAndroidJars)' == 'true'" />
</ItemGroup>
<ItemGroup Condition="'$(SilkNativePackage)' == 'true' and $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
<AndroidNativeLibrary Include="$(MSBuildProjectDirectory)/runtimes/android*/native/*.so" />
<ProguardConfiguration Include="$(MSBuildProjectDirectory)/android/proguard.txt" Condition="Exists('$(MSBuildProjectDirectory)/android/proguard.txt')" />
<AndroidLibrary Include="$(MSBuildProjectDirectory)/android/*.jar" Bind="true" Pack="true" />
<TransformFile Include="$(MSBuildProjectDirectory)/android/*.xml" />
</ItemGroup>

<!-- Trimming -->
<PropertyGroup Condition="'$(SilkTrimmingExempt)' == ''">
<IsTrimmable>true</IsTrimmable>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<EnableAotAnalyzer>true</EnableAotAnalyzer>
<EnableSingleFileAnalyzer>true</EnableSingleFileAnalyzer>
<TrimMode>full</TrimMode>
</PropertyGroup>
</Target>


<!-- Closest things to documentation on what the hell this voodoo does:
https://github.com/NuGet/Home/issues/10063#issuecomment-713083004
https://github.com/xamarin/xamarin-android/pull/5242
https://github.com/dotnet/sdk/issues/14042
https://github.com/dotnet/sdk/blob/main/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackTool.targets#L54
https://github.com/xamarin/xamarin-android/issues/5957
https://github.com/xamarin/xamarin-android/blob/main/Documentation/guides/OneDotNetEmbeddedResources.md

This is an adaptation of what we used in Silk.NET 2.X to add files to packages, which was originally focused on
Android. For 3.0, we're trying to lean as much as possible on the built-in stuff for e.g. jars as this is in a
much better state these days. However, some of the links above may only be relevant with that context. -->
<Target Name="SilkNativePackaging" Condition="'$(SilkNativePackage)' == 'true'">
<GetNuGetShortFolderName TargetFrameworkMoniker="$(TargetFrameworkMoniker)" TargetPlatformMoniker="$(TargetPlatformMoniker)">
<Output TaskParameter="NuGetShortFolderName" PropertyName="SilkNuGetShortFolderName" />
</GetNuGetShortFolderName>
<ReadLinesFromFile File="$(MSBuildThisFileDirectory)eng/native/nuget/NativeNuGetPackage.targets">
<Output TaskParameter="Lines" ItemName="SilkNativeNuGetPackageTargets" />
</ReadLinesFromFile>
<WriteLinesToFile File="$(IntermediateOutputPath)$(TargetFramework)/$(MSBuildProjectName).targets"
Lines="@(SilkNativeNuGetPackageTargets->'%(Identity)'->Replace('TO_BE_REPLACED_MTOUCH_NATIVE_REFERENCE_LINKER_FLAGS', '$(SilkNativeiOSLinkerFlags)')->Replace('TO_BE_REPLACED_PROPERTY_PREFIX', '$(MSBuildProjectName.Replace('.', '_'))'))" />
<WriteLinesToFile File="$(IntermediateOutputPath)$(TargetFramework)/_._" Lines="@(SilkDummyItem)" />
<ItemGroup>
<TfmSpecificPackageFile Include="$(IntermediateOutputPath)$(TargetFramework)/$(MSBuildProjectName).targets"
Link="build/$(SilkNuGetShortFolderName)/$(MSBuildProjectName).targets"
Pack="true"
PackagePath="build/$(SilkNuGetShortFolderName)/$(MSBuildProjectName).targets" />
<TfmSpecificPackageFile Include="$(IntermediateOutputPath)$(TargetFramework)/$(MSBuildProjectName).targets"
Link="build/$(SilkNuGetShortFolderName)/$(MSBuildProjectName).targets"
Pack="true"
PackagePath="buildTransitive/$(SilkNuGetShortFolderName)/$(MSBuildProjectName).targets" />
<TfmSpecificPackageFile Include="$(IntermediateOutputPath)$(TargetFramework)/_._"
Link="lib/$(SilkNuGetShortFolderName)/_._"
Pack="true"
PackagePath="lib/$(SilkNuGetShortFolderName)/_._"
Condition="'$(IncludeBuildOutput)' == 'false'" />
</ItemGroup>
</Target>
</Project>
3 changes: 3 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
<PackageVersion Include="Fody" Version="6.8.2" PrivateAssets="all" />
<PackageVersion Include="InlineIL.Fody" Version="1.9.0" PrivateAssets="all" />

<!-- Analyzers -->
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />

<!-- SilkTouch -->
<PackageVersion Include="ClangSharp.PInvokeGenerator" Version="18.1.0.2" />
<PackageVersion Include="CSharpier.Core" Version="0.30.2" />
Expand Down
Loading
Loading