Implemented macro loader. Updated Makefile. Closes #5

main
Alexander Griffith 2021-09-13 01:25:46 -04:00
parent b5e74ae246
commit 2254527d3d
2 changed files with 19 additions and 10 deletions

View File

@ -4,4 +4,19 @@ table.insert(package.loaders, fennel.make_searcher({correlate=true}))
pp = function(x) print(fennel.view(x)) end
lume = require("lib.lume")
local make_love_searcher = function(env)
return function(module_name)
local path = module_name:gsub("%.", "/") .. ".fnl"
if love.filesystem.getInfo(path) then
return function(...)
local code = love.filesystem.read(path)
return fennel.eval(code, {env=env}, ...)
end, path
end
end
end
table.insert(package.loaders, make_love_searcher(_G))
table.insert(fennel["macro-searchers"], make_love_searcher("_COMPILER"))
require("wrap")

View File

@ -9,22 +9,16 @@ DESCRIPTION="Minimal setup for trying out Phil Hagelberg's fennel/love game desi
LIBS := $(wildcard lib/*)
LUA := $(wildcard *.lua)
SRC := $(wildcard *.fnl)
OUT := $(patsubst %.fnl,%.lua,$(SRC))
run: ; love .
run: $(OUT) ; love .
count: ; cloc *.fnl
count: ; cloc *.fnl --force-lang=clojure
clean: ; rm -rf releases/* $(OUT)
cleansrc: ; rm -rf $(OUT)
%.lua: %.fnl; lua lib/fennel --compile --correlate $< > $@
clean: ; rm -rf releases/*
LOVEFILE=releases/$(NAME)-$(VERSION).love
$(LOVEFILE): $(LUA) $(OUT) $(LIBS)
$(LOVEFILE): $(LUA) $(SRC) $(LIBS)
mkdir -p releases/
find $^ -type f | LC_ALL=C sort | env TZ=UTC zip -r -q -9 -X $@ -@