|
| 1 | +name: Build Linux |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + runner-label: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + unreal-engine-version: |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + unreal-engine-zip: |
| 13 | + required: true |
| 14 | + type: string |
| 15 | + unreal-program-name: |
| 16 | + required: true |
| 17 | + type: string |
| 18 | + upload-package-base-name: |
| 19 | + required: true |
| 20 | + type: string |
| 21 | + extra-choco-packages: |
| 22 | + required: false |
| 23 | + type: string |
| 24 | + default: '' |
| 25 | + clang-version: |
| 26 | + required: true |
| 27 | + type: string |
| 28 | +jobs: |
| 29 | + build: |
| 30 | + runs-on: ${{ inputs.runner-label }} |
| 31 | + - name: Check out repository code |
| 32 | + uses: actions/checkout@v4 |
| 33 | + with: |
| 34 | + submodules: recursive |
| 35 | + - name: Install nasm |
| 36 | + |
| 37 | + - name: Install Ninja |
| 38 | + run: | |
| 39 | + sudo apt install ninja |
| 40 | + - name: Install Unreal Engine |
| 41 | + uses: ./.github/actions/install-unreal-linux |
| 42 | + with: |
| 43 | + unreal-engine-zip: ${{ inputs.unreal-engine-zip }} |
| 44 | + unreal-program-name: ${{ inputs.unreal-program-name }} |
| 45 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 46 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 47 | + - name: Set environment variables |
| 48 | + run: | |
| 49 | + echo "CESIUM_UNREAL_VERSION=$GITHUB_REF_NAME" >> "$GITHUB_ENV" |
| 50 | + echo "BUILD_CESIUM_UNREAL_PACKAGE_NAME=${{ inputs.upload-package-base-name }}-${CESIUM_UNREAL_VERSION}" >> "$GITHUB_ENV" |
| 51 | + echo "UNREAL_ENGINE_DIR=$HOME/${{ inputs.unreal-program-name }}" >> "$GITHUB_ENV" |
| 52 | + echo "LINUX_MULTIARCH_ROOT=$UNREAL_ENGINE_DIR/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/${{ inputs.clang-version }}/" >> "$GITHUB_ENV" |
| 53 | + - name: Build cesium-native |
| 54 | + run: | |
| 55 | + export UNREAL_ENGINE_COMPILER_DIR="${LINUX_MULTIARCH_ROOT}x86_64-unknown-linux-gnu" |
| 56 | + export UNREAL_ENGINE_LIBCXX_DIR="${UNREAL_ENGINE_DIR}/Engine/Source/ThirdParty/Unix/LibCxx" |
| 57 | + cd extern |
| 58 | + cmake -B build -S . -G Ninja -DCMAKE_TOOLCHAIN_FILE="unreal-linux-toolchain.cmake" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=Release |
| 59 | + cmake --build build --config Release --target install -j8 |
| 60 | + cd .. |
| 61 | + rm -rf extern |
| 62 | + - name: Build plugin |
| 63 | + run: | |
| 64 | + mkdir -p ~/.config/Unreal\ Engine/UnrealBuildTool |
| 65 | + printf '<?xml version="1.0" encoding="utf-8" ?>\n<Configuration xmlns="https://www.unrealengine.com/BuildConfiguration">\n <BuildConfiguration>\n <MaxParallelActions>2</MaxParallelActions>\n </BuildConfiguration>\n</Configuration>\n' > ~/.config/Unreal\ Engine/UnrealBuildTool/BuildConfiguration.xml |
| 66 | + sed -i 's/\"EngineVersion\": \"5.1.0\"/\"EngineVersion\": \"${{ inputs.unreal-engine-version }}\"/g' CesiumForUnreal.uplugin |
| 67 | + cd $UNREAL_ENGINE_DIR/Engine/Build/BatchFiles |
| 68 | + ./RunUAT.sh BuildPlugin -Plugin="$GITHUB_WORKSPACE/CesiumForUnreal.uplugin" -Package="$GITHUB_WORKSPACE/packages/CesiumForUnreal" -CreateSubFolder -TargetPlatforms=Linux |
| 69 | + - name: Fix RPATH |
| 70 | + run: | |
| 71 | + sudo yum install -y patchelf |
| 72 | + cd $GITHUB_WORKSPACE/packages/CesiumForUnreal/Binaries/Linux |
| 73 | + patchelf --print-rpath libUnrealEditor-CesiumRuntime.so |
| 74 | + export UPDATED_RPATH=`patchelf --print-rpath libUnrealEditor-CesiumRuntime.so | sed 's/${ORIGIN}[^:]*\/SunPosition\/Binaries\/Linux/${ORIGIN}\/..\/..\/..\/..\/Runtime\/SunPosition\/Binaries\/Linux/'` |
| 75 | + patchelf --force-rpath --set-rpath "$UPDATED_RPATH" libUnrealEditor-CesiumRuntime.so |
| 76 | + - name: Compress debug sections |
| 77 | + run: | |
| 78 | + for f in packages/CesiumForUnreal/Binaries/Linux/*.so; do objcopy --compress-debug-sections $f; done |
| 79 | + for f in packages/CesiumForUnreal/Binaries/Linux/*.debug; do objcopy --compress-debug-sections $f; done |
| 80 | + for f in packages/CesiumForUnreal/Intermediate/Build/Linux/x64/UnrealGame/Development/CesiumRuntime/*.o; do objcopy --compress-debug-sections $f; done |
| 81 | + for f in packages/CesiumForUnreal/Intermediate/Build/Linux/x64/UnrealGame/Shipping/CesiumRuntime/*.o; do objcopy --compress-debug-sections $f; done |
| 82 | + - name: Publish plugin package artifact |
| 83 | + if: ${{ success() }} |
| 84 | + uses: actions/upload-artifact@v4 |
| 85 | + with: |
| 86 | + name: ${{ env.BUILD_CESIUM_UNREAL_PACKAGE_NAME}} |
| 87 | + path: packages |
0 commit comments