Skip to content

Instantly share code, notes, and snippets.

@Solessfir
Created April 11, 2026 13:06
Show Gist options
  • Select an option

  • Save Solessfir/4b9fa58630a5a78d9e82c272221635a4 to your computer and use it in GitHub Desktop.

Select an option

Save Solessfir/4b9fa58630a5a78d9e82c272221635a4 to your computer and use it in GitHub Desktop.
Unreal Engine Standalone Plugin Builder for Linux
#!/usr/bin/env bash
# Copyright (c) Solessfir under MIT license
# This script builds an Unreal Engine plugin
# Place it near .uplugin file and run it
set -euo pipefail
# Configuration
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TARGET_PLATFORM="Linux"
# 1. Locate Plugin
if ls "$SCRIPT_DIR"/*.uplugin &>/dev/null; then
PLUGIN_DIR="$SCRIPT_DIR"
elif ls "$SCRIPT_DIR/.."/*.uplugin &>/dev/null 2>&1; then
PLUGIN_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
else
echo "Error: No .uplugin file found."
exit 1
fi
UPLUGIN_FILE="$(ls "$PLUGIN_DIR"/*.uplugin | head -1)"
PLUGIN_NAME="$(basename "$UPLUGIN_FILE" .uplugin)"
# 2. Extract Engine Version (optional field)
RAW_VERSION="$(grep -i '"EngineVersion"' "$UPLUGIN_FILE" | sed 's/.*: *"\([^"]*\)".*/\1/' || true)"
# 3. Locate Engine Installation
ENGINE_DIR=""
# A. Try exact version match under /opt (Arch AUR convention: /opt/unreal-engine-X.Y.Z)
if [[ -n "$RAW_VERSION" ]]; then
if [[ -d "/opt/unreal-engine-${RAW_VERSION}" ]]; then
ENGINE_DIR="/opt/unreal-engine-${RAW_VERSION}"
else
# Try Major.Minor match
SHORT_VERSION="$(echo "$RAW_VERSION" | cut -d. -f1,2)"
for DIR in /opt/unreal-engine-"${SHORT_VERSION}".*; do
[[ -d "$DIR" ]] && ENGINE_DIR="$DIR" && break
done
fi
fi
# B. Fall back: any /opt/unreal-engine-* installation (newest by version sort)
if [[ -z "$ENGINE_DIR" ]]; then
for DIR in $(ls -d /opt/unreal-engine-* 2>/dev/null | sort -V -r); do
[[ -f "$DIR/Engine/Build/BatchFiles/RunUAT.sh" ]] && ENGINE_DIR="$DIR" && break
done
fi
# C. Check Relative Path
if [[ -z "$ENGINE_DIR" ]]; then
if [[ -f "$PLUGIN_DIR/../../Engine/Build/BatchFiles/RunUAT.sh" ]]; then
ENGINE_DIR="$(cd "$PLUGIN_DIR/../.." && pwd)"
fi
fi
if [[ -z "$ENGINE_DIR" ]]; then
echo "Error: Unreal Engine installation not found${RAW_VERSION:+ for version: $RAW_VERSION}."
exit 1
fi
RUN_UAT="$ENGINE_DIR/Engine/Build/BatchFiles/RunUAT.sh"
if [[ ! -f "$RUN_UAT" ]]; then
echo "Error: RunUAT.sh not found at:"
echo "$RUN_UAT"
exit 1
fi
# 4. Build Plugin
clear
echo ":: Building Plugin: $PLUGIN_NAME ::"
[[ -n "$RAW_VERSION" ]] && echo "Version: $RAW_VERSION"
echo "Engine: $ENGINE_DIR"
echo
OUTPUT_DIR="$PLUGIN_DIR/Build"
# Clean previous build
if [[ -d "$OUTPUT_DIR" ]]; then
echo "Cleaning previous build..."
rm -rf "$OUTPUT_DIR"
fi
# Execute RunUAT
set +e
bash "$RUN_UAT" BuildPlugin \
-Plugin="$UPLUGIN_FILE" \
-Package="$OUTPUT_DIR" \
-Rocket \
-TargetPlatforms="$TARGET_PLATFORM"
BUILD_RESULT=$?
set -e
echo
if [[ $BUILD_RESULT -ne 0 ]]; then
echo "Build Failed. Check log above."
else
echo "Build Successful."
echo "Output: $OUTPUT_DIR"
fi
exit $BUILD_RESULT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment