Files
Matteo Benedetto 5f82187c67 progress: barra di avanzamento per download ed estrazione
Aggiunge src/progress.{c,h}: barra a una riga attiva solo quando stdout e' un
terminale (con output rediretto/pipeline non stampa nulla, quindi l'output resta
identico al client Python: parita' 30/30 invariata).

- due fasi: "Scaricamento" (byte da Content-Length) ed "Estrazione" (byte
  compressi consumati + membri processati: nuovo contatore in gz_reader e
  callback tar_progress_fn/tar_extract_cb)
- controllo con CELLAR_PROGRESS=auto|bar|plain|off (default auto)
- nessun codice ANSI, solo '\r' e riempimento con spazi; glifi ASCII se la
  locale non e' UTF-8, larghezza da TIOCGWINSZ e misurata in colonne (i glifi
  UTF-8 sono multi-byte), ridisegno throttled, velocita' a media mobile, ETA
- percorsi d'errore: progress_abort() chiude la riga senza riepilogo; il file
  parziale resta come nel client Python
- tests/progress_test.sh: pipe silenziosa, PTY via script (barra, ETA, riepilogo,
  nessun ANSI, righe entro la larghezza), modalita' plain e off, integrita' del
  file scaricato e della bottiglia installata (13/13 verdi)
- tests/parity_test.sh resta 30/30; mock_server.py con --throttle per i test
2026-09-20 17:46:29 +02:00

58 lines
1.9 KiB
Makefile

# cellar-cli-c — reimplementazione C del client CLI di Cellar
#
# Target principali:
# make -> dist/cellar-cli (x86-64 statico, glibc)
# make 32 -> dist/cellar-cli-i686 (i686 statico, per sistemi 32 bit)
# make arm64 -> dist/cellar-cli-aarch64 (aarch64 statico via cross toolchain)
# make dist -> tutti e tre
# make verify -> controlla dipendenze, simboli GLIBC richiesti, ldd, size
# make test -> parity test contro il client Python (server mock incluso)
# make asan -> build dinamica con AddressSanitizer/UBSan per i test
CC ?= gcc
AARCH64_CC ?= $(HOME)/toolchains/arm-gnu-toolchain-13.2.Rel1-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-gcc
CFLAGS ?= -std=c99 -O2 -Wall -Wextra -Wno-unused-parameter
CPPFLAGS += -D_POSIX_C_SOURCE=200809L -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Isrc -Ithird_party
SRCS := $(wildcard src/*.c) third_party/miniz.c
DIST := dist
NAME := cellar-cli
.PHONY: all 32 arm64 dist verify test asan clean
all: $(DIST)/$(NAME)
$(DIST)/$(NAME): $(SRCS)
@mkdir -p $(DIST)
$(CC) $(CFLAGS) $(CPPFLAGS) -static -static-libgcc -s -o $@ $(SRCS)
$(DIST)/$(NAME)-i686: $(SRCS)
@mkdir -p $(DIST)
$(CC) -m32 $(CFLAGS) $(CPPFLAGS) -static -static-libgcc -s -o $@ $(SRCS)
$(DIST)/$(NAME)-aarch64: $(SRCS)
@mkdir -p $(DIST)
$(AARCH64_CC) $(CFLAGS) $(CPPFLAGS) -static -s -o $@ $(SRCS)
32: $(DIST)/$(NAME)-i686
arm64: $(DIST)/$(NAME)-aarch64
dist: all 32 arm64
# Build dinamica con sanitizzatori: usata dai test di parità.
$(DIST)/$(NAME)-asan: $(SRCS)
@mkdir -p $(DIST)
$(CC) -g -O1 -fsanitize=address,undefined -fno-omit-frame-pointer $(CFLAGS) $(CPPFLAGS) -o $@ $(SRCS)
asan: $(DIST)/$(NAME)-asan
verify: all
tests/verify_binary.sh $(DIST)/$(NAME)
test: asan
tests/parity_test.sh # parita' col client Python (30 casi + artefatti)
tests/progress_test.sh # barra di avanzamento (pipe/PTY/plain/off)
clean:
rm -rf $(DIST) build tests/tmp