diff options
| author | Indrajith K L | 2025-11-09 06:37:45 +0530 |
|---|---|---|
| committer | Indrajith K L | 2025-11-09 06:37:45 +0530 |
| commit | 0fbc961bb8e7b9864c0982bb86b0de2e25d6f4aa (patch) | |
| tree | b446af7c63385e59b6d5e41fb9071164ee59c2bb /scripts | |
| parent | 7cdb3b65f437219d03f7c0609bcde4651d7f9e2e (diff) | |
| download | reilua-enhanced-0fbc961bb8e7b9864c0982bb86b0de2e25d6f4aa.tar.gz reilua-enhanced-0fbc961bb8e7b9864c0982bb86b0de2e25d6f4aa.tar.bz2 reilua-enhanced-0fbc961bb8e7b9864c0982bb86b0de2e25d6f4aa.zip | |
Add macOS support and project creation tool
- Add macOS static and dynamic library linking support
- Add cross-platform build scripts for Windows, macOS, and Linux
- Add project creation script with metadata embedding
- Add macOS app bundle creation with icon support
- Update CMakeLists.txt for platform detection
- Fix STB rect pack duplicate symbols
- Remove test images and unused files
- Consolidate documentation into MACOS.md
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/.DS_Store | bin | 0 -> 8196 bytes | |||
| -rwxr-xr-x[-rw-r--r--] | scripts/build_dev.sh | 84 | ||||
| -rwxr-xr-x[-rw-r--r--] | scripts/build_release.sh | 90 | ||||
| -rwxr-xr-x | scripts/create_project.sh | 578 | ||||
| -rwxr-xr-x | scripts/macos/build_static_libs.sh | 149 | ||||
| -rwxr-xr-x | scripts/macos/create_app_bundle.sh | 152 |
6 files changed, 1036 insertions, 17 deletions
diff --git a/scripts/.DS_Store b/scripts/.DS_Store Binary files differnew file mode 100644 index 0000000..a08bf15 --- /dev/null +++ b/scripts/.DS_Store diff --git a/scripts/build_dev.sh b/scripts/build_dev.sh index ed5079d..5912bb0 100644..100755 --- a/scripts/build_dev.sh +++ b/scripts/build_dev.sh @@ -1,6 +1,6 @@ #!/bin/bash # ReiLua Development Build Script -# Run this from w64devkit shell +# Works on Windows (w64devkit) and macOS echo "================================" echo "ReiLua - Development Build" @@ -11,6 +11,53 @@ echo "" SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd "$SCRIPT_DIR/.." || exit 1 +# Check for dependencies on macOS +if [[ "$OSTYPE" == "darwin"* ]]; then + echo "Checking macOS build configuration..." + + # Check if static libraries exist + if [ -f "../lib/macos/libraylib.a" ] && [ -f "../lib/macos/liblua.a" ]; then + echo "✓ Static libraries found - building for distribution" + echo " (Single-file executable, no dependencies)" + echo "" + else + echo "⚠️ Static libraries not found - using Homebrew libraries" + echo "" + echo "This build will require raylib/lua at runtime." + echo "" + echo "For distribution builds (single executable), run:" + echo " ./scripts/macos/build_static_libs.sh" + echo "" + + # Check for Homebrew dependencies + MISSING_DEPS=() + + if ! brew list glfw &>/dev/null; then + MISSING_DEPS+=("glfw") + fi + + if ! brew list raylib &>/dev/null; then + MISSING_DEPS+=("raylib") + fi + + if ! brew list lua &>/dev/null; then + MISSING_DEPS+=("lua") + fi + + if [ ${#MISSING_DEPS[@]} -gt 0 ]; then + echo "ERROR: Missing Homebrew packages: ${MISSING_DEPS[*]}" + echo "" + echo "Install with:" + echo " brew install ${MISSING_DEPS[*]} pkg-config" + echo "" + exit 1 + fi + + echo "✓ Homebrew dependencies found" + echo "" + fi +fi + # Create and navigate to build directory mkdir -p build cd build || exit 1 @@ -60,9 +107,24 @@ if [ "$1" == "clean" ]; then echo "" fi -# Configure with MinGW -echo "Configuring CMake for development..." -cmake -G "MinGW Makefiles" .. +# Detect platform and set appropriate generator +if [[ "$OSTYPE" == "darwin"* ]]; then + # macOS + CMAKE_GENERATOR="Unix Makefiles" + BUILD_CMD="make" +elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "mingw"* ]]; then + # Windows with MinGW + CMAKE_GENERATOR="MinGW Makefiles" + BUILD_CMD="make" +else + # Linux and others + CMAKE_GENERATOR="Unix Makefiles" + BUILD_CMD="make" +fi + +# Configure +echo "Configuring CMake for development (${OSTYPE})..." +cmake -G "$CMAKE_GENERATOR" .. if [ $? -ne 0 ]; then echo "" @@ -72,7 +134,7 @@ fi echo "" echo "Building ReiLua..." -make +$BUILD_CMD if [ $? -ne 0 ]; then echo "" @@ -87,12 +149,20 @@ echo "================================" echo "" echo "Development build created successfully!" echo "" + +# Detect executable name based on platform +if [[ "$OSTYPE" == "darwin"* ]]; then + EXE_NAME="ReiLua" +else + EXE_NAME="ReiLua.exe" +fi + echo "To run your game:" echo " cd /path/to/your/game" -echo " /path/to/ReiLua/build/ReiLua.exe" +echo " /path/to/ReiLua/build/$EXE_NAME" echo "" echo "To run with console logging:" -echo " /path/to/ReiLua/build/ReiLua.exe --log" +echo " /path/to/ReiLua/build/$EXE_NAME --log" echo "" echo "Features:" echo " - Lua files load from file system" diff --git a/scripts/build_release.sh b/scripts/build_release.sh index cccdefe..41a050c 100644..100755 --- a/scripts/build_release.sh +++ b/scripts/build_release.sh @@ -1,6 +1,6 @@ #!/bin/bash # ReiLua Release Build Script -# Run this from w64devkit shell +# Works on Windows (w64devkit) and macOS echo "================================" echo "ReiLua - Release Build" @@ -17,6 +17,53 @@ if [ ! -f "CMakeLists.txt" ]; then exit 1 fi +# Check for dependencies on macOS +if [[ "$OSTYPE" == "darwin"* ]]; then + echo "Checking macOS build configuration..." + + # Check if static libraries exist + if [ -f "../lib/macos/libraylib.a" ] && [ -f "../lib/macos/liblua.a" ]; then + echo "✓ Static libraries found - building for distribution" + echo " (Single-file executable, no dependencies)" + echo "" + else + echo "⚠️ Static libraries not found - using Homebrew libraries" + echo "" + echo "This build will require raylib/lua at runtime." + echo "" + echo "For distribution builds (single executable), run:" + echo " ./scripts/macos/build_static_libs.sh" + echo "" + + # Check for Homebrew dependencies + MISSING_DEPS=() + + if ! brew list glfw &>/dev/null; then + MISSING_DEPS+=("glfw") + fi + + if ! brew list raylib &>/dev/null; then + MISSING_DEPS+=("raylib") + fi + + if ! brew list lua &>/dev/null; then + MISSING_DEPS+=("lua") + fi + + if [ ${#MISSING_DEPS[@]} -gt 0 ]; then + echo "ERROR: Missing Homebrew packages: ${MISSING_DEPS[*]}" + echo "" + echo "Install with:" + echo " brew install ${MISSING_DEPS[*]} pkg-config" + echo "" + exit 1 + fi + + echo "✓ Homebrew dependencies found" + echo "" + fi +fi + # Create and navigate to build directory mkdir -p build cd build || exit 1 @@ -88,10 +135,25 @@ echo "" echo "Cleaning CMake cache..." rm -rf CMakeCache.txt CMakeFiles/ +# Detect platform and set appropriate generator +if [[ "$OSTYPE" == "darwin"* ]]; then + # macOS + CMAKE_GENERATOR="Unix Makefiles" + BUILD_CMD="make" +elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "mingw"* ]]; then + # Windows with MinGW + CMAKE_GENERATOR="MinGW Makefiles" + BUILD_CMD="make" +else + # Linux and others + CMAKE_GENERATOR="Unix Makefiles" + BUILD_CMD="make" +fi + # Configure with embedding enabled echo "" -echo "Configuring CMake for release..." -cmake -G "MinGW Makefiles" .. -DEMBED_MAIN=ON -DEMBED_ASSETS=$EMBED_ASSETS -DCMAKE_BUILD_TYPE=Release +echo "Configuring CMake for release (${OSTYPE})..." +cmake -G "$CMAKE_GENERATOR" .. -DEMBED_MAIN=ON -DEMBED_ASSETS=$EMBED_ASSETS -DCMAKE_BUILD_TYPE=Release if [ $? -ne 0 ]; then echo "" @@ -102,7 +164,7 @@ fi # Build echo "" echo "Building ReiLua Release..." -make +$BUILD_CMD if [ $? -ne 0 ]; then echo "" @@ -137,19 +199,27 @@ echo "" echo "================================" echo "Build Complete!" echo "================================" -EXESIZE=$(du -h ReiLua.exe | cut -f1) + +# Detect executable name based on platform +if [[ "$OSTYPE" == "darwin"* ]]; then + EXE_NAME="ReiLua" +else + EXE_NAME="ReiLua.exe" +fi + +EXESIZE=$(du -h "$EXE_NAME" | cut -f1) echo "" -echo "Executable: ReiLua.exe ($EXESIZE)" -echo "Location: $(pwd)/ReiLua.exe" +echo "Executable: $EXE_NAME ($EXESIZE)" +echo "Location: $(pwd)/$EXE_NAME" echo "" echo "Your game is ready for distribution!" echo "" echo "To test the release build:" -echo " ./ReiLua.exe --log (with console)" -echo " ./ReiLua.exe (production mode)" +echo " ./$EXE_NAME --log (with console)" +echo " ./$EXE_NAME (production mode)" echo "" echo "To distribute:" -echo " - Copy ReiLua.exe to your distribution folder" +echo " - Copy $EXE_NAME to your distribution folder" echo " - Rename it to your game name (optional)" echo " - That's it! Single file distribution!" echo "" diff --git a/scripts/create_project.sh b/scripts/create_project.sh new file mode 100755 index 0000000..e6a2173 --- /dev/null +++ b/scripts/create_project.sh @@ -0,0 +1,578 @@ +#!/bin/bash +# ReiLua-Enhanced Project Setup Script +# Creates a new game project with custom metadata + +set -e + +echo "╔════════════════════════════════════════════════════════════════════╗" +echo "║ ║" +echo "║ ReiLua-Enhanced - Project Setup Wizard ║" +echo "║ ║" +echo "╚════════════════════════════════════════════════════════════════════╝" +echo "" + +# Get script directory (ReiLua-Enhanced root) +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd "$SCRIPT_DIR" + +# Function to validate alphanumeric input +validate_alphanumeric() { + if [[ ! "$1" =~ ^[a-zA-Z0-9]+$ ]]; then + return 1 + fi + return 0 +} + +# Get project information +echo "Please provide your project information:" +echo "==========================================" +echo "" + +# Project Name +while true; do + read -p "Project Name (alphanumeric only, e.g., MyAwesomeGame): " PROJECT_NAME + if validate_alphanumeric "$PROJECT_NAME"; then + break + else + echo "❌ Invalid! Use only letters and numbers (no spaces or symbols)." + fi +done + +# Executable Name +read -p "Executable Name (default: $PROJECT_NAME): " EXECUTABLE_NAME +EXECUTABLE_NAME=${EXECUTABLE_NAME:-$PROJECT_NAME} + +# Author Name +read -p "Author Name: " AUTHOR_NAME +if [ -z "$AUTHOR_NAME" ]; then + AUTHOR_NAME="Unknown Author" +fi + +# Author Email +read -p "Author Email: " AUTHOR_EMAIL +if [ -z "$AUTHOR_EMAIL" ]; then + AUTHOR_EMAIL="author@example.com" +fi + +# Description +read -p "Project Description: " DESCRIPTION +if [ -z "$DESCRIPTION" ]; then + DESCRIPTION="A game made with ReiLua" +fi + +# Company/Organization (for bundle identifier) +read -p "Company/Organization (for bundle ID, default: reilua): " COMPANY +COMPANY=${COMPANY:-reilua} + +# Convert to lowercase and remove spaces for bundle ID +BUNDLE_ID=$(echo "${COMPANY}.${PROJECT_NAME}" | tr '[:upper:]' '[:lower:]' | tr -d ' ') + +# Version +read -p "Version (default: 1.0.0): " VERSION +VERSION=${VERSION:-1.0.0} + +echo "" +echo "==========================================" +echo "Project Summary:" +echo "==========================================" +echo "Project Name: $PROJECT_NAME" +echo "Executable: $EXECUTABLE_NAME" +echo "Author: $AUTHOR_NAME" +echo "Email: $AUTHOR_EMAIL" +echo "Description: $DESCRIPTION" +echo "Bundle ID: $BUNDLE_ID" +echo "Version: $VERSION" +echo "==========================================" +echo "" + +read -p "Create project with these settings? (Y/n): " -n 1 -r +echo "" +if [[ ! $REPLY =~ ^[Yy]$ ]] && [[ ! -z $REPLY ]]; then + echo "Setup cancelled." + exit 0 +fi + +# Create project directory +PROJECTS_ROOT="$SCRIPT_DIR/../projects" +mkdir -p "$PROJECTS_ROOT" + +PROJECT_DIR="$PROJECTS_ROOT/${PROJECT_NAME}" + +if [ -d "$PROJECT_DIR" ]; then + echo "" + echo "❌ ERROR: Directory 'projects/$PROJECT_NAME' already exists!" + read -p "Delete it and continue? (y/N): " -n 1 -r + echo "" + if [[ $REPLY =~ ^[Yy]$ ]]; then + rm -rf "$PROJECT_DIR" + else + echo "Setup cancelled." + exit 1 + fi +fi + +echo "" +echo "Creating project directory: projects/$PROJECT_NAME" +mkdir -p "$PROJECT_DIR" + +# Copy ReiLua structure +echo "Copying ReiLua-Enhanced files..." + +# Create directory structure first +mkdir -p "$PROJECT_DIR"/{src,include,lib,scripts/macos,fonts,logo,cmake} + +# Copy files using find to preserve structure, excluding unnecessary files +(cd "$SCRIPT_DIR/.." && \ + find . -type f \ + ! -path './build/*' \ + ! -path './deps/*' \ + ! -path './.git/*' \ + ! -path './projects/*' \ + ! -path './docs/*' \ + ! -path './docs_md/*' \ + ! -path './examples/*' \ + ! -path './template/*' \ + ! -path './tools/*' \ + ! -name '*.app' \ + ! -name '*.dmg' \ + ! -name '*.zip' \ + ! -name '*.o' \ + ! -name '*.md' \ + ! -name 'changelog' \ + ! -name 'devnotes' \ + ! -name '*.png' \ + ! -name 'LICENSE' \ + ! -name 'zed.sample.settings.json' \ + ! -name 'create_project.sh' \ + -exec sh -c 'mkdir -p "$0/$(dirname "{}")" && cp "{}" "$0/{}"' "$PROJECT_DIR" \;) + +echo "✓ Files copied (essentials only: src, lib, scripts, assets)" +echo "" +echo "Setting up project files..." + +# Get absolute paths for lua and raylib (sibling to ReiLua-Enhanced) +LUA_PATH="$(cd "$SCRIPT_DIR/.." && pwd)/lua" +RAYLIB_PATH="$(cd "$SCRIPT_DIR/.." && pwd)/raylib" + +# Update build_static_libs.sh with correct paths +if [ -f "$PROJECT_DIR/scripts/macos/build_static_libs.sh" ]; then + cat > "$PROJECT_DIR/scripts/macos/build_static_libs.sh" << 'EOFSCRIPT' +#!/bin/bash +# Build static raylib and lua libraries for macOS + +set -e + +echo "========================================" +echo "Building Static Libraries for macOS" +echo "========================================" +echo "" + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +PROJECT_ROOT="$SCRIPT_DIR/../.." +cd "$PROJECT_ROOT" + +# Look for lua and raylib as siblings to this project +LUA_SRC="$(cd "$PROJECT_ROOT/.." && pwd)/lua" +RAYLIB_SRC="$(cd "$PROJECT_ROOT/.." && pwd)/raylib" + +if [ ! -d "$LUA_SRC" ]; then + echo "ERROR: Lua source not found at: $LUA_SRC" + echo "" + echo "Expected: ../lua relative to project" + exit 1 +fi + +if [ ! -d "$RAYLIB_SRC" ]; then + echo "ERROR: Raylib source not found at: $RAYLIB_SRC" + echo "" + echo "Expected: ../raylib relative to project" + exit 1 +fi + +echo "Using sources:" +echo " Lua: $LUA_SRC" +echo " Raylib: $RAYLIB_SRC" +echo "" + +mkdir -p "$PROJECT_ROOT/lib/macos" + +# Build Lua +echo "========================================" +echo "Building Lua 5.4 (static)" +echo "========================================" +cd "$LUA_SRC" +make clean || true + +CFLAGS="-O2 -Wall -DLUA_USE_MACOSX -DLUA_USE_DLOPEN" +OBJS="" +for file in lapi lcode lctype ldebug ldo ldump lfunc lgc llex lmem lobject lopcodes lparser lstate lstring ltable ltm lundump lvm lzio lauxlib lbaselib ldblib liolib lmathlib loslib ltablib lstrlib lutf8lib loadlib lcorolib linit; do + cc $CFLAGS -c ${file}.c -o ${file}.o + OBJS="$OBJS ${file}.o" +done +ar rcs liblua.a $OBJS +cp liblua.a "$PROJECT_ROOT/lib/macos/" +LUASIZE=$(du -h "$PROJECT_ROOT/lib/macos/liblua.a" | cut -f1) +echo "✓ Lua: $LUASIZE" + +# Build Raylib +echo "" +echo "========================================" +echo "Building Raylib 5.5 (static)" +echo "========================================" +cd "$RAYLIB_SRC" +rm -rf build_static +mkdir -p build_static && cd build_static +cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DBUILD_EXAMPLES=OFF -DUSE_EXTERNAL_GLFW=OFF -DCUSTOMIZE_BUILD=ON +make -j$(sysctl -n hw.ncpu) +cp raylib/libraylib.a "$PROJECT_ROOT/lib/macos/" +RAYLIBSIZE=$(du -h "$PROJECT_ROOT/lib/macos/libraylib.a" | cut -f1) +echo "✓ Raylib: $RAYLIBSIZE" + +echo "" +echo "Static libraries ready in lib/macos/" +EOFSCRIPT + chmod +x "$PROJECT_DIR/scripts/macos/build_static_libs.sh" +fi + +# Create custom resources.rc for Windows +cat > "$PROJECT_DIR/resources.rc" << EOFRC +IDI_ICON1 ICON "icon.ico" + +1 VERSIONINFO +FILEVERSION ${VERSION//./,},0 +PRODUCTVERSION ${VERSION//./,},0 +FILEFLAGSMASK 0x3fL +FILEFLAGS 0x0L +FILEOS 0x40004L +FILETYPE 0x1L +FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "$AUTHOR_NAME" + VALUE "FileDescription", "$DESCRIPTION" + VALUE "FileVersion", "$VERSION" + VALUE "InternalName", "$EXECUTABLE_NAME" + VALUE "LegalCopyright", "Copyright (C) $AUTHOR_NAME, $(date +%Y)" + VALUE "OriginalFilename", "${EXECUTABLE_NAME}.exe" + VALUE "ProductName", "$PROJECT_NAME" + VALUE "ProductVersion", "$VERSION" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END +EOFRC + +# Create updated create_app_bundle.sh for macOS +cat > "$PROJECT_DIR/scripts/macos/create_app_bundle.sh" << 'EOFBUNDLE' +#!/bin/bash +# Create macOS App Bundle with Icon and Metadata + +set -e + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +PROJECT_ROOT="$SCRIPT_DIR/../.." +cd "$PROJECT_ROOT" + +# Read project metadata +PROJECT_NAME="__PROJECT_NAME__" +EXECUTABLE_NAME="__EXECUTABLE_NAME__" +BUNDLE_ID="__BUNDLE_ID__" +VERSION="__VERSION__" +AUTHOR_NAME="__AUTHOR_NAME__" +DESCRIPTION="__DESCRIPTION__" + +if [ ! -f "build/ReiLua" ]; then + echo "ERROR: ReiLua executable not found! Build first." + exit 1 +fi + +APP_NAME="${1:-$EXECUTABLE_NAME}" +APP_BUNDLE="${APP_NAME}.app" + +echo "Creating $APP_BUNDLE..." +mkdir -p "$APP_BUNDLE/Contents/MacOS" +mkdir -p "$APP_BUNDLE/Contents/Resources" + +cp build/ReiLua "$APP_BUNDLE/Contents/MacOS/$APP_NAME" +chmod +x "$APP_BUNDLE/Contents/MacOS/$APP_NAME" + +# Convert icon +ICNS_FILE="$APP_BUNDLE/Contents/Resources/icon.icns" +if [ -f "icon.ico" ]; then + mkdir -p icon.iconset + sips -s format png icon.ico --out icon.iconset/icon_512x512.png -z 512 512 2>/dev/null || true + if [ -f "icon.iconset/icon_512x512.png" ]; then + sips -z 256 256 icon.iconset/icon_512x512.png --out icon.iconset/icon_256x256.png + sips -z 128 128 icon.iconset/icon_512x512.png --out icon.iconset/icon_128x128.png + sips -z 64 64 icon.iconset/icon_512x512.png --out icon.iconset/icon_64x64.png + sips -z 32 32 icon.iconset/icon_512x512.png --out icon.iconset/icon_32x32.png + sips -z 16 16 icon.iconset/icon_512x512.png --out icon.iconset/icon_16x16.png + cp icon.iconset/icon_512x512.png icon.iconset/icon_256x256@2x.png + cp icon.iconset/icon_256x256.png icon.iconset/icon_128x128@2x.png + cp icon.iconset/icon_128x128.png icon.iconset/icon_64x64@2x.png + cp icon.iconset/icon_64x64.png icon.iconset/icon_32x32@2x.png + cp icon.iconset/icon_32x32.png icon.iconset/icon_16x16@2x.png + iconutil -c icns icon.iconset -o "$ICNS_FILE" + fi + rm -rf icon.iconset +fi + +# Create Info.plist with project metadata +cat > "$APP_BUNDLE/Contents/Info.plist" << EOF +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleExecutable</key> + <string>$APP_NAME</string> + <key>CFBundleIconFile</key> + <string>icon.icns</string> + <key>CFBundleIdentifier</key> + <string>$BUNDLE_ID</string> + <key>CFBundleName</key> + <string>$PROJECT_NAME</string> + <key>CFBundleDisplayName</key> + <string>$PROJECT_NAME</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleShortVersionString</key> + <string>$VERSION</string> + <key>CFBundleVersion</key> + <string>$VERSION</string> + <key>NSHumanReadableCopyright</key> + <string>Copyright © $(date +%Y) $AUTHOR_NAME. All rights reserved.</string> + <key>LSMinimumSystemVersion</key> + <string>10.12</string> + <key>NSHighResolutionCapable</key> + <true/> +</dict> +</plist> +EOF + +echo "✓ $APP_BUNDLE created!" +echo " open $APP_BUNDLE" +EOFBUNDLE + +# Replace placeholders in create_app_bundle.sh +if [ -f "$PROJECT_DIR/scripts/macos/create_app_bundle.sh" ]; then + # Cross-platform sed: detect OS and use appropriate syntax + if [[ "$OSTYPE" == "darwin"* ]]; then + # macOS requires empty string after -i + SED_INPLACE="sed -i ''" + else + # Linux/Windows Git Bash + SED_INPLACE="sed -i" + fi + + $SED_INPLACE "s/__PROJECT_NAME__/$PROJECT_NAME/g" "$PROJECT_DIR/scripts/macos/create_app_bundle.sh" + $SED_INPLACE "s/__EXECUTABLE_NAME__/$EXECUTABLE_NAME/g" "$PROJECT_DIR/scripts/macos/create_app_bundle.sh" + $SED_INPLACE "s/__BUNDLE_ID__/$BUNDLE_ID/g" "$PROJECT_DIR/scripts/macos/create_app_bundle.sh" + $SED_INPLACE "s/__VERSION__/$VERSION/g" "$PROJECT_DIR/scripts/macos/create_app_bundle.sh" + $SED_INPLACE "s/__AUTHOR_NAME__/$AUTHOR_NAME/g" "$PROJECT_DIR/scripts/macos/create_app_bundle.sh" + $SED_INPLACE "s/__DESCRIPTION__/$DESCRIPTION/g" "$PROJECT_DIR/scripts/macos/create_app_bundle.sh" + chmod +x "$PROJECT_DIR/scripts/macos/create_app_bundle.sh" +fi + +# Create project metadata file +cat > "$PROJECT_DIR/project.info" << EOFINFO +# Project Information +PROJECT_NAME=$PROJECT_NAME +EXECUTABLE_NAME=$EXECUTABLE_NAME +AUTHOR_NAME=$AUTHOR_NAME +AUTHOR_EMAIL=$AUTHOR_EMAIL +DESCRIPTION=$DESCRIPTION +BUNDLE_ID=$BUNDLE_ID +VERSION=$VERSION +COMPANY=$COMPANY +CREATED=$(date +%Y-%m-%d) +EOFINFO + +# Create README for the project +cat > "$PROJECT_DIR/README.md" << EOFREADME +# $PROJECT_NAME + +$DESCRIPTION + +## Project Information + +- **Author:** $AUTHOR_NAME <$AUTHOR_EMAIL> +- **Version:** $VERSION +- **Created:** $(date +%Y-%m-%d) +- **Built with:** ReiLua-Enhanced + +## Building + +### Development Build +\`\`\`bash +./scripts/build_dev.sh +\`\`\` + +### Release Build +\`\`\`bash +# Copy your Lua files and assets +mkdir -p build +cp *.lua build/ +cp -r assets build/ + +# Build +./scripts/build_release.sh +\`\`\` + +### macOS App Bundle +\`\`\`bash +./scripts/macos/create_app_bundle.sh +\`\`\` + +## Project Structure + +\`\`\` +$PROJECT_NAME/ +├── main.lua # Your game entry point +├── assets/ # Game assets (images, sounds, etc.) +├── build/ # Build output directory +├── scripts/ # Build scripts +│ ├── build_dev.sh +│ ├── build_release.sh +│ └── macos/ +│ ├── build_static_libs.sh +│ └── create_app_bundle.sh +├── src/ # ReiLua C source +├── include/ # Headers +└── lib/ # Static libraries +\`\`\` + +## Game Development + +Edit \`main.lua\` and add your game code: + +\`\`\`lua +function init() + -- Initialize your game +end + +function update(dt) + -- Update game logic +end + +function draw() + -- Draw your game +end +\`\`\` + +## Distribution + +### Windows +\`\`\`bash +# After build_release.sh +# The executable is: build/${EXECUTABLE_NAME}.exe +\`\`\` + +### macOS +\`\`\`bash +# Create app bundle +./scripts/macos/create_app_bundle.sh + +# Create DMG for distribution +hdiutil create -volname '$PROJECT_NAME' \\ + -srcfolder '${EXECUTABLE_NAME}.app' \\ + -ov -format UDZO ${EXECUTABLE_NAME}.dmg +\`\`\` + +### Linux +\`\`\`bash +# After build_release.sh +# The executable is: build/ReiLua (rename to ${EXECUTABLE_NAME}) +\`\`\` + +## License + +Add your license information here. + +--- + +Built with [ReiLua-Enhanced](https://github.com/nullstare/ReiLua) +EOFREADME + +# Create example main.lua +cat > "$PROJECT_DIR/main.lua" << EOFLUA +-- $PROJECT_NAME +-- $DESCRIPTION +-- Author: $AUTHOR_NAME + +function init() + print("$PROJECT_NAME initialized!") + print("Version: $VERSION") + print("Author: $AUTHOR_NAME") + + -- Initialize your game here +end + +function update(dt) + -- Update game logic here + -- dt = delta time in seconds +end + +function draw() + -- Draw your game here + RL.clearBackground(RL.RAYWHITE) + + RL.drawText("$PROJECT_NAME", 10, 10, 40, RL.BLACK) + RL.drawText("Press ESC to exit", 10, 60, 20, RL.DARKGRAY) + + if RL.isKeyPressed(RL.KEY_ESCAPE) then + RL.closeWindow() + end +end +EOFLUA + +# Create assets directory +mkdir -p "$PROJECT_DIR/assets" +cat > "$PROJECT_DIR/assets/.gitkeep" << EOFKEEP +# Place your game assets here: +# - Images (.png, .jpg) +# - Sounds (.wav, .ogg, .mp3) +# - Fonts (.ttf) +# - Other resources +EOFKEEP + +echo "" +echo "╔════════════════════════════════════════════════════════════════════╗" +echo "║ ║" +echo "║ ✅ Project Setup Complete! ✅ ║" +echo "║ ║" +echo "╚════════════════════════════════════════════════════════════════════╝" +echo "" +echo "Project Details:" +echo " Name: $PROJECT_NAME" +echo " Location: projects/$PROJECT_NAME" +echo " Executable: $EXECUTABLE_NAME" +echo " Author: $AUTHOR_NAME" +echo "" +echo "Next Steps:" +echo " 1. cd projects/$PROJECT_NAME" +echo " 2. Edit main.lua (your game code)" +echo " 3. Add assets to assets/ folder" +echo " 4. Build: ./scripts/build_dev.sh" +echo " 5. Run: ./build/ReiLua" +echo "" +echo "Files Created:" +echo " ✓ main.lua - Game entry point" +echo " ✓ project.info - Project metadata" +echo " ✓ README.md - Project documentation" +echo " ✓ resources.rc - Windows metadata (embedded in .exe)" +echo " ✓ scripts/macos/create_app_bundle.sh - macOS bundle with metadata" +echo " ✓ assets/ - Asset directory" +echo "" +echo "Build Scripts Updated:" +echo " ✓ Lua path: ../lua (sibling directory)" +echo " ✓ Raylib path: ../raylib (sibling directory)" +echo "" +echo "All projects are in: projects/ folder" +echo "Happy game development! 🎮" +echo "" diff --git a/scripts/macos/build_static_libs.sh b/scripts/macos/build_static_libs.sh new file mode 100755 index 0000000..90f82a8 --- /dev/null +++ b/scripts/macos/build_static_libs.sh @@ -0,0 +1,149 @@ +#!/bin/bash +# Build static raylib and lua libraries for macOS +# This creates static libraries that can be linked into ReiLua for distribution + +set -e # Exit on error + +echo "========================================" +echo "Building Static Libraries for macOS" +echo "========================================" +echo "" + +# Get script directory +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +PROJECT_ROOT="$SCRIPT_DIR/../.." +cd "$PROJECT_ROOT" + +# Use source directories relative to project root (one level up, then into folders) +LUA_SRC="$(cd "$PROJECT_ROOT/.." && pwd)/lua" +RAYLIB_SRC="$(cd "$PROJECT_ROOT/.." && pwd)/raylib" + +# Check for required tools +if ! command -v cmake &> /dev/null; then + echo "ERROR: cmake is required but not installed." + echo "Install with: brew install cmake" + exit 1 +fi + +# Check that source directories exist +if [ ! -d "$LUA_SRC" ]; then + echo "ERROR: Lua source not found at: $LUA_SRC" + echo "" + echo "Expected directory structure:" + echo " /path/to/tools/" + echo " ├── ReiLua-Enhanced/ (this project)" + echo " ├── lua/ (Lua source)" + echo " └── raylib/ (Raylib source)" + echo "" + exit 1 +fi + +if [ ! -d "$RAYLIB_SRC" ]; then + echo "ERROR: Raylib source not found at: $RAYLIB_SRC" + echo "" + echo "Expected directory structure:" + echo " /path/to/tools/" + echo " ├── ReiLua-Enhanced/ (this project)" + echo " ├── lua/ (Lua source)" + echo " └── raylib/ (Raylib source)" + echo "" + exit 1 +fi + +echo "Using existing sources:" +echo " Lua: $LUA_SRC" +echo " Raylib: $RAYLIB_SRC" +echo "" + +# Create lib/macos directory +mkdir -p "$PROJECT_ROOT/lib/macos" + +# Build Lua +echo "========================================" +echo "Building Lua 5.4 (static)" +echo "========================================" +echo "" + +cd "$LUA_SRC" +echo "Compiling Lua..." + +# Clean previous build +make clean || true + +# Compile Lua core files +CFLAGS="-O2 -Wall -DLUA_USE_MACOSX -DLUA_USE_DLOPEN" +OBJS="" + +for file in lapi lcode lctype ldebug ldo ldump lfunc lgc llex lmem lobject lopcodes lparser lstate lstring ltable ltm lundump lvm lzio lauxlib lbaselib ldblib liolib lmathlib loslib ltablib lstrlib lutf8lib loadlib lcorolib linit; do + echo " Compiling ${file}.c..." + cc $CFLAGS -c ${file}.c -o ${file}.o + OBJS="$OBJS ${file}.o" +done + +# Create static library +echo "Creating static library..." +ar rcs liblua.a $OBJS + +# Copy to lib directory +echo "Installing Lua static library..." +cp liblua.a "$PROJECT_ROOT/lib/macos/" +LUASIZE=$(du -h "$PROJECT_ROOT/lib/macos/liblua.a" | cut -f1) +echo "✓ Lua static library: lib/macos/liblua.a ($LUASIZE)" +echo "" + +# Build Raylib +echo "========================================" +echo "Building Raylib 5.5 (static)" +echo "========================================" +echo "" + +cd "$RAYLIB_SRC" +rm -rf build_static +mkdir -p build_static +cd build_static + +echo "Configuring Raylib..." +cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=OFF \ + -DBUILD_EXAMPLES=OFF \ + -DUSE_EXTERNAL_GLFW=OFF \ + -DCUSTOMIZE_BUILD=ON + +echo "Compiling Raylib..." +make -j$(sysctl -n hw.ncpu) + +# Copy to lib directory +echo "Installing Raylib static library..." +cp raylib/libraylib.a "$PROJECT_ROOT/lib/macos/" +RAYLIBSIZE=$(du -h "$PROJECT_ROOT/lib/macos/libraylib.a" | cut -f1) +echo "✓ Raylib static library: lib/macos/libraylib.a ($RAYLIBSIZE)" +echo "" + +cd "$PROJECT_ROOT" + +# Verify libraries +echo "========================================" +echo "Verification" +echo "========================================" +echo "" +ls -lh lib/macos/*.a +echo "" +file lib/macos/liblua.a +file lib/macos/libraylib.a +echo "" + +echo "========================================" +echo "Success! Static libraries built." +echo "========================================" +echo "" +echo "Libraries created in: lib/macos/" +echo " - liblua.a ($LUASIZE)" +echo " - libraylib.a ($RAYLIBSIZE)" +echo "" +echo "You can now build ReiLua with static linking." +echo "Run: ./scripts/build_dev.sh" +echo "" +echo "This will create a single-file executable that" +echo "doesn't require users to install raylib or lua!" +echo "" diff --git a/scripts/macos/create_app_bundle.sh b/scripts/macos/create_app_bundle.sh new file mode 100755 index 0000000..ec3f316 --- /dev/null +++ b/scripts/macos/create_app_bundle.sh @@ -0,0 +1,152 @@ +#!/bin/bash +# Create macOS App Bundle with Icon +# This creates a proper .app bundle for distribution on macOS + +set -e + +echo "========================================" +echo "Creating macOS App Bundle" +echo "========================================" +echo "" + +# Get script directory +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +PROJECT_ROOT="$SCRIPT_DIR/../.." +cd "$PROJECT_ROOT" + +# Check if executable exists +if [ ! -f "build/ReiLua" ]; then + echo "ERROR: ReiLua executable not found!" + echo "Please run ./scripts/build_dev.sh or ./scripts/build_release.sh first" + exit 1 +fi + +# App name (can be customized) +APP_NAME="${1:-ReiLua}" +APP_BUNDLE="${APP_NAME}.app" + +echo "Creating app bundle: $APP_BUNDLE" +echo "" + +# Create app bundle structure +mkdir -p "$APP_BUNDLE/Contents/MacOS" +mkdir -p "$APP_BUNDLE/Contents/Resources" + +# Copy executable +echo "Copying executable..." +cp build/ReiLua "$APP_BUNDLE/Contents/MacOS/$APP_NAME" +chmod +x "$APP_BUNDLE/Contents/MacOS/$APP_NAME" + +# Convert icon.ico to .icns if needed +ICNS_FILE="$APP_BUNDLE/Contents/Resources/icon.icns" + +if [ -f "icon.ico" ]; then + echo "Converting icon..." + + # Create temporary iconset directory + mkdir -p icon.iconset + + # Use sips to convert and resize (macOS built-in tool) + # Extract from .ico and create different sizes + sips -s format png icon.ico --out icon.iconset/icon_512x512.png -z 512 512 2>/dev/null || { + echo "Note: sips conversion had warnings, using ImageMagick if available..." + if command -v convert &> /dev/null; then + convert icon.ico -resize 512x512 icon.iconset/icon_512x512.png + else + echo "WARNING: Could not convert icon. Install ImageMagick with: brew install imagemagick" + echo " Or provide an icon.png file at 512x512 resolution" + fi + } + + # Create other required sizes if we have the 512x512 version + if [ -f "icon.iconset/icon_512x512.png" ]; then + sips -z 256 256 icon.iconset/icon_512x512.png --out icon.iconset/icon_256x256.png + sips -z 128 128 icon.iconset/icon_512x512.png --out icon.iconset/icon_128x128.png + sips -z 64 64 icon.iconset/icon_512x512.png --out icon.iconset/icon_64x64.png + sips -z 32 32 icon.iconset/icon_512x512.png --out icon.iconset/icon_32x32.png + sips -z 16 16 icon.iconset/icon_512x512.png --out icon.iconset/icon_16x16.png + + # Create @2x versions (retina) + cp icon.iconset/icon_512x512.png icon.iconset/icon_256x256@2x.png + cp icon.iconset/icon_256x256.png icon.iconset/icon_128x128@2x.png + cp icon.iconset/icon_128x128.png icon.iconset/icon_64x64@2x.png + cp icon.iconset/icon_64x64.png icon.iconset/icon_32x32@2x.png + cp icon.iconset/icon_32x32.png icon.iconset/icon_16x16@2x.png + + # Convert to .icns + iconutil -c icns icon.iconset -o "$ICNS_FILE" + echo "✓ Icon created: $ICNS_FILE" + fi + + # Clean up + rm -rf icon.iconset +else + echo "WARNING: icon.ico not found, app will have no icon" +fi + +# Create Info.plist +echo "Creating Info.plist..." +cat > "$APP_BUNDLE/Contents/Info.plist" << EOF +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleExecutable</key> + <string>$APP_NAME</string> + <key>CFBundleIconFile</key> + <string>icon.icns</string> + <key>CFBundleIdentifier</key> + <string>com.reilua.$APP_NAME</string> + <key>CFBundleName</key> + <string>$APP_NAME</string> + <key>CFBundleDisplayName</key> + <string>$APP_NAME</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleShortVersionString</key> + <string>1.0.0</string> + <key>CFBundleVersion</key> + <string>1</string> + <key>LSMinimumSystemVersion</key> + <string>10.12</string> + <key>NSHighResolutionCapable</key> + <true/> + <key>NSSupportsAutomaticGraphicsSwitching</key> + <true/> +</dict> +</plist> +EOF + +echo "✓ Info.plist created" +echo "" + +# Get app size +APP_SIZE=$(du -sh "$APP_BUNDLE" | cut -f1) + +echo "========================================" +echo "App Bundle Created!" +echo "========================================" +echo "" +echo "App: $APP_BUNDLE" +echo "Size: $APP_SIZE" +echo "Location: $(pwd)/$APP_BUNDLE" +echo "" +echo "To test:" +echo " open $APP_BUNDLE" +echo "" +echo "To distribute:" +echo " 1. Zip the .app bundle:" +echo " zip -r ${APP_NAME}.zip $APP_BUNDLE" +echo "" +echo " 2. Or create a DMG (requires hdiutil):" +echo " hdiutil create -volname '$APP_NAME' -srcfolder '$APP_BUNDLE' -ov -format UDZO ${APP_NAME}.dmg" +echo "" +echo "The app bundle includes:" +echo " - Executable: $APP_BUNDLE/Contents/MacOS/$APP_NAME" +if [ -f "$ICNS_FILE" ]; then +echo " - Icon: $APP_BUNDLE/Contents/Resources/icon.icns" +else +echo " - Icon: (not available, provide icon.ico or icon.png)" +fi +echo " - Info.plist with app metadata" +echo "" |
