add pxl8-ase.sh tool script
This commit is contained in:
parent
015d823814
commit
c37208f961
3 changed files with 160 additions and 106 deletions
149
pxl8.sh
149
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 <command> [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
|
||||
|
|
@ -235,9 +210,9 @@ 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
|
||||
|
|
@ -258,15 +233,15 @@ update_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
|
||||
|
|
@ -283,7 +258,7 @@ update_miniz() {
|
|||
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
|
||||
|
|
@ -305,9 +280,33 @@ update_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|"")
|
||||
|
|
|
|||
|
|
@ -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