diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5b8aabe34a..acbe9e885a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,6 +13,10 @@ jobs: - uses: actions/checkout@v2 with: submodules: 'true' + - name: Setup .NET 6.0 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.0.100-preview.7.21379.14 - name: Setup .NET 5.0 uses: actions/setup-dotnet@v1 with: @@ -23,6 +27,9 @@ jobs: dotnet-version: 3.1.404 - name: Setup NUKE run: dotnet tool install Nuke.GlobalTool --global + - name: Install Workloads + # TODO: This is slow. Maybe we can make a docker container with this already done? + run: dotnet workload install android android-aot ios maccatalyst maui - name: Test # skip Clean, Restore, and Compile as this will build the affect the whole solution. # dotnet test will compile the necessary projects for testing only. @@ -31,7 +38,7 @@ jobs: run: nuke ValidateSolution - name: Pack # TODO build native mixins such as BuildLibSilkDroid - run: nuke Pack --configuration Release --msbuild-properties VersionSuffix=build${{ github.run_number }}.0 ContinuousIntegrationBuild=true --feature-sets Android iOS + run: nuke Pack --configuration Release --msbuild-properties VersionSuffix=build${{ github.run_number }}.0 ContinuousIntegrationBuild=true --feature-sets Legacy-Android Legacy-iOS - name: Push to NuGet if: ${{ github.repository == 'dotnet/Silk.NET' && github.event_name != 'pull_request' }} run: nuke PushToNuGet --skip Clean Restore Compile Pack --nuget-feed https://pkgs.dev.azure.com/UltzOS/Silk.NET/_packaging/Experimental/nuget/v3/index.json --nuget-username ${{ secrets.AZDO_ARTIFACTS_USERNAME }} --nuget-password ${{ secrets.AZDO_ARTIFACTS_TOKEN }} --nuget-api-key az diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ef20681386..a7283bf725 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -12,14 +12,27 @@ jobs: - uses: actions/checkout@v2 with: submodules: 'true' - - name: Setup .NET Core + - name: Setup .NET 6.0 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.0.100-preview.7.21379.14 + - name: Setup .NET 5.0 uses: actions/setup-dotnet@v1 with: dotnet-version: 5.0.201 + - name: Setup .NET Core 3.1 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.404 + - name: Setup NUKE + run: dotnet tool install Nuke.GlobalTool --global + - name: Install Workloads + # TODO: This is slow. Maybe we can make a docker container with this already done? + run: dotnet workload install android android-aot ios maccatalyst maui - name: Setup NUKE run: dotnet tool install Nuke.GlobalTool --global - name: Pack - run: nuke Pack --msbuild-properties ContinuousIntegrationBuild=true SilkEnableSourceLink=true --feature-sets Android iOS + run: nuke Pack --msbuild-properties ContinuousIntegrationBuild=true SilkEnableSourceLink=true --feature-sets Legacy-Android Legacy-iOS - name: Upload Unsigned Artifacts to Actions uses: actions/upload-artifact@v2.2.4 with: diff --git a/README.md b/README.md index cf351c4975..793bc12973 100644 --- a/README.md +++ b/README.md @@ -54,13 +54,21 @@ In addition, the Silk.NET working group help drive larger user-facing changes pr

Building from source

