add pxl8-ase.sh tool script
This commit is contained in:
parent
015d823814
commit
c37208f961
3 changed files with 160 additions and 106 deletions
169
pxl8.sh
169
pxl8.sh
|
|
@ -37,7 +37,6 @@ esac
|
||||||
|
|
||||||
RED='\033[0;31m'
|
RED='\033[0;31m'
|
||||||
GREEN='\033[0;32m'
|
GREEN='\033[0;32m'
|
||||||
BLUE='\033[0;34m'
|
|
||||||
BOLD='\033[1m'
|
BOLD='\033[1m'
|
||||||
NC='\033[0m'
|
NC='\033[0m'
|
||||||
|
|
||||||
|
|
@ -45,6 +44,30 @@ if [[ "$(uname)" == "Linux" ]]; then
|
||||||
CFLAGS="$CFLAGS -D_GNU_SOURCE"
|
CFLAGS="$CFLAGS -D_GNU_SOURCE"
|
||||||
fi
|
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() {
|
compile_source_file() {
|
||||||
local src_file="$1"
|
local src_file="$1"
|
||||||
local obj_file="$2"
|
local obj_file="$2"
|
||||||
|
|
@ -83,15 +106,11 @@ make_lib_dirs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
print_error() {
|
print_error() {
|
||||||
echo -e "${RED}${BOLD}error:${NC} $1" >&2
|
echo -e "${RED}${BOLD}[$(timestamp) ERROR]${NC} $1" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
print_info() {
|
print_info() {
|
||||||
echo -e "${BLUE}${BOLD}info:${NC} $1"
|
echo -e "${GREEN}${BOLD}[$(timestamp) INFO]${NC} $1"
|
||||||
}
|
|
||||||
|
|
||||||
print_success() {
|
|
||||||
echo -e "${GREEN}${BOLD}✓${NC} $1"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print_usage() {
|
print_usage() {
|
||||||
|
|
@ -101,7 +120,7 @@ print_usage() {
|
||||||
echo " ./pxl8.sh <command> [options]"
|
echo " ./pxl8.sh <command> [options]"
|
||||||
echo
|
echo
|
||||||
echo -e "${BOLD}COMMANDS:${NC}"
|
echo -e "${BOLD}COMMANDS:${NC}"
|
||||||
echo " aseprite Package Aseprite extensions"
|
echo " aseprite Aseprite tools (use 'aseprite help' for subcommands)"
|
||||||
echo " build Build pxl8"
|
echo " build Build pxl8"
|
||||||
echo " clean Remove build artifacts"
|
echo " clean Remove build artifacts"
|
||||||
echo " help Show this help message"
|
echo " help Show this help message"
|
||||||
|
|
@ -115,54 +134,6 @@ print_usage() {
|
||||||
echo " --release Build/run/clean in release mode (default: debug)"
|
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() {
|
setup_sdl3() {
|
||||||
if [[ -d "lib/SDL/build" ]]; then
|
if [[ -d "lib/SDL/build" ]]; then
|
||||||
SDL3_CFLAGS="-Ilib/SDL/include"
|
SDL3_CFLAGS="-Ilib/SDL/include"
|
||||||
|
|
@ -214,14 +185,18 @@ setup_sdl3() {
|
||||||
LIBS="$LIBS $SDL3_LIBS $SDL3_RPATH"
|
LIBS="$LIBS $SDL3_LIBS $SDL3_RPATH"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
timestamp() {
|
||||||
|
date +"%H:%M:%S"
|
||||||
|
}
|
||||||
|
|
||||||
update_fennel() {
|
update_fennel() {
|
||||||
print_info "Fetching Fennel"
|
print_info "Fetching Fennel"
|
||||||
|
|
||||||
local version="1.5.3"
|
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
|
if [[ -f "lib/fennel/fennel.lua" ]] && [[ -s "lib/fennel/fennel.lua" ]]; then
|
||||||
print_success "Updated Fennel (${version})"
|
print_info "Updated Fennel (${version})"
|
||||||
else
|
else
|
||||||
print_error "Downloaded file is empty or missing"
|
print_error "Downloaded file is empty or missing"
|
||||||
return 1
|
return 1
|
||||||
|
|
@ -234,10 +209,10 @@ update_fennel() {
|
||||||
|
|
||||||
update_linenoise() {
|
update_linenoise() {
|
||||||
print_info "Fetching 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 && \
|
if curl -sL --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
|
curl -sL --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"
|
print_info "Updated linenoise"
|
||||||
else
|
else
|
||||||
print_error "Failed to download linenoise"
|
print_error "Failed to download linenoise"
|
||||||
return 1
|
return 1
|
||||||
|
|
@ -246,10 +221,10 @@ update_linenoise() {
|
||||||
|
|
||||||
update_luajit() {
|
update_luajit() {
|
||||||
print_info "Fetching LuaJIT"
|
print_info "Fetching LuaJIT"
|
||||||
|
|
||||||
local version="2.1"
|
local version="2.1"
|
||||||
local branch="v${version}"
|
local branch="v${version}"
|
||||||
|
|
||||||
if [[ -d "lib/luajit/.git" ]]; then
|
if [[ -d "lib/luajit/.git" ]]; then
|
||||||
cd lib/luajit && git pull --quiet origin ${branch}
|
cd lib/luajit && git pull --quiet origin ${branch}
|
||||||
cd - > /dev/null
|
cd - > /dev/null
|
||||||
|
|
@ -257,16 +232,16 @@ update_luajit() {
|
||||||
rm -rf lib/luajit
|
rm -rf lib/luajit
|
||||||
git clone --quiet --branch ${branch} https://github.com/LuaJIT/LuaJIT.git lib/luajit
|
git clone --quiet --branch ${branch} https://github.com/LuaJIT/LuaJIT.git lib/luajit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
print_success "Updated LuaJIT (${version})"
|
print_info "Updated LuaJIT (${version})"
|
||||||
}
|
}
|
||||||
|
|
||||||
update_microui() {
|
update_microui() {
|
||||||
print_info "Fetching 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 && \
|
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 -s --max-time 5 -o lib/microui/src/microui.h https://raw.githubusercontent.com/rxi/microui/master/src/microui.h 2>/dev/null; then
|
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_success "Updated microui"
|
print_info "Updated microui"
|
||||||
else
|
else
|
||||||
print_error "Failed to download microui"
|
print_error "Failed to download microui"
|
||||||
return 1
|
return 1
|
||||||
|
|
@ -275,15 +250,15 @@ update_microui() {
|
||||||
|
|
||||||
update_miniz() {
|
update_miniz() {
|
||||||
print_info "Fetching miniz"
|
print_info "Fetching miniz"
|
||||||
|
|
||||||
local version="3.0.2"
|
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
|
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
|
unzip -qjo /tmp/miniz.zip miniz.c miniz.h -d lib/miniz/ 2>/dev/null
|
||||||
rm -f /tmp/miniz.zip
|
rm -f /tmp/miniz.zip
|
||||||
|
|
||||||
if [[ -f "lib/miniz/miniz.c" ]] && [[ -f "lib/miniz/miniz.h" ]]; then
|
if [[ -f "lib/miniz/miniz.c" ]] && [[ -f "lib/miniz/miniz.h" ]]; then
|
||||||
print_success "Updated miniz (${version})"
|
print_info "Updated miniz (${version})"
|
||||||
else
|
else
|
||||||
print_error "Failed to extract miniz files"
|
print_error "Failed to extract miniz files"
|
||||||
return 1
|
return 1
|
||||||
|
|
@ -296,7 +271,7 @@ update_miniz() {
|
||||||
|
|
||||||
update_sdl() {
|
update_sdl() {
|
||||||
print_info "Fetching SDL3"
|
print_info "Fetching SDL3"
|
||||||
|
|
||||||
if [[ -d "lib/SDL/.git" ]]; then
|
if [[ -d "lib/SDL/.git" ]]; then
|
||||||
cd lib/SDL && git pull --quiet origin main
|
cd lib/SDL && git pull --quiet origin main
|
||||||
cd - > /dev/null
|
cd - > /dev/null
|
||||||
|
|
@ -304,10 +279,34 @@ update_sdl() {
|
||||||
rm -rf lib/SDL
|
rm -rf lib/SDL
|
||||||
git clone --quiet https://github.com/libsdl-org/SDL.git lib/SDL
|
git clone --quiet https://github.com/libsdl-org/SDL.git lib/SDL
|
||||||
fi
|
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
|
case "$COMMAND" in
|
||||||
build)
|
build)
|
||||||
mkdir -p "$BUILDDIR"
|
mkdir -p "$BUILDDIR"
|
||||||
|
|
@ -443,7 +442,7 @@ case "$COMMAND" in
|
||||||
print_info "All files are up to date, skipping build"
|
print_info "All files are up to date, skipping build"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
print_success "Build complete"
|
print_info "Build complete"
|
||||||
print_info "Binary: $EXECUTABLE"
|
print_info "Binary: $EXECUTABLE"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
@ -491,25 +490,26 @@ case "$COMMAND" in
|
||||||
if [[ "$CLEAN_ALL" == true ]]; then
|
if [[ "$CLEAN_ALL" == true ]]; then
|
||||||
print_info "Removing build artifacts and dependencies"
|
print_info "Removing build artifacts and dependencies"
|
||||||
rm -rf "$BUILD_PATH" "$BIN_PATH" lib
|
rm -rf "$BUILD_PATH" "$BIN_PATH" lib
|
||||||
print_success "Cleaned all"
|
print_info "Cleaned all"
|
||||||
elif [[ "$CLEAN_DEPS" == true ]]; then
|
elif [[ "$CLEAN_DEPS" == true ]]; then
|
||||||
print_info "Removing dependencies"
|
print_info "Removing dependencies"
|
||||||
rm -rf lib
|
rm -rf lib
|
||||||
print_success "Cleaned dependencies"
|
print_info "Cleaned dependencies"
|
||||||
else
|
else
|
||||||
print_info "Removing build artifacts"
|
print_info "Removing build artifacts"
|
||||||
rm -rf "$BUILD_PATH" "$BIN_PATH"
|
rm -rf "$BUILD_PATH" "$BIN_PATH"
|
||||||
print_success "Cleaned"
|
print_info "Cleaned"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
update)
|
update)
|
||||||
update_linenoise
|
make_lib_dirs
|
||||||
update_fennel
|
update_fennel
|
||||||
|
update_linenoise
|
||||||
update_luajit
|
update_luajit
|
||||||
update_microui
|
update_microui
|
||||||
update_miniz
|
update_miniz
|
||||||
print_success "All dependencies updated"
|
print_info "All dependencies updated"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
vendor)
|
vendor)
|
||||||
|
|
@ -517,8 +517,7 @@ case "$COMMAND" in
|
||||||
;;
|
;;
|
||||||
|
|
||||||
aseprite)
|
aseprite)
|
||||||
print_info "Packaging Aseprite extensions"
|
bash tools/aseprite/pxl8-ase.sh "$@"
|
||||||
bash tools/aseprite/package.sh
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
help|--help|-h|"")
|
help|--help|-h|"")
|
||||||
|
|
|
||||||
|
|
@ -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"
|
|
||||||
76
tools/aseprite/pxl8-ase.sh
Executable file
76
tools/aseprite/pxl8-ase.sh
Executable file
|
|
@ -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 <command>"
|
||||||
|
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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue