Files
tc.preset/build.sh

110 lines
3.1 KiB
Bash
Executable File

#!/bin/bash
# Max Package Build Script
# Builds version-specific packages for Max 8 and Max 9
# Generated by Claude Sonnet 4.5
set -e # Exit on error
# Configuration
PACKAGE_NAME="tc.preset"
DIST_DIR="./dist"
MAX8_DIR="$DIST_DIR/Max 8/$PACKAGE_NAME"
MAX9_DIR="$DIST_DIR/Max 9/$PACKAGE_NAME"
INSTALL_MAX8="$HOME/Documents/Max 8/Packages/$PACKAGE_NAME"
INSTALL_MAX9="$HOME/Documents/Max 9/Packages/$PACKAGE_NAME"
echo "Building Max packages..."
# Clean and create dist directories
rm -rf "$DIST_DIR"
mkdir -p "$MAX8_DIR"
mkdir -p "$MAX9_DIR"
# Function to copy files recursively
copy_files() {
local target_dir=$1
local prefix=$2
# Find all files (not directories) in the repo
find . -type f \
-not -path "*/.*" \
-not -path "./dist/*" \
-not -path "./media/*" \
-not -name "build.sh" | while read -r file; do
# Get filename without path
local filename=$(basename "$file")
# Get relative path from repo root
local relpath="${file#./}"
local dirpath=$(dirname "$relpath")
# Determine if file should be copied to this version
if [[ $filename == max8.* ]] && [[ $prefix == "max8" ]]; then
# Remove max8. prefix and copy
local newname="${filename#max8.}"
local target="$target_dir/$dirpath/$newname"
mkdir -p "$(dirname "$target")"
cp "$file" "$target"
echo "$relpath (as $dirpath/$newname) [Max 8]"
elif [[ $filename == max9.* ]] && [[ $prefix == "max9" ]]; then
# Remove max9. prefix and copy
local newname="${filename#max9.}"
local target="$target_dir/$dirpath/$newname"
mkdir -p "$(dirname "$target")"
cp "$file" "$target"
echo "$relpath (as $dirpath/$newname) [Max 9]"
elif [[ $filename != max8.* ]] && [[ $filename != max9.* ]]; then
# Copy shared files to both versions
local target="$target_dir/$relpath"
mkdir -p "$(dirname "$target")"
cp "$file" "$target"
echo "$relpath [shared]"
fi
done
}
echo ""
echo "Building Max 8 version..."
copy_files "$MAX8_DIR" "max8"
echo ""
echo "Building Max 9 version..."
copy_files "$MAX9_DIR" "max9"
echo ""
echo "Build complete!"
echo ""
echo "Max 8 package: $MAX8_DIR"
echo "Max 9 package: $MAX9_DIR"
echo ""
# Ask to install
read -p "Install to Max Packages folders (~/Documents/Max <8|9>/Packages)? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Installing packages..."
# Create Packages directories if they don't exist
mkdir -p "$HOME/Documents/Max 8/Packages"
mkdir -p "$HOME/Documents/Max 9/Packages"
# Copy to Max 8
if [ -d "$INSTALL_MAX8" ]; then
rm -rf "$INSTALL_MAX8"
fi
cp -r "$MAX8_DIR" "$INSTALL_MAX8"
echo "✓ Installed to $INSTALL_MAX8"
# Copy to Max 9
if [ -d "$INSTALL_MAX9" ]; then
rm -rf "$INSTALL_MAX9"
fi
cp -r "$MAX9_DIR" "$INSTALL_MAX9"
echo "✓ Installed to $INSTALL_MAX9"
echo ""
echo "Installation complete!"
else
echo "Skipped installation."
fi