From c37208f961542ee2b799bb652974c57b84f6e3df Mon Sep 17 00:00:00 2001 From: asrael Date: Wed, 5 Nov 2025 13:33:47 -0600 Subject: [PATCH] add pxl8-ase.sh tool script --- pxl8.sh | 169 ++++++++++++++++++------------------- tools/aseprite/package.sh | 21 ----- tools/aseprite/pxl8-ase.sh | 76 +++++++++++++++++ 3 files changed, 160 insertions(+), 106 deletions(-) delete mode 100755 tools/aseprite/package.sh create mode 100755 tools/aseprite/pxl8-ase.sh diff --git a/pxl8.sh b/pxl8.sh index b8dd467..3b2518c 100755 --- a/pxl8.sh +++ b/pxl8.sh @@ -37,7 +37,6 @@ esac RED='\033[0;31m' GREEN='\033[0;32m' -BLUE='\033[0;34m' BOLD='\033[1m' NC='\033[0m' @@ -45,6 +44,30 @@ if [[ "$(uname)" == "Linux" ]]; then CFLAGS="$CFLAGS -D_GNU_SOURCE" fi +build_luajit() { + if [[ ! -f "lib/luajit/src/libluajit.a" ]]; then + print_info "Building LuaJIT" + cd lib/luajit + + make clean >/dev/null 2>&1 || true + make -j$(nproc 2>/dev/null || echo 4) > /dev/null 2>&1 + cd - > /dev/null + print_info "Built LuaJIT" + fi +} + +build_sdl() { + if [[ ! -f "lib/SDL/build/libSDL3.so" ]] && [[ ! -f "lib/SDL/build/libSDL3.a" ]] && [[ ! -f "lib/SDL/build/libSDL3.dylib" ]]; then + print_info "Building SDL3" + mkdir -p lib/SDL/build + cd lib/SDL/build + cmake .. -DCMAKE_BUILD_TYPE=Release > /dev/null 2>&1 + cmake --build . --parallel $(nproc 2>/dev/null || echo 4) > /dev/null 2>&1 + cd - > /dev/null + print_info "Built SDL3" + fi +} + compile_source_file() { local src_file="$1" local obj_file="$2" @@ -83,15 +106,11 @@ make_lib_dirs() { } print_error() { - echo -e "${RED}${BOLD}error:${NC} $1" >&2 + echo -e "${RED}${BOLD}[$(timestamp) ERROR]${NC} $1" >&2 } print_info() { - echo -e "${BLUE}${BOLD}info:${NC} $1" -} - -print_success() { - echo -e "${GREEN}${BOLD}✓${NC} $1" + echo -e "${GREEN}${BOLD}[$(timestamp) INFO]${NC} $1" } print_usage() { @@ -101,7 +120,7 @@ print_usage() { echo " ./pxl8.sh [options]" echo echo -e "${BOLD}COMMANDS:${NC}" - echo " aseprite Package Aseprite extensions" + echo " aseprite Aseprite tools (use 'aseprite help' for subcommands)" echo " build Build pxl8" echo " clean Remove build artifacts" echo " help Show this help message" @@ -115,54 +134,6 @@ print_usage() { echo " --release Build/run/clean in release mode (default: debug)" } -COMMAND="$1" -shift || true - -for arg in "$@"; do - case $arg in - --release) - MODE="release" - ;; - esac -done - -SIMD_FLAGS=$(detect_simd) - -if [ "$MODE" = "release" ]; then - CFLAGS="$CFLAGS -O3 -march=native -mtune=native -ffast-math -funroll-loops -fno-unwind-tables -fno-asynchronous-unwind-tables $SIMD_FLAGS" - - BUILDDIR="$BUILDDIR/release" - BINDIR="$BINDIR/release" -else - CFLAGS="$CFLAGS -g -O1 -DDEBUG $SIMD_FLAGS" - BUILDDIR="$BUILDDIR/debug" - BINDIR="$BINDIR/debug" -fi - -build_luajit() { - if [[ ! -f "lib/luajit/src/libluajit.a" ]]; then - print_info "Building LuaJIT" - cd lib/luajit - - make clean >/dev/null 2>&1 || true - make -j$(nproc 2>/dev/null || echo 4) > /dev/null 2>&1 - cd - > /dev/null - print_success "Built LuaJIT" - fi -} - -build_sdl() { - if [[ ! -f "lib/SDL/build/libSDL3.so" ]] && [[ ! -f "lib/SDL/build/libSDL3.a" ]] && [[ ! -f "lib/SDL/build/libSDL3.dylib" ]]; then - print_info "Building SDL3" - mkdir -p lib/SDL/build - cd lib/SDL/build - cmake .. -DCMAKE_BUILD_TYPE=Release > /dev/null 2>&1 - cmake --build . --parallel $(nproc 2>/dev/null || echo 4) > /dev/null 2>&1 - cd - > /dev/null - print_success "Built SDL3" - fi -} - setup_sdl3() { if [[ -d "lib/SDL/build" ]]; then SDL3_CFLAGS="-Ilib/SDL/include" @@ -214,14 +185,18 @@ setup_sdl3() { LIBS="$LIBS $SDL3_LIBS $SDL3_RPATH" } +timestamp() { + date +"%H:%M:%S" +} + update_fennel() { print_info "Fetching Fennel" local version="1.5.3" - if curl -s --max-time 5 -o lib/fennel/fennel.lua "https://fennel-lang.org/downloads/fennel-${version}.lua" 2>/dev/null; then + if curl -sL --max-time 5 -o lib/fennel/fennel.lua "https://fennel-lang.org/downloads/fennel-${version}.lua" 2>/dev/null; then if [[ -f "lib/fennel/fennel.lua" ]] && [[ -s "lib/fennel/fennel.lua" ]]; then - print_success "Updated Fennel (${version})" + print_info "Updated Fennel (${version})" else print_error "Downloaded file is empty or missing" return 1 @@ -234,10 +209,10 @@ update_fennel() { update_linenoise() { print_info "Fetching linenoise" - - if curl -s --max-time 5 -o lib/linenoise/linenoise.c https://raw.githubusercontent.com/antirez/linenoise/master/linenoise.c 2>/dev/null && \ - curl -s --max-time 5 -o lib/linenoise/linenoise.h https://raw.githubusercontent.com/antirez/linenoise/master/linenoise.h 2>/dev/null; then - print_success "Updated linenoise" + + if curl -sL --max-time 5 -o lib/linenoise/linenoise.c https://raw.githubusercontent.com/antirez/linenoise/master/linenoise.c 2>/dev/null && \ + curl -sL --max-time 5 -o lib/linenoise/linenoise.h https://raw.githubusercontent.com/antirez/linenoise/master/linenoise.h 2>/dev/null; then + print_info "Updated linenoise" else print_error "Failed to download linenoise" return 1 @@ -246,10 +221,10 @@ update_linenoise() { update_luajit() { print_info "Fetching LuaJIT" - + local version="2.1" local branch="v${version}" - + if [[ -d "lib/luajit/.git" ]]; then cd lib/luajit && git pull --quiet origin ${branch} cd - > /dev/null @@ -257,16 +232,16 @@ update_luajit() { rm -rf lib/luajit git clone --quiet --branch ${branch} https://github.com/LuaJIT/LuaJIT.git lib/luajit fi - - print_success "Updated LuaJIT (${version})" + + print_info "Updated LuaJIT (${version})" } update_microui() { print_info "Fetching microui" - - if curl -s --max-time 5 -o lib/microui/src/microui.c https://raw.githubusercontent.com/rxi/microui/master/src/microui.c 2>/dev/null && \ - curl -s --max-time 5 -o lib/microui/src/microui.h https://raw.githubusercontent.com/rxi/microui/master/src/microui.h 2>/dev/null; then - print_success "Updated microui" + + if curl -sL --max-time 5 -o lib/microui/src/microui.c https://raw.githubusercontent.com/rxi/microui/master/src/microui.c 2>/dev/null && \ + curl -sL --max-time 5 -o lib/microui/src/microui.h https://raw.githubusercontent.com/rxi/microui/master/src/microui.h 2>/dev/null; then + print_info "Updated microui" else print_error "Failed to download microui" return 1 @@ -275,15 +250,15 @@ update_microui() { update_miniz() { print_info "Fetching miniz" - + local version="3.0.2" - + if curl -sL --max-time 5 -o /tmp/miniz.zip "https://github.com/richgel999/miniz/releases/download/${version}/miniz-${version}.zip" 2>/dev/null; then unzip -qjo /tmp/miniz.zip miniz.c miniz.h -d lib/miniz/ 2>/dev/null rm -f /tmp/miniz.zip - + if [[ -f "lib/miniz/miniz.c" ]] && [[ -f "lib/miniz/miniz.h" ]]; then - print_success "Updated miniz (${version})" + print_info "Updated miniz (${version})" else print_error "Failed to extract miniz files" return 1 @@ -296,7 +271,7 @@ update_miniz() { update_sdl() { print_info "Fetching SDL3" - + if [[ -d "lib/SDL/.git" ]]; then cd lib/SDL && git pull --quiet origin main cd - > /dev/null @@ -304,10 +279,34 @@ update_sdl() { rm -rf lib/SDL git clone --quiet https://github.com/libsdl-org/SDL.git lib/SDL fi - - print_success "Updated SDL3" + + print_info "Updated SDL3" } +COMMAND="$1" +shift || true + +for arg in "$@"; do + case $arg in + --release) + MODE="release" + ;; + esac +done + +SIMD_FLAGS=$(detect_simd) + +if [ "$MODE" = "release" ]; then + CFLAGS="$CFLAGS -O3 -march=native -mtune=native -ffast-math -funroll-loops -fno-unwind-tables -fno-asynchronous-unwind-tables $SIMD_FLAGS" + + BUILDDIR="$BUILDDIR/release" + BINDIR="$BINDIR/release" +else + CFLAGS="$CFLAGS -g -O1 -DDEBUG $SIMD_FLAGS" + BUILDDIR="$BUILDDIR/debug" + BINDIR="$BINDIR/debug" +fi + case "$COMMAND" in build) mkdir -p "$BUILDDIR" @@ -443,7 +442,7 @@ case "$COMMAND" in print_info "All files are up to date, skipping build" fi - print_success "Build complete" + print_info "Build complete" print_info "Binary: $EXECUTABLE" ;; @@ -491,25 +490,26 @@ case "$COMMAND" in if [[ "$CLEAN_ALL" == true ]]; then print_info "Removing build artifacts and dependencies" rm -rf "$BUILD_PATH" "$BIN_PATH" lib - print_success "Cleaned all" + print_info "Cleaned all" elif [[ "$CLEAN_DEPS" == true ]]; then print_info "Removing dependencies" rm -rf lib - print_success "Cleaned dependencies" + print_info "Cleaned dependencies" else print_info "Removing build artifacts" rm -rf "$BUILD_PATH" "$BIN_PATH" - print_success "Cleaned" + print_info "Cleaned" fi ;; update) - update_linenoise + make_lib_dirs update_fennel + update_linenoise update_luajit update_microui update_miniz - print_success "All dependencies updated" + print_info "All dependencies updated" ;; vendor) @@ -517,8 +517,7 @@ case "$COMMAND" in ;; aseprite) - print_info "Packaging Aseprite extensions" - bash tools/aseprite/package.sh + bash tools/aseprite/pxl8-ase.sh "$@" ;; help|--help|-h|"") diff --git a/tools/aseprite/package.sh b/tools/aseprite/package.sh deleted file mode 100755 index fd28687..0000000 --- a/tools/aseprite/package.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -set -e - -EXTENSION_NAME="tile-props" -SOURCE_DIR="$(cd "$(dirname "$0")" && pwd)/$EXTENSION_NAME" -ZIP_FILE="$(cd "$(dirname "$0")" && pwd)/${EXTENSION_NAME}.aseprite-extension" - -echo "Creating extension package: ${EXTENSION_NAME}.aseprite-extension" -cd "$(dirname "$SOURCE_DIR")" -rm -f "$ZIP_FILE" -zip -q -r "$ZIP_FILE" "$EXTENSION_NAME" - -echo "✓ Extension package created: $ZIP_FILE" -echo "" -echo "To install in Aseprite:" -echo "1. Open Aseprite" -echo "2. Go to Edit → Preferences → Extensions" -echo "3. Click 'Add Extension'" -echo "4. Select: $ZIP_FILE" -echo "5. Restart Aseprite" diff --git a/tools/aseprite/pxl8-ase.sh b/tools/aseprite/pxl8-ase.sh new file mode 100755 index 0000000..532f15a --- /dev/null +++ b/tools/aseprite/pxl8-ase.sh @@ -0,0 +1,76 @@ +#!/bin/bash + +set -e + +GREEN='\033[0;32m' +RED='\033[0;31m' +BOLD='\033[1m' +NC='\033[0m' + +EXTENSION_NAME="tile-props" +SOURCE_DIR="$(cd "$(dirname "$0")" && pwd)/$EXTENSION_NAME" +ZIP_FILE="$(cd "$(dirname "$0")" && pwd)/${EXTENSION_NAME}.aseprite-extension" + +print_error() { + echo -e "${RED}${BOLD}[$(timestamp) ERROR]${NC} $1" >&2 +} + +print_info() { + echo -e "${GREEN}${BOLD}[$(timestamp) INFO]${NC} $1" +} + +print_usage() { + echo -e "${BOLD}pxl8-ase${NC} - aseprite tools" + echo + echo -e "${BOLD}USAGE:${NC}" + echo " ./pxl8-ase.sh " + echo + echo -e "${BOLD}COMMANDS:${NC}" + echo " clean Remove packaged extension" + echo " help Show this help message" + echo " package Package extension for installation" +} + +timestamp() { + date +"%H:%M:%S" +} + +COMMAND="$1" +shift || true + +case "$COMMAND" in + package) + print_info "Creating extension package: ${EXTENSION_NAME}.aseprite-extension" + cd "$(dirname "$SOURCE_DIR")" + rm -f "$ZIP_FILE" + zip -q -r "$ZIP_FILE" "$EXTENSION_NAME" + print_info "Extension package created: $ZIP_FILE" + echo "" + echo "To install in Aseprite:" + echo "1. Open Aseprite" + echo "2. Go to Edit → Preferences → Extensions" + echo "3. Click 'Add Extension'" + echo "4. Select: $ZIP_FILE" + echo "5. Restart Aseprite" + ;; + + clean) + if [[ -f "$ZIP_FILE" ]]; then + print_info "Removing extension package" + rm -f "$ZIP_FILE" + print_info "Cleaned" + else + print_info "No extension package to remove" + fi + ;; + + help|--help|-h|"") + print_usage + ;; + + *) + print_error "Unknown command: $COMMAND" + print_usage + exit 1 + ;; +esac