diff --git a/main.lua b/main.lua index 6d9a950..d7db906 100644 --- a/main.lua +++ b/main.lua @@ -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") diff --git a/makefile b/makefile index bc03a7e..8329918 100644 --- a/makefile +++ b/makefile @@ -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 $@ -@