feat: backporting existing raylib-cs examples and new official raylib examples to WASM, adopting raylib's original code style
This commit is contained in:
parent
6aa91e3097
commit
f804ab7773
234 changed files with 38997 additions and 10578 deletions
|
|
@ -3,20 +3,54 @@
|
|||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<StartupObject>Examples.Program</StartupObject>
|
||||
<StartupObject Condition="'$(RuntimeIdentifier)' != 'browser-wasm'">Examples.Program</StartupObject>
|
||||
<StartupObject Condition="'$(RuntimeIdentifier)' == 'browser-wasm'">Examples.Web.Host</StartupObject>
|
||||
<RunWorkingDirectory>$(MSBuildThisFileDirectory)</RunWorkingDirectory>
|
||||
<LangVersion>12</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'browser-wasm'">
|
||||
<SelfContained>true</SelfContained>
|
||||
<WasmMainJSPath>Web/main.js</WasmMainJSPath>
|
||||
<Nullable>disable</Nullable>
|
||||
<!-- [JSExport] is browser-only by design; these files only compile for browser-wasm. -->
|
||||
<NoWarn>$(NoWarn);CA1416</NoWarn>
|
||||
<DefineConstants>$(DefineConstants);BROWSER</DefineConstants>
|
||||
|
||||
<!-- Link the native raylib.a (shipped by the Raylib-cs package) into the wasm module. -->
|
||||
<WasmBuildNative>true</WasmBuildNative>
|
||||
<WasmAllowUndefinedSymbols>true</WasmAllowUndefinedSymbols>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
<EmccFlags>$(EmccFlags) -sALLOW_MEMORY_GROWTH=1 -sINITIAL_MEMORY=64MB</EmccFlags>
|
||||
|
||||
<!-- Avoid wasm-opt on SDK/workload combinations where Binaryen rejects bulk-memory-opt. -->
|
||||
<EmccLinkOptimizationFlag Condition="'$(EmccLinkOptimizationFlag)' == ''">-O0</EmccLinkOptimizationFlag>
|
||||
<EmccCompileOptimizationFlag Condition="'$(EmccCompileOptimizationFlag)' == ''">-O0</EmccCompileOptimizationFlag>
|
||||
<WasmNativeStrip Condition="'$(WasmNativeStrip)' == ''">false</WasmNativeStrip>
|
||||
<WasmEmitSymbolMap Condition="'$(WasmEmitSymbolMap)' == ''">false</WasmEmitSymbolMap>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Core/LoadingThread.cs"/>
|
||||
<Compile Remove="Text/Unicode.cs"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(RuntimeIdentifier)' != 'browser-wasm'">
|
||||
<Compile Remove="Web/**/*.cs"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(RuntimeIdentifier)' == 'browser-wasm'">
|
||||
<Compile Remove="Program.cs"/>
|
||||
<!-- Examples are discovered via reflection (ExampleRegistry);
|
||||
therefore they must be excluded from trimming. -->
|
||||
<TrimmerRootAssembly Include="Examples"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="Raylib_cs"/>
|
||||
<Using Include="Raylib_cs.Raylib" Static="true"/>
|
||||
<Using Include="System.Numerics"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(UseRaylibCsPackage)' != 'true'">
|
||||
|
|
@ -27,8 +61,15 @@
|
|||
so the native raylib library is downloaded and copied to the output. -->
|
||||
<Import Project="..\Raylib-cs\Raylib-cs.targets" Condition="'$(UseRaylibCsPackage)' != 'true'"/>
|
||||
|
||||
<ItemGroup Condition="'$(UseRaylibCsPackage)' == 'true'">
|
||||
<PackageReference Include="Raylib-cs" Version="$(RaylibCsVersion)"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(RuntimeIdentifier)' == 'browser-wasm'">
|
||||
<WasmExtraFilesToDeploy Include="Web/index.html" TargetPath="index.html"/>
|
||||
<WasmExtraFilesToDeploy Include="Web/main.js" TargetPath="main.js"/>
|
||||
<WasmExtraFilesToDeploy Include="Web/scaleUtils.js" TargetPath="scaleUtils.js"/>
|
||||
<WasmExtraFilesToDeploy Include="..\Raylib-cs\logo\raylib-cs.ico" TargetPath="favicon.ico"/>
|
||||
|
||||
<!-- Bundle the example assets into the wasm virtual filesystem at /resources/...
|
||||
so examples load from "resources/..." work unchanged. -->
|
||||
<WasmFilesToIncludeInFileSystem Include="resources\**\*.*"
|
||||
TargetPath="resources\%(RecursiveDir)%(Filename)%(Extension)"/>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
|||
Loading…
Reference in a new issue