Skip to content

Instantly share code, notes, and snippets.

@tomduckering
Last active April 6, 2025 03:49
Show Gist options
  • Save tomduckering/979ccfeecc370f9b093b462a7b7e897c to your computer and use it in GitHub Desktop.
Save tomduckering/979ccfeecc370f9b093b462a7b7e897c to your computer and use it in GitHub Desktop.
HL2 on Apple Silicon
#!/bin/bash -x
TEMP_INSTALL_DIR="$HOME/SourceEngineGames/Half Life 2"
TEMP_CHECKOUT_DIR="/tmp/source-engine"
STEAM_INSTALL="$HOME/Library/Application Support/Steam/steamapps/common/Half-Life 2"
if ! test -d "$STEAM_INSTALL"; then
echo "Ensure you have HL2 installed - ensure it's the steam_legacy edition (Steam -> Library -> Half Life 2 -> Properties -> Betas -> Beta Participation"
echo "Did not find it installed at ${STEAM_INSTALL}"
exit 1
fi
if ! command -v brew > /dev/null; then
echo "You need brew installed - visit https://brew.sh for installation instructions."
exit 1
fi
if ! command -v git > /dev/null; then
echo "You need xcode dev tools installed (for git and compilers) - run \"xcode-select --install\" to install them."
exit 1
fi
brew install sdl2 freetype2 fontconfig pkg-config opus jpeg jpeg-turbo libpng libedit python3
if ! test -d "$TEMP_CHECKOUT_DIR"; then
git clone --recursive https://github.com/nillerusr/source-engine $TEMP_CHECKOUT_DIR
fi
cd ${TEMP_CHECKOUT_DIR}
python3 waf configure -T release --prefix='' --build-games=hl2
python3 waf build
python3 waf install --destdir="${TEMP_INSTALL_DIR}"
mv "${STEAM_INSTALL}/platform" "$TEMP_INSTALL_DIR"
find "${STEAM_INSTALL}/hl2" -maxdepth 1 -mindepth 1 ! -name bin -exec cp "{}" "$TEMP_INSTALL_DIR/hl2" \;
cp "${STEAM_INSTALL}/hl2.sh" "$TEMP_INSTALL_DIR"
cp "$TEMP_INSTALL_DIR/hl2_launcher" "$TEMP_INSTALL_DIR/hl2_osx"
rm -Rf "${STEAM_INSTALL}"
mv "$TEMP_INSTALL_DIR/" "${STEAM_INSTALL}"
# Flashlight fix
echo "r_newflashlight 0" > "${STEAM_INSTALL}/hl2/cfg/autoexec.cfg"
rm -Rf "${TEMP_CHECKOUT_DIR}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment