Makefile (2378B)
1 # st80 : Smalltalk-80 (image Xerox du 1er avril 1983) dans le navigateur, servi sur https://st80.schurger.org 2 # La VM « by the Bluebook » de Dan Banay (vm/, MIT) est compilée en WebAssembly par Emscripten ; 3 # l'image et les sources sont servies en fichiers statiques (web/images/). 4 HOST = apostrophe 5 WWW = /var/www/st80.schurger.org 6 VHOST = st80.schurger.org 7 8 # Emscripten par l'image Docker officielle (le paquet Debian est incompatible avec le nodejs de nodesource). 9 # Le cache (port SDL2 compilé) vit dans .emcache/, ignoré par git. 10 EMSDK_IMAGE = emscripten/emsdk:6.0.13 11 DOCKER = docker run --rm -u $(shell id -u):$(shell id -g) -e HOME=/tmp -e EM_CACHE=/src/.emcache \ 12 -v $(CURDIR):/src -w /src $(EMSDK_IMAGE) 13 14 SRCS = vm/objmemory.cpp vm/bitblt.cpp vm/interpreter.cpp vm/main.cpp 15 HDRS = $(wildcard vm/*.h) 16 EMFLAGS = -std=c++17 -O3 -sUSE_SDL=2 -sALLOW_MEMORY_GROWTH=1 -sENVIRONMENT=web \ 17 -sMODULARIZE=1 -sEXPORT_NAME=createST80 \ 18 -sEXPORTED_RUNTIME_METHODS=FS,callMain,ccall,UTF8ToString \ 19 -sEXPORTED_FUNCTIONS=_main,_st80_set_budget,_st80_set_paused,_st80_cycle_count,_st80_image_name 20 21 .PHONY: all build test serve deploy install-vhost clean 22 23 all: build 24 25 build: web/st80.js 26 27 web/st80.js: $(SRCS) $(HDRS) Makefile 28 $(DOCKER) em++ $(EMFLAGS) $(SRCS) -o web/st80.js 29 30 # Démarrage dans un Chromium headless : capture d'écran et compteur de bytecodes 31 test: build 32 python3 -m http.server 8082 -d web --bind 127.0.0.1 >/dev/null 2>&1 & echo $$! > .serve.pid; \ 33 sleep 1; node test/browser.mjs http://127.0.0.1:8082/ 12 /tmp/st80.png; r=$$?; kill `cat .serve.pid`; rm -f .serve.pid; exit $$r 34 35 # Essai local : http://localhost:8082/ 36 serve: 37 python3 -m http.server 8082 -d web 38 39 # Publication : fichiers statiques copiés sur apostrophe 40 deploy: build 41 ssh $(HOST) 'sudo install -d -o jeansch -g jeansch $(WWW)' 42 rsync -rc --delete --exclude '.*' web/ $(HOST):$(WWW)/ 43 @echo "https://$(VHOST)/" 44 45 # Vhost nginx (une fois) : 8443 derrière sslh, certificat joker, comme les autres sites d'apostrophe 46 install-vhost: 47 scp deploy/$(VHOST) $(HOST):/tmp/$(VHOST) 48 ssh $(HOST) 'sudo install -m 644 /tmp/$(VHOST) /etc/nginx/sites-available/$(VHOST) && sudo ln -sf /etc/nginx/sites-available/$(VHOST) /etc/nginx/sites-enabled/$(VHOST) && sudo nginx -t && sudo systemctl reload nginx && rm /tmp/$(VHOST)' 49 50 clean: 51 rm -f web/st80.js web/st80.wasm