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/macos | |
| 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/macos')
| -rwxr-xr-x | scripts/macos/build_static_libs.sh | 149 | ||||
| -rwxr-xr-x | scripts/macos/create_app_bundle.sh | 152 |
2 files changed, 301 insertions, 0 deletions
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 "" |
