Skip to content

Commit

Permalink
Build MacOS x86_64 app
Browse files Browse the repository at this point in the history
  • Loading branch information
polybluez committed Jan 20, 2025
1 parent 3295253 commit 1d76d20
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 14 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,23 @@ jobs:
with:
name: doom2df-arm64-apple-darwin
path: doom2df-arm64-apple-darwin.zip
- name: Build MacOS x86_64 app bundle
env:
D2DF_LAST_COMMIT_DATE: ${{ env.D2DF_LAST_COMMIT_DATE }}
RES_LAST_COMMIT_DATE: ${{ env.RES_LAST_COMMIT_DATE }}
EDITOR_LAST_COMMIT_DATE: ${{ env.EDITOR_LAST_COMMIT_DATE }}
DISTRO_CONTENT_CREATION_DATE: ${{ env.DISTRO_CONTENT_CREATION_DATE }}
run: |
export D2DF_LAST_COMMIT_DATE=$D2DF_LAST_COMMIT_DATE
export RES_LAST_COMMIT_DATE=$RES_LAST_COMMIT_DATE
export EDITOR_LAST_COMMIT_DATE=$EDITOR_LAST_COMMIT_DATE
export DISTRO_CONTENT_CREATION_DATE=$DISTRO_CONTENT_CREATION_DATE
bash ./game/bundle/scripts/mkApple.bash
- uses: actions/upload-artifact@v4
with:
name: Doom2DF.dmg
path: Doom2DF.dmg
if-no-files-found: error
- name: Calculate new build number
run: |
Expand All @@ -164,7 +181,7 @@ jobs:
- uses: ncipollo/release-action@v1
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch'}}
with:
artifacts: doom2df-mingw32.zip, doom2df-android.apk, doom2df-mingw64.zip, doom2df-x86_64-apple-darwin.zip, doom2df-arm64-apple-darwin.zip
artifacts: doom2df-mingw32.zip, doom2df-android.apk, doom2df-mingw64.zip, doom2df-x86_64-apple-darwin.zip, doom2df-arm64-apple-darwin.zip, Doom2DF.dmg
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ env.RELEASE_NAME }}
bodyFile: release_body
Expand Down
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
coreutils-full
(pkgs.writeShellScriptBin "zipalign" "${self.legacyPackages.${system}.arm64-v8a-linux-android.__archPkgs.androidSdk}/libexec/android-sdk/build-tools/35.0.0/zipalign $@")
(pkgs.writeShellScriptBin "apksigner" "${self.legacyPackages.${system}.arm64-v8a-linux-android.__archPkgs.androidSdk}/libexec/android-sdk/build-tools/35.0.0/apksigner $@")
cdrkit
];
};
};
Expand Down
2 changes: 2 additions & 0 deletions game/assets/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{callPackage}: {
androidRoot = ./android;
androidIcons = ./dirtyAssets/android/res;
macOsIcns = ./dirtyAssets/macOS/Doom2DF.icns;
macOsPlist = ./macOS/Info.plist;
mkAndroidManifest = callPackage ./androidManifest.nix;
mkAssetsPath = callPackage ./mkAssetsPath.nix;
}
Binary file added game/assets/dirtyAssets/macOS/Doom2DF.icns
Binary file not shown.
30 changes: 30 additions & 0 deletions game/assets/macOS/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleGetInfoString</key>
<string>Copyleft 2003-2025 Jabberwock AND rs.falcon</string>
<key>NSHumanReadableCopyright</key>
<string>Copyleft 2003-2025 Jabberwock AND rs.falcon</string>
<key>CFBundleExecutable</key>
<string>Doom2DF</string>
<key>CFBundleIdentifier</key>
<string>org.doom2df</string>
<key>CFBundleName</key>
<string>Doom2D Forever</string>
<key>CFBundleDisplayName</key>
<string>Doom2D Forever</string>
<key>CFBundleIconFile</key>
<string>Doom2DF</string>
<key>CFBundleShortVersionString</key>
<string>0.667</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>IFmajorVersion</key>
<integer>0</integer>
<key>IFMinorVersion</key>
<integer>667</integer>
</dict>
</plist>
37 changes: 37 additions & 0 deletions game/bundle/scripts/mkApple.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
set -euo pipefail

