-
Notifications
You must be signed in to change notification settings - Fork 0
Add interactive build script for KorGE Forge #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 252.25557
Are you sure you want to change the base?
Changes from all commits
84b8079
6422a26
c125150
d85702f
ddecaa3
7be5145
8462fb5
d99d33c
08b6c70
917b28f
c821829
028e3ca
e7219c8
f4485ec
b721b2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,11 @@ | ||
| # How to build KorGE Forge? | ||
|
|
||
| 1. Clone korge-forge plugin: git clone https://github.com/korlibs/korge-forge-plugin.git | ||
| 2. ./gradlew doForgeRelease in korge-forge-plugin | ||
| 3. Execute ./build_forge.sh | ||
| 2. Run `./gradlew doForgeRelease` in korge-forge-plugin | ||
| 3. Execute `./build_forge.sh` | ||
|
|
||
| The build script provides an interactive interface with: | ||
| - Automatic Java detection | ||
| - Platform selection (current platform or all platforms) | ||
| - Incremental build option | ||
| - Colored output for better visibility | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,222 @@ | ||
| #!/usr/bin/env bash | ||
| # | ||
| # KorGE Forge Interactive Build Script | ||
| # This script provides an interactive menu to build KorGE Forge | ||
| # | ||
|
|
||
| set -e | ||
| export JAVA_HOME=/home/sauron/.jdks/jbr-21.0.8 | ||
| export PATH=$JAVA_HOME/bin:$PATH | ||
| BUILD_ONLY_CURRENT_PLATFORM=true | ||
|
|
||
| echo 'Starting KorGE Forge build script!' | ||
|
|
||
| if [ "$BUILD_ONLY_CURRENT_PLATFORM" = "true" ]; then | ||
| echo 'Starting building for current platform...' | ||
| ./installers.cmd -Dintellij.build.target.os=current | ||
| else | ||
| echo 'Starting building for all platforms...' | ||
| ./installers.cmd | ||
| fi | ||
|
|
||
| echo 'Find the built KorGE Forge in out/korgeforge/artifacts/ and extract it' | ||
| echo 'Run with ./korge.sh in bin/' | ||
|
|
||
| # Colors for output | ||
| RED='\033[0;31m' | ||
| GREEN='\033[0;32m' | ||
| YELLOW='\033[1;33m' | ||
| BLUE='\033[0;34m' | ||
| CYAN='\033[0;36m' | ||
| BOLD='\033[1m' | ||
| NC='\033[0m' # No Color | ||
|
|
||
| # Default values | ||
| BUILD_PLATFORM="current" | ||
| JAVA_HOME_PATH="" | ||
| INCREMENTAL_BUILD="false" | ||
|
|
||
| # Print colored header | ||
| print_header() { | ||
| echo -e "${CYAN}" | ||
| echo "╔════════════════════════════════════════════════════════════╗" | ||
| echo "║ KorGE Forge Interactive Build Script ║" | ||
| echo "╚════════════════════════════════════════════════════════════╝" | ||
| echo -e "${NC}" | ||
| } | ||
|
|
||
| # Print info message | ||
| info() { | ||
| echo -e "${BLUE}[INFO]${NC} $1" | ||
| } | ||
|
|
||
| # Print success message | ||
| success() { | ||
| echo -e "${GREEN}[SUCCESS]${NC} $1" | ||
| } | ||
|
|
||
| # Print warning message | ||
| warn() { | ||
| echo -e "${YELLOW}[WARNING]${NC} $1" | ||
| } | ||
|
|
||
| # Print error message | ||
| error() { | ||
| echo -e "${RED}[ERROR]${NC} $1" | ||
| } | ||
|
|
||
| # Get Java version from a java binary | ||
| get_java_version() { | ||
| "$1" -version 2>&1 | head -n 1 | cut -d'"' -f2 | ||
| } | ||
|
|
||
| # Detect Java installation | ||
| detect_java() { | ||
| info "Detecting Java installation..." | ||
|
|
||
| if [ -n "$JAVA_HOME" ]; then | ||
| if [ -x "$JAVA_HOME/bin/java" ]; then | ||
| JAVA_VERSION=$(get_java_version "$JAVA_HOME/bin/java") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
🤖 Was this useful? React with 👍 or 👎 |
||
| success "Found Java at JAVA_HOME: $JAVA_HOME (Version: $JAVA_VERSION)" | ||
| JAVA_HOME_PATH="$JAVA_HOME" | ||
| return 0 | ||
| fi | ||
| fi | ||
|
|
||
| if command -v java &> /dev/null; then | ||
| JAVA_PATH=$(which java) | ||
| JAVA_VERSION=$(get_java_version java) | ||
| success "Found Java in PATH: $JAVA_PATH (Version: $JAVA_VERSION)" | ||
| # Try to determine JAVA_HOME from java path | ||
| JAVA_REAL_PATH=$(readlink -f "$JAVA_PATH" 2>/dev/null || echo "$JAVA_PATH") | ||
| JAVA_BIN_DIR=$(dirname "$JAVA_REAL_PATH") | ||
| JAVA_HOME_PATH=$(dirname "$JAVA_BIN_DIR") | ||
| return 0 | ||
| fi | ||
|
|
||
| error "Java not found. Please install JDK 21 or set JAVA_HOME." | ||
| return 1 | ||
| } | ||
|
|
||
| # Platform selection menu | ||
| select_platform() { | ||
| echo -e "\n${BOLD}Select Build Platform:${NC}" | ||
| echo " 1) Current platform only (faster)" | ||
| echo " 2) All platforms (Windows, macOS, Linux)" | ||
| echo "" | ||
|
|
||
| while true; do | ||
| read -p "Enter choice [1-2]: " choice | ||
| case $choice in | ||
| 1) | ||
| BUILD_PLATFORM="current" | ||
| info "Selected: Build for current platform only" | ||
| break | ||
| ;; | ||
| 2) | ||
| BUILD_PLATFORM="all" | ||
| info "Selected: Build for all platforms" | ||
| break | ||
| ;; | ||
| *) | ||
| warn "Invalid choice. Please enter 1 or 2." | ||
| ;; | ||
| esac | ||
| done | ||
| } | ||
|
|
||
| # Incremental build option | ||
| select_incremental() { | ||
| echo -e "\n${BOLD}Incremental Build:${NC}" | ||
| echo " 1) Full build (clean)" | ||
| echo " 2) Incremental build (faster, may have issues)" | ||
| echo "" | ||
|
|
||
| while true; do | ||
| read -p "Enter choice [1-2]: " choice | ||
| case $choice in | ||
| 1) | ||
| INCREMENTAL_BUILD="false" | ||
| info "Selected: Full build" | ||
| break | ||
| ;; | ||
| 2) | ||
| INCREMENTAL_BUILD="true" | ||
| info "Selected: Incremental build" | ||
| break | ||
| ;; | ||
| *) | ||
| warn "Invalid choice. Please enter 1 or 2." | ||
| ;; | ||
| esac | ||
| done | ||
| } | ||
|
|
||
| # Confirmation prompt | ||
| confirm_build() { | ||
| echo -e "\n${BOLD}Build Configuration Summary:${NC}" | ||
| echo " • Platform: $BUILD_PLATFORM" | ||
| echo " • Incremental: $INCREMENTAL_BUILD" | ||
| echo " • Java Home: $JAVA_HOME_PATH" | ||
| echo "" | ||
|
|
||
| while true; do | ||
| read -p "Proceed with build? [y/n]: " yn | ||
| case $yn in | ||
| [Yy]* ) | ||
| return 0 | ||
| ;; | ||
| [Nn]* ) | ||
| info "Build cancelled by user." | ||
| exit 0 | ||
| ;; | ||
| * ) | ||
| warn "Please answer y or n." | ||
| ;; | ||
| esac | ||
| done | ||
| } | ||
|
|
||
| # Run the build | ||
| run_build() { | ||
| echo -e "\n${CYAN}═══════════════════════════════════════════════════════════════${NC}" | ||
| info "Starting KorGE Forge build..." | ||
| echo -e "${CYAN}═══════════════════════════════════════════════════════════════${NC}\n" | ||
|
|
||
| # Set JAVA_HOME | ||
| export JAVA_HOME="$JAVA_HOME_PATH" | ||
| export PATH="$JAVA_HOME/bin:$PATH" | ||
|
|
||
| # Build arguments as array for safe argument passing | ||
| BUILD_ARGS=() | ||
|
|
||
| if [ "$BUILD_PLATFORM" = "current" ]; then | ||
| BUILD_ARGS+=("-Dintellij.build.target.os=current") | ||
| fi | ||
|
|
||
| if [ "$INCREMENTAL_BUILD" = "true" ]; then | ||
| BUILD_ARGS+=("-Dintellij.build.incremental.compilation=true") | ||
| fi | ||
|
|
||
| info "Running: ./installers.cmd ${BUILD_ARGS[*]}" | ||
| echo "" | ||
|
|
||
| # Run the build with array expansion | ||
| ./installers.cmd "${BUILD_ARGS[@]}" | ||
|
|
||
| echo "" | ||
| success "Build completed!" | ||
| echo -e "\n${GREEN}Find the built KorGE Forge in out/korgeforge/artifacts/${NC}" | ||
| echo -e "${GREEN}Extract and run with ./korge.sh in bin/${NC}\n" | ||
| } | ||
|
|
||
| # Main function | ||
| main() { | ||
| print_header | ||
|
|
||
| # Check we're in the right directory | ||
| if [ ! -f "installers.cmd" ]; then | ||
| error "This script must be run from the korge-forge root directory." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Detect Java | ||
| if ! detect_java; then | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Interactive menu | ||
| select_platform | ||
| select_incremental | ||
|
|
||
| # Confirm and build | ||
| confirm_build | ||
| run_build | ||
| } | ||
|
|
||
| # Run main | ||
| main "$@" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file still has no trailing newline (shown as “No newline at end of file” in the diff), which can cause minor tooling issues.
🤖 Was this useful? React with 👍 or 👎