Figura atual como no pyplot: linha, linha x-y, pontos, barras com nomes, histograma, titulo, nomes dos eixos (y na vertical), legenda, grade, limites e series com nome que crescem a cada passo (curvas de treino). Desenha numa imagem (para o palco) ou grava em PNG/BMP/PPM. Valores de lista, de texto ou de tensor. Paleta tab10; marcas "redondas" (1, 2, 5 x 10^n) com folga de 5%; linhas e pontos com antisserrilhado; fonte DejaVu Sans 12 px embutida (tools/gen_font.c, via tinyblocks-opentype), com os acentos do portugues. Convolucoes da ai: "filtros de tamanho %3" (o rotulo repetia o campo). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
866 lines
39 KiB
Makefile
866 lines
39 KiB
Makefile
CC := gcc
|
|
CFLAGS := -std=c11 -Wall -Wextra -pedantic -fvisibility=hidden \
|
|
-D_POSIX_C_SOURCE=200809L -Iinclude
|
|
CFLAGS_DBG := $(CFLAGS) -g -DDEBUG -fsanitize=address,undefined
|
|
CFLAGS_REL := $(CFLAGS) -O2 -DNDEBUG
|
|
|
|
BUILD := build
|
|
LIB_A := $(BUILD)/libtinyblocks.a
|
|
LIB_SO := $(BUILD)/libtinyblocks.so
|
|
EXAMPLE := $(BUILD)/hello
|
|
|
|
# Diretórios das libraries (cada uma com Makefile e build/ próprios)
|
|
LIBDIR := libraries
|
|
EV_DIR := $(LIBDIR)/tinyblocks-events
|
|
CT_DIR := $(LIBDIR)/tinyblocks-control
|
|
OP_DIR := $(LIBDIR)/tinyblocks-operators
|
|
VR_DIR := $(LIBDIR)/tinyblocks-variables
|
|
AP_DIR := $(LIBDIR)/tinyblocks-appearance
|
|
PN_DIR := $(LIBDIR)/tinyblocks-pen
|
|
FS_DIR := $(LIBDIR)/tinyblocks-fs
|
|
EN_DIR := $(LIBDIR)/tinyblocks-environ
|
|
TOML_DIR := $(LIBDIR)/tinyblocks-toml
|
|
JSON_DIR := $(LIBDIR)/tinyblocks-json
|
|
XML_DIR := $(LIBDIR)/tinyblocks-xml
|
|
CSV_DIR := $(LIBDIR)/tinyblocks-csv
|
|
BP_DIR := $(LIBDIR)/tinyblocks-blueprint
|
|
B64_DIR := $(LIBDIR)/tinyblocks-base64
|
|
CV_DIR := $(LIBDIR)/tinyblocks-curves
|
|
PPM_DIR := $(LIBDIR)/tinyblocks-ppm
|
|
BMP_DIR := $(LIBDIR)/tinyblocks-bmp
|
|
PNG_DIR := $(LIBDIR)/tinyblocks-png
|
|
IMG_DIR := $(LIBDIR)/tinyblocks-image
|
|
VG_DIR := $(LIBDIR)/tinyblocks-vg
|
|
SVG_DIR := $(LIBDIR)/tinyblocks-svg
|
|
JPG_DIR := $(LIBDIR)/tinyblocks-jpg
|
|
SYN_DIR := $(LIBDIR)/tinyblocks-syntax
|
|
SB_DIR := $(LIBDIR)/tinyblocks-scratchblocks
|
|
RE_DIR := $(LIBDIR)/tinyblocks-regex
|
|
MD_DIR := $(LIBDIR)/tinyblocks-markdown
|
|
OT_DIR := $(LIBDIR)/tinyblocks-opentype
|
|
API_DIR := $(LIBDIR)/tinyblocks-api
|
|
LIBM_DIR := $(LIBDIR)/tinyblocks-libman
|
|
ED_DIR := $(LIBDIR)/tinyblocks-editor
|
|
GX_DIR := $(LIBDIR)/tinyblocks-graphics
|
|
SD_DIR := $(LIBDIR)/tinyblocks-sdl2
|
|
PY_DIR := $(LIBDIR)/tinyblocks-python
|
|
MC_DIR := $(LIBDIR)/tinyblocks-mcp
|
|
A11Y_DIR := $(LIBDIR)/tinyblocks-a11y
|
|
MCPS_DIR := $(LIBDIR)/tinyblocks-mcp-server
|
|
|
|
GFX_INC := $(GX_DIR)/include
|
|
GFX_HDR := $(GFX_INC)/tb_graphics.h
|
|
|
|
SDL2_CFLAGS := $(shell sdl2-config --cflags)
|
|
SDL2_LIBS := $(shell sdl2-config --libs)
|
|
SDL2TTF_CFLAGS:= $(shell pkg-config --cflags SDL2_ttf 2>/dev/null)
|
|
SDL2TTF_LIBS := $(shell pkg-config --libs SDL2_ttf 2>/dev/null)
|
|
PYTHON_CFLAGS := $(shell python3-config --cflags --embed 2>/dev/null || python3-config --cflags)
|
|
PYTHON_LIBS := $(shell python3-config --ldflags --embed 2>/dev/null || python3-config --ldflags)
|
|
|
|
SRCS := src/tinyblocks.c \
|
|
src/tb_value.c \
|
|
src/tb_block.c \
|
|
src/tb_type_block.c \
|
|
src/tb_library_block.c \
|
|
src/tb_text_block.c \
|
|
src/tb_integer_block.c \
|
|
src/tb_real_block.c \
|
|
src/tb_vector_block.c \
|
|
src/tb_renderable_block.c \
|
|
src/tb_stage.c \
|
|
src/tb_input.c \
|
|
src/tb_vars.c \
|
|
src/tb_result.c \
|
|
src/tb_object.c \
|
|
src/tb_json_block.c \
|
|
src/tb_image.c \
|
|
src/tb_meta.c
|
|
|
|
OBJS := $(patsubst src/%.c,$(BUILD)/%.o,$(SRCS))
|
|
OBJS_DBG := $(patsubst src/%.c,$(BUILD)/%-dbg.o,$(SRCS))
|
|
|
|
CAT_LIBS := events control errors input operators number string variables vector appearance pen fs os environ
|
|
CAT_A := $(foreach l,$(CAT_LIBS),$(LIBDIR)/tinyblocks-$(l)/build/libtinyblocks-$(l).a)
|
|
CAT_LDFLAGS := $(foreach l,$(CAT_LIBS),-ltinyblocks-$(l))
|
|
CAT_INCS := $(foreach l,$(CAT_LIBS),-I$(LIBDIR)/tinyblocks-$(l)/include)
|
|
# Libraries que o editor registra como as de categoria, mas com varios
|
|
# fontes e o Makefile proprio (o harness nao as compila junto)
|
|
APP_LIBS := socket ssl http archive tensor ai plot
|
|
APP_A := $(foreach l,$(APP_LIBS),$(LIBDIR)/tinyblocks-$(l)/build/libtinyblocks-$(l).a)
|
|
APP_INCS := $(foreach l,$(APP_LIBS),-I$(LIBDIR)/tinyblocks-$(l)/include)
|
|
APP_LDLIBS := -lssl -lcrypto -lz -lpthread
|
|
ED_A := $(ED_DIR)/build/libtinyblocks-editor.a
|
|
GX_A := $(GX_DIR)/build/libtinyblocks-graphics.a
|
|
SD_A := $(SD_DIR)/build/libtinyblocks-sdl2.a
|
|
TOML_A := $(TOML_DIR)/build/libtinyblocks-toml.a
|
|
JSON_A := $(JSON_DIR)/build/libtinyblocks-json.a
|
|
XML_A := $(XML_DIR)/build/libtinyblocks-xml.a
|
|
CSV_A := $(CSV_DIR)/build/libtinyblocks-csv.a
|
|
BP_A := $(BP_DIR)/build/libtinyblocks-blueprint.a
|
|
API_A := $(API_DIR)/build/libtinyblocks-api.a
|
|
LIBM_A := $(LIBM_DIR)/build/libtinyblocks-libman.a
|
|
SYN_A := $(SYN_DIR)/build/libtinyblocks-syntax.a
|
|
SB_A := $(SB_DIR)/build/libtinyblocks-scratchblocks.a
|
|
A11Y_A := $(A11Y_DIR)/build/libtinyblocks-a11y.a
|
|
MCPS_A := $(MCPS_DIR)/build/libtinyblocks-mcp-server.a
|
|
LIB_LDFLAGS := -L$(ED_DIR)/build -L$(GX_DIR)/build -L$(SD_DIR)/build \
|
|
$(foreach l,$(CAT_LIBS),-L$(LIBDIR)/tinyblocks-$(l)/build) -L$(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 test-a11y test-mcp test-mcp-server test-base64 test-curves test-meta test-ppm test-bmp test-png test-image test-vg test-svg test-jpg \
|
|
test-tensor test-ai test-http test-archive test-plot test-syntax test-os test-value test-vars test-scratchblocks test-input test-stdlib test-regex test-markdown test-opentype \
|
|
category-libs category-sos libs app-libs \
|
|
lib-events lib-control lib-errors lib-input lib-operators lib-number lib-string lib-variables lib-vector lib-appearance lib-pen lib-fs lib-os \
|
|
lib-environ \
|
|
lib-editor lib-graphics lib-sdl2 lib-python lib-mcp lib-toml \
|
|
lib-json lib-xml lib-csv lib-blueprint lib-base64 lib-curves lib-ppm lib-bmp lib-png lib-image lib-vg lib-svg lib-jpg lib-syntax lib-scratchblocks lib-regex lib-markdown lib-opentype lib-api lib-libman \
|
|
test-libman test-environ
|
|
|
|
all: static example ## Compila a biblioteca estática e o exemplo hello (padrão)
|
|
|
|
help: ## Lista os alvos disponíveis
|
|
@echo "TinyBlocks - alvos do make:"
|
|
@echo
|
|
@awk 'BEGIN {FS = ":.*## "} /^[a-zA-Z0-9_-]+:.*## / { printf " \033[36m%-18s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
|
|
@echo
|
|
@echo "Exemplo: make run-editor (libraries extras: ./build/editor build/mylib.so)"
|
|
|
|
# -- Biblioteca principal (runtime) ---
|
|
static: $(LIB_A) ## Compila build/libtinyblocks.a
|
|
shared: $(LIB_SO) ## Compila build/libtinyblocks.so
|
|
|
|
HDRS := $(wildcard include/tinyblocks/*.h)
|
|
|
|
$(BUILD)/%.o: src/%.c $(HDRS)
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_REL) -fPIC -c $< -o $@
|
|
|
|
$(BUILD)/%-dbg.o: src/%.c $(HDRS)
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -fPIC -c $< -o $@
|
|
|
|
$(LIB_A): $(OBJS)
|
|
ar rcs $@ $^
|
|
|
|
$(LIB_SO): $(OBJS)
|
|
$(CC) -shared -o $@ $^
|
|
|
|
# -- Exemplo hello ---
|
|
$(EXAMPLE): examples/hello/main.c $(LIB_A)
|
|
$(CC) $(CFLAGS_REL) $< -o $@ -L$(BUILD) -ltinyblocks
|
|
|
|
example: $(EXAMPLE) ## Compila o exemplo hello
|
|
|
|
run: example ## Compila e roda o exemplo hello
|
|
./$(EXAMPLE)
|
|
|
|
# -- Build de debug com ASan/UBSan ---
|
|
$(BUILD)/libtinyblocks-dbg.a: $(OBJS_DBG)
|
|
ar rcs $@ $^
|
|
|
|
$(BUILD)/hello-dbg: examples/hello/main.c $(BUILD)/libtinyblocks-dbg.a
|
|
$(CC) $(CFLAGS_DBG) $< -o $@ -L$(BUILD) -ltinyblocks-dbg
|
|
|
|
debug: $(BUILD)/hello-dbg ## Compila e roda o hello com ASan/UBSan
|
|
./$(BUILD)/hello-dbg
|
|
|
|
# ── Libraries (cada uma tem Makefile + build/ próprios) ──────────────────
|
|
define CAT_LIB_TARGET
|
|
lib-$(1):
|
|
$(MAKE) -C $(LIBDIR)/tinyblocks-$(1)
|
|
endef
|
|
$(foreach l,$(CAT_LIBS),$(eval $(call CAT_LIB_TARGET,$(l))))
|
|
$(foreach l,$(APP_LIBS),$(eval $(call CAT_LIB_TARGET,$(l))))
|
|
|
|
app-libs: $(foreach l,$(APP_LIBS),lib-$(l)) ## Compila tensor e as outras libraries do app (.a/.so)
|
|
|
|
lib-editor: lib-a11y lib-mcp-server
|
|
$(MAKE) -C $(ED_DIR)
|
|
|
|
lib-a11y:
|
|
$(MAKE) -C $(A11Y_DIR)
|
|
|
|
lib-mcp-server:
|
|
$(MAKE) -C $(MCPS_DIR)
|
|
|
|
lib-toml:
|
|
$(MAKE) -C $(TOML_DIR)
|
|
|
|
lib-json:
|
|
$(MAKE) -C $(JSON_DIR)
|
|
|
|
lib-xml:
|
|
$(MAKE) -C $(XML_DIR)
|
|
|
|
lib-csv:
|
|
$(MAKE) -C $(CSV_DIR)
|
|
|
|
lib-blueprint:
|
|
$(MAKE) -C $(BP_DIR)
|
|
|
|
lib-base64:
|
|
$(MAKE) -C $(B64_DIR)
|
|
|
|
lib-curves:
|
|
$(MAKE) -C $(CV_DIR)
|
|
|
|
lib-ppm:
|
|
$(MAKE) -C $(PPM_DIR)
|
|
|
|
lib-bmp:
|
|
$(MAKE) -C $(BMP_DIR)
|
|
|
|
lib-png:
|
|
$(MAKE) -C $(PNG_DIR)
|
|
|
|
lib-image:
|
|
$(MAKE) -C $(IMG_DIR)
|
|
|
|
lib-vg:
|
|
$(MAKE) -C $(VG_DIR)
|
|
|
|
lib-svg: lib-vg lib-base64
|
|
$(MAKE) -C $(SVG_DIR)
|
|
|
|
lib-jpg:
|
|
$(MAKE) -C $(JPG_DIR)
|
|
|
|
lib-syntax:
|
|
$(MAKE) -C $(SYN_DIR)
|
|
|
|
lib-scratchblocks:
|
|
$(MAKE) -C $(SB_DIR)
|
|
|
|
lib-regex:
|
|
$(MAKE) -C $(RE_DIR)
|
|
|
|
lib-markdown:
|
|
$(MAKE) -C $(MD_DIR)
|
|
|
|
lib-opentype:
|
|
$(MAKE) -C $(OT_DIR)
|
|
|
|
lib-api:
|
|
$(MAKE) -C $(API_DIR)
|
|
|
|
lib-libman: lib-api lib-toml
|
|
$(MAKE) -C $(LIBM_DIR)
|
|
|
|
lib-graphics:
|
|
$(MAKE) -C $(GX_DIR)
|
|
|
|
lib-sdl2:
|
|
$(MAKE) -C $(SD_DIR)
|
|
|
|
lib-python:
|
|
$(MAKE) -C $(PY_DIR)
|
|
|
|
lib-mcp: lib-python
|
|
$(MAKE) -C $(MC_DIR)
|
|
|
|
libs: static app-libs lib-events lib-control lib-errors lib-operators lib-variables \
|
|
lib-appearance lib-pen lib-fs lib-os lib-input lib-number lib-string lib-vector lib-environ lib-graphics lib-sdl2 lib-toml \
|
|
lib-json lib-xml lib-csv lib-blueprint lib-base64 lib-curves lib-ppm lib-bmp lib-png lib-image lib-vg lib-svg lib-jpg lib-syntax lib-scratchblocks lib-regex lib-markdown lib-opentype lib-api lib-libman lib-a11y lib-mcp-server lib-editor
|
|
@echo "Libraries OK: category + graphics + sdl2 + toml + json + xml + csv + blueprint + base64 + curves + ppm + bmp + png + image + vg + svg + jpg + syntax + regex + markdown + opentype + api + libman + a11y + editor"
|
|
|
|
category-libs: static $(foreach l,$(CAT_LIBS),lib-$(l)) ## Compila as libraries de categoria (.a/.so)
|
|
@echo "Build category libs OK"
|
|
|
|
category-sos: category-libs ## Alias: as libraries de categoria tambem geram .so
|
|
|
|
# -- Library SDL2 (backend) ---
|
|
$(BUILD)/sdl2-example: examples/sdl2/main.c static lib-sdl2
|
|
$(CC) $(CFLAGS_REL) $(SDL2_CFLAGS) $(SDL2TTF_CFLAGS) \
|
|
-I$(SD_DIR)/include \
|
|
$< -o $@ \
|
|
-L$(SD_DIR)/build -L$(BUILD) -ltinyblocks-sdl2 -ltinyblocks \
|
|
$(SDL2_LIBS) $(SDL2TTF_LIBS) -lm
|
|
|
|
sdl2: static lib-sdl2 $(BUILD)/sdl2-example ## Compila a library SDL2 e seu exemplo
|
|
@echo "Build SDL2 OK: $(BUILD)/sdl2-example"
|
|
|
|
sdl2-backend: static lib-sdl2 ## Backend SDL2 como .so (./build/editor --backend libraries/tinyblocks-sdl2/build/libtinyblocks-sdl2.so)
|
|
@echo "Build backend OK: $(SD_DIR)/build/libtinyblocks-sdl2.so"
|
|
|
|
run-sdl2: sdl2 ## Compila e roda o exemplo SDL2
|
|
LD_LIBRARY_PATH=$(SD_DIR)/build:$(BUILD) ./$(BUILD)/sdl2-example
|
|
|
|
# -- Library Graphics (interface; backend padrão: SDL2) ---
|
|
graphics: static lib-sdl2 lib-graphics ## Interface gráfica (com backend SDL2)
|
|
@echo "Build graphics OK: $(GX_DIR)/build/libtinyblocks-graphics.a"
|
|
|
|
# -- Library Editor ---
|
|
EDITOR_SRC := $(ED_DIR)/src
|
|
EW_DIR := $(ED_DIR)/libraries/tinyblocks-editor-widgets
|
|
EIMG_DIR := $(ED_DIR)/libraries/tinyblocks-editor-image
|
|
EW_A := $(EW_DIR)/build/libtinyblocks-editor-widgets.a
|
|
EIMG_A := $(EIMG_DIR)/build/libtinyblocks-editor-image.a
|
|
EFILES_DIR := $(ED_DIR)/libraries/tinyblocks-editor-files
|
|
EDITOR_HDRS := $(ED_DIR)/include/tb_stage_widget.h $(ED_DIR)/include/tb_editor.h $(GFX_HDR) $(HDRS)
|
|
|
|
$(BUILD)/editor: examples/editor/main.c static libs
|
|
$(CC) $(CFLAGS_REL) \
|
|
-I$(ED_DIR)/include -I$(GFX_INC) $(CAT_INCS) $(APP_INCS) \
|
|
-I$(FS_DIR)/include -I$(EN_DIR)/include -I$(TOML_DIR)/include \
|
|
-I$(JSON_DIR)/include -I$(XML_DIR)/include -I$(CSV_DIR)/include -I$(BP_DIR)/include \
|
|
-I$(API_DIR)/include -I$(LIBM_DIR)/include -I$(SYN_DIR)/include -I$(A11Y_DIR)/include -I$(MCPS_DIR)/include \
|
|
$< -o $@ \
|
|
-Wl,--start-group $(ED_A) $(A11Y_A) $(MCPS_A) $(GX_A) $(SD_A) $(TOML_A) $(JSON_A) $(XML_A) $(CSV_A) $(BP_A) $(SB_A) $(API_A) $(LIBM_A) $(SYN_A) $(CAT_A) $(APP_A) $(LIB_A) -Wl,--end-group \
|
|
$(SDL2_LIBS) $(SDL2TTF_LIBS) $(APP_LDLIBS) -ldl -lm -rdynamic \
|
|
'-Wl,-rpath,$$ORIGIN'
|
|
|
|
editor: static libs $(BUILD)/editor ## Compila o editor visual (estilo Scratch)
|
|
@echo "Build editor OK: $(BUILD)/editor"
|
|
|
|
run-editor: editor ## Compila e abre o editor visual
|
|
./$(BUILD)/editor
|
|
|
|
# ── Empacotamento AppImage ──────────────────────────────────────────────
|
|
# Libraries com blocos (categoria) que vao empacotadas como extensoes.
|
|
APPIMAGE_LIBS := $(CAT_LIBS) $(APP_LIBS) toml json xml csv blueprint base64 curves ppm bmp png image vg svg jpg syntax regex markdown opentype
|
|
|
|
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 as libraries privadas do editor (bundle, hot reload)..."
|
|
@mkdir -p $(APPDIR)/usr/lib/tinyblocks-editor
|
|
@cp $(EW_DIR)/build/libtinyblocks-editor-widgets.so $(APPDIR)/usr/lib/tinyblocks-editor/ 2>/dev/null || true
|
|
@cp $(EIMG_DIR)/build/libtinyblocks-editor-image.so $(APPDIR)/usr/lib/tinyblocks-editor/ 2>/dev/null || true
|
|
@cp $(EFILES_DIR)/build/libtinyblocks-editor-files.so $(APPDIR)/usr/lib/tinyblocks-editor/ 2>/dev/null || true
|
|
@echo "Empacotando libraries de extensao (.so + library.toml)..."
|
|
@mkdir -p $(APPDIR)/usr/share/tinyblocks/libraries
|
|
@for l in $(APPIMAGE_LIBS); do \
|
|
d=$(LIBDIR)/tinyblocks-$$l; \
|
|
[ -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/tinyblocks-$$l/build"; \
|
|
cp "$$d/library.toml" "$(APPDIR)/usr/share/tinyblocks/libraries/tinyblocks-$$l/"; \
|
|
cp "$$so" "$(APPDIR)/usr/share/tinyblocks/libraries/tinyblocks-$$l/build/"; \
|
|
ldd "$$so" 2>/dev/null | awk '/=> \//{print $$3}' | while read dep; do \
|
|
dn=$$(basename "$$dep"); \
|
|
skip=0; \
|
|
for ex in $(APPIMAGE_EXCLUDE); do case "$$dn" in $$ex*) skip=1;; esac; done; \
|
|
[ $$skip -eq 0 ] && cp -L "$$dep" $(APPDIR)/usr/lib/ 2>/dev/null || true; \
|
|
done; \
|
|
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 \
|
|
$< -o $@ -L$(BUILD) -ltinyblocks '-Wl,-rpath,$$ORIGIN'
|
|
|
|
mylib: static $(BUILD)/mylib.so ## Library de exemplo (hot reload) -> build/mylib.so
|
|
@echo "Build mylib OK: $(BUILD)/mylib.so -> Carregue no editor com Ctrl+O"
|
|
|
|
# -- Library de vetor 2D ---
|
|
$(BUILD)/vector.so: examples/vector/vector.c $(LIB_A)
|
|
$(CC) $(CFLAGS_REL) -Iinclude -fPIC -shared \
|
|
$< -o $@ -L$(BUILD) -ltinyblocks '-Wl,-rpath,$$ORIGIN'
|
|
|
|
vector: static $(BUILD)/vector.so ## Library de vetor 2D -> build/vector.so
|
|
@echo "Build vector OK: $(BUILD)/vector.so -> Carregue no editor com Ctrl+O"
|
|
|
|
# -- Library de JSON ---
|
|
$(BUILD)/json.so: examples/json/json.c $(LIB_A)
|
|
$(CC) $(CFLAGS_REL) -Iinclude -fPIC -shared \
|
|
$< -o $@ -L$(BUILD) -ltinyblocks '-Wl,-rpath,$$ORIGIN'
|
|
|
|
json: static $(BUILD)/json.so ## Library de JSON -> build/json.so
|
|
@echo "Build json OK: $(BUILD)/json.so -> Carregue no editor com Ctrl+O"
|
|
|
|
# -- Library de aparência personalizada (on_render demo) ---
|
|
$(BUILD)/customappearance.so: examples/customappearance/customappearance.c $(LIB_A)
|
|
$(CC) $(CFLAGS_REL) -Iinclude -fPIC -shared \
|
|
$< -o $@ -L$(BUILD) -ltinyblocks -lm '-Wl,-rpath,$$ORIGIN'
|
|
|
|
customappearance: static $(BUILD)/customappearance.so ## Library de demo do on_draw -> build/customappearance.so
|
|
@echo "Build customappearance OK: $(BUILD)/customappearance.so"
|
|
|
|
# -- Library Python (embedding CPython) ---
|
|
$(BUILD)/python.so: examples/python/python.c static lib-python
|
|
$(CC) $(CFLAGS_REL) $(PYTHON_CFLAGS) \
|
|
-I$(PY_DIR)/include -Iinclude -fPIC -shared \
|
|
$< -o $@ -L$(PY_DIR)/build -L$(BUILD) -ltinyblocks-python -ltinyblocks \
|
|
'-Wl,-rpath,$$ORIGIN' '-Wl,-rpath,$(abspath $(PY_DIR)/build)'
|
|
|
|
python-lib: static lib-python $(BUILD)/python.so ## Library Python (CPython embutido) -> build/python.so
|
|
@echo "Build python OK: $(BUILD)/python.so"
|
|
|
|
# -- Library MCP (cliente MCP em Python embutido; blocos da categoria "MCP") ---
|
|
mcp-lib: static lib-mcp ## Library MCP -> libraries/tinyblocks-mcp/build/libtinyblocks-mcp.so
|
|
@echo "Build mcp OK: $(MC_DIR)/build/libtinyblocks-mcp.so"
|
|
|
|
ed-modules: ## Reconstroi so as libraries privadas do editor (hot reload)
|
|
$(MAKE) -C $(ED_DIR)
|
|
|
|
# ── Testes (harness headless com ASan/UBSan) ─────────────────────────────
|
|
$(BUILD)/editor_harness: tests/editor_harness.c $(SRCS) \
|
|
$(EDITOR_SRC)/tb_editor.c $(EDITOR_SRC)/tb_stage_widget.c \
|
|
$(EDITOR_SRC)/tb_editor_modules.c \
|
|
$(EW_DIR)/include/tb_editor_widgets.h \
|
|
$(EIMG_DIR)/include/tb_editor_image.h \
|
|
$(EFILES_DIR)/include/tb_editor_files.h \
|
|
$(GX_DIR)/src/tb_graphics.c $(A11Y_DIR)/src/tb_a11y.c $(A11Y_DIR)/include/tb_a11y.h \
|
|
$(EDITOR_SRC)/tb_editor_mcp.c $(EDITOR_SRC)/tb_editor_jit.c $(MCPS_DIR)/src/tb_mcp_server.c $(MCPS_DIR)/src/tb_mcp_http.c \
|
|
lib-blueprint ed-modules
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) \
|
|
-I$(ED_DIR)/include -I$(A11Y_DIR)/include -I$(MCPS_DIR)/include -DTB_EDITOR_PRIVATE_API -DTB_MCP_SERVER_PRIVATE_API -I$(EW_DIR)/include -I$(EIMG_DIR)/include -I$(EFILES_DIR)/include -I$(GFX_INC) $(CAT_INCS) -I$(BP_DIR)/include \
|
|
-I$(API_DIR)/include -I$(LIBM_DIR)/include -I$(EN_DIR)/include -I$(TOML_DIR)/include -I$(CV_DIR)/include -I$(B64_DIR)/include -I$(PPM_DIR)/include -I$(SYN_DIR)/include -I$(SB_DIR)/include \
|
|
$(SRCS) \
|
|
$(EDITOR_SRC)/tb_editor.c $(EDITOR_SRC)/tb_stage_widget.c \
|
|
$(EDITOR_SRC)/tb_editor_modules.c \
|
|
$(GX_DIR)/src/tb_graphics.c $(A11Y_DIR)/src/tb_a11y.c \
|
|
$(EDITOR_SRC)/tb_editor_mcp.c $(EDITOR_SRC)/tb_editor_jit.c $(MCPS_DIR)/src/tb_mcp_server.c $(MCPS_DIR)/src/tb_mcp_http.c \
|
|
$(BP_DIR)/src/blueprint.c $(BP_DIR)/src/serialize.c \
|
|
$(API_DIR)/src/tb_api.c $(LIBM_DIR)/src/tb_libman.c \
|
|
$(TOML_LIB_SRCS) $(TOML_DIR)/src/tb_toml.c \
|
|
$(foreach l,$(CAT_LIBS),$(LIBDIR)/tinyblocks-$(l)/src/tb_$(l).c) \
|
|
$(CV_DIR)/src/tb_curves.c $(B64_DIR)/src/tb_base64.c $(PPM_DIR)/src/tb_ppm.c $(SYN_DIR)/src/tb_syntax.c $(SB_DIR)/src/tb_scratchblocks.c tests/editor_harness.c -o $@ -ldl -lm -rdynamic
|
|
|
|
$(BUILD)/vm_bench: tests/vm_bench.c $(IMG_DIR)/src/tb_imglib.c $(SRCS) \
|
|
$(EDITOR_SRC)/tb_editor.c $(EDITOR_SRC)/tb_stage_widget.c \
|
|
$(EDITOR_SRC)/tb_editor_modules.c \
|
|
$(EW_DIR)/include/tb_editor_widgets.h \
|
|
$(EIMG_DIR)/include/tb_editor_image.h \
|
|
$(EFILES_DIR)/include/tb_editor_files.h \
|
|
$(GX_DIR)/src/tb_graphics.c $(A11Y_DIR)/src/tb_a11y.c $(A11Y_DIR)/include/tb_a11y.h \
|
|
$(EDITOR_SRC)/tb_editor_mcp.c $(EDITOR_SRC)/tb_editor_jit.c $(MCPS_DIR)/src/tb_mcp_server.c $(MCPS_DIR)/src/tb_mcp_http.c \
|
|
lib-blueprint ed-modules
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_REL) -g -I$(IMG_DIR)/include \
|
|
-I$(ED_DIR)/include -I$(A11Y_DIR)/include -I$(MCPS_DIR)/include -DTB_EDITOR_PRIVATE_API -DTB_MCP_SERVER_PRIVATE_API -I$(EW_DIR)/include -I$(EIMG_DIR)/include -I$(EFILES_DIR)/include -I$(GFX_INC) $(CAT_INCS) -I$(BP_DIR)/include \
|
|
-I$(API_DIR)/include -I$(LIBM_DIR)/include -I$(EN_DIR)/include -I$(TOML_DIR)/include -I$(CV_DIR)/include -I$(B64_DIR)/include -I$(PPM_DIR)/include -I$(SYN_DIR)/include -I$(SB_DIR)/include \
|
|
$(SRCS) \
|
|
$(EDITOR_SRC)/tb_editor.c $(EDITOR_SRC)/tb_stage_widget.c \
|
|
$(EDITOR_SRC)/tb_editor_modules.c \
|
|
$(GX_DIR)/src/tb_graphics.c $(A11Y_DIR)/src/tb_a11y.c \
|
|
$(EDITOR_SRC)/tb_editor_mcp.c $(EDITOR_SRC)/tb_editor_jit.c $(MCPS_DIR)/src/tb_mcp_server.c $(MCPS_DIR)/src/tb_mcp_http.c \
|
|
$(BP_DIR)/src/blueprint.c $(BP_DIR)/src/serialize.c \
|
|
$(API_DIR)/src/tb_api.c $(LIBM_DIR)/src/tb_libman.c \
|
|
$(TOML_LIB_SRCS) $(TOML_DIR)/src/tb_toml.c \
|
|
$(foreach l,$(CAT_LIBS),$(LIBDIR)/tinyblocks-$(l)/src/tb_$(l).c) \
|
|
$(CV_DIR)/src/tb_curves.c $(B64_DIR)/src/tb_base64.c $(PPM_DIR)/src/tb_ppm.c $(SYN_DIR)/src/tb_syntax.c $(SB_DIR)/src/tb_scratchblocks.c $(IMG_DIR)/src/tb_imglib.c tests/vm_bench.c -o $@ -ldl -lm -rdynamic
|
|
|
|
bench-vm: $(BUILD)/vm_bench ## Mede a VM do editor num projeto (BENCH=projeto.json)
|
|
./$(BUILD)/vm_bench $(BENCH) 10
|
|
|
|
test-editor: $(BUILD)/editor_harness ## Roda o harness headless do editor (ASan/UBSan)
|
|
./$(BUILD)/editor_harness
|
|
|
|
# -- Teste do parser TOML ---
|
|
TOML_LIB_SRCS := $(TOML_DIR)/src/lexer.c $(TOML_DIR)/src/parser.c
|
|
|
|
$(BUILD)/toml_test: tests/toml_test.c $(TOML_LIB_SRCS) $(TOML_DIR)/include/ast.h $(TOML_DIR)/include/lexeme.h
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -I$(TOML_DIR)/include $(TOML_LIB_SRCS) tests/toml_test.c -o $@
|
|
|
|
test-toml: $(BUILD)/toml_test ## Roda o teste do parser TOML (ASan/UBSan)
|
|
./$(BUILD)/toml_test
|
|
|
|
# -- Teste da blueprint (modelo + serializacao) ---
|
|
BP_LIB_SRCS := $(BP_DIR)/src/blueprint.c $(BP_DIR)/src/serialize.c
|
|
|
|
$(BUILD)/blueprint_test: tests/blueprint_test.c $(BP_LIB_SRCS) static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -I$(BP_DIR)/include $(BP_LIB_SRCS) tests/blueprint_test.c -o $@ \
|
|
-Wl,--start-group $(LIB_A) -Wl,--end-group
|
|
|
|
test-blueprint: $(BUILD)/blueprint_test ## Roda o teste da blueprint (ASan/UBSan)
|
|
./$(BUILD)/blueprint_test
|
|
|
|
# -- Teste do gestor de libraries (libman + api) ---
|
|
$(BUILD)/libman_test: tests/libman_test.c \
|
|
$(API_DIR)/src/tb_api.c $(LIBM_DIR)/src/tb_libman.c \
|
|
$(TOML_LIB_SRCS) $(TOML_DIR)/src/tb_toml.c \
|
|
$(foreach l,$(CAT_LIBS),$(LIBDIR)/tinyblocks-$(l)/src/tb_$(l).c) static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -I$(API_DIR)/include -I$(LIBM_DIR)/include -I$(TOML_DIR)/include -I$(GFX_INC) \
|
|
$(CAT_INCS) \
|
|
$(API_DIR)/src/tb_api.c $(LIBM_DIR)/src/tb_libman.c \
|
|
$(TOML_LIB_SRCS) $(TOML_DIR)/src/tb_toml.c \
|
|
$(foreach l,$(CAT_LIBS),$(LIBDIR)/tinyblocks-$(l)/src/tb_$(l).c) \
|
|
tests/libman_test.c -o $@ \
|
|
-Wl,--start-group $(LIB_A) -Wl,--end-group -ldl -lm
|
|
|
|
test-libman: $(BUILD)/libman_test ## Roda o teste do libman/api (ASan/UBSan)
|
|
./$(BUILD)/libman_test
|
|
|
|
# -- Teste da library environ (store + blocos + CSV) ---
|
|
$(BUILD)/environ_test: tests/environ_test.c $(EN_DIR)/src/tb_environ.c static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -I$(EN_DIR)/include $(EN_DIR)/src/tb_environ.c \
|
|
tests/environ_test.c -o $@ \
|
|
-Wl,--start-group $(LIB_A) -Wl,--end-group
|
|
|
|
test-environ: $(BUILD)/environ_test ## Roda o teste da environ (ASan/UBSan)
|
|
./$(BUILD)/environ_test
|
|
|
|
# -- Teste da library mcp (servidor de teste tests/mcp_server.py, stdio e HTTP) ---
|
|
# Sem sanitizers: o CPython embutido nao convive bem com o ASan.
|
|
ER_DIR := $(LIBDIR)/tinyblocks-errors
|
|
$(BUILD)/mcp_test: tests/mcp_test.c tests/mcp_server.py $(ER_DIR)/src/tb_errors.c static lib-mcp lib-mcp-server
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS) -g -I$(MC_DIR)/include -I$(PY_DIR)/include -I$(ER_DIR)/include -I$(MCPS_DIR)/include \
|
|
tests/mcp_test.c $(ER_DIR)/src/tb_errors.c $(MCPS_A) -o $@ \
|
|
-Wl,--whole-archive $(LIB_A) -Wl,--no-whole-archive \
|
|
-L$(MC_DIR)/build -L$(PY_DIR)/build -ltinyblocks-mcp -ltinyblocks-python -lm -rdynamic \
|
|
'-Wl,-rpath,$(abspath $(MC_DIR)/build)' '-Wl,-rpath,$(abspath $(PY_DIR)/build)'
|
|
|
|
test-mcp: $(BUILD)/mcp_test ## Roda o teste do cliente MCP (stdio, HTTP e SSE)
|
|
./$(BUILD)/mcp_test
|
|
|
|
# -- Teste do servidor MCP (as duas eras do protocolo, stdio e HTTP) ---
|
|
$(BUILD)/mcp_server_test: tests/mcp_server_test.c $(MCPS_DIR)/src/tb_mcp_server.c $(MCPS_DIR)/src/tb_mcp_http.c \
|
|
$(MCPS_DIR)/include/tb_mcp_server.h $(MCPS_DIR)/include/tb_mcp_server_internal.h static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -DTB_MCP_SERVER_PRIVATE_API -I$(MCPS_DIR)/include \
|
|
$(MCPS_DIR)/src/tb_mcp_server.c $(MCPS_DIR)/src/tb_mcp_http.c tests/mcp_server_test.c -o $@ $(LIB_A) -lm
|
|
|
|
test-mcp-server: $(BUILD)/mcp_server_test ## Roda o teste do servidor MCP (ASan/UBSan)
|
|
./$(BUILD)/mcp_server_test
|
|
|
|
# -- Teste da library a11y (arvore acessivel) ---
|
|
$(BUILD)/a11y_test: tests/a11y_test.c $(A11Y_DIR)/src/tb_a11y.c $(A11Y_DIR)/include/tb_a11y.h static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -I$(A11Y_DIR)/include $(A11Y_DIR)/src/tb_a11y.c tests/a11y_test.c -o $@
|
|
|
|
test-a11y: $(BUILD)/a11y_test ## Roda o teste da interface de acessibilidade (ASan/UBSan)
|
|
./$(BUILD)/a11y_test
|
|
|
|
# -- Teste da library base64 ---
|
|
$(BUILD)/base64_test: tests/base64_test.c $(B64_DIR)/src/tb_base64.c static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -I$(B64_DIR)/include $(B64_DIR)/src/tb_base64.c \
|
|
tests/base64_test.c -o $@ \
|
|
-Wl,--start-group $(LIB_A) -Wl,--end-group
|
|
|
|
test-base64: $(BUILD)/base64_test ## Roda o teste da base64 (ASan/UBSan)
|
|
./$(BUILD)/base64_test
|
|
|
|
# -- Teste dos metadados de blocos (core tb_meta) ---
|
|
$(BUILD)/meta_test: tests/meta_test.c $(OP_DIR)/src/tb_operators.c static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -I$(OP_DIR)/include $(OP_DIR)/src/tb_operators.c \
|
|
tests/meta_test.c -o $@ -Wl,--start-group $(LIB_A) -Wl,--end-group -lm
|
|
|
|
test-meta: $(BUILD)/meta_test ## Roda o teste dos metadados de blocos (ASan/UBSan)
|
|
./$(BUILD)/meta_test
|
|
|
|
# -- Teste da library tensor (valores e gradientes por diferenca finita) ---
|
|
TENSOR_DIR := $(LIBDIR)/tinyblocks-tensor
|
|
TENSOR_SRCS := $(TENSOR_DIR)/src/tensor.c $(TENSOR_DIR)/src/ops.c $(TENSOR_DIR)/src/blocks.c
|
|
$(BUILD)/tensor_test: tests/tensor_test.c $(TENSOR_SRCS) $(TENSOR_DIR)/include/tb_tensor.h $(TENSOR_DIR)/src/tensor_internal.h static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -I$(TENSOR_DIR)/include $(TENSOR_SRCS) tests/tensor_test.c -o $@ \
|
|
-Wl,--start-group $(LIB_A) -Wl,--end-group -lm -lpthread
|
|
|
|
test-tensor: $(BUILD)/tensor_test ## Roda o teste da tensor (ASan/UBSan)
|
|
./$(BUILD)/tensor_test
|
|
|
|
# -- Teste da library ai (gradiente de cada camada, Adam, BPE, genetico) ---
|
|
AI_DIR := $(LIBDIR)/tinyblocks-ai
|
|
AI_SRCS := $(AI_DIR)/src/ai_ops.c $(AI_DIR)/src/ai_conv.c $(AI_DIR)/src/ai_bpe.c
|
|
$(BUILD)/ai_test: tests/ai_test.c $(AI_SRCS) $(AI_DIR)/src/ai_blocks.c $(AI_DIR)/src/ai_internal.h $(TENSOR_SRCS) static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -I$(TENSOR_DIR)/include -I$(AI_DIR)/include -I$(AI_DIR)/src \
|
|
$(TENSOR_SRCS) $(AI_SRCS) tests/ai_test.c -o $@ \
|
|
-Wl,--start-group $(LIB_A) -Wl,--end-group -lm -lpthread
|
|
|
|
test-ai: $(BUILD)/ai_test ## Roda o teste da ai (ASan/UBSan)
|
|
./$(BUILD)/ai_test
|
|
|
|
# -- Teste de socket + ssl + http (servidor local; internet se houver) ---
|
|
NET_SRCS := $(LIBDIR)/tinyblocks-socket/src/tb_socket.c $(LIBDIR)/tinyblocks-ssl/src/tb_ssl.c $(LIBDIR)/tinyblocks-http/src/tb_http.c
|
|
NET_INCS := -I$(LIBDIR)/tinyblocks-socket/include -I$(LIBDIR)/tinyblocks-ssl/include -I$(LIBDIR)/tinyblocks-http/include
|
|
$(BUILD)/http_test: tests/http_test.c $(NET_SRCS) static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) $(NET_INCS) $(NET_SRCS) tests/http_test.c -o $@ \
|
|
-Wl,--start-group $(LIB_A) -Wl,--end-group -lssl -lcrypto -lpthread -lm
|
|
|
|
test-http: $(BUILD)/http_test ## Roda o teste de socket/ssl/http (ASan/UBSan)
|
|
./$(BUILD)/http_test
|
|
|
|
# -- Teste da library archive (.tar / .tar.gz) ---
|
|
$(BUILD)/archive_test: tests/archive_test.c $(LIBDIR)/tinyblocks-archive/src/tb_archive.c static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -I$(LIBDIR)/tinyblocks-archive/include $(LIBDIR)/tinyblocks-archive/src/tb_archive.c \
|
|
tests/archive_test.c -o $@ -Wl,--start-group $(LIB_A) -Wl,--end-group -lz -lm
|
|
|
|
test-archive: $(BUILD)/archive_test ## Roda o teste da archive (ASan/UBSan)
|
|
./$(BUILD)/archive_test
|
|
|
|
# -- Teste da library plot (figura -> imagem PNG) ---
|
|
PLOT_DIR := $(LIBDIR)/tinyblocks-plot
|
|
$(BUILD)/plot_test: tests/plot_test.c $(PLOT_DIR)/src/tb_plot.c $(PLOT_DIR)/src/plot_font.h $(TENSOR_SRCS) static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -I$(TENSOR_DIR)/include -I$(PLOT_DIR)/include -I$(PNG_DIR)/include \
|
|
$(TENSOR_SRCS) $(PLOT_DIR)/src/tb_plot.c $(PNG_DIR)/src/tb_png.c tests/plot_test.c -o $@ \
|
|
-Wl,--start-group $(LIB_A) -Wl,--end-group -lpng -lm -lpthread
|
|
|
|
test-plot: $(BUILD)/plot_test ## Roda o teste da plot (ASan/UBSan; grava /tmp/tb_plot_*.png)
|
|
./$(BUILD)/plot_test
|
|
|
|
# -- Teste da library curves ---
|
|
$(BUILD)/curves_test: tests/curves_test.c $(CV_DIR)/src/tb_curves.c static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -I$(CV_DIR)/include $(CV_DIR)/src/tb_curves.c \
|
|
tests/curves_test.c -o $@ \
|
|
-Wl,--start-group $(LIB_A) -Wl,--end-group -lm
|
|
|
|
test-curves: $(BUILD)/curves_test ## Roda o teste da curves (ASan/UBSan)
|
|
./$(BUILD)/curves_test
|
|
|
|
# -- Teste da library ppm (usa o tipo imagem do core) ---
|
|
$(BUILD)/ppm_test: tests/ppm_test.c $(PPM_DIR)/src/tb_ppm.c static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -I$(PPM_DIR)/include $(PPM_DIR)/src/tb_ppm.c \
|
|
tests/ppm_test.c -o $@ \
|
|
-Wl,--start-group $(LIB_A) -Wl,--end-group
|
|
|
|
test-ppm: $(BUILD)/ppm_test ## Roda o teste da ppm (ASan/UBSan)
|
|
./$(BUILD)/ppm_test
|
|
|
|
# -- Teste da library bmp ---
|
|
$(BUILD)/bmp_test: tests/bmp_test.c $(BMP_DIR)/src/tb_bmp.c static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -I$(BMP_DIR)/include $(BMP_DIR)/src/tb_bmp.c \
|
|
tests/bmp_test.c -o $@ \
|
|
-Wl,--start-group $(LIB_A) -Wl,--end-group
|
|
|
|
test-bmp: $(BUILD)/bmp_test ## Roda o teste da bmp (ASan/UBSan)
|
|
./$(BUILD)/bmp_test
|
|
|
|
# -- Teste da library png (libpng) ---
|
|
PNG_CFLAGS := $(shell pkg-config --cflags libpng 2>/dev/null)
|
|
PNG_LIBS := $(shell pkg-config --libs libpng 2>/dev/null)
|
|
|
|
FREETYPE_CFLAGS := $(shell pkg-config --cflags freetype2 2>/dev/null)
|
|
FREETYPE_LIBS := $(shell pkg-config --libs freetype2 2>/dev/null) -lm
|
|
EXTRA_TEST_LIBS :=
|
|
$(BUILD)/png_test: tests/png_test.c $(PNG_DIR)/src/tb_png.c static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) $(PNG_CFLAGS) -I$(PNG_DIR)/include $(PNG_DIR)/src/tb_png.c \
|
|
tests/png_test.c -o $@ \
|
|
-Wl,--start-group $(LIB_A) -Wl,--end-group $(PNG_LIBS)
|
|
|
|
test-png: $(BUILD)/png_test ## Roda o teste da png (ASan/UBSan)
|
|
./$(BUILD)/png_test
|
|
|
|
# -- Teste da library image (ops genericas + registro de formatos) ---
|
|
$(BUILD)/image_test: tests/image_test.c $(IMG_DIR)/src/tb_imglib.c $(PPM_DIR)/src/tb_ppm.c $(BMP_DIR)/src/tb_bmp.c static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -I$(IMG_DIR)/include -I$(PPM_DIR)/include -I$(BMP_DIR)/include \
|
|
$(IMG_DIR)/src/tb_imglib.c $(PPM_DIR)/src/tb_ppm.c $(BMP_DIR)/src/tb_bmp.c \
|
|
tests/image_test.c -o $@ \
|
|
-Wl,--start-group $(LIB_A) -Wl,--end-group -lm
|
|
|
|
test-image: $(BUILD)/image_test ## Roda o teste da image (ASan/UBSan)
|
|
./$(BUILD)/image_test
|
|
|
|
# -- Teste da library vg (vetorial + rasterizador) ---
|
|
$(BUILD)/vg_test: tests/vg_test.c $(VG_DIR)/src/tb_vg.c static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -I$(VG_DIR)/include $(VG_DIR)/src/tb_vg.c \
|
|
tests/vg_test.c -o $@ \
|
|
-Wl,--start-group $(LIB_A) -Wl,--end-group -lm
|
|
|
|
test-vg: $(BUILD)/vg_test ## Roda o teste da vg (ASan/UBSan)
|
|
./$(BUILD)/vg_test
|
|
|
|
# -- Teste da library svg (parser + rasterizacao via vg + base64) ---
|
|
$(BUILD)/svg_test: tests/svg_test.c $(SVG_DIR)/src/tb_svg.c $(VG_DIR)/src/tb_vg.c $(B64_DIR)/src/tb_base64.c static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -I$(SVG_DIR)/include -I$(VG_DIR)/include -I$(B64_DIR)/include \
|
|
$(SVG_DIR)/src/tb_svg.c $(VG_DIR)/src/tb_vg.c $(B64_DIR)/src/tb_base64.c \
|
|
tests/svg_test.c -o $@ \
|
|
-Wl,--start-group $(LIB_A) -Wl,--end-group -lm
|
|
|
|
test-svg: $(BUILD)/svg_test ## Roda o teste da svg (ASan/UBSan)
|
|
./$(BUILD)/svg_test
|
|
|
|
# -- Testes das libraries de texto/sintaxe -------------------------------
|
|
$(BUILD)/syntax_test: tests/syntax_test.c $(SYN_DIR)/src/tb_syntax.c static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -I$(SYN_DIR)/include $(SYN_DIR)/src/tb_syntax.c tests/syntax_test.c \
|
|
-o $@ -Wl,--start-group $(LIB_A) -Wl,--end-group $(EXTRA_TEST_LIBS)
|
|
|
|
test-syntax: $(BUILD)/syntax_test ## Roda o teste da syntax (ASan/UBSan)
|
|
./$(BUILD)/syntax_test
|
|
|
|
$(BUILD)/os_fs_test: tests/os_fs_test.c $(FS_DIR)/src/tb_fs.c $(LIBDIR)/tinyblocks-os/src/tb_os.c static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -I$(FS_DIR)/include -I$(LIBDIR)/tinyblocks-os/include \
|
|
$(FS_DIR)/src/tb_fs.c $(LIBDIR)/tinyblocks-os/src/tb_os.c tests/os_fs_test.c \
|
|
-o $@ -Wl,--start-group $(LIB_A) -Wl,--end-group $(EXTRA_TEST_LIBS)
|
|
|
|
test-os: $(BUILD)/os_fs_test ## Roda o teste de tinyblocks-os + pastas do tinyblocks-fs (ASan/UBSan)
|
|
./$(BUILD)/os_fs_test
|
|
|
|
$(BUILD)/value_test: tests/value_test.c static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) tests/value_test.c -o $@ -Wl,--start-group $(LIB_A) -Wl,--end-group $(EXTRA_TEST_LIBS)
|
|
|
|
test-value: $(BUILD)/value_test ## Roda o teste das classes de valor e do Result (ASan/UBSan)
|
|
./$(BUILD)/value_test
|
|
|
|
$(BUILD)/vars_test: tests/vars_test.c $(LIBDIR)/tinyblocks-variables/src/tb_variables.c static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -I$(LIBDIR)/tinyblocks-variables/include \
|
|
$(LIBDIR)/tinyblocks-variables/src/tb_variables.c tests/vars_test.c \
|
|
-o $@ -Wl,--start-group $(LIB_A) -Wl,--end-group -lm $(EXTRA_TEST_LIBS)
|
|
|
|
test-vars: $(BUILD)/vars_test ## Roda o teste das variáveis com escopos (ASan/UBSan)
|
|
./$(BUILD)/vars_test
|
|
|
|
$(BUILD)/scratchblocks_test: tests/scratchblocks_test.c $(SB_DIR)/src/tb_scratchblocks.c $(BP_LIB_SRCS)
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -I$(SB_DIR)/include -I$(BP_DIR)/include \
|
|
$(SB_DIR)/src/tb_scratchblocks.c $(BP_LIB_SRCS) tests/scratchblocks_test.c \
|
|
-o $@ -Wl,--start-group $(LIB_A) -Wl,--end-group $(EXTRA_TEST_LIBS)
|
|
|
|
test-scratchblocks: $(BUILD)/scratchblocks_test static ## Roda o teste da notação scratchblocks (ASan/UBSan)
|
|
./$(BUILD)/scratchblocks_test
|
|
|
|
$(BUILD)/input_test: tests/input_test.c $(LIBDIR)/tinyblocks-input/src/tb_input.c static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -I$(LIBDIR)/tinyblocks-input/include -I$(GFX_INC) \
|
|
$(LIBDIR)/tinyblocks-input/src/tb_input.c tests/input_test.c \
|
|
-o $@ -Wl,--start-group $(LIB_A) -Wl,--end-group -lm $(EXTRA_TEST_LIBS)
|
|
|
|
test-input: $(BUILD)/input_test ## Roda o teste de tinyblocks-input + estado de entrada do core (ASan/UBSan)
|
|
./$(BUILD)/input_test
|
|
|
|
STD_DIRS := $(LIBDIR)/tinyblocks-string $(LIBDIR)/tinyblocks-number $(LIBDIR)/tinyblocks-vector $(LIBDIR)/tinyblocks-operators
|
|
STD_SRCS := $(foreach d,$(STD_DIRS),$(d)/src/$(patsubst tinyblocks-%,tb_%,$(notdir $(d))).c)
|
|
|
|
$(BUILD)/stdlib_test: tests/stdlib_test.c $(STD_SRCS) static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) $(foreach d,$(STD_DIRS),-I$(d)/include) $(STD_SRCS) tests/stdlib_test.c \
|
|
-o $@ -Wl,--start-group $(LIB_A) -Wl,--end-group -lm $(EXTRA_TEST_LIBS)
|
|
|
|
test-stdlib: $(BUILD)/stdlib_test ## Roda o teste de tinyblocks-string/number/vector (ASan/UBSan)
|
|
./$(BUILD)/stdlib_test
|
|
|
|
$(BUILD)/regex_test: tests/regex_test.c $(RE_DIR)/src/tb_regex.c static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -I$(RE_DIR)/include $(RE_DIR)/src/tb_regex.c tests/regex_test.c \
|
|
-o $@ -Wl,--start-group $(LIB_A) -Wl,--end-group $(EXTRA_TEST_LIBS)
|
|
|
|
test-regex: $(BUILD)/regex_test ## Roda o teste da regex (ASan/UBSan)
|
|
./$(BUILD)/regex_test
|
|
|
|
$(BUILD)/markdown_test: tests/markdown_test.c $(MD_DIR)/src/tb_markdown.c static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -I$(MD_DIR)/include $(MD_DIR)/src/tb_markdown.c tests/markdown_test.c \
|
|
-o $@ -Wl,--start-group $(LIB_A) -Wl,--end-group $(EXTRA_TEST_LIBS)
|
|
|
|
test-markdown: $(BUILD)/markdown_test ## Roda o teste da markdown (ASan/UBSan)
|
|
./$(BUILD)/markdown_test
|
|
|
|
$(BUILD)/opentype_test: tests/opentype_test.c $(OT_DIR)/src/tb_opentype.c static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -I$(OT_DIR)/include $(FREETYPE_CFLAGS) $(OT_DIR)/src/tb_opentype.c tests/opentype_test.c \
|
|
-o $@ -Wl,--start-group $(LIB_A) -Wl,--end-group $(FREETYPE_LIBS) $(EXTRA_TEST_LIBS)
|
|
|
|
test-opentype: $(BUILD)/opentype_test ## Roda o teste da opentype (ASan/UBSan)
|
|
./$(BUILD)/opentype_test
|
|
|
|
# -- Teste da library jpg (libjpeg; pulado se os headers faltarem) ---
|
|
JPG_TEST_AVAILABLE := $(shell printf '#include <jpeglib.h>\nint main(void){return 0;}\n' | \
|
|
$(CC) -xc - -ljpeg -o /dev/null >/dev/null 2>&1 && echo yes)
|
|
ifeq ($(JPG_TEST_AVAILABLE),yes)
|
|
$(BUILD)/jpg_test: tests/jpg_test.c $(JPG_DIR)/src/tb_jpg.c static
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -I$(JPG_DIR)/include $(JPG_DIR)/src/tb_jpg.c \
|
|
tests/jpg_test.c -o $@ \
|
|
-Wl,--start-group $(LIB_A) -Wl,--end-group -ljpeg
|
|
|
|
test-jpg: $(BUILD)/jpg_test ## Roda o teste da jpg (ASan/UBSan)
|
|
./$(BUILD)/jpg_test
|
|
else
|
|
test-jpg: ## (libjpeg-dev ausente: teste ignorado)
|
|
@echo "test-jpg: <jpeglib.h>/libjpeg-dev ausente - pulando"
|
|
endif
|
|
|
|
# -- Teste de plugin .so standalone ---
|
|
FS_SO := $(FS_DIR)/build/libtinyblocks-fs.so
|
|
|
|
$(BUILD)/plugin_test: tests/plugin_test.c static $(FS_SO)
|
|
@mkdir -p $(BUILD)
|
|
$(CC) $(CFLAGS_DBG) -Iinclude tests/plugin_test.c -o $@ \
|
|
-Wl,--start-group $(LIB_A) -Wl,--end-group -ldl -rdynamic
|
|
|
|
test-plugin: $(BUILD)/plugin_test ## Carrega library-fs .so via dlopen e testa
|
|
./$(BUILD)/plugin_test $(FS_SO)
|
|
|
|
# ── Limpeza ──────────────────────────────────────────────────────────────
|
|
clean: ## Remove os diretórios build/ (raiz e libraries)
|
|
$(RM) -r $(BUILD)
|
|
@for d in $(EV_DIR) $(CT_DIR) $(OP_DIR) $(VR_DIR) $(AP_DIR) $(PN_DIR) $(FS_DIR) \
|
|
$(TOML_DIR) $(JSON_DIR) $(XML_DIR) $(CSV_DIR) $(BP_DIR) \
|
|
$(B64_DIR) $(CV_DIR) $(PPM_DIR) $(BMP_DIR) $(PNG_DIR) $(IMG_DIR) $(VG_DIR) $(SVG_DIR) $(JPG_DIR) $(SYN_DIR) $(RE_DIR) $(MD_DIR) $(OT_DIR) \
|
|
$(API_DIR) $(LIBM_DIR) \
|
|
$(ED_DIR) $(GX_DIR) $(SD_DIR) $(PY_DIR) $(MC_DIR); do \
|
|
$(MAKE) -C $$d clean >/dev/null 2>&1 || true; \
|
|
done
|
|
$(RM) $(MC_DIR)/src/tb_mcp_py.h
|