Automacao de empacotamento AppImage (make appimage)
- Makefile: alvos "appdir" (monta build/TinyBlocks.AppDir), "appimage"
(baixa o appimagetool e gera build/TinyBlocks-<ver>-x86_64.AppImage),
"run-appimage" e "icon".
- packaging/: tinyblocks.desktop, AppRun, tinyblocks.png (icone 256x256)
e make_icon.py (gera o icone sem dependencias externas).
- appdir:
* empacota o editor + SDL2/SDL2_ttf (com uma excludelist das libs do
sistema: glibc, X11/GL, som, dbus, systemd...);
* copia as libraries de extensao (.so + library.toml) para
usr/share/tinyblocks/libraries/<nome>/build;
- libman: tb_libman_scan_defaults agora tambem varre libraries ao lado do
executavel (usr/share/tinyblocks/libraries e usr/lib/...), de modo que o
AppImage acha suas extensoes mesmo rodando fora do repositorio.
Verificado: AppImage monta, abre o editor e carrega um .so empacotado
(TOML) pela tela "Escolha uma Extensao".
This commit is contained in:
1 parent
b29908e65b
commit
4de611cc1e
6 files changed
+206
No files matched your search
@@ -77,6 +77,7 @@ LIB_LDFLAGS := -L$(ED_DIR)/build -L$(GX_DIR)/build -L$(SD_DIR)/build \
|
||||
|
||||
.PHONY: all help debug release static shared example sdl2 clean run python-lib mcp-lib json \
|
||||
editor run-editor run-sdl2 mylib vector customappearance graphics sdl2-backend test-editor \
|
||||
appdir appimage run-appimage icon \
|
||||
test-toml test-plugin test-blueprint \
|
||||
category-libs category-sos libs \
|
||||
lib-events lib-control lib-operators lib-variables lib-appearance lib-pen lib-fs \
|
||||
@@ -228,6 +229,76 @@ editor: static libs $(BUILD)/editor ## Compila o editor visual (estilo Scratch)
|
||||
run-editor: editor ## Compila e abre o editor visual
|
||||
./$(BUILD)/editor
|
||||
|
||||
# ── Empacotamento AppImage ──────────────────────────────────────────────
|
||||
APP_NAME := TinyBlocks
|
||||
APP_VER := 0.1.0
|
||||
APPDIR := $(BUILD)/$(APP_NAME).AppDir
|
||||
APPIMAGE := $(BUILD)/$(APP_NAME)-$(APP_VER)-x86_64.AppImage
|
||||
AITOOL := $(BUILD)/.tools/appimagetool-x86_64.AppImage
|
||||
AITOOL_URL := https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage
|
||||
PKG_DIR := packaging
|
||||
|
||||
# Bibliotecas que NAO devem ser empacotadas (glibc, X11/GL/som do sistema).
|
||||
APPIMAGE_EXCLUDE := ld-linux libc.so libm.so libpthread librt libdl libgcc_s libstdc++ \
|
||||
libGL libEGL libGLX libGLdispatch libOpenGL libGLU libdrm libgbm \
|
||||
libX11 libxcb libXau libXdmcp libXext libXrender libXfixes libXi libXrandr \
|
||||
libXcursor libXss libXinerama libxkbcommon libwayland libdecor \
|
||||
libdbus libasound libpulse libpulsecommon libsystemd libudev libselinux libmount
|
||||
|
||||
$(AITOOL):
|
||||
@mkdir -p $(BUILD)/.tools
|
||||
@echo "Baixando appimagetool..."
|
||||
@curl -fL --retry 3 -o $@ $(AITOOL_URL) || { rm -f $@; \
|
||||
echo "Falha ao baixar appimagetool. Baixe manualmente em"; \
|
||||
echo " $(AITOOL_URL)"; \
|
||||
echo "e rode: make appimage APPIMAGETOOL=/caminho/appimagetool"; exit 1; }
|
||||
@chmod +x $@
|
||||
|
||||
appdir: editor ## Monta o AppDir (build/TinyBlocks.AppDir) para o AppImage
|
||||
$(RM) -r $(APPDIR)
|
||||
mkdir -p $(APPDIR)/usr/bin $(APPDIR)/usr/lib \
|
||||
$(APPDIR)/usr/share/applications \
|
||||
$(APPDIR)/usr/share/icons/hicolor/256x256/apps
|
||||
cp $(BUILD)/editor $(APPDIR)/usr/bin/tinyblocks
|
||||
cp $(PKG_DIR)/tinyblocks.png $(APPDIR)/usr/share/icons/hicolor/256x256/apps/tinyblocks.png
|
||||
cp $(PKG_DIR)/tinyblocks.png $(APPDIR)/tinyblocks.png
|
||||
cp $(PKG_DIR)/tinyblocks.desktop $(APPDIR)/tinyblocks.desktop
|
||||
cp $(PKG_DIR)/tinyblocks.desktop $(APPDIR)/usr/share/applications/tinyblocks.desktop
|
||||
cp $(PKG_DIR)/AppRun $(APPDIR)/AppRun
|
||||
chmod +x $(APPDIR)/AppRun
|
||||
@echo "Empacotando bibliotecas (exceto as do sistema)..."
|
||||
@ldd $(BUILD)/editor | awk '/=> \//{print $$1, $$3}' | while read name path; do \
|
||||
skip=0; \
|
||||
for ex in $(APPIMAGE_EXCLUDE); do case "$$name" in $$ex*) skip=1;; esac; done; \
|
||||
[ $$skip -eq 0 ] && cp -L "$$path" $(APPDIR)/usr/lib/ 2>/dev/null || true; \
|
||||
done
|
||||
@echo "Empacotando libraries de extensao (.so + library.toml)..."
|
||||
@mkdir -p $(APPDIR)/usr/share/tinyblocks/libraries
|
||||
@for d in $(LIBDIR)/tinyblocks-*/; do \
|
||||
name=$$(basename "$$d"); \
|
||||
[ -f "$$d"library.toml ] || continue; \
|
||||
so=$$(ls "$${d}build/"*.so 2>/dev/null | head -1); \
|
||||
[ -n "$$so" ] || continue; \
|
||||
mkdir -p "$(APPDIR)/usr/share/tinyblocks/libraries/$$name/build"; \
|
||||
cp "$$d"library.toml "$(APPDIR)/usr/share/tinyblocks/libraries/$$name/"; \
|
||||
cp "$$so" "$(APPDIR)/usr/share/tinyblocks/libraries/$$name/build/"; \
|
||||
done
|
||||
@echo "AppDir pronto: $(APPDIR)"
|
||||
|
||||
appimage: appdir ## Gera o AppImage portatil (build/TinyBlocks-*.AppImage)
|
||||
@test -n "$(APPIMAGETOOL)" || $(MAKE) $(AITOOL)
|
||||
@TOOL="$(if $(APPIMAGETOOL),$(APPIMAGETOOL),$(abspath $(AITOOL)))"; \
|
||||
cd $(BUILD) && ARCH=x86_64 APPIMAGE_EXTRACT_AND_RUN=1 \
|
||||
"$$TOOL" --no-appstream $(abspath $(APPDIR)) $(abspath $(APPIMAGE))
|
||||
@echo "AppImage: $(APPIMAGE)"
|
||||
@echo "Rode com: $(APPIMAGE)"
|
||||
|
||||
run-appimage: appimage ## Gera e abre o AppImage
|
||||
./$(APPIMAGE)
|
||||
|
||||
icon: ## (Re)gera o icone do AppImage (packaging/tinyblocks.png)
|
||||
python3 $(PKG_DIR)/make_icon.py
|
||||
|
||||
# -- Exemplo de library externa (hot reload) ---
|
||||
$(BUILD)/mylib.so: examples/mylib/mylib.c $(LIB_A)
|
||||
$(CC) $(CFLAGS_REL) -Iinclude -fPIC -shared \
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <ctype.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <tinyblocks/tinyblocks.h>
|
||||
#include "tb_libman.h"
|
||||
@@ -124,9 +125,33 @@ int tb_libman_scan(const char* root, int max_depth) {
|
||||
return scan_dir(root, max_depth);
|
||||
}
|
||||
|
||||
/* Varre libraries ao lado do executavel (ex.: AppImage em
|
||||
* usr/bin/tinyblocks -> usr/share/tinyblocks/libraries). */
|
||||
static int scan_exe_roots(void) {
|
||||
char exe[TBLM_PATH_LEN];
|
||||
ssize_t k = readlink("/proc/self/exe", exe, sizeof(exe) - 1);
|
||||
if (k <= 0) return 0;
|
||||
exe[k] = 0;
|
||||
char* slash = strrchr(exe, '/');
|
||||
if (!slash) return 0;
|
||||
*slash = 0; /* diretorio do executavel */
|
||||
static const char* rels[] = {
|
||||
"/../share/tinyblocks/libraries",
|
||||
"/../lib/tinyblocks/libraries",
|
||||
};
|
||||
int n = 0;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
char buf[TBLM_PATH_LEN];
|
||||
snprintf(buf, sizeof(buf), "%s%s", exe, rels[i]);
|
||||
n += tb_libman_scan(buf, 3);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
int tb_libman_scan_defaults(void) {
|
||||
int n = 0;
|
||||
n += tb_libman_scan("libraries", 3);
|
||||
n += scan_exe_roots();
|
||||
const char* home = getenv("HOME");
|
||||
if (home && home[0]) {
|
||||
char buf[TBLM_PATH_LEN];
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
# AppRun do AppImage do TinyBlocks.
|
||||
# Descobre o diretorio do proprio AppRun e roda o editor usando as
|
||||
# bibliotecas empacotadas em usr/lib.
|
||||
HERE="$(dirname "$(readlink -f "$0")")"
|
||||
export LD_LIBRARY_PATH="$HERE/usr/lib:$HERE/usr/lib/x86_64-linux-gnu:${LD_LIBRARY_PATH}"
|
||||
export TINYBLOCKS_APPDIR="$HERE"
|
||||
exec "$HERE/usr/bin/tinyblocks" "$@"
|
||||
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Gera packaging/tinyblocks.png (icone 256x256 do editor TinyBlocks).
|
||||
|
||||
Sem dependencias: escreve o PNG direto com zlib + struct. Faz supersampling
|
||||
4x para bordas suaves. Uso: python3 packaging/make_icon.py [saida.png]
|
||||
"""
|
||||
import struct, sys, zlib
|
||||
|
||||
S = 4 # supersampling
|
||||
OUT = 256
|
||||
W = OUT * S
|
||||
|
||||
def rrect(x, y, x0, y0, x1, y1, r):
|
||||
if x < x0 or x > x1 or y < y0 or y > y1:
|
||||
return False
|
||||
cx = min(max(x, x0 + r), x1 - r)
|
||||
cy = min(max(y, y0 + r), y1 - r)
|
||||
dx, dy = x - cx, y - cy
|
||||
return dx * dx + dy * dy <= r * r
|
||||
|
||||
def rect(x, y, x0, y0, x1, y1):
|
||||
return x0 <= x <= x1 and y0 <= y <= y1
|
||||
|
||||
def tri_signed(px, py, ax, ay, bx, by, cx, cy):
|
||||
return (px - bx) * (ay - by) - (ax - bx) * (py - by)
|
||||
|
||||
def in_tri(x, y, ax, ay, bx, by, cx, cy):
|
||||
d1 = tri_signed(x, y, ax, ay, bx, by, cx, cy)
|
||||
d2 = tri_signed(x, y, bx, by, cx, cy, ax, ay)
|
||||
d3 = tri_signed(x, y, cx, cy, ax, ay, bx, by)
|
||||
neg = (d1 < 0) or (d2 < 0) or (d3 < 0)
|
||||
pos = (d1 > 0) or (d2 > 0) or (d3 > 0)
|
||||
return not (neg and pos)
|
||||
|
||||
def px(x, y):
|
||||
# coords em escala OUT (0..256)
|
||||
X, Y = x / S, y / S
|
||||
# fundo arredondado azul
|
||||
if rrect(X, Y, 4, 4, 252, 252, 54):
|
||||
c = (74, 144, 226)
|
||||
else:
|
||||
return (0, 0, 0, 0)
|
||||
# brilho no topo
|
||||
if Y < 128:
|
||||
t = 1.0 - Y / 128.0
|
||||
c = (int(c[0] + 40 * t), int(c[1] + 30 * t), int(c[2] + 20 * t))
|
||||
# haste da bandeira
|
||||
if rect(X, Y, 176, 44, 182, 124):
|
||||
c = (240, 80, 80)
|
||||
# triangulo verde
|
||||
if in_tri(X, Y, 183, 44, 216, 58, 183, 74):
|
||||
c = (76, 175, 80)
|
||||
# corpo do bloco (branco)
|
||||
if rrect(X, Y, 60, 108, 196, 200, 16):
|
||||
c = (245, 247, 250)
|
||||
# encaixe no topo do bloco
|
||||
if rrect(X, Y, 106, 86, 150, 118, 9):
|
||||
c = (245, 247, 250)
|
||||
# "janela" escura no bloco
|
||||
if rrect(X, Y, 80, 130, 176, 150, 6):
|
||||
c = (74, 144, 226)
|
||||
return (c[0], c[1], c[2], 255)
|
||||
|
||||
def main():
|
||||
out = sys.argv[1] if len(sys.argv) > 1 else "packaging/tinyblocks.png"
|
||||
buf = bytearray()
|
||||
for oy in range(OUT):
|
||||
buf.append(0) # filtro 0 por scanline
|
||||
for ox in range(OUT):
|
||||
r = g = b = a = 0
|
||||
for dy in range(S):
|
||||
for dx in range(S):
|
||||
p = px(ox * S + dx, oy * S + dy)
|
||||
r += p[0]; g += p[1]; b += p[2]; a += p[3]
|
||||
n = S * S
|
||||
buf += bytes((r // n, g // n, b // n, a // n))
|
||||
|
||||
def chunk(tag, data):
|
||||
return (struct.pack(">I", len(data)) + tag + data +
|
||||
struct.pack(">I", zlib.crc32(tag + data) & 0xffffffff))
|
||||
|
||||
png = b"\x89PNG\r\n\x1a\n"
|
||||
png += chunk(b"IHDR", struct.pack(">IIBBBBB", OUT, OUT, 8, 6, 0, 0, 0))
|
||||
png += chunk(b"IDAT", zlib.compress(bytes(buf), 9))
|
||||
png += chunk(b"IEND", b"")
|
||||
with open(out, "wb") as f:
|
||||
f.write(png)
|
||||
print("icone escrito:", out)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=TinyBlocks
|
||||
GenericName=Editor de blocos
|
||||
Comment=Editor visual de programacao em blocos (estilo Scratch)
|
||||
Exec=tinyblocks
|
||||
Icon=tinyblocks
|
||||
Terminal=false
|
||||
Categories=Development;Education;Graphics;
|
||||
Keywords=scratch;blocos;blocks;programacao;
|
||||
StartupWMClass=TinyBlocks Editor
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.6 KiB |
Reference in new issue
Block a user