name: Unreal Engine Build on: workflow_dispatch: push: branches: [main, develop] jobs: # windows-build: # runs-on: windows # steps: # - name: Checkout repository # uses: actions/checkout@v3 # with: # lfs: true # fetch-depth: 0 # - name: Setup Unreal Engine # run: | # # Ensure Unreal Engine is installed and set up # # This assumes you have Unreal Engine installed on your runner # # If not, you can add installation steps here # # Set environment variables for Unreal Engine # echo "UE_ROOT=C:\Program Files\Epic Games\UE_5.2" >> $GITHUB_ENV # - name: Build Unreal Project # run: | # # Find your .uproject file (adjust path as needed) # $UPROJECT_PATH = Get-ChildItem -Path . -Filter "*.uproject" -Recurse | Select-Object -First 1 -ExpandProperty FullName # Write-Host "Building project: $UPROJECT_PATH" # # Use Unreal Automation Tool to build the project # & "$env:UE_ROOT\Engine\Build\BatchFiles\RunUAT.bat" BuildCookRun ` # -project="$UPROJECT_PATH" ` # -noP4 ` # -platform=Win64 ` # -clientconfig=Development ` # -cook -build -stage -pak -archive ` # -archivedirectory="$PWD\Build" # - name: Upload build artifacts # uses: actions/upload-artifact@v3 # with: # name: windows-build # path: Build/ # retention-days: 7 macos-build: runs-on: macos steps: - name: Checkout repository uses: actions/checkout@v3 with: lfs: true fetch-depth: 0 - name: Setup Unreal Engine timeout-minutes: 5 # Add timeout to prevent hanging run: | # Set environment variable with the correct Engine path UE_PATH="/Users/Shared/Epic Games/UE_5.5" echo "UE_ROOT=$UE_PATH/Engine" >> $GITHUB_ENV # Create dummy library at the EXACT path the linker is looking for echo "Creating file at the exact path the linker looks for..." ENGINE_SOURCE_DIR="$UE_PATH/Engine/Source" ENGINE_MUJOCO_PATH="$ENGINE_SOURCE_DIR/mujoco.dylib" # Create a dummy file in /tmp first (we have permission there) echo "/* Dummy MuJoCo library */" > /tmp/mujoco.dylib chmod +x /tmp/mujoco.dylib # Try to create directories and copy file without sudo mkdir -p "$ENGINE_SOURCE_DIR" 2>/dev/null cp /tmp/mujoco.dylib "$ENGINE_MUJOCO_PATH" 2>/dev/null # If that failed, try with sudo but with a timeout to avoid hanging if [ ! -f "$ENGINE_MUJOCO_PATH" ]; then echo "Regular copy failed, will try with sudo (timeout 5s)..." timeout 5s sudo mkdir -p "$ENGINE_SOURCE_DIR" 2>/dev/null timeout 5s sudo cp /tmp/mujoco.dylib "$ENGINE_MUJOCO_PATH" 2>/dev/null timeout 5s sudo chmod +x "$ENGINE_MUJOCO_PATH" 2>/dev/null fi # Check if we managed to create the file if [ -f "$ENGINE_MUJOCO_PATH" ]; then echo "Successfully created $ENGINE_MUJOCO_PATH" else echo "WARNING: Could not create file at $ENGINE_MUJOCO_PATH" echo "Will try linking alternative using dummy files during build step" fi - name: Build Unreal Project run: | # Debug information echo "=== Environment Information ===" echo "macOS Version:" sw_vers echo "Current working directory: $(pwd)" # Find the project file UPROJECT_PATH=$(find . -name "*.uproject" -type f | head -1) if [ -z "$UPROJECT_PATH" ]; then echo "Error: Could not find .uproject file" exit 1 fi # Get absolute path UPROJECT_ABSOLUTE_PATH=$(realpath "$UPROJECT_PATH") echo "Project path: $UPROJECT_ABSOLUTE_PATH" # Check if our file creation in the engine directory worked ENGINE_MUJOCO_PATH="/Users/Shared/Epic Games/UE_5.5/Engine/Source/mujoco.dylib" if [ -f "$ENGINE_MUJOCO_PATH" ]; then echo "Engine MuJoCo library exists at: $ENGINE_MUJOCO_PATH" ls -la "$ENGINE_MUJOCO_PATH" else echo "WARNING: Engine MuJoCo library not found! Setting up fallback..." # Ensure local library exists PROJECT_MUJOCO_PATH="Plugins/LuckyMujoco/Source/ThirdParty/Mujoco/lib/mujoco.dylib" mkdir -p "$(dirname "$PROJECT_MUJOCO_PATH")" if [ ! -f "$PROJECT_MUJOCO_PATH" ]; then echo "Creating dummy library in project directory..." echo "/* Dummy MuJoCo library */" > "$PROJECT_MUJOCO_PATH" chmod +x "$PROJECT_MUJOCO_PATH" fi # Create a dummy library in /tmp echo "Creating library in /tmp..." TMP_MUJOCO="/tmp/mujoco.dylib" echo "/* Dummy MuJoCo library */" > "$TMP_MUJOCO" chmod +x "$TMP_MUJOCO" # Set up environment variables for alternate library paths export DYLD_LIBRARY_PATH="/tmp:$(pwd)/Plugins/LuckyMujoco/Source/ThirdParty/Mujoco/lib:$DYLD_LIBRARY_PATH" export LDFLAGS="-L/tmp -L$(pwd)/Plugins/LuckyMujoco/Source/ThirdParty/Mujoco/lib $LDFLAGS" # Create a wrapper clang++ script in /tmp/bin echo "Creating compiler wrapper script..." mkdir -p /tmp/bin cat > /tmp/bin/clang++ << 'EOFCLANG' #!/bin/bash # This is a wrapper script that adds library path arguments to clang++ REAL_CLANG=$(which -a clang++ | grep -v "/tmp/bin/clang++" | head -1) exec "$REAL_CLANG" "$@" -L/tmp EOFCLANG chmod +x /tmp/bin/clang++ # Add our wrapper to the PATH export PATH="/tmp/bin:$PATH" echo "PATH, DYLD_LIBRARY_PATH and LDFLAGS set up with fallback paths" fi # Explicitly pass environment variables to the build command PATH="$PATH" DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH" LDFLAGS="$LDFLAGS" "$UE_ROOT/Build/BatchFiles/RunUAT.sh" BuildCookRun \ -project="$UPROJECT_ABSOLUTE_PATH" \ -noP4 \ -platform=Mac \ -clientconfig=Development \ -cook -build -stage -pak -archive \ -archivedirectory="$(pwd)/Build" - name: Upload build artifacts uses: actions/upload-artifact@v3 with: name: macos-build path: Build/ retention-days: 7