Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 29 additions & 14 deletions DuckGame/DuckGame.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>lib\MonoMod.exe</HintPath>
</Reference>
<Reference Include="netstandard">
<HintPath>..\packages\Microsoft.NETFramework.ReferenceAssemblies.net48.1.0.3\build\.NETFramework\v4.8\Facades\netstandard.dll</HintPath>
</Reference>
<Reference Include="NAudio">
<HintPath>lib\NAudio.dll</HintPath>
</Reference>
Expand All @@ -244,8 +247,12 @@
<Reference Include="NVorbis.NAudioSupport">
<HintPath>lib\NVorbis.NAudioSupport.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="PresentationCore">
<HintPath>..\packages\Microsoft.NETFramework.ReferenceAssemblies.net48.1.0.3\build\.NETFramework\v4.8\PresentationCore.dll</HintPath>
</Reference>
<Reference Include="PresentationFramework">
<HintPath>..\packages\Microsoft.NETFramework.ReferenceAssemblies.net48.1.0.3\build\.NETFramework\v4.8\PresentationFramework.dll</HintPath>
</Reference>
<Reference Include="SixLabors.Fonts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d998eea7b14cab13, processorArchitecture=MSIL">
<HintPath>..\packages\SixLabors.Fonts.1.0.1\lib\netstandard2.0\SixLabors.Fonts.dll</HintPath>
</Reference>
Expand All @@ -256,6 +263,10 @@
<HintPath>..\packages\SixLabors.ImageSharp.Drawing.1.0.0\lib\net472\SixLabors.ImageSharp.Drawing.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Collections.Immutable, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Collections.Immutable.7.0.0\lib\net462\System.Collections.Immutable.dll</HintPath>
</Reference>
Expand All @@ -268,7 +279,7 @@
<!-- </Reference>-->
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\deps\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http" />
<Reference Include="System.Numerics" />
Expand All @@ -277,9 +288,11 @@
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\deps\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Speech">
<HintPath>..\packages\Microsoft.NETFramework.ReferenceAssemblies.net48.1.0.3\build\.NETFramework\v4.8\System.Speech.dll</HintPath>
</Reference>
<Reference Include="System.Speech" />
<Reference Include="System.Text.Encoding.CodePages, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encoding.CodePages.7.0.0\lib\net462\System.Text.Encoding.CodePages.dll</HintPath>
</Reference>
Expand All @@ -290,7 +303,9 @@
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="WindowsBase" />
<Reference Include="WindowsBase">
<HintPath>..\packages\Microsoft.NETFramework.ReferenceAssemblies.net48.1.0.3\build\.NETFramework\v4.8\WindowsBase.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AddedContent\Biverom\Tape\Guns\Propaganda.cs" />
Expand Down Expand Up @@ -2489,18 +2504,18 @@
<Exec Command="echo $(SolutionDir) &gt; $(ProjectDir)SlnPath.txt" />
</Target>
<Target Name="AfterBuild">
<Exec Command="cp -rv $(SolutionDir)deps/* $(SolutionDir)bin/" Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))'" />
<Exec Command="cp -r &quot;$(SolutionDir)deps/&quot;* &quot;$(SolutionDir)bin/&quot;" Condition="'$(OS)' != 'Windows_NT'" />
<!-- <Exec Command="sh $(SolutionDir)shaders_source/buildshaders.sh" Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))'" />-->
<Exec Command="Xcopy &quot;$(SolutionDir)\deps&quot; &quot;$(SolutionDir)\bin&quot; /E /H /C /I /Y" Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))'" />
<Exec Command="call &quot;$(SolutionDir)shaders_source\buildshaders.bat&quot;" Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))'" />
<Exec Command="Xcopy &quot;$(SolutionDir)\deps&quot; &quot;$(SolutionDir)\bin&quot; /E /H /C /I /Y" Condition="'$(OS)' == 'Windows_NT'" />
<Exec Command="call &quot;$(SolutionDir)shaders_source\buildshaders.bat&quot;" Condition="'$(OS)' == 'Windows_NT'" />
</Target>
<Import Project="..\packages\Microsoft.NETFramework.ReferenceAssemblies.net48.1.0.3\build\Microsoft.NETFramework.ReferenceAssemblies.net48.targets" Condition="Exists('..\packages\Microsoft.NETFramework.ReferenceAssemblies.net48.1.0.3\build\Microsoft.NETFramework.ReferenceAssemblies.net48.targets')" />
<Import Project="..\packages\Microsoft.NETFramework.ReferenceAssemblies.net48.1.0.3\build\Microsoft.NETFramework.ReferenceAssemblies.net48.targets" Condition="'$(OS)' == 'Windows_NT' and Exists('..\packages\Microsoft.NETFramework.ReferenceAssemblies.net48.1.0.3\build\Microsoft.NETFramework.ReferenceAssemblies.net48.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.NETFramework.ReferenceAssemblies.net48.1.0.3\build\Microsoft.NETFramework.ReferenceAssemblies.net48.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NETFramework.ReferenceAssemblies.net48.1.0.3\build\Microsoft.NETFramework.ReferenceAssemblies.net48.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.VisualStudio.Setup.Configuration.Interop.3.8.2112\build\Microsoft.VisualStudio.Setup.Configuration.Interop.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.VisualStudio.Setup.Configuration.Interop.3.8.2112\build\Microsoft.VisualStudio.Setup.Configuration.Interop.targets'))" />
<Error Condition="'$(OS)' == 'Windows_NT' and !Exists('..\packages\Microsoft.NETFramework.ReferenceAssemblies.net48.1.0.3\build\Microsoft.NETFramework.ReferenceAssemblies.net48.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NETFramework.ReferenceAssemblies.net48.1.0.3\build\Microsoft.NETFramework.ReferenceAssemblies.net48.targets'))" />
<Error Condition="'$(OS)' == 'Windows_NT' and !Exists('..\packages\Microsoft.VisualStudio.Setup.Configuration.Interop.3.8.2112\build\Microsoft.VisualStudio.Setup.Configuration.Interop.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.VisualStudio.Setup.Configuration.Interop.3.8.2112\build\Microsoft.VisualStudio.Setup.Configuration.Interop.targets'))" />
</Target>
<Import Project="..\packages\Microsoft.VisualStudio.Setup.Configuration.Interop.3.8.2112\build\Microsoft.VisualStudio.Setup.Configuration.Interop.targets" Condition="Exists('..\packages\Microsoft.VisualStudio.Setup.Configuration.Interop.3.8.2112\build\Microsoft.VisualStudio.Setup.Configuration.Interop.targets')" />
</Project>
<Import Project="..\packages\Microsoft.VisualStudio.Setup.Configuration.Interop.3.8.2112\build\Microsoft.VisualStudio.Setup.Configuration.Interop.targets" Condition="'$(OS)' == 'Windows_NT' and Exists('..\packages\Microsoft.VisualStudio.Setup.Configuration.Interop.3.8.2112\build\Microsoft.VisualStudio.Setup.Configuration.Interop.targets')" />
</Project>
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,13 @@ Note: your IDE will scream at you with 200+ warnings when building, which is nor
* `msbuild -m -p:Configuration=Debug`
* Run the game (will crash unless Steam is currently running)
* `mono ./bin/DuckGame.exe`

### Building on macOS (Mono)

* Install build dependencies with Homebrew
* `brew install mono mono-libgdiplus nuget cmake sdl2`
* Build the game and native macOS libraries
* `./scripts/build-macos.sh Release`
* Run the game from the build output
* `./bin/DuckGame.sh -nosteam`
* Omit `-nosteam` when Steam is running and `steam_api` is available
104 changes: 104 additions & 0 deletions scripts/build-macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
CONFIGURATION="${1:-Debug}"
CPU_COUNT="$(sysctl -n hw.ncpu)"
CMAKE_POLICY_VERSION_MINIMUM="${CMAKE_POLICY_VERSION_MINIMUM:-3.5}"

require_command() {
if ! command -v "$1" >/dev/null 2>&1; then
echo "Missing required command: $1" >&2
exit 1
fi
}

copy_sdl2_dylib() {
local sdl2_dylib=""
local brew_prefix=""

if command -v brew >/dev/null 2>&1; then
brew_prefix="$(brew --prefix sdl2 2>/dev/null || true)"
if [[ -n "$brew_prefix" && -f "$brew_prefix/lib/libSDL2-2.0.0.dylib" ]]; then
sdl2_dylib="$brew_prefix/lib/libSDL2-2.0.0.dylib"
fi
fi

if [[ -z "$sdl2_dylib" && -f "/opt/homebrew/lib/libSDL2-2.0.0.dylib" ]]; then
sdl2_dylib="/opt/homebrew/lib/libSDL2-2.0.0.dylib"
fi

if [[ -z "$sdl2_dylib" && -f "/usr/local/lib/libSDL2-2.0.0.dylib" ]]; then
sdl2_dylib="/usr/local/lib/libSDL2-2.0.0.dylib"
fi

if [[ -z "$sdl2_dylib" ]]; then
echo "Could not find libSDL2-2.0.0.dylib. Install sdl2 first (brew install sdl2)." >&2
exit 1
fi

cp -f "$sdl2_dylib" "$ROOT_DIR/bin/libSDL2-2.0.0.dylib"
}