export BUILD_ARCH="x86_64-apple-darwin"
export BUILD_FOLDER="Doom2DF.app"
export MACOS_ICNS="$(nix build --verbose --show-trace --print-build-logs --print-out-paths .#assetsLib.x86_64-linux.macOsIcns)"
export MACOS_INFO="$(nix build --verbose --show-trace --print-build-logs --print-out-paths .#assetsLib.x86_64-linux.macOsPlist)"
mkdir -p $BUILD_FOLDER/Contents/{MacOS,Resources}
nix build --print-build-logs ".#${BUILD_ARCH}.bundles.default"
cp -r result/executables/* $BUILD_FOLDER/Contents/MacOS
mv $BUILD_FOLDER/Contents/MacOS/Doom2DF $BUILD_FOLDER/Contents/MacOS/Doom2DF_unwrapped
cp $MACOS_INFO $BUILD_FOLDER/Contents/Info.plist
cat << EOF > $BUILD_FOLDER/Contents/MacOS/Doom2DF
LAUNCH_PATH="\$(dirname "\$0")"
DYLD_FALLBACK_LIBRARY_PATH="\$LAUNCH_PATH:\$DYLD_FALLBACK_LIBRARY_PATH" \
LD_LIBRARY_PATH="\$LAUNCH_PATH:\$LD_LIBRARY_PATH" \
"\$LAUNCH_PATH/Doom2DF_unwrapped"
EOF
touch -d "$D2DF_LAST_COMMIT_DATE" "$BUILD_FOLDER/Contents/MacOS/Doom2DF_unwrapped"
touch -d "$D2DF_LAST_COMMIT_DATE" "$BUILD_FOLDER/Contents/MacOS/Doom2DF"
touch -d "$D2DF_LAST_COMMIT_DATE" "$BUILD_FOLDER/Contents/Info.plist"
find $BUILD_FOLDER/Contents/MacOS/ -type f -iname '*.dylib' -exec touch -d "$D2DF_LAST_COMMIT_DATE" {} \;
cp -r result/assets/* $BUILD_FOLDER/Contents/Resources
find $BUILD_FOLDER/Contents/Resources -type f -exec touch -d "$RES_LAST_COMMIT_DATE" {} \;
find $BUILD_FOLDER/Contents/Resources -type f -iname 'editor*.lng' -exec touch -d "$EDITOR_LAST_COMMIT_DATE" {} \;
touch -d "$DISTRO_CONTENT_CREATION_DATE" "${BUILD_FOLDER}/Contents/Resources/Get MORE game content HERE.txt"
chmod -R 777 $BUILD_FOLDER
cp "$MACOS_ICNS" $BUILD_FOLDER/Contents/Resources/Doom2DF.icns
[ ! -f "df_distro_content.rar" ] && cp $(nix eval '.#dfInputs' --json 2>/dev/null | jq --raw-output '."x86_64-linux"."d2df-distro-content"') df_distro_content.rar
rar x -tsp df_distro_content.rar $BUILD_FOLDER/Contents/Resources
genisoimage -D -V "Doom2D Forever" -no-pad -r -apple -file-mode 0555 -o Doom2DF.dmg $BUILD_FOLDER
25 changes: 13 additions & 12 deletions packages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -150,20 +150,21 @@
withMiniupnpc = true;
};
executables = allCombos;
bundles = lib.recursiveUpdate {} (lib.optionalAttrs (!info.loadedAsLibrary) {
default = callPackage mkGamePath {
gameExecutablePath = callPackage mkExecutablePath rec {
byArchPkgsAttrs = {
"${arch}" = {
sharedLibraries = lib.map (drv: drv.out) defaultExecutable.buildInputs;
doom2df = defaultExecutable;
editor = archAttrs.editor;
isWindows = archAttrs.infoAttrs.isWindows;
asLibrary = info.loadedAsLibrary;
prefix = ".";
};
bundles = lib.recursiveUpdate {} (lib.optionalAttrs (!info.loadedAsLibrary) rec {
gameExecutablePath = callPackage mkExecutablePath rec {
byArchPkgsAttrs = {
"${arch}" = {
sharedLibraries = lib.map (drv: drv.out) defaultExecutable.buildInputs;
doom2df = defaultExecutable;
editor = archAttrs.editor;
isWindows = archAttrs.infoAttrs.isWindows;
asLibrary = info.loadedAsLibrary;
prefix = ".";
};
};
};
default = callPackage mkGamePath {
inherit gameExecutablePath;
gameAssetsPath = defaultAssetsPath.override {toLower = archAttrs.infoAttrs.caseSensitive;};
};
});
Expand Down
2 changes: 1 addition & 1 deletion packages/executables.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
in
prevFpcAttrs
// {
cpuArgs = prevFpcAttrs.cpuArgs ++ ["-O3" "-g" "gl"];
cpuArgs = prevFpcAttrs.cpuArgs ++ ["-O3" "-g" "-gl"];
toolchainPaths =
prevFpcAttrs.toolchainPaths
++ [
Expand Down

0 comments on commit 1d76d20

Please sign in to comment.