diff --git a/.gitea/workflows/unreal-build.yml b/.gitea/workflows/unreal-build.yml index 6da324d6..7f2cf7e0 100644 --- a/.gitea/workflows/unreal-build.yml +++ b/.gitea/workflows/unreal-build.yml @@ -4,8 +4,6 @@ on: workflow_dispatch: push: branches: [ main, develop ] - pull_request: - branches: [ main, develop ] jobs: # windows-build: @@ -54,71 +52,159 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 with: + fetch-depth: 1 lfs: true - fetch-depth: 0 + sparse-checkout: | + Config/ + Content/ + Plugins/ + Source/ + *.uproject + + - name: Cache build dependencies + uses: actions/cache@v3 + with: + path: | + ~/Library/Caches/Unreal Engine + Intermediate/ + Saved/ + DerivedDataCache/ + key: ${{ runner.os }}-unreal-build-${{ hashFiles('**/*.uproject') }} + restore-keys: | + ${{ runner.os }}-unreal-build- - name: Setup Unreal Engine run: | # Use the correct path where Unreal Engine is installed - UE_PATH="/Users/Shared/Epic Games/UE_5.5" + # Note: Paths with spaces need special handling + UE_PATH="/Users/Shared/Epic\ Games/UE_5.5" - if [ ! -d "$UE_PATH" ]; then + # Check the directory exists but use unescaped version for test + if [ ! -d "/Users/Shared/Epic Games/UE_5.5" ]; then echo "Error: Unreal Engine is not installed in the expected location" - echo "Please ensure Unreal Engine is installed at $UE_PATH" + echo "Please ensure Unreal Engine is installed at /Users/Shared/Epic Games/UE_5.5" exit 1 fi - # Set environment variable with the correct Engine path - echo "UE_ROOT=$UE_PATH/Engine" >> $GITHUB_ENV - echo "Using Unreal Engine 5.5" + # Set environment variables with proper escaping + # Use double quotes to preserve the backslash escaping + echo "UE_ROOT=\"${UE_PATH}/Engine\"" >> $GITHUB_ENV + echo "UE_PATH=\"${UE_PATH}\"" >> $GITHUB_ENV + + # Export variables directly for this script + export UE_ROOT="${UE_PATH}/Engine" + export UE_PATH="${UE_PATH}" + + echo "Unreal Engine paths:" + echo "UE_ROOT=$UE_ROOT" + echo "UE_PATH=$UE_PATH" + + # Set up MuJoCo library + MUJOCO_LIB_DIR="Plugins/LuckyMujoco/Source/ThirdParty/Mujoco/lib" + mkdir -p "$MUJOCO_LIB_DIR" + + # Cache MuJoCo dylib + if [ ! -f "$MUJOCO_LIB_DIR/mujoco.dylib" ]; then + echo "MuJoCo dylib not in cache, setting up..." + + # Try to find mujoco.dylib in the repository + if [ -f "Plugins/UEMujoco.rar" ]; then + echo "Found UEMujoco.rar, attempting to extract..." + mkdir -p /tmp/mujoco_extract + unrar x "Plugins/UEMujoco.rar" /tmp/mujoco_extract || echo "Failed to extract UEMujoco.rar" + + # Look for mujoco.dylib in extracted files + DYLIB_PATH=$(find /tmp/mujoco_extract -name "mujoco.dylib" | head -1) + if [ -n "$DYLIB_PATH" ]; then + echo "Found mujoco.dylib at $DYLIB_PATH" + cp "$DYLIB_PATH" "$MUJOCO_LIB_DIR/" + else + echo "Could not find mujoco.dylib in extracted files" + fi + fi + + # If still no dylib, try to download it + if [ ! -f "$MUJOCO_LIB_DIR/mujoco.dylib" ]; then + echo "Attempting to download mujoco.dylib..." + curl -L -o "$MUJOCO_LIB_DIR/mujoco.dylib" "https://github.com/deepmind/mujoco/releases/download/2.3.7/mujoco-2.3.7-macos-universal2.dmg" + fi + else + echo "Using cached MuJoCo dylib" + fi + + # Verify the library exists + if [ ! -f "$MUJOCO_LIB_DIR/mujoco.dylib" ]; then + echo "ERROR: Failed to set up mujoco.dylib" + exit 1 + fi + + # Make sure the library is executable + chmod +x "$MUJOCO_LIB_DIR/mujoco.dylib" + + # Try multiple locations for the mujoco library + # 1. Create directory in Engine/Source + UE_ENGINE_PATH="/Users/Shared/Epic Games/UE_5.5/Engine" + mkdir -p "${UE_ENGINE_PATH}/Source" + echo "Created directory: ${UE_ENGINE_PATH}/Source" + + # 2. Copy the library directly (don't rely on symlinks) + cp "$(pwd)/$MUJOCO_LIB_DIR/mujoco.dylib" "${UE_ENGINE_PATH}/Source/" + echo "Copied library to: ${UE_ENGINE_PATH}/Source/mujoco.dylib" + + # 3. Also copy to Binaries/Mac directory + mkdir -p "${UE_ENGINE_PATH}/Binaries/Mac" + cp "$(pwd)/$MUJOCO_LIB_DIR/mujoco.dylib" "${UE_ENGINE_PATH}/Binaries/Mac/" + echo "Copied library to: ${UE_ENGINE_PATH}/Binaries/Mac/mujoco.dylib" + + # 4. Add a fallback into /usr/local/lib + sudo mkdir -p /usr/local/lib + sudo cp "$(pwd)/$MUJOCO_LIB_DIR/mujoco.dylib" /usr/local/lib/ + echo "Copied library to: /usr/local/lib/mujoco.dylib" + + # Set up environment for the build + export DYLD_LIBRARY_PATH="$(pwd)/Plugins/LuckyMujoco/Source/ThirdParty/Mujoco/lib:${UE_ENGINE_PATH}/Source:${UE_ENGINE_PATH}/Binaries/Mac:/usr/local/lib:$DYLD_LIBRARY_PATH" + export DYLD_FRAMEWORK_PATH="${UE_ENGINE_PATH}/Binaries/Mac:$DYLD_FRAMEWORK_PATH" + export DYLD_FALLBACK_LIBRARY_PATH="${UE_ENGINE_PATH}/Binaries/Mac:${UE_ENGINE_PATH}/Source:/usr/local/lib:$DYLD_FALLBACK_LIBRARY_PATH" - name: Build Unreal Project run: | - # Debug information - echo "=== Environment Information ===" - echo "macOS Version:" - sw_vers - echo "Current working directory: $(pwd)" - ls -la # List all files in current directory + # Use direct path instead of environment variable + UE_ENGINE_PATH="/Users/Shared/Epic Games/UE_5.5/Engine" - echo "=== Unreal Engine Information ===" - ls -la "$UE_ROOT/Build/BatchFiles" - - echo "=== Project Information ===" - # Detailed search for the project file - echo "Searching for .uproject files:" - find . -name "*.uproject" -type f - - # Get the absolute path of the project file - UPROJECT_PATH=$(find . -name "*.uproject" -type f | head -1) + # Find project file (using direct find instead of recursive search for speed) + UPROJECT_PATH=$(find . -maxdepth 1 -name "*.uproject" -type f | head -1) if [ -z "$UPROJECT_PATH" ]; then - echo "Error: Could not find .uproject file" + echo "Error: Could not find .uproject file in root directory" exit 1 fi - # Convert to absolute path and verify file exists + # Convert to absolute path UPROJECT_ABSOLUTE_PATH=$(realpath "$UPROJECT_PATH") echo "Project absolute path: $UPROJECT_ABSOLUTE_PATH" - if [ ! -f "$UPROJECT_ABSOLUTE_PATH" ]; then - echo "Error: Project file does not exist at: $UPROJECT_ABSOLUTE_PATH" - exit 1 - fi - - echo "Using Unreal Engine at: $UE_ROOT" - # Make the project file readable and executable chmod 755 "$UPROJECT_ABSOLUTE_PATH" # Run the build using absolute paths - chmod +x "$UE_ROOT/Build/BatchFiles/RunUAT.sh" - "$UE_ROOT/Build/BatchFiles/RunUAT.sh" BuildCookRun \ + chmod +x "${UE_ENGINE_PATH}/Build/BatchFiles/RunUAT.sh" + + # Set up runtime environment for the build + export DYLD_LIBRARY_PATH="$(pwd)/Plugins/LuckyMujoco/Source/ThirdParty/Mujoco/lib:${UE_ENGINE_PATH}/Source:${UE_ENGINE_PATH}/Binaries/Mac:/usr/local/lib:$DYLD_LIBRARY_PATH" + export DYLD_FRAMEWORK_PATH="${UE_ENGINE_PATH}/Binaries/Mac:$DYLD_FRAMEWORK_PATH" + export DYLD_FALLBACK_LIBRARY_PATH="${UE_ENGINE_PATH}/Binaries/Mac:${UE_ENGINE_PATH}/Source:/usr/local/lib:$DYLD_FALLBACK_LIBRARY_PATH" + + # Speed up build by using optimal parameters + "${UE_ENGINE_PATH}/Build/BatchFiles/RunUAT.sh" BuildCookRun \ -project="$UPROJECT_ABSOLUTE_PATH" \ -noP4 \ -platform=Mac \ -clientconfig=Development \ -cook -build -stage -pak -archive \ - -archivedirectory="$(pwd)/Build" + -archivedirectory="$(pwd)/Build" \ + -SkipCookingEditorContent \ + -iterativecooking \ + -fastcook \ + -compressed - name: Upload build artifacts uses: actions/upload-artifact@v3 diff --git a/README.md b/README.md index a04c046a..b621919a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,20 @@ # luckyworld this is our unreal repository with our complete source code... + +steps to pull the source code down and compile + +* (Don't download the .zip file. It's best to use the CLI or a visual tool so LFS can install the proper libraries) +* git clone https://luckyrobots.com/luckyrobots/luckyworld.git +* cd luckyworld +* install git lfs + * brew install git-lfs (macOS) + * sudo yum install git-lfs (linux) + * choco install git (windows) or via https://git-scm.com/download/win + * select option to install git-lfs +* git lfs pull (just in case) +* right click .uproject file. +* Generate Visual Studio Project Files (windows) + * Open the generated .sln file with your IDE (i.e. Visual Studio or Rider) +* (The project starts in 5.5 binary version so if you're using source you will need to right click the .uproject and switch your engine version) +* Debug 'luckyrobots' \ No newline at end of file