copy_libgdiplus_dylib() {
local gdiplus_dylib=""
local brew_prefix=""

if command -v brew >/dev/null 2>&1; then
brew_prefix="$(brew --prefix mono-libgdiplus 2>/dev/null || true)"
if [[ -n "$brew_prefix" && -f "$brew_prefix/lib/libgdiplus.dylib" ]]; then
gdiplus_dylib="$brew_prefix/lib/libgdiplus.dylib"
fi
fi

if [[ -z "$gdiplus_dylib" && -f "/opt/homebrew/lib/libgdiplus.dylib" ]]; then
gdiplus_dylib="/opt/homebrew/lib/libgdiplus.dylib"
fi

if [[ -z "$gdiplus_dylib" && -f "/usr/local/lib/libgdiplus.dylib" ]]; then
gdiplus_dylib="/usr/local/lib/libgdiplus.dylib"
fi

if [[ -z "$gdiplus_dylib" ]]; then
echo "Could not find libgdiplus.dylib. Install mono-libgdiplus (brew install mono-libgdiplus)." >&2
exit 1
fi

cp -f "$gdiplus_dylib" "$ROOT_DIR/bin/libgdiplus.dylib"
}

require_command nuget
require_command xbuild
require_command cmake
require_command make
require_command mono

echo "[1/4] Restoring NuGet packages"
nuget restore "$ROOT_DIR/DuckGame.sln"

echo "[2/4] Building native macOS libraries"
cmake -S "$ROOT_DIR/FNA/lib/FAudio" -B "$ROOT_DIR/FNA/lib/FAudio/build" -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM="$CMAKE_POLICY_VERSION_MINIMUM"
cmake --build "$ROOT_DIR/FNA/lib/FAudio/build" --config Release --parallel "$CPU_COUNT"

cmake -S "$ROOT_DIR/FNA/lib/FNA3D" -B "$ROOT_DIR/FNA/lib/FNA3D/build" -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM="$CMAKE_POLICY_VERSION_MINIMUM"
cmake --build "$ROOT_DIR/FNA/lib/FNA3D/build" --config Release --parallel "$CPU_COUNT"

make -C "$ROOT_DIR/FNA/lib/Theorafile"

echo "[3/4] Building DuckGame ($CONFIGURATION) with Mono"
xbuild \
/p:Configuration="$CONFIGURATION" \
/p:SolutionDir="$ROOT_DIR/" \
"$ROOT_DIR/DuckGame/DuckGame.csproj"

echo "[4/4] Copying runtime macOS libraries"
mkdir -p "$ROOT_DIR/bin"
cp -f "$ROOT_DIR/FNA/lib/FAudio/build/libFAudio.0.dylib" "$ROOT_DIR/bin/"
cp -f "$ROOT_DIR/FNA/lib/FNA3D/build/libFNA3D.0.dylib" "$ROOT_DIR/bin/"
cp -f "$ROOT_DIR/FNA/lib/Theorafile/libtheorafile.dylib" "$ROOT_DIR/bin/"
copy_sdl2_dylib
copy_libgdiplus_dylib
cp -f "$ROOT_DIR/deps/steam_api.bundle/Contents/MacOS/libsteam_api.dylib" "$ROOT_DIR/bin/libsteam_api.dylib"

echo "Build complete."
echo "Run with: cd \"$ROOT_DIR/bin\" && ./DuckGame.sh"