-- Make sure you have at least the .NET 5 SDK installed, preferably with Visual Studio's .NET Framework and Xamarin workloads too. -- Clone the repository -- Run build.sh, build.cmd, build.ps1, or `nuke build`. To build for iOS and Android, add the `--feature-sets ios android` arguments. +Prerequisites +- **Must**: .NET 6 SDK +- **Should**: Android (w/ AOT), iOS, and MAUI .NET 6 workloads (use `dotnet workload install android android-aot ios maui` to install them) +- **Should**: Android SDK version 30 with NDK tools installed +- **Could**: Java JDK (for gradle) +- **Could**: Visual Studio 2019 Community version 16.10 or later + +Instructions +- Clone the repository (recursively) +- Run build.sh, build.cmd, build.ps1, or `nuke compile`. By default all packages targeting .NET Core, Standard, or .NET 6 are built. To build our older Xamarin iOS and Android packages, add the `--feature-sets legacy-ios legacy-android` arguments. +- Use the DLLs. To get nupkgs you can use with NuGet instead, use `nuke pack`. There are more advanced build actions you can do too, such as FullBuild, Pack, FullPack, among others which you can view by doing `nuke --plan`. -Some projects may not build properly without being configured to use Desktop MSBuild (i.e. the MSBuild shipped with Visual Studio). As a result, you will ideally need to be on Windows and have Visual Studio 2019 Community (or greater) installed with .NET Core and Xamarin workloads. If you don't have this (i.e. because you're on Linux or Mac), you can still develop Silk.NET in a limited capacity but you will not be able to work on mobile workloads. +The older Xamarin projects will not build properly without being configured to use Desktop MSBuild (i.e. the MSBuild shipped with Visual Studio). As a result, you will ideally need to be on Windows and have Visual Studio 2019 Community (v16.10 or greater) installed with .NET Core and Xamarin workloads. If you don't have this (i.e. because you're on Linux or Mac), you won't be able to build the older Xamarin packages.

Contributing

diff --git a/Silk.NET.sln b/Silk.NET.sln index 565f9416ed..e67bfccf66 100644 --- a/Silk.NET.sln +++ b/Silk.NET.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30517.126 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31612.314 MinimumVisualStudioVersion = 15.0.26124.0 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.BuildTools", "src\Core\Silk.NET.BuildTools\Silk.NET.BuildTools.csproj", "{FD24E9FF-1097-4777-A418-F2D88C558665}" EndProject @@ -392,67 +392,65 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WavePlayer", "examples\CSha EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImGuiVulkan", "src\Lab\Experiments\ImGuiVulkan\ImGuiVulkan.csproj", "{89B03DDB-EBCA-4E6A-80AB-9FFD48110097}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.OpenAL.Soft.Native", "src\Native\Silk.NET.OpenAL.Soft.Native\Silk.NET.OpenAL.Soft.Native.csproj", "{0DF430D1-39E6-46F5-AE58-B6DE0BD3F72B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.OpenAL.Soft.Native", "src\Native\Silk.NET.OpenAL.Soft.Native\Silk.NET.OpenAL.Soft.Native.csproj", "{0DF430D1-39E6-46F5-AE58-B6DE0BD3F72B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.OpenXR.Extensions.EPIC", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.EPIC\Silk.NET.OpenXR.Extensions.EPIC.csproj", "{591836FE-0DAC-48A5-86AB-4C317A6B009A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.OpenXR.Extensions.EPIC", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.EPIC\Silk.NET.OpenXR.Extensions.EPIC.csproj", "{591836FE-0DAC-48A5-86AB-4C317A6B009A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.OpenXR.Extensions.EXTX", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.EXTX\Silk.NET.OpenXR.Extensions.EXTX.csproj", "{960CCDC0-5327-4DD6-A4FE-90466B27F9C9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.OpenXR.Extensions.EXTX", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.EXTX\Silk.NET.OpenXR.Extensions.EXTX.csproj", "{960CCDC0-5327-4DD6-A4FE-90466B27F9C9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.OpenXR.Extensions.FB", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.FB\Silk.NET.OpenXR.Extensions.FB.csproj", "{749B0BAE-63F0-4B22-A883-CD521F725DAA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.OpenXR.Extensions.FB", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.FB\Silk.NET.OpenXR.Extensions.FB.csproj", "{749B0BAE-63F0-4B22-A883-CD521F725DAA}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.OpenXR.Extensions.HUAWEI", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.HUAWEI\Silk.NET.OpenXR.Extensions.HUAWEI.csproj", "{A1D90A8D-B1FE-463A-884E-AEC201FB75EF}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.OpenXR.Extensions.HUAWEI", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.HUAWEI\Silk.NET.OpenXR.Extensions.HUAWEI.csproj", "{A1D90A8D-B1FE-463A-884E-AEC201FB75EF}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.OpenXR.Extensions.HTC", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.HTC\Silk.NET.OpenXR.Extensions.HTC.csproj", "{60AFD661-4BE5-4040-896A-CE2EA95F98B7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.OpenXR.Extensions.HTC", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.HTC\Silk.NET.OpenXR.Extensions.HTC.csproj", "{60AFD661-4BE5-4040-896A-CE2EA95F98B7}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.OpenXR.Extensions.LUNARG", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.LUNARG\Silk.NET.OpenXR.Extensions.LUNARG.csproj", "{71FF6EB5-2AA9-4B6B-8C7C-CE9AC889A50E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.OpenXR.Extensions.LUNARG", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.LUNARG\Silk.NET.OpenXR.Extensions.LUNARG.csproj", "{71FF6EB5-2AA9-4B6B-8C7C-CE9AC889A50E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.OpenXR.Extensions.MAGICLEAP", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.MAGICLEAP\Silk.NET.OpenXR.Extensions.MAGICLEAP.csproj", "{AF8E3CF5-EEAD-477C-80DF-E0CF576D5A73}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.OpenXR.Extensions.MAGICLEAP", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.MAGICLEAP\Silk.NET.OpenXR.Extensions.MAGICLEAP.csproj", "{AF8E3CF5-EEAD-477C-80DF-E0CF576D5A73}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.OpenXR.Extensions.ML", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.ML\Silk.NET.OpenXR.Extensions.ML.csproj", "{4CFC3947-9763-4FD1-869B-EEDFA7EB53AC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.OpenXR.Extensions.ML", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.ML\Silk.NET.OpenXR.Extensions.ML.csproj", "{4CFC3947-9763-4FD1-869B-EEDFA7EB53AC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.OpenXR.Extensions.MND", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.MND\Silk.NET.OpenXR.Extensions.MND.csproj", "{3076E116-F160-4C5D-A3D9-B3B51845675C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.OpenXR.Extensions.MND", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.MND\Silk.NET.OpenXR.Extensions.MND.csproj", "{3076E116-F160-4C5D-A3D9-B3B51845675C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.OpenXR.Extensions.MNDX", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.MNDX\Silk.NET.OpenXR.Extensions.MNDX.csproj", "{A1890199-5E68-4AF3-A2AD-21A1D84AF22B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.OpenXR.Extensions.MNDX", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.MNDX\Silk.NET.OpenXR.Extensions.MNDX.csproj", "{A1890199-5E68-4AF3-A2AD-21A1D84AF22B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.OpenXR.Extensions.OCULUS", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.OCULUS\Silk.NET.OpenXR.Extensions.OCULUS.csproj", "{358A6DC8-866C-4C8D-8F41-682F6683E683}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.OpenXR.Extensions.OCULUS", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.OCULUS\Silk.NET.OpenXR.Extensions.OCULUS.csproj", "{358A6DC8-866C-4C8D-8F41-682F6683E683}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.OpenXR.Extensions.ULTRALEAP", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.ULTRALEAP\Silk.NET.OpenXR.Extensions.ULTRALEAP.csproj", "{CBE8E2D0-B1DE-422D-BF66-7FF02AE81CB9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.OpenXR.Extensions.ULTRALEAP", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.ULTRALEAP\Silk.NET.OpenXR.Extensions.ULTRALEAP.csproj", "{CBE8E2D0-B1DE-422D-BF66-7FF02AE81CB9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.OpenXR.Extensions.VALVE", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.VALVE\Silk.NET.OpenXR.Extensions.VALVE.csproj", "{5C59C1E1-6392-41AA-AD73-6DA34B1B369B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.OpenXR.Extensions.VALVE", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.VALVE\Silk.NET.OpenXR.Extensions.VALVE.csproj", "{5C59C1E1-6392-41AA-AD73-6DA34B1B369B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.OpenXR.Extensions.VARJO", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.VARJO\Silk.NET.OpenXR.Extensions.VARJO.csproj", "{51868FC9-C052-4C2D-98F9-10379AAD2671}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.OpenXR.Extensions.VARJO", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.VARJO\Silk.NET.OpenXR.Extensions.VARJO.csproj", "{51868FC9-C052-4C2D-98F9-10379AAD2671}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.OpenCL.Extensions.LOADER", "src\OpenCL\Extensions\Silk.NET.OpenCL.Extensions.LOADER\Silk.NET.OpenCL.Extensions.LOADER.csproj", "{23172004-FF6B-45D8-9653-944CECE741E1}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.OpenCL.Extensions.LOADER", "src\OpenCL\Extensions\Silk.NET.OpenCL.Extensions.LOADER\Silk.NET.OpenCL.Extensions.LOADER.csproj", "{23172004-FF6B-45D8-9653-944CECE741E1}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Vulkan.Extensions.ARM", "src\Vulkan\Extensions\Silk.NET.Vulkan.Extensions.ARM\Silk.NET.Vulkan.Extensions.ARM.csproj", "{04E05BC4-5769-4FC1-BBA0-06EC9D8E3130}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.Vulkan.Extensions.ARM", "src\Vulkan\Extensions\Silk.NET.Vulkan.Extensions.ARM\Silk.NET.Vulkan.Extensions.ARM.csproj", "{04E05BC4-5769-4FC1-BBA0-06EC9D8E3130}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Vulkan.Extensions.BRCM", "src\Vulkan\Extensions\Silk.NET.Vulkan.Extensions.BRCM\Silk.NET.Vulkan.Extensions.BRCM.csproj", "{98C25360-F03A-4929-959B-C80A48D21FF2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.Vulkan.Extensions.BRCM", "src\Vulkan\Extensions\Silk.NET.Vulkan.Extensions.BRCM\Silk.NET.Vulkan.Extensions.BRCM.csproj", "{98C25360-F03A-4929-959B-C80A48D21FF2}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Vulkan.Extensions.IMG", "src\Vulkan\Extensions\Silk.NET.Vulkan.Extensions.IMG\Silk.NET.Vulkan.Extensions.IMG.csproj", "{FD32964B-4144-43CD-B313-2A5DD6A05DEA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.Vulkan.Extensions.IMG", "src\Vulkan\Extensions\Silk.NET.Vulkan.Extensions.IMG\Silk.NET.Vulkan.Extensions.IMG.csproj", "{FD32964B-4144-43CD-B313-2A5DD6A05DEA}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Vulkan.Extensions.MESA", "src\Vulkan\Extensions\Silk.NET.Vulkan.Extensions.MESA\Silk.NET.Vulkan.Extensions.MESA.csproj", "{859A77A8-73F0-447B-9076-B42D5CA3CA33}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.Vulkan.Extensions.MESA", "src\Vulkan\Extensions\Silk.NET.Vulkan.Extensions.MESA\Silk.NET.Vulkan.Extensions.MESA.csproj", "{859A77A8-73F0-447B-9076-B42D5CA3CA33}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Vulkan.Extensions.QCOM", "src\Vulkan\Extensions\Silk.NET.Vulkan.Extensions.QCOM\Silk.NET.Vulkan.Extensions.QCOM.csproj", "{92FCD7CC-52BE-487F-B990-1B5CACF9D40F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.Vulkan.Extensions.QCOM", "src\Vulkan\Extensions\Silk.NET.Vulkan.Extensions.QCOM\Silk.NET.Vulkan.Extensions.QCOM.csproj", "{92FCD7CC-52BE-487F-B990-1B5CACF9D40F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Vulkan.Extensions.HUAWEI", "src\Vulkan\Extensions\Silk.NET.Vulkan.Extensions.HUAWEI\Silk.NET.Vulkan.Extensions.HUAWEI.csproj", "{64E177FC-38AA-45AE-B748-419E91F95EC7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.Vulkan.Extensions.HUAWEI", "src\Vulkan\Extensions\Silk.NET.Vulkan.Extensions.HUAWEI\Silk.NET.Vulkan.Extensions.HUAWEI.csproj", "{64E177FC-38AA-45AE-B748-419E91F95EC7}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Vulkan.Extensions.QNX", "src\Vulkan\Extensions\Silk.NET.Vulkan.Extensions.QNX\Silk.NET.Vulkan.Extensions.QNX.csproj", "{F16B4AE5-F68F-42A2-8AB5-029282032CE0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.Vulkan.Extensions.QNX", "src\Vulkan\Extensions\Silk.NET.Vulkan.Extensions.QNX\Silk.NET.Vulkan.Extensions.QNX.csproj", "{F16B4AE5-F68F-42A2-8AB5-029282032CE0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Vulkan.Extensions.VALVE", "src\Vulkan\Extensions\Silk.NET.Vulkan.Extensions.VALVE\Silk.NET.Vulkan.Extensions.VALVE.csproj", "{AB59F09A-9BD9-4CBB-8497-87B768C7C949}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.Vulkan.Extensions.VALVE", "src\Vulkan\Extensions\Silk.NET.Vulkan.Extensions.VALVE\Silk.NET.Vulkan.Extensions.VALVE.csproj", "{AB59F09A-9BD9-4CBB-8497-87B768C7C949}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Vulkan.Extensions.JUICE", "src\Vulkan\Extensions\Silk.NET.Vulkan.Extensions.JUICE\Silk.NET.Vulkan.Extensions.JUICE.csproj", "{86B6B40E-EA8F-47F0-9D1F-FDBAFBE2842C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.Vulkan.Extensions.JUICE", "src\Vulkan\Extensions\Silk.NET.Vulkan.Extensions.JUICE\Silk.NET.Vulkan.Extensions.JUICE.csproj", "{86B6B40E-EA8F-47F0-9D1F-FDBAFBE2842C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Vulkan.Extensions.FB", "src\Vulkan\Extensions\Silk.NET.Vulkan.Extensions.FB\Silk.NET.Vulkan.Extensions.FB.csproj", "{D1DD841D-9F34-47A6-91EB-A8632D577BD7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.Vulkan.Extensions.FB", "src\Vulkan\Extensions\Silk.NET.Vulkan.Extensions.FB\Silk.NET.Vulkan.Extensions.FB.csproj", "{D1DD841D-9F34-47A6-91EB-A8632D577BD7}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{16AFCF73-8CC1-4B5D-8969-A90F468DC6D5}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "OpenXR", "OpenXR", "{1E76124C-D849-4D44-B7A2-5383C8C636B9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.OpenXR.Extensions.UNITY", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.UNITY\Silk.NET.OpenXR.Extensions.UNITY.csproj", "{AE5A7BBD-E303-46C4-9DDC-29E80C9128F5}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Extensions", "Extensions", "{048B85BE-276B-4C75-B4FF-BB825C0FEE54}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.OpenXR.Extensions.LIV", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.LIV\Silk.NET.OpenXR.Extensions.LIV.csproj", "{0D1E5AD9-E329-4B84-A5FE-FC1EE33BF038}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.OpenXR.Extensions.UNITY", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.UNITY\Silk.NET.OpenXR.Extensions.UNITY.csproj", "{AE5A7BBD-E303-46C4-9DDC-29E80C9128F5}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.OpenXR.Extensions.LIV", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.LIV\Silk.NET.OpenXR.Extensions.LIV.csproj", "{0D1E5AD9-E329-4B84-A5FE-FC1EE33BF038}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TriangleNET6", "src\Lab\Experiments\TriangleNET6\TriangleNET6.csproj", "{477046D2-AF81-4E2B-83BD-20176A971FDD}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -2695,16 +2693,30 @@ Global {0D1E5AD9-E329-4B84-A5FE-FC1EE33BF038}.Release|x64.Build.0 = Release|Any CPU {0D1E5AD9-E329-4B84-A5FE-FC1EE33BF038}.Release|x86.ActiveCfg = Release|Any CPU {0D1E5AD9-E329-4B84-A5FE-FC1EE33BF038}.Release|x86.Build.0 = Release|Any CPU + {477046D2-AF81-4E2B-83BD-20176A971FDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {477046D2-AF81-4E2B-83BD-20176A971FDD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {477046D2-AF81-4E2B-83BD-20176A971FDD}.Debug|x64.ActiveCfg = Debug|Any CPU + {477046D2-AF81-4E2B-83BD-20176A971FDD}.Debug|x64.Build.0 = Debug|Any CPU + {477046D2-AF81-4E2B-83BD-20176A971FDD}.Debug|x86.ActiveCfg = Debug|Any CPU + {477046D2-AF81-4E2B-83BD-20176A971FDD}.Debug|x86.Build.0 = Debug|Any CPU + {477046D2-AF81-4E2B-83BD-20176A971FDD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {477046D2-AF81-4E2B-83BD-20176A971FDD}.Release|Any CPU.Build.0 = Release|Any CPU + {477046D2-AF81-4E2B-83BD-20176A971FDD}.Release|x64.ActiveCfg = Release|Any CPU + {477046D2-AF81-4E2B-83BD-20176A971FDD}.Release|x64.Build.0 = Release|Any CPU + {477046D2-AF81-4E2B-83BD-20176A971FDD}.Release|x86.ActiveCfg = Release|Any CPU + {477046D2-AF81-4E2B-83BD-20176A971FDD}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {FD24E9FF-1097-4777-A418-F2D88C558665} = {0651C5EF-50AA-4598-8D9C-8F210ADD8490} + {23324041-2076-477C-A4BF-B385B8066C6C} = {16AFCF73-8CC1-4B5D-8969-A90F468DC6D5} {BFE429EB-4C2E-4BF3-A302-C9C5A2FDA6D7} = {23324041-2076-477C-A4BF-B385B8066C6C} {136C6154-D300-4B82-80D3-17B637841A2B} = {0651C5EF-50AA-4598-8D9C-8F210ADD8490} {0A18FCAE-572E-47FF-B8E3-C97ED15132FA} = {23324041-2076-477C-A4BF-B385B8066C6C} {956F722C-DFD3-435E-9D2E-A0549C4D8BC0} = {23324041-2076-477C-A4BF-B385B8066C6C} + {081E7761-B200-4DBF-8950-941464DECACE} = {16AFCF73-8CC1-4B5D-8969-A90F468DC6D5} {5A41E9D5-67F5-447C-8AE2-78FED7A45206} = {081E7761-B200-4DBF-8950-941464DECACE} {896B1A79-FEC8-4B7A-8A9C-0CC8EDA2CCFC} = {081E7761-B200-4DBF-8950-941464DECACE} {FC015604-3326-4BCC-9212-C5CB0DFB0D12} = {896B1A79-FEC8-4B7A-8A9C-0CC8EDA2CCFC} @@ -2712,6 +2724,8 @@ Global {352E06E3-9D5E-4C2B-836D-C5538F8AA48D} = {896B1A79-FEC8-4B7A-8A9C-0CC8EDA2CCFC} {94D7D3A3-3640-4791-BE19-CA50C59187C6} = {896B1A79-FEC8-4B7A-8A9C-0CC8EDA2CCFC} {8FFF49D6-B029-400B-8510-1A088868DFA6} = {FA9D1C95-5585-4DEC-B226-1447A486C376} + {FA9D1C95-5585-4DEC-B226-1447A486C376} = {16AFCF73-8CC1-4B5D-8969-A90F468DC6D5} + {0E9C83A8-A413-4921-8F39-59519BFF939B} = {16AFCF73-8CC1-4B5D-8969-A90F468DC6D5} {A01F43A5-B4ED-47C5-B426-D1AC3C94B5E7} = {0E9C83A8-A413-4921-8F39-59519BFF939B} {446DD80A-CAF4-4E19-B87E-A43135E2D59D} = {0E9C83A8-A413-4921-8F39-59519BFF939B} {24CE7080-FF44-46BF-886F-456F30E54442} = {0E9C83A8-A413-4921-8F39-59519BFF939B} @@ -2769,9 +2783,11 @@ Global {3BC72F4A-8B32-490A-9EA7-B68320991E15} = {CF69D5C3-4ACE-4458-BA5A-0E9A3B294CDC} {6D2F52DB-2DB4-49EF-8DD1-212FA33CE034} = {CF69D5C3-4ACE-4458-BA5A-0E9A3B294CDC} {8D534FE1-6113-457A-97DD-FD42782580A5} = {CF69D5C3-4ACE-4458-BA5A-0E9A3B294CDC} + {0651C5EF-50AA-4598-8D9C-8F210ADD8490} = {16AFCF73-8CC1-4B5D-8969-A90F468DC6D5} {3908DEF6-7403-49F5-B8EC-5B3B12C325D4} = {FA9D1C95-5585-4DEC-B226-1447A486C376} {020A8E88-B607-4281-BA0D-5ED03484A201} = {FA9D1C95-5585-4DEC-B226-1447A486C376} {7BB1DE56-DA1C-4776-A961-B810574E1EF4} = {0651C5EF-50AA-4598-8D9C-8F210ADD8490} + {E2ABDF45-C329-47B2-8E09-B7298E2557F7} = {16AFCF73-8CC1-4B5D-8969-A90F468DC6D5} {7F347EDA-EC20-4E3F-9C25-CF32ED7D9642} = {E2ABDF45-C329-47B2-8E09-B7298E2557F7} {49BC383A-D7E6-4013-93C7-371479B984CC} = {E2ABDF45-C329-47B2-8E09-B7298E2557F7} {043852EA-FBD4-4F42-9CDC-92078F9EF942} = {49BC383A-D7E6-4013-93C7-371479B984CC} @@ -2787,8 +2803,10 @@ Global {65E16908-BD7A-4FC2-BC23-FD8194039C5B} = {49BC383A-D7E6-4013-93C7-371479B984CC} {3D945DE0-1E2D-439E-991D-9C65C325F82F} = {49BC383A-D7E6-4013-93C7-371479B984CC} {D27D10F0-F22B-49B5-9933-375BB120AD70} = {CF69D5C3-4ACE-4458-BA5A-0E9A3B294CDC} + {DFA0E841-33E5-4533-AF00-964E21A141B8} = {16AFCF73-8CC1-4B5D-8969-A90F468DC6D5} {3501BAD6-406A-49BC-BE0E-5A49A3AAAE6A} = {23324041-2076-477C-A4BF-B385B8066C6C} {50D5EAD9-78BB-4D1B-AF37-130BF3AF82FD} = {3501BAD6-406A-49BC-BE0E-5A49A3AAAE6A} + {D00DC827-E7DF-48A9-9BEB-E1ED2F73C990} = {16AFCF73-8CC1-4B5D-8969-A90F468DC6D5} {93041A0D-9BA2-4BAB-B01E-3003AEAC0A31} = {D00DC827-E7DF-48A9-9BEB-E1ED2F73C990} {757F2B10-B69D-4C19-BFE0-D99070A00AD9} = {D00DC827-E7DF-48A9-9BEB-E1ED2F73C990} {13AAF660-1E37-4C63-B2B7-49140B9F5049} = {757F2B10-B69D-4C19-BFE0-D99070A00AD9} @@ -2802,11 +2820,13 @@ Global {45407BC4-DF4C-49BD-ADEF-706683C90E14} = {757F2B10-B69D-4C19-BFE0-D99070A00AD9} {8D84B804-168F-4EAA-BC09-F55A35A29887} = {FA9D1C95-5585-4DEC-B226-1447A486C376} {8DCB2EB4-D0DE-4EF9-ACB3-332055D594CB} = {8D84B804-168F-4EAA-BC09-F55A35A29887} + {ABD1AF6D-D9D1-4157-A1FF-AC98A054DA92} = {16AFCF73-8CC1-4B5D-8969-A90F468DC6D5} {B6017708-8E8C-4230-95AD-2D06237D68D4} = {ABD1AF6D-D9D1-4157-A1FF-AC98A054DA92} {90471225-AC23-424E-B62E-F6EC4C6ECAC0} = {ABD1AF6D-D9D1-4157-A1FF-AC98A054DA92} {59C98A03-427A-40A0-8467-C85C4807907F} = {90471225-AC23-424E-B62E-F6EC4C6ECAC0} {0030C8EE-8EBB-499F-A310-957BE176AEB1} = {90471225-AC23-424E-B62E-F6EC4C6ECAC0} {E51CD67A-A6D9-4850-A8A6-348B23C5DA7F} = {90471225-AC23-424E-B62E-F6EC4C6ECAC0} + {6EADA376-E83F-40B7-9539-71DD17AEF7A4} = {16AFCF73-8CC1-4B5D-8969-A90F468DC6D5} {19586F56-E799-49EA-9B3C-910BF2D4976A} = {6EADA376-E83F-40B7-9539-71DD17AEF7A4} {00D8F04F-2063-4F4E-B793-0F9DCF2BCFA9} = {23324041-2076-477C-A4BF-B385B8066C6C} {6B703607-0D63-4A25-BB6A-EC1FBBD77A8C} = {0651C5EF-50AA-4598-8D9C-8F210ADD8490} @@ -2818,6 +2838,7 @@ Global {603F28D1-E982-47C0-98D9-3E6DA1DD37E2} = {488775D1-32CC-46D7-8DD7-BB331EC659B9} {488775D1-32CC-46D7-8DD7-BB331EC659B9} = {23324041-2076-477C-A4BF-B385B8066C6C} {B9A8D738-FE7D-4860-A446-4A03E3DDEB74} = {0651C5EF-50AA-4598-8D9C-8F210ADD8490} + {F2CF5D32-4B41-425E-B229-8FFC48F88063} = {16AFCF73-8CC1-4B5D-8969-A90F468DC6D5} {F3B7A9D6-5B15-45E8-925B-20B5BBD33428} = {F2CF5D32-4B41-425E-B229-8FFC48F88063} {A768A346-6388-4881-8FF6-15F0163B76E0} = {F2CF5D32-4B41-425E-B229-8FFC48F88063} {2C3099EA-C01C-4639-8300-153A9BD79292} = {F2CF5D32-4B41-425E-B229-8FFC48F88063} @@ -2825,10 +2846,12 @@ Global {07DD7965-849F-4311-9DAD-07C1CCF8BEA4} = {F2CF5D32-4B41-425E-B229-8FFC48F88063} {4712BFE1-67DA-407F-8BDC-FAF529E5BF94} = {F2CF5D32-4B41-425E-B229-8FFC48F88063} {E8DE9BA0-8391-4278-926D-DD931C4172AF} = {F2CF5D32-4B41-425E-B229-8FFC48F88063} + {41EEBDB3-75C4-4A60-B4D5-673FBCA791E7} = {16AFCF73-8CC1-4B5D-8969-A90F468DC6D5} {BD86AB4D-74FD-429D-9AEE-79B0C429BB3A} = {41EEBDB3-75C4-4A60-B4D5-673FBCA791E7} {07915304-3B6B-400C-94F8-C49EF5F347E7} = {41EEBDB3-75C4-4A60-B4D5-673FBCA791E7} {8C7A30EF-C257-421C-AABD-D42FF6D955A5} = {41EEBDB3-75C4-4A60-B4D5-673FBCA791E7} {DE477265-8F7D-4D7F-B5DA-F3C5DE631788} = {3501BAD6-406A-49BC-BE0E-5A49A3AAAE6A} + {72E7FA64-5B1E-477D-BD30-63B7F206B3C4} = {16AFCF73-8CC1-4B5D-8969-A90F468DC6D5} {F9AA41B4-1C36-472B-A1A5-4A10EE0A79FC} = {72E7FA64-5B1E-477D-BD30-63B7F206B3C4} {84F51960-D814-450D-80EB-D9E46A1D5187} = {72E7FA64-5B1E-477D-BD30-63B7F206B3C4} {D3D9891B-88E6-46AD-919C-7EC4EABE5266} = {72E7FA64-5B1E-477D-BD30-63B7F206B3C4} @@ -2887,21 +2910,20 @@ Global {CBE8E2D0-B1DE-422D-BF66-7FF02AE81CB9} = {90471225-AC23-424E-B62E-F6EC4C6ECAC0} {5C59C1E1-6392-41AA-AD73-6DA34B1B369B} = {90471225-AC23-424E-B62E-F6EC4C6ECAC0} {51868FC9-C052-4C2D-98F9-10379AAD2671} = {90471225-AC23-424E-B62E-F6EC4C6ECAC0} + {23172004-FF6B-45D8-9653-944CECE741E1} = {757F2B10-B69D-4C19-BFE0-D99070A00AD9} {04E05BC4-5769-4FC1-BBA0-06EC9D8E3130} = {49BC383A-D7E6-4013-93C7-371479B984CC} {98C25360-F03A-4929-959B-C80A48D21FF2} = {49BC383A-D7E6-4013-93C7-371479B984CC} - {64E177FC-38AA-45AE-B748-419E91F95EC7} = {49BC383A-D7E6-4013-93C7-371479B984CC} {FD32964B-4144-43CD-B313-2A5DD6A05DEA} = {49BC383A-D7E6-4013-93C7-371479B984CC} - {86B6B40E-EA8F-47F0-9D1F-FDBAFBE2842C} = {49BC383A-D7E6-4013-93C7-371479B984CC} {859A77A8-73F0-447B-9076-B42D5CA3CA33} = {49BC383A-D7E6-4013-93C7-371479B984CC} {92FCD7CC-52BE-487F-B990-1B5CACF9D40F} = {49BC383A-D7E6-4013-93C7-371479B984CC} + {64E177FC-38AA-45AE-B748-419E91F95EC7} = {49BC383A-D7E6-4013-93C7-371479B984CC} {F16B4AE5-F68F-42A2-8AB5-029282032CE0} = {49BC383A-D7E6-4013-93C7-371479B984CC} {AB59F09A-9BD9-4CBB-8497-87B768C7C949} = {49BC383A-D7E6-4013-93C7-371479B984CC} - {23172004-FF6B-45D8-9653-944CECE741E1} = {757F2B10-B69D-4C19-BFE0-D99070A00AD9} + {86B6B40E-EA8F-47F0-9D1F-FDBAFBE2842C} = {49BC383A-D7E6-4013-93C7-371479B984CC} {D1DD841D-9F34-47A6-91EB-A8632D577BD7} = {49BC383A-D7E6-4013-93C7-371479B984CC} - {1E76124C-D849-4D44-B7A2-5383C8C636B9} = {16AFCF73-8CC1-4B5D-8969-A90F468DC6D5} - {048B85BE-276B-4C75-B4FF-BB825C0FEE54} = {1E76124C-D849-4D44-B7A2-5383C8C636B9} - {AE5A7BBD-E303-46C4-9DDC-29E80C9128F5} = {048B85BE-276B-4C75-B4FF-BB825C0FEE54} - {0D1E5AD9-E329-4B84-A5FE-FC1EE33BF038} = {048B85BE-276B-4C75-B4FF-BB825C0FEE54} + {AE5A7BBD-E303-46C4-9DDC-29E80C9128F5} = {90471225-AC23-424E-B62E-F6EC4C6ECAC0} + {0D1E5AD9-E329-4B84-A5FE-FC1EE33BF038} = {90471225-AC23-424E-B62E-F6EC4C6ECAC0} + {477046D2-AF81-4E2B-83BD-20176A971FDD} = {39B598E9-44BA-4A61-A1BB-7C543734DBA6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {F5273D7F-3334-48DF-94E3-41AE6816CD4D} diff --git a/build/nuke/Build.cs b/build/nuke/Build.cs index c15d97b7b3..d7f0fbcaa3 100644 --- a/build/nuke/Build.cs +++ b/build/nuke/Build.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Runtime.InteropServices; using System.Threading.Tasks; +using JetBrains.Annotations; using Nuke.Common; using Nuke.Common.Execution; using Nuke.Common.IO; @@ -25,8 +26,7 @@ class Build : NukeBuild /// - JetBrains Rider https://nuke.build/rider /// - Microsoft VisualStudio https://nuke.build/visualstudio /// - Microsoft VSCode https://nuke.build/vscode - - public static int Main () => Execute(x => x.Compile); + public static int Main() => Execute(x => x.Compile); static int IndexOfOrThrow(string x, char y) { @@ -47,7 +47,7 @@ bool HasDesktopMsBuild { return false; } - + try { MSBuildToolPathResolver.Resolve(); // throws if it can't find msbuild @@ -59,15 +59,21 @@ bool HasDesktopMsBuild } } } - + bool HasProcessedSolutions { get; set; } bool HasProcessedProperties { get; set; } - [Parameter("The feature sets to build - Could include Core, iOS, or Android. Any projects that aren't " + - "categorized into a feature set will always be built.")] - string[] FeatureSets = {"core"}; - - [Parameter("Forces the build system to use \"dotnet build\" instead of \"msbuild\" if available.")] + [Parameter + ( + "The feature sets to build - Could include Core, Legacy-iOS, or Legacy-Android. Any projects that aren't " + + "categorized into a feature set will always be built." + )] + string[] FeatureSets = { "core" }; + + [Parameter + ( + "Forces the build system to use \"dotnet build\" instead of \"msbuild\" if available. Ignored for legacy Android and iOS feature sets." + )] readonly bool ForceDotnet; [Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")] @@ -80,26 +86,19 @@ bool HasDesktopMsBuild [Parameter("NuGet password")] readonly string NugetPassword; [Parameter("Code-signing service username")] readonly string SignUsername; [Parameter("Code-signing service password")] readonly string SignPassword; + [Parameter("Extra properties passed to MSBuild commands")] - readonly string[] MsbuildProperties = Array.Empty(); + readonly string[] MsbuildProperties = Array.Empty(); [Solution] readonly Solution Solution; - Solution ProcessedSolution - { - get - { - if (!HasProcessedSolutions) - { - Projects.ProcessSolution(Solution, FeatureSets, HasDesktopMsBuild); - HasProcessedSolutions = true; - } - - return Solution; - } - } + [CanBeNull] Dictionary SolutionsValue; + + Dictionary Solutions + => SolutionsValue ??= Projects.ProcessSolution(Solution, FeatureSets, HasDesktopMsBuild); Dictionary ProcessedMsbuildPropertiesValue; + Dictionary ProcessedMsbuildProperties { get @@ -127,9 +126,8 @@ Dictionary ProcessedMsbuildProperties // ReSharper disable once RedundantEmptyObjectOrCollectionInitializer readonly HashSet AllowedExclusions = new() { - }; - + Target ValidateSolution => _ => _ .Executes ( @@ -158,7 +156,7 @@ Dictionary ProcessedMsbuildProperties $"\"{file}\" if this is acceptable please add the project name (excluding the path and " + "extension) to the AllowedExclusions array in the NUKE Build.cs file." ); - + missedOut.Add(file); } } @@ -178,52 +176,58 @@ Dictionary ProcessedMsbuildProperties Target Clean => _ => _ .Before(Restore) - .Executes(() => - { - if (!HasProcessedSolutions) + .Executes + ( + () => { - var slnDir = Path.Combine(Solution.Directory!, "build", "sln"); - if (Directory.Exists(slnDir)) + if (!HasProcessedSolutions) { - Directory.Delete(slnDir, true); + var slnDir = Path.Combine(Solution.Directory!, "build", "sln"); + if (Directory.Exists(slnDir)) + { + Directory.Delete(slnDir, true); + } + } + else + { + Logger.Warn + ( + "Solution has already been preprocessed prior to the Clean target. " + + "Unable to clean the preprocessed solution folder." + ); } - } - else - { - Logger.Warn - ( - "Solution has already been preprocessed prior to the Clean target. " + - "Unable to clean the preprocessed solution folder." - ); - } - - - if (HasDesktopMsBuild) - { - MSBuild - ( - s => s.SetTargetPath(ProcessedSolution) - .SetTargets("Clean") - .SetMaxCpuCount(Environment.ProcessorCount) - .SetProperties(ProcessedMsbuildProperties) - ); - } - else - { - DotNetClean(s => s.SetProject(ProcessedSolution) - .SetConfiguration(Configuration) - .SetProperties(ProcessedMsbuildProperties)); - } - if (Directory.Exists(RootDirectory / "build" / "output_packages")) - { - Directory.Delete(RootDirectory / "build" / "output_packages", true); - } + foreach (var (key, (sln, useDesktopMsBuild)) in Solutions) + { + Logger.Info($"Cleaning feature set \"{key}\" ({sln})"); + if (useDesktopMsBuild) + { + MSBuild + ( + s => s.SetTargets("Clean") + .SetMaxCpuCount(Environment.ProcessorCount) + .SetProperties(ProcessedMsbuildProperties) + .SetTargetPath(sln) + ); + } + else + { + DotNetClean + ( + s => s.SetProject(sln) + .SetConfiguration(Configuration) + .SetProperties(ProcessedMsbuildProperties) + ); + } + } + + if (Directory.Exists(RootDirectory / "build" / "output_packages")) + { + Directory.Delete(RootDirectory / "build" / "output_packages", true); + } + + Directory.CreateDirectory(RootDirectory / "build" / "output_packages"); - Directory.CreateDirectory(RootDirectory / "build" / "output_packages"); - - if (FeatureSets.Any(x => x.Equals("android", StringComparison.InvariantCultureIgnoreCase))) - { var silkDroid = SourceDirectory / "Windowing" / "Android" / "SilkDroid"; using var process = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? StartProcess("bash", "-c \"./gradlew clean\"", silkDroid) @@ -231,67 +235,78 @@ Dictionary ProcessedMsbuildProperties process.AssertZeroExitCode(); return process.Output; } - - Logger.Warn("Skipping gradlew clean because Android hasn't been specified as a feature set."); - return default; - }); + ); Target Restore => _ => _ .After(Clean) - .Executes(() => - { - if (HasDesktopMsBuild) - { - MSBuild - ( - s => s - .SetTargetPath(ProcessedSolution) - .SetConfiguration(Configuration) - .SetTargets("Restore") - .SetMaxCpuCount(Environment.ProcessorCount) - .SetProperties(ProcessedMsbuildProperties) - ); - } - else + .Executes + ( + () => { - DotNetRestore - ( - s => s - .SetProjectFile(ProcessedSolution) - .SetProperties(ProcessedMsbuildProperties) - ); + foreach (var (key, (sln, useDesktopMsBuild)) in Solutions) + { + Logger.Info($"Restoring {key}"); + if (useDesktopMsBuild) + { + MSBuild + ( + s => s + .SetTargetPath(sln) + .SetConfiguration(Configuration) + .SetTargets("Restore") + .SetMaxCpuCount(Environment.ProcessorCount) + .SetProperties(ProcessedMsbuildProperties) + ); + } + else + { + DotNetRestore + ( + s => s + .SetProjectFile(sln) + .SetProperties(ProcessedMsbuildProperties) + ); + } + } } - }); + ); Target Compile => _ => _ .DependsOn(Clean, Restore) - .Executes(() => - { - if (HasDesktopMsBuild) - { - MSBuild - ( - s => s - .SetTargets("Build") - .SetTargetPath(ProcessedSolution) - .SetConfiguration(Configuration) - .SetMaxCpuCount(Environment.ProcessorCount) - .SetNodeReuse(IsLocalBuild) - .SetProperties(ProcessedMsbuildProperties) - ); - } - else + .Executes + ( + () => { - DotNetBuild - ( - s => s - .SetProjectFile(ProcessedSolution) - .SetConfiguration(Configuration) - .SetNoRestore(true) - .SetProperties(ProcessedMsbuildProperties) - ); + foreach (var (key, (sln, useDesktopMsBuild)) in Solutions) + { + Logger.Info($"Compiling {key}"); + if (useDesktopMsBuild) + { + MSBuild + ( + s => s + .SetTargets("Build") + .SetTargetPath(sln) + .SetConfiguration(Configuration) + .SetMaxCpuCount(Environment.ProcessorCount) + .SetNodeReuse(IsLocalBuild) + .SetProperties(ProcessedMsbuildProperties) + ); + } + else + { + DotNetBuild + ( + s => s + .SetProjectFile(sln) + .SetConfiguration(Configuration) + .SetNoRestore(true) + .SetProperties(ProcessedMsbuildProperties) + ); + } + } } - }); + ); Target Test => _ => _ .DependsOn(Compile) @@ -304,7 +319,7 @@ Dictionary ProcessedMsbuildProperties ControlFlow.Fail("The Test target can currently not run against additional feature sets."); } - foreach (var project in ProcessedSolution.GetProjects("*")) + foreach (var project in Solutions["Core"].Solution.GetProjects("*")) { if (project.Name.Contains("tests", StringComparison.InvariantCultureIgnoreCase)) { @@ -320,7 +335,7 @@ Dictionary ProcessedMsbuildProperties ( () => { - var project = ProcessedSolution.GetProject("Silk.NET.BuildTools"); + var project = Solutions["Core"].Solution.GetProject("Silk.NET.BuildTools"); if (project == default) { Logger.Error("Couldn't find BuildTools in the solution file."); @@ -342,12 +357,6 @@ Dictionary ProcessedMsbuildProperties ( () => { - if (!FeatureSets.Any(x => x.Equals("android", StringComparison.InvariantCultureIgnoreCase))) - { - Logger.Warn("Skipping BuildLibSilkDroid because Android hasn't been specified as a feature set."); - return default; - } - var sdl = RootDirectory / "build" / "submodules" / "SDL"; var silkDroid = SourceDirectory / "Windowing" / "Android" / "SilkDroid"; var xcopy = new (string, string)[] @@ -363,7 +372,7 @@ Dictionary ProcessedMsbuildProperties { ControlFlow.Fail($"\"{from}\" does not exist (did you forget to recursively clone the repo?)"); } - + CopyDirectoryRecursively(from, to, DirectoryExistsPolicy.Merge, FileExistsPolicy.Overwrite); } @@ -389,38 +398,45 @@ Dictionary ProcessedMsbuildProperties Target Pack => _ => _ .DependsOn(Clean, Restore) .After(RegenerateBindings, BuildLibSilkDroid) - .Executes(() => - { - if (HasDesktopMsBuild) - { - MSBuild - ( - s => s - .SetTargets("Pack") - .SetTargetPath(ProcessedSolution) - .SetConfiguration(Configuration) - .SetMaxCpuCount(Environment.ProcessorCount) - .SetNodeReuse(IsLocalBuild) - .SetProperties(ProcessedMsbuildProperties) - ); - } - else + .Executes + ( + () => { - DotNetPack - ( - s => s - .SetProject(ProcessedSolution) - .SetConfiguration(Configuration) - .SetNoRestore(true) - .SetProperties(ProcessedMsbuildProperties) - ); + foreach (var (key, (sln, useDesktopMsBuild)) in Solutions) + { + Logger.Info($"Packing {key}"); + if (useDesktopMsBuild) + { + MSBuild + ( + s => s + .SetTargets("Pack") + .SetTargetPath(sln) + .SetConfiguration(Configuration) + .SetMaxCpuCount(Environment.ProcessorCount) + .SetNodeReuse(IsLocalBuild) + .SetProperties(ProcessedMsbuildProperties) + ); + } + else + { + DotNetPack + ( + s => s + .SetProject(sln) + .SetConfiguration(Configuration) + .SetNoRestore(true) + .SetProperties(ProcessedMsbuildProperties) + ); + } + } } - }); + ); Target FullPack => _ => _ .DependsOn(BuildLibSilkDroid, RegenerateBindings, Pack); - Target PushToNuGet => _ => _ + Target PushToNuGet => _ => _ .DependsOn(Pack) .Executes(PushPackages); @@ -428,6 +444,7 @@ Dictionary ProcessedMsbuildProperties .DependsOn(FullPack, PushToNuGet); static string PackageDirectory => RootDirectory / "build" / "output_packages"; + static IEnumerable Packages => Directory.GetFiles(PackageDirectory, "*.nupkg") .Where(x => Path.GetFileName(x).StartsWith("Silk.NET") || Path.GetFileName(x).StartsWith("Ultz.Native")); @@ -462,7 +479,7 @@ async Task PushPackages() } } - var allFiles = Packages.Select((x, i) => new {Index = i, Value = x}) + var allFiles = Packages.Select((x, i) => new { Index = i, Value = x }) .GroupBy(x => x.Index / rateLimit) .Select(x => x.Select(v => v.Value).ToList()) .ToList(); diff --git a/build/nuke/Projects.cs b/build/nuke/Projects.cs index 95082033d9..ba06784bcb 100644 --- a/build/nuke/Projects.cs +++ b/build/nuke/Projects.cs @@ -9,39 +9,66 @@ using Nuke.Common; using Nuke.Common.IO; using Nuke.Common.ProjectModel; +using static Nuke.Common.ProjectModel.ProjectModelTasks; public static class Projects { // Modify this bit if you want to define another feature set public static readonly IReadOnlyList FeatureSets = new[] { - new FeatureSet("iOS", true, "Silk.NET.Windowing.Sdl.iOS", "TriangleIOS"), - new FeatureSet("Android", true, "Silk.NET.Windowing.Sdl.Android", "TriangleDroid", "TriangleDroidUvExperiment"), - new FeatureSet("NUKE", false, "Silk.NET.NUKE", "Silk.NET.NUKE.SshAgent"), + new FeatureSet("Legacy-iOS", true, true, "Silk.NET.Windowing.Sdl.iOS", "TriangleIOS"), + new FeatureSet("Legacy-Android", true, true, "Silk.NET.Windowing.Sdl.Android", "TriangleDroid", "TriangleDroidUvExperiment"), + new FeatureSet("NUKE", false, false, "Silk.NET.NUKE", "Silk.NET.NUKE.SshAgent"), }; - public static void ProcessSolution(Solution originalSolution, string[] featureSets, bool hasDesktopMsBuild) + public static Dictionary ProcessSolution + ( + Solution originalSolution, + string[] featureSets, + bool hasDesktopMsBuild + ) { + var originalSolutionPath = originalSolution; + var featureSetSpecificSolutions = new Dictionary(); + var rm = new List(); foreach (var featureSet in FeatureSets!) { + rm.Clear(); var featureSetUsed = featureSets.Any (x => x.Equals(featureSet.Name, StringComparison.OrdinalIgnoreCase)); if (featureSetUsed && !hasDesktopMsBuild && featureSet.RequiresDesktopMsBuild) { throw new NotSupportedException("Desktop MSBuild is not available."); } - + foreach (var proj in originalSolution.GetProjects("*")) { - if (!featureSetUsed && - featureSet.Projects.Any(x => x.Equals(proj.Name, StringComparison.OrdinalIgnoreCase))) + if (!featureSet.Projects.Any(x => x.Equals(proj.Name, StringComparison.OrdinalIgnoreCase))) + { + rm.Add(proj.Path); + continue; + } + + if (!featureSetUsed) { Logger.Trace($"\"{proj.Name}\" will not be built as its feature set \"{featureSet.Name}\" has " + "not been enabled. To build this project, specify the feature set name when " + "invoking NUKE."); - - originalSolution.RemoveProject(proj); } + + originalSolution.RemoveProject(proj); + } + + if (!featureSet.GenerateExclusiveSln) + { + break; + } + + var sln = ParseSolution(originalSolutionPath); + featureSetSpecificSolutions[featureSet.Name] = (sln, featureSet.RequiresDesktopMsBuild); + foreach (var removal in rm) + { + sln.RemoveProject(sln.GetProject(removal)); } } @@ -51,20 +78,28 @@ public static void ProcessSolution(Solution originalSolution, string[] featureSe Directory.CreateDirectory(slnDir); } - var filename = Path.Combine(slnDir, Path.GetRandomFileName() + ".gen.sln"); - originalSolution.SaveAs(filename); + featureSetSpecificSolutions["Core"] = (originalSolution, false); + + foreach (var (key, (sln, _)) in featureSetSpecificSolutions) + { + sln.SaveAs(Path.Combine(slnDir, key + ".gen.sln")); + } + + return featureSetSpecificSolutions; } public struct FeatureSet { public string Name { get; } public bool RequiresDesktopMsBuild { get; } + public bool GenerateExclusiveSln { get; } public string[] Projects { get; } - public FeatureSet(string name, bool requiresDesktopMsBuild, params string[] projects) + public FeatureSet(string name, bool requiresDesktopMsBuild, bool generateExclusiveSln, params string[] projects) { Name = name; RequiresDesktopMsBuild = requiresDesktopMsBuild; + GenerateExclusiveSln = generateExclusiveSln; Projects = projects; } } diff --git a/global.json b/global.json index 6b78d4bca5..21f25390e7 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "5.0.201", + "version": "6.0.100-preview.7.21379.14", "rollForward": "major" } } diff --git a/src/Core/Silk.NET.SilkTouch/Extensions.cs b/src/Core/Silk.NET.SilkTouch/Extensions.cs new file mode 100644 index 0000000000..e5720a5cb0 --- /dev/null +++ b/src/Core/Silk.NET.SilkTouch/Extensions.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +namespace Silk.NET.SilkTouch +{ + internal static class Extensions + { + public static bool IsNet5OrGreater(this SyntaxTree syntaxTree) + => syntaxTree + .Options + .PreprocessorSymbolNames // newer SDKs (circa .NET 6) have _OR_GREATER + .Any(static x => x is "NET5_0" or "NET6_0" or "NET5_0_OR_GREATER"); + + public static string GetCallingConvention(this CallingConvention convention) + => convention switch + { + // CallingConvention.Winapi => "", netstandard2.0 doesn't allow this + CallingConvention.Cdecl => "Cdecl", + CallingConvention.ThisCall => "Thiscall", + CallingConvention.StdCall => "Stdcall", + CallingConvention.FastCall => "Fastcall", + _ => throw new ArgumentException("convention is invalid", nameof(convention)) + }; + + public static FunctionPointerTypeSyntax GetFuncPtrType + ( + this IEnumerable loadTypes, + CallingConvention? unmanagedCallingConvention + ) => loadTypes.Select + ( + static x => FunctionPointerParameter + (IdentifierName(x.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat))) + ) + .GetFuncPtrType(unmanagedCallingConvention); + + public static FunctionPointerTypeSyntax GetFuncPtrType + ( + this IEnumerable loadTypes, + CallingConvention? unmanagedCallingConvention + ) => loadTypes + .Select(FunctionPointerParameter) + .GetFuncPtrType(unmanagedCallingConvention); + + public static FunctionPointerTypeSyntax GetFuncPtrType + ( + this IEnumerable parameters, + CallingConvention? unmanagedCallingConvention + ) => FunctionPointerType + ( + unmanagedCallingConvention switch + { + CallingConvention.Winapi => FunctionPointerCallingConvention(Token(SyntaxKind.UnmanagedKeyword)), + { } => FunctionPointerCallingConvention + ( + Token(SyntaxKind.UnmanagedKeyword), + FunctionPointerUnmanagedCallingConventionList + ( + SingletonSeparatedList + ( + FunctionPointerUnmanagedCallingConvention + (Identifier(GetCallingConvention(unmanagedCallingConvention.Value))) + ) + ) + ), + _ => FunctionPointerCallingConvention(Token(SyntaxKind.ManagedKeyword)) + }, + FunctionPointerParameterList(SeparatedList(parameters)) + ); + } +} diff --git a/src/Core/Silk.NET.SilkTouch/INativeContextOverride.cs b/src/Core/Silk.NET.SilkTouch/INativeContextOverride.cs index 73e9383414..0878bd813b 100644 --- a/src/Core/Silk.NET.SilkTouch/INativeContextOverride.cs +++ b/src/Core/Silk.NET.SilkTouch/INativeContextOverride.cs @@ -3,12 +3,13 @@ using System; using System.Collections.Generic; +using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; namespace Silk.NET.SilkTouch { public interface INativeContextOverride { - TypeDeclarationSyntax Type(string name, string lib, EntryPoint[] entrypoints); + TypeDeclarationSyntax Type(OverrideContext ctx); } } diff --git a/src/Core/Silk.NET.SilkTouch/NameGenerator.cs b/src/Core/Silk.NET.SilkTouch/NameGenerator.cs index 7d11e13454..096f193fff 100644 --- a/src/Core/Silk.NET.SilkTouch/NameGenerator.cs +++ b/src/Core/Silk.NET.SilkTouch/NameGenerator.cs @@ -1,40 +1,52 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Text; +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Threading; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; namespace Silk.NET.SilkTouch { public static class NameGenerator { private static int _c = 1; - - private static char ToAlphabet(int i) - { - return (char) (i + 65); - } - + private static ConcurrentDictionary _names = new(); + private const int ColumnBase = 26; + private const int MaxLength = 7 + 1; // 7 characters can contain zero through int.MaxValue, +1 for underscore + private const string Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; private static string ToAlphabetString(int i) { - const int maxChar = 26; - var s = ""; + if (i <= ColumnBase) + { + Span theResult = stackalloc char[]{'_', Digits[i - 1]}; + return theResult.ToString(); + } + + Span result = stackalloc char[MaxLength]; + var offset = MaxLength; while (i > 0) { - var x = (i - 1) % maxChar; - s = ToAlphabet(x) + s; - i = (i - x) / 24; + result[--offset] = Digits[--i % ColumnBase]; + i /= ColumnBase; } + + // Make all identifiers start with _. Otherwise, eventually we will end up generating stuff like "GL" and + // "SDL" out of sheer luck for example, which could conflict. + result[--offset] = '_'; - return s; + return result.Slice(offset, MaxLength - offset).ToString(); } +#if DEBUG + public static string Name(string suggestion) => suggestion; +#else public static string Name(string suggestion) - { - // BUG the name shortener for some reason is causing duplicate member bugs. such as: - // GL.3491994.gen.cs(107452,35): Error CS0111 : Type 'GL.TXDY' already defines a member called 'VNWU' with - // the same parameter types - // return ToAlphabetString(_c++); - return suggestion; - } + => _names.GetOrAdd(suggestion, static _ => ToAlphabetString(Interlocked.Increment(ref _c))); +#endif + + public static IdentifierNameSyntax IdentifierSilk(string hint) => IdentifierName(Name(hint)); } } diff --git a/src/Core/Silk.NET.SilkTouch/NativeApiGenerator.cs b/src/Core/Silk.NET.SilkTouch/NativeApiGenerator.cs index 8e6b7ec3df..8f11839a60 100644 --- a/src/Core/Silk.NET.SilkTouch/NativeApiGenerator.cs +++ b/src/Core/Silk.NET.SilkTouch/NativeApiGenerator.cs @@ -16,6 +16,7 @@ using Silk.NET.Core.Native; using Silk.NET.SilkTouch.NativeContextOverrides; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; +using static Silk.NET.SilkTouch.NameGenerator; namespace Silk.NET.SilkTouch { @@ -324,7 +325,14 @@ where declaration.Item1.Modifiers.Any ); } - ProcessNativeContextOverrides(processedEntrypoints.ToArray(), ref newMembers, sharedClassSymbol, excludeFromOverrideAttribute); + ProcessNativeContextOverrides + ( + processedEntrypoints.ToArray(), + ref newMembers, + sharedClassSymbol, + excludeFromOverrideAttribute, + compilation + ); var newNamespace = namespaceDeclaration.WithMembers ( @@ -393,39 +401,6 @@ SyntaxList generationusings ) { const string invocationShimName = "StCall"; - static FunctionPointerTypeSyntax GetFuncPtrType - ( - CallingConvention callingConvention, - ITypeSymbol[] loadTypes - ) => FunctionPointerType - ( - callingConvention == CallingConvention.Winapi ? FunctionPointerCallingConvention - ( - Token(SyntaxKind.UnmanagedKeyword) - ) : FunctionPointerCallingConvention - ( - Token(SyntaxKind.UnmanagedKeyword), - FunctionPointerUnmanagedCallingConventionList - ( - SingletonSeparatedList - ( - FunctionPointerUnmanagedCallingConvention - (Identifier(GetCallingConvention(callingConvention))) - ) - ) - ), - FunctionPointerParameterList - ( - SeparatedList - ( - loadTypes.Select - ( - x => FunctionPointerParameter - (IdentifierName(x.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat))) - ) - ) - ) - ); static MemberAccessExpressionSyntax GetFuncPtrExpr ( @@ -441,7 +416,7 @@ string entryPoint SyntaxKind.AsExpression, IdentifierName("CurrentVTable"), IdentifierName(generatedVTableName) ) - ), IdentifierName(FirstLetterToUpper(entryPoint)) + ), IdentifierSilk(entryPoint) ); void BuildLoadInvoke(ref IMarshalContext ctx, Action next) @@ -471,14 +446,7 @@ void BuildLoadInvoke(ref IMarshalContext ctx, Action next) Func expression; - var defs = declaration.SyntaxTree.Options.PreprocessorSymbolNames; - - // ReSharper disable PossibleMultipleEnumeration - just not an issue - var hasFastWinapi = defs.Contains("NET5_0") || - defs.Contains("NET6_0") || - defs.Contains("NET5_0_OR_GREATER"); // newer SDKs (circa .NET 6) have _OR_GREATER - // ReSharper restore PossibleMultipleEnumeration - + var hasFastWinapi = declaration.SyntaxTree.IsNet5OrGreater(); var needsInvocationShim = callingConvention == CallingConvention.Winapi && !hasFastWinapi; if ((classIsSealed || generateSeal) && generateVTable) @@ -486,7 +454,7 @@ void BuildLoadInvoke(ref IMarshalContext ctx, Action next) // build load + invocation expression = ctx => { - var fPtrType = GetFuncPtrType(callingConvention, ctx.LoadTypes); + var fPtrType = ctx.LoadTypes.GetFuncPtrType(callingConvention); return InvocationExpression ( needsInvocationShim ? IdentifierName(invocationShimName) : ParenthesizedExpression @@ -619,7 +587,7 @@ CallingConvention callingConvention ( CastExpression ( - GetFuncPtrType(callingConvention, ctx.LoadTypes), + ctx.LoadTypes.GetFuncPtrType(callingConvention), GetFuncPtrExpr(generatedVTableName, entryPoint) ) ), @@ -713,17 +681,6 @@ StatementSyntax ManualWinapiInvokeShim(IMarshalContext ctx) } } - private static string GetCallingConvention(CallingConvention convention) - => convention switch - { - // CallingConvention.Winapi => "", netstandard2.0 doesn't allow this - CallingConvention.Cdecl => "Cdecl", - CallingConvention.ThisCall => "Thiscall", - CallingConvention.StdCall => "Stdcall", - CallingConvention.FastCall => "Fastcall", - _ => throw new ArgumentException("convention is invalid", nameof(convention)) - }; - private static NativeApiAttribute? ToNativeApiAttribute(AttributeData? attributeData) { if (attributeData is null) diff --git a/src/Core/Silk.NET.SilkTouch/NativeContextOverrideGeneration.cs b/src/Core/Silk.NET.SilkTouch/NativeContextOverrideGeneration.cs index 49568e3e11..16fa5d8659 100644 --- a/src/Core/Silk.NET.SilkTouch/NativeContextOverrideGeneration.cs +++ b/src/Core/Silk.NET.SilkTouch/NativeContextOverrideGeneration.cs @@ -24,7 +24,8 @@ private void ProcessNativeContextOverrides EntryPoint[] entrypoints, ref List members, ITypeSymbol classSymbol, - INamedTypeSymbol excludeFromOverrideAttribute + INamedTypeSymbol excludeFromOverrideAttribute, + Compilation comp ) { var overrides = FindNativeContextOverrides(classSymbol); @@ -50,8 +51,8 @@ INamedTypeSymbol excludeFromOverrideAttribute foreach (var (attSymbol, attId, lib, @override) in overrides.OrderBy(x => x.Item2)) { - var name = $"OVERRIDE_{attId}"; - members.Add(@override.Type(name, lib, entrypoints.Where(x => x.SourceSymbol.GetAttributes() + var name = NameGenerator.Name($"OVERRIDE_{attId}"); + members.Add(@override.Type(new(name, lib, entrypoints.Where(x => x.SourceSymbol.GetAttributes() .All(x2 => { if (!SymbolEqualityComparer.Default.Equals(x2.AttributeClass, excludeFromOverrideAttribute)) @@ -59,7 +60,7 @@ INamedTypeSymbol excludeFromOverrideAttribute var matchId = (int) x2.ConstructorArguments[0].Value!; return matchId != attId; - })).ToArray())); + })).ToArray(), comp.SyntaxTrees?.FirstOrDefault()?.IsNet5OrGreater() ?? false))); last = IfStatement ( BinaryExpression diff --git a/src/Core/Silk.NET.SilkTouch/NativeContextOverrides/PInvokeNativeContextOverride.cs b/src/Core/Silk.NET.SilkTouch/NativeContextOverrides/PInvokeNativeContextOverride.cs index 04781712e7..e83484ba2d 100644 --- a/src/Core/Silk.NET.SilkTouch/NativeContextOverrides/PInvokeNativeContextOverride.cs +++ b/src/Core/Silk.NET.SilkTouch/NativeContextOverrides/PInvokeNativeContextOverride.cs @@ -8,19 +8,20 @@ using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; +using static Silk.NET.SilkTouch.NameGenerator; namespace Silk.NET.SilkTouch.NativeContextOverrides { public sealed class PInvokeNativeContextOverride : INativeContextOverride { /// - public TypeDeclarationSyntax Type(string name, string lib, EntryPoint[] entrypoints) + public TypeDeclarationSyntax Type(OverrideContext ctx) { - static BlockSyntax GetSlotSwitch(EntryPoint[] entrypoints, List members) + var canUseCorrectCallConv = ctx.IsNet5OrGreater; + static BlockSyntax GetSlotSwitch(EntryPoint[] entrypoints, List members, bool canUseCorrectCallConv) { members.Add(NativeContextOverrideHelper.GetProcAddress); members.Add(NativeContextOverrideHelper.TryGetProcAddress); - return Block ( ReturnStatement @@ -41,16 +42,21 @@ static BlockSyntax GetSlotSwitch(EntryPoint[] entrypoints, List MethodDeclaration(entrypoint.LoadTypes.Last(), Identifier($"I_{entrypoint.Name}")) - .WithAttributeLists + MethodDeclarationSyntax GetMethodFromEntrypoint(EntryPoint entrypoint, bool callConvCorrection = false) + { + var ret = MethodDeclaration + ( + entrypoint.LoadTypes.Last(), + Identifier(Name(callConvCorrection ? $"S_{entrypoint.Name}" : $"I_{entrypoint.Name}")) + ) + .WithAttributeLists + ( + SingletonList ( - SingletonList + AttributeList ( - AttributeList + SingletonSeparatedList ( - SingletonSeparatedList - ( - Attribute + callConvCorrection + ? Attribute + ( + QualifiedName + ( + QualifiedName + ( + QualifiedName + (IdentifierName("System"), IdentifierName("Runtime")), + IdentifierName("InteropServices") + ), IdentifierName("UnmanagedCallersOnly") + ) + ) + .WithArgumentList + ( + AttributeArgumentList + ( + SeparatedList + ( + new SyntaxNodeOrToken[] + { + AttributeArgument + ( + ImplicitArrayCreationExpression + ( + InitializerExpression + ( + SyntaxKind.ArrayInitializerExpression, + SingletonSeparatedList + ( + TypeOfExpression + ( + QualifiedName + ( + QualifiedName + ( + QualifiedName + ( + IdentifierName + ("System"), + IdentifierName + ("Runtime") + ), + IdentifierName + ("CompilerServices") + ), + IdentifierName + ( + "CallConv" + + entrypoint.CallingConvention + .GetCallingConvention() + ) + ) + ) + ) + ) + ) + ) + .WithNameEquals(NameEquals(IdentifierName("CallConvs"))) + } + ) + ) + ) + : Attribute ( QualifiedName ( QualifiedName ( - QualifiedName(IdentifierName("System"), IdentifierName("Runtime")), + QualifiedName + (IdentifierName("System"), IdentifierName("Runtime")), IdentifierName("InteropServices") ), IdentifierName("DllImport") ) @@ -94,7 +169,10 @@ MethodDeclarationSyntax GetMethodFromEntrypoint(EntryPoint entrypoint) AttributeArgument ( LiteralExpression - (SyntaxKind.StringLiteralExpression, Literal(lib)) + ( + SyntaxKind.StringLiteralExpression, + Literal(ctx.Library) + ) ), Token(SyntaxKind.CommaToken), AttributeArgument @@ -105,7 +183,8 @@ MethodDeclarationSyntax GetMethodFromEntrypoint(EntryPoint entrypoint) Literal(entrypoint.Name) ) ) - .WithNameEquals(NameEquals(IdentifierName("EntryPoint"))), + .WithNameEquals + (NameEquals(IdentifierName("EntryPoint"))), Token(SyntaxKind.CommaToken), AttributeArgument ( @@ -135,35 +214,67 @@ MethodDeclarationSyntax GetMethodFromEntrypoint(EntryPoint entrypoint) ) ) ) - ) ) ) ) - .WithModifiers - ( - TokenList + ) + .WithModifiers + ( + callConvCorrection + ? TokenList(Token(SyntaxKind.PrivateKeyword), Token(SyntaxKind.StaticKeyword)) + : TokenList ( - Token(SyntaxKind.PrivateKeyword), Token(SyntaxKind.StaticKeyword), + Token(SyntaxKind.PrivateKeyword), + Token(SyntaxKind.StaticKeyword), Token(SyntaxKind.ExternKeyword) ) + ) + .WithParameterList + ( + ParameterList + ( + SeparatedList + ( + entrypoint.LoadTypes.Take + (entrypoint.LoadTypes.Length - 1) + .Select((x, i) => Parameter(default, default, x, Identifier($"p{i}"), default)) + ) ) - .WithParameterList + ); + + if (callConvCorrection) + { + ret = ret.WithExpressionBody ( - ParameterList + ArrowExpressionClause ( - SeparatedList + InvocationExpression ( - entrypoint.LoadTypes.Take - (entrypoint.LoadTypes.Length - 1) - .Select((x, i) => Parameter(default, default, x, Identifier($"p_{i}"), default)) + IdentifierSilk($"I_{entrypoint.Name}"), + ArgumentList + ( + SeparatedList + ( + entrypoint.LoadTypes.Take(entrypoint.LoadTypes.Length - 1) + .Select((_, i) => Argument(IdentifierName($"p{i}"))) + ) + ) ) ) - ) - .WithSemicolonToken(Token(SyntaxKind.SemicolonToken)); + ); + } + + return ret.WithSemicolonToken(Token(SyntaxKind.SemicolonToken)); + } - var v = entrypoints.Distinct(new NameComparer()).ToArray(); + var v = ctx.EntryPoints.Distinct(new NameComparer()).ToArray(); var members = new List(); - members.AddRange(v.Select(GetMethodFromEntrypoint)); + members.AddRange(v.Select(x => GetMethodFromEntrypoint(x))); + if (canUseCorrectCallConv) + { + members.AddRange(v.Select(x => GetMethodFromEntrypoint(x, true))); + } + members.Add ( MethodDeclaration(IdentifierName("IntPtr"), Identifier("CoreGetProcAddress")) @@ -197,7 +308,7 @@ MethodDeclarationSyntax GetMethodFromEntrypoint(EntryPoint entrypoint) ) ) ) - .WithBody(GetSlotSwitch(v, members)) + .WithBody(GetSlotSwitch(v, members, canUseCorrectCallConv)) ); members.Add ( @@ -206,7 +317,7 @@ MethodDeclarationSyntax GetMethodFromEntrypoint(EntryPoint entrypoint) .WithModifiers(TokenList(Token(SyntaxKind.PublicKeyword))) .WithBody(Block()) ); - return ClassDeclaration(name) + return ClassDeclaration(ctx.Name) .WithBaseList ( BaseList diff --git a/src/Core/Silk.NET.SilkTouch/OverrideContext.cs b/src/Core/Silk.NET.SilkTouch/OverrideContext.cs new file mode 100644 index 0000000000..b4169d8eb9 --- /dev/null +++ b/src/Core/Silk.NET.SilkTouch/OverrideContext.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Silk.NET.SilkTouch +{ + public readonly struct OverrideContext + { + public OverrideContext(string name, string lib, EntryPoint[] entrypoints, bool isNet5OrGreater) + => (Name, Library, EntryPoints, IsNet5OrGreater) = (name, lib, entrypoints, isNet5OrGreater); + public string Name { get; } + public string Library { get; } + public EntryPoint[] EntryPoints { get; } + public bool IsNet5OrGreater { get; } + } +} diff --git a/src/Core/Silk.NET.SilkTouch/VTableGeneration.cs b/src/Core/Silk.NET.SilkTouch/VTableGeneration.cs index 662e04be60..a64f517103 100644 --- a/src/Core/Silk.NET.SilkTouch/VTableGeneration.cs +++ b/src/Core/Silk.NET.SilkTouch/VTableGeneration.cs @@ -6,6 +6,7 @@ using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; +using static Silk.NET.SilkTouch.NameGenerator; namespace Silk.NET.SilkTouch { @@ -58,7 +59,7 @@ private TypeDeclarationSyntax GenerateVTable AssignmentExpression ( SyntaxKind.SimpleAssignmentExpression, - IdentifierName($"_{entryPoint}"), + IdentifierSilk($"_{entryPoint}"), InvocationExpression ( MemberAccessExpression @@ -90,7 +91,7 @@ private TypeDeclarationSyntax GenerateVTable vTableMembers.Add ( - ConstructorDeclaration("GeneratedVTable") + ConstructorDeclaration(Name("GeneratedVTable")) .WithModifiers(TokenList(Token(SyntaxKind.InternalKeyword))) .WithParameterList ( @@ -114,8 +115,7 @@ private TypeDeclarationSyntax GenerateVTable List slotVars = new List(); foreach (var entrypoint in entryPoints.Distinct()) { - var name = $"_{entrypoint}"; - slotVars.Add(VariableDeclarator(name)); + slotVars.Add(VariableDeclarator(Name($"_{entrypoint}"))); } vTableMembers.Add @@ -207,7 +207,7 @@ private TypeDeclarationSyntax GenerateVTable ( ConstantPattern (LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(s))), - IdentifierName(FirstLetterToUpper(s)) + IdentifierSilk(s) ) ) .Append @@ -248,8 +248,7 @@ private TypeDeclarationSyntax GenerateVTable ( entryPoints.Distinct().Select ( - s => PropertyDeclaration - (IdentifierName("nint"), FirstLetterToUpper(s)) + s => PropertyDeclaration(IdentifierName("nint"), Name(s)) .WithExpressionBody ( ArrowExpressionClause @@ -258,14 +257,14 @@ private TypeDeclarationSyntax GenerateVTable ( BinaryExpression ( - SyntaxKind.NotEqualsExpression, IdentifierName("_" + s), + SyntaxKind.NotEqualsExpression, IdentifierSilk("_" + s), DefaultExpression(IdentifierName("nint")) - ), IdentifierName("_" + s), + ), IdentifierSilk("_" + s), ParenthesizedExpression ( AssignmentExpression ( - SyntaxKind.SimpleAssignmentExpression, IdentifierName("_" + s), + SyntaxKind.SimpleAssignmentExpression, IdentifierSilk("_" + s), InvocationExpression ( IdentifierName("_ctx.GetProcAddress"), @@ -308,7 +307,7 @@ private TypeDeclarationSyntax GenerateVTable AssignmentExpression ( SyntaxKind.SimpleAssignmentExpression, - IdentifierName($"_{x}"), + IdentifierSilk($"_{x}"), DefaultExpression (IdentifierName("nint")) ) @@ -344,10 +343,5 @@ private TypeDeclarationSyntax GenerateVTable ), List(), List(vTableMembers) ); } - - private static string FirstLetterToUpper(string s) - { - return s.First().ToString().ToUpper() + s.Substring(1); - } } } diff --git a/src/Lab/Experiments/InputTest/Program.cs b/src/Lab/Experiments/InputTest/Program.cs index d62d151cec..836837e173 100644 --- a/src/Lab/Experiments/InputTest/Program.cs +++ b/src/Lab/Experiments/InputTest/Program.cs @@ -12,7 +12,14 @@ namespace InputTest { public class Program { - private static void Main() +#if !NET6_0 + // Exclude the entry point if we're running in .NET 6, as this file is + // compiled into the TriangleNET6 project too which has its own + // entrypoint. + private static void Main() => Run(); +#endif + + private static void Run() { //Window.PrioritizeSdl(); diff --git a/src/Lab/Experiments/Triangle/Program.cs b/src/Lab/Experiments/Triangle/Program.cs index 5ebf1bcd18..7146df2e56 100644 --- a/src/Lab/Experiments/Triangle/Program.cs +++ b/src/Lab/Experiments/Triangle/Program.cs @@ -29,7 +29,14 @@ public static class Program public static GraphicsAPI API { get; set; } = GraphicsAPI.Default; - public static void Main(string[] args) +#if !NET6_0 + // Exclude the entry point if we're running in .NET 6, as this file is + // compiled into the TriangleNET6 project too which has its own + // entrypoint. + public static void Main() => Run(); +#endif + + public static void Run() { //Silk.NET.Windowing.Sdl.SdlWindowing.Use(); //SdlProvider.SetMainReady = true; @@ -96,7 +103,11 @@ private static unsafe void Load() (GLEnum.ArrayBuffer, (nuint)( _vertices.Length * sizeof(float)), vertices, GLEnum.StaticDraw); } +#if NET6_0 + _shader = new Shader("TriangleNET6.shader.vert", "TriangleNET6.shader.frag", _gl, typeof(Program)); +#else _shader = new Shader("Triangle.shader.vert", "Triangle.shader.frag", _gl, typeof(Program)); +#endif _shader.Use(); _vertexArrayObject = _gl.GenVertexArray(); _gl.BindVertexArray(_vertexArrayObject); diff --git a/src/Lab/Experiments/TriangleDroid/MainActivity.cs b/src/Lab/Experiments/TriangleDroid/MainActivity.cs index 854c6243a5..f4aaba0108 100644 --- a/src/Lab/Experiments/TriangleDroid/MainActivity.cs +++ b/src/Lab/Experiments/TriangleDroid/MainActivity.cs @@ -1,3 +1,4 @@ +#if __ANDROID__ using Android.App; using Android.Content.PM; using Silk.NET.Windowing; @@ -8,8 +9,11 @@ namespace TriangleDroid { [Activity ( - Label = "@string/app_name", Theme = "@style/AppTheme", MainLauncher = true, - ConfigurationChanges = ConfigChangesFlags + Label = "@string/app_name", + MainLauncher = true, + ConfigurationChanges = ConfigChangesFlags, + ScreenOrientation = ScreenOrientation.Landscape, + Theme = "@android:style/Theme.Black.NoTitleBar.Fullscreen" )] public class MainActivity : SilkActivity { @@ -17,7 +21,8 @@ protected override void OnRun() { Program.API = new GraphicsAPI (ContextAPI.OpenGLES, ContextProfile.Compatability, ContextFlags.Default, new APIVersion(3, 0)); - Program.Main(null!); + Program.Run(); } } } +#endif diff --git a/src/Lab/Experiments/TriangleDroid/Properties/AndroidManifest.xml b/src/Lab/Experiments/TriangleDroid/Properties/AndroidManifest.xml index fc347b9ad5..720aefe59b 100644 --- a/src/Lab/Experiments/TriangleDroid/Properties/AndroidManifest.xml +++ b/src/Lab/Experiments/TriangleDroid/Properties/AndroidManifest.xml @@ -2,7 +2,8 @@ + package="com.companyname.triangledroid" + android:theme="@android:style/Theme.NoTitleBar"> + + + + + diff --git a/src/Lab/Experiments/TriangleNET6/Program.cs b/src/Lab/Experiments/TriangleNET6/Program.cs new file mode 100644 index 0000000000..2c97fbb3ea --- /dev/null +++ b/src/Lab/Experiments/TriangleNET6/Program.cs @@ -0,0 +1,3 @@ +#if !__IOS__ && !__ANDROID__ +Triangle.Program.Run(); +#endif diff --git a/src/Lab/Experiments/TriangleNET6/Resources/AboutResources.txt b/src/Lab/Experiments/TriangleNET6/Resources/AboutResources.txt new file mode 100644 index 0000000000..219f42544b --- /dev/null +++ b/src/Lab/Experiments/TriangleNET6/Resources/AboutResources.txt @@ -0,0 +1,44 @@ +Images, layout descriptions, binary blobs and string dictionaries can be included +in your application as resource files. Various Android APIs are designed to +operate on the resource IDs instead of dealing with images, strings or binary blobs +directly. + +For example, a sample Android app that contains a user interface layout (main.xml), +an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) +would keep its resources in the "Resources" directory of the application: + +Resources/ + drawable/ + icon.png + + layout/ + main.xml + + values/ + strings.xml + +In order to get the build system to recognize Android resources, set the build action to +"AndroidResource". The native Android APIs do not operate directly with filenames, but +instead operate on resource IDs. When you compile an Android application that uses resources, +the build system will package the resources for distribution and generate a class called "Resource" +(this is an Android convention) that contains the tokens for each one of the resources +included. For example, for the above Resources layout, this is what the Resource class would expose: + +public class Resource { + public class Drawable { + public const int icon = 0x123; + } + + public class Layout { + public const int main = 0x456; + } + + public class Strings { + public const int first_string = 0xabc; + public const int second_string = 0xbcd; + } +} + +You would then use Resource.Drawable.icon to reference the drawable/icon.png file, or +Resource.Layout.main to reference the layout/main.xml file, or Resource.Strings.first_string +to reference the first string in the dictionary file values/strings.xml. \ No newline at end of file diff --git a/src/Lab/Experiments/TriangleNET6/Resources/layout/activity_main.xml b/src/Lab/Experiments/TriangleNET6/Resources/layout/activity_main.xml new file mode 100644 index 0000000000..f94985291b --- /dev/null +++ b/src/Lab/Experiments/TriangleNET6/Resources/layout/activity_main.xml @@ -0,0 +1,13 @@ + + + + \ No newline at end of file diff --git a/src/Lab/Experiments/TriangleNET6/Resources/mipmap-anydpi-v26/ic_launcher.xml b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000000..036d09bc5f --- /dev/null +++ b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/Lab/Experiments/TriangleNET6/Resources/mipmap-anydpi-v26/ic_launcher_round.xml b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000000..036d09bc5f --- /dev/null +++ b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/Lab/Experiments/TriangleNET6/Resources/mipmap-hdpi/ic_launcher.png b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000..2531cb31ef Binary files /dev/null and b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-hdpi/ic_launcher.png differ diff --git a/src/Lab/Experiments/TriangleNET6/Resources/mipmap-hdpi/ic_launcher_foreground.png b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000000..7a859c2555 Binary files /dev/null and b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/src/Lab/Experiments/TriangleNET6/Resources/mipmap-hdpi/ic_launcher_round.png b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000000..b8d35b3a1c Binary files /dev/null and b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-hdpi/ic_launcher_round.png differ diff --git a/src/Lab/Experiments/TriangleNET6/Resources/mipmap-mdpi/ic_launcher.png b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000..795ea7c005 Binary files /dev/null and b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-mdpi/ic_launcher.png differ diff --git a/src/Lab/Experiments/TriangleNET6/Resources/mipmap-mdpi/ic_launcher_foreground.png b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000000..a12b157f00 Binary files /dev/null and b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/src/Lab/Experiments/TriangleNET6/Resources/mipmap-mdpi/ic_launcher_round.png b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000000..8f56909cdd Binary files /dev/null and b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-mdpi/ic_launcher_round.png differ diff --git a/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xhdpi/ic_launcher.png b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000000..761cc91d90 Binary files /dev/null and b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xhdpi/ic_launcher.png differ diff --git a/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xhdpi/ic_launcher_foreground.png b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000000..e7d70a5e2d Binary files /dev/null and b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xhdpi/ic_launcher_round.png b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000000..9737d79c04 Binary files /dev/null and b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xxhdpi/ic_launcher.png b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000..9133e31b43 Binary files /dev/null and b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xxhdpi/ic_launcher.png differ diff --git a/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xxhdpi/ic_launcher_foreground.png b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000000..73ccaa6a2b Binary files /dev/null and b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xxhdpi/ic_launcher_round.png b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000000..c3ae5f5ccd Binary files /dev/null and b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xxxhdpi/ic_launcher.png b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000..d4fd714eed Binary files /dev/null and b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000000..f6584afd4d Binary files /dev/null and b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xxxhdpi/ic_launcher_round.png b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000000..ef89bd5215 Binary files /dev/null and b/src/Lab/Experiments/TriangleNET6/Resources/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/src/Lab/Experiments/TriangleNET6/Resources/values/ic_launcher_background.xml b/src/Lab/Experiments/TriangleNET6/Resources/values/ic_launcher_background.xml new file mode 100644 index 0000000000..6ec24e6413 --- /dev/null +++ b/src/Lab/Experiments/TriangleNET6/Resources/values/ic_launcher_background.xml @@ -0,0 +1,4 @@ + + + #2C3E50 + \ No newline at end of file diff --git a/src/Lab/Experiments/TriangleNET6/Resources/values/strings.xml b/src/Lab/Experiments/TriangleNET6/Resources/values/strings.xml new file mode 100644 index 0000000000..59a3f7289a --- /dev/null +++ b/src/Lab/Experiments/TriangleNET6/Resources/values/strings.xml @@ -0,0 +1,4 @@ + + Silk.NET Triangle + Hello, Android! + diff --git a/src/Lab/Experiments/TriangleNET6/TriangleNET6.csproj b/src/Lab/Experiments/TriangleNET6/TriangleNET6.csproj new file mode 100644 index 0000000000..4823747477 --- /dev/null +++ b/src/Lab/Experiments/TriangleNET6/TriangleNET6.csproj @@ -0,0 +1,28 @@ + + + + Exe + net6.0;net6.0-android + true + preview + $(NETCoreSdkRuntimeIdentifier) + android-arm64;android-x86;android-arm;android-x64 + + + + + + + + + + + + + + + + + + + diff --git a/src/Windowing/Android/Silk.NET.Windowing.Sdl.Android/Additions/SilkActivity.cs b/src/Windowing/Android/Silk.NET.Windowing.Sdl.Android/Additions/SilkActivity.cs index 34a3be3201..26c735290a 100644 --- a/src/Windowing/Android/Silk.NET.Windowing.Sdl.Android/Additions/SilkActivity.cs +++ b/src/Windowing/Android/Silk.NET.Windowing.Sdl.Android/Additions/SilkActivity.cs @@ -2,9 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Android.App; using Android.Content.PM; +using Android.Provider; using Org.Libsdl.App; using Silk.NET.Core.Loader; using Silk.NET.Core.Native; @@ -47,7 +49,7 @@ internal static unsafe void Main() public override unsafe void LoadLibraries() { base.LoadLibraries(); - if (!(Instance is null)) + if (Instance is not null) { throw new InvalidOperationException("Only one SilkActivity may be present throughout the whole application."); } @@ -56,6 +58,11 @@ public override unsafe void LoadLibraries() SetupMain(SilkMarshal.DelegateToPtr(CurrentMain)); } + public override void SetOrientationBis(int w, int h, bool resizable, string hint) + { + // do nothing, Silk.NET respects the OS and doesn't want to do any meddling the consumer can't control. + } + protected abstract void OnRun(); private void Run() diff --git a/src/Windowing/Android/Silk.NET.Windowing.Sdl.Android/Silk.NET.Windowing.Sdl.Android.targets b/src/Windowing/Android/Silk.NET.Windowing.Sdl.Android/Silk.NET.Windowing.Sdl.Android.targets index d632d2d7e9..2525d3e898 100644 --- a/src/Windowing/Android/Silk.NET.Windowing.Sdl.Android/Silk.NET.Windowing.Sdl.Android.targets +++ b/src/Windowing/Android/Silk.NET.Windowing.Sdl.Android/Silk.NET.Windowing.Sdl.Android.targets @@ -1,6 +1,10 @@ - + - + + diff --git a/src/Windowing/Silk.NET.Windowing.Sdl/SdlView.cs b/src/Windowing/Silk.NET.Windowing.Sdl/SdlView.cs index c1f7cface0..d1b22d3ba6 100644 --- a/src/Windowing/Silk.NET.Windowing.Sdl/SdlView.cs +++ b/src/Windowing/Silk.NET.Windowing.Sdl/SdlView.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Reflection; @@ -11,7 +10,9 @@ using Silk.NET.Maths; using Silk.NET.SDL; using Silk.NET.Windowing.Internals; -using Point = System.Drawing.Point; + +// We can't import System because System has a type called nint on iOS and Mac Catalyst. +// As such, throughout this file System is fully qualified. // ReSharper disable BitwiseOperatorOnEnumWithoutFlags @@ -47,10 +48,10 @@ public SdlView(void* nativeHandle, IGLContext? ctx, SdlPlatform platform) : base } // Events - public override event Action>? Resize; - public override event Action>? FramebufferResize; - public override event Action? Closing; - public override event Action? FocusChanged; + public override event System.Action>? Resize; + public override event System.Action>? FramebufferResize; + public override event System.Action? Closing; + public override event System.Action? FocusChanged; // Properties protected override IGLContext? CoreGLContext => API.API == ContextAPI.OpenGL || API.API == ContextAPI.OpenGLES @@ -113,10 +114,13 @@ protected void CoreInitialize { var flags = WindowFlags.WindowAllowHighdpi | WindowFlags.WindowShown; - if (additionalFlags is null) { - flags |= WindowFlags.WindowResizable; + flags |= _platform.IsViewOnly switch + { + true => WindowFlags.WindowBorderless | WindowFlags.WindowFullscreen, + false => WindowFlags.WindowResizable + }; } else { @@ -173,7 +177,7 @@ protected void CoreInitialize { ContextProfile.Core => GLprofile.GLContextProfileCore, ContextProfile.Compatability => GLprofile.GLContextProfileCompatibility, - _ => throw new ArgumentOutOfRangeException(nameof(opts), "Bad ContextProfile") + _ => throw new System.ArgumentOutOfRangeException(nameof(opts), "Bad ContextProfile") }) ), (GLattr.GLContextFlags, (int) opts.API.Flags), diff --git a/src/Windowing/Silk.NET.Windowing.Sdl/SdlVkSurface.cs b/src/Windowing/Silk.NET.Windowing.Sdl/SdlVkSurface.cs index 464f42137b..33c7127338 100644 --- a/src/Windowing/Silk.NET.Windowing.Sdl/SdlVkSurface.cs +++ b/src/Windowing/Silk.NET.Windowing.Sdl/SdlVkSurface.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Runtime.InteropServices; using Silk.NET.Core; using Silk.NET.Core.Contexts; diff --git a/src/Windowing/Silk.NET.Windowing.Sdl/Silk.NET.Windowing.Sdl.csproj b/src/Windowing/Silk.NET.Windowing.Sdl/Silk.NET.Windowing.Sdl.csproj index 62f3a4b4fb..60c916efbb 100644 --- a/src/Windowing/Silk.NET.Windowing.Sdl/Silk.NET.Windowing.Sdl.csproj +++ b/src/Windowing/Silk.NET.Windowing.Sdl/Silk.NET.Windowing.Sdl.csproj @@ -1,10 +1,11 @@ - + - netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0 + netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0;net6.0-android;net6.0-ios;net6.0-maccatalyst 8 true enable + true @@ -20,6 +21,47 @@ + + + + + + + + + + + + + + + + + + + $(TargetsForTfmSpecificContentInPackage);_SdlTfmSpecific + + + + + + + + + + + + + + + + + diff --git a/src/Windowing/Silk.NET.Windowing/Silk.NET.Windowing.csproj b/src/Windowing/Silk.NET.Windowing/Silk.NET.Windowing.csproj index 93ea17b96c..7586402520 100644 --- a/src/Windowing/Silk.NET.Windowing/Silk.NET.Windowing.csproj +++ b/src/Windowing/Silk.NET.Windowing/Silk.NET.Windowing.csproj @@ -1,16 +1,27 @@ - netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0 + netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0;net6.0-android;net6.0-ios;net6.0-maccatalyst false + + + + + + + + + + + diff --git a/src/Windowing/iOS/Silk.NET.Windowing.Sdl.iOS/Silk.NET.Windowing.Sdl.iOS.csproj b/src/Windowing/iOS/Silk.NET.Windowing.Sdl.iOS/Silk.NET.Windowing.Sdl.iOS.csproj index dbd22080f7..46798c7feb 100644 --- a/src/Windowing/iOS/Silk.NET.Windowing.Sdl.iOS/Silk.NET.Windowing.Sdl.iOS.csproj +++ b/src/Windowing/iOS/Silk.NET.Windowing.Sdl.iOS/Silk.NET.Windowing.Sdl.iOS.csproj @@ -1,4 +1,4 @@ - + xamarinios10 Library diff --git a/src/Windowing/iOS/Silk.NET.Windowing.Sdl.iOS/Class1.cs b/src/Windowing/iOS/Silk.NET.Windowing.Sdl.iOS/SilkMobile.cs similarity index 100% rename from src/Windowing/iOS/Silk.NET.Windowing.Sdl.iOS/Class1.cs rename to src/Windowing/iOS/Silk.NET.Windowing.Sdl.iOS/SilkMobile.cs