Updated makefile.
This commit is contained in:
parent
ff33a7538e
commit
e16c012a0b
133
lib/fennel
133
lib/fennel
|
@ -3,132 +3,55 @@
|
||||||
local fennel_dir = arg[0]:match("(.-)[^\\/]+$")
|
local fennel_dir = arg[0]:match("(.-)[^\\/]+$")
|
||||||
package.path = fennel_dir .. "?.lua;" .. package.path
|
package.path = fennel_dir .. "?.lua;" .. package.path
|
||||||
local fennel = require('fennel')
|
local fennel = require('fennel')
|
||||||
local unpack = unpack or table.unpack
|
|
||||||
|
|
||||||
local help = [[
|
local help = [[
|
||||||
Usage: fennel [FLAG] [FILE]
|
Usage: fennel [FLAG] [FILE]
|
||||||
|
|
||||||
Run fennel, a lisp programming language for the Lua runtime.
|
|
||||||
|
|
||||||
--repl : Launch an interactive repl session
|
--repl : Launch an interactive repl session
|
||||||
--compile FILES : Compile files and write their Lua to stdout
|
--compile FILES : Compile files and write their Lua to stdout
|
||||||
|
|
||||||
--no-searcher : Skip installing package.searchers entry
|
|
||||||
--indent VAL : Indent compiler output with VAL
|
|
||||||
--add-package-path PATH : Add PATH to package.path for finding Lua modules
|
|
||||||
--add-fennel-path PATH : Add PATH to fennel.path for finding Fennel modules
|
|
||||||
--globals G1[,G2...] : Allow these globals in addition to standard ones
|
|
||||||
--globals-only G1[,G2] : Same as above, but exclude standard ones
|
|
||||||
|
|
||||||
--help : Display this text
|
--help : Display this text
|
||||||
--version : Show version
|
|
||||||
|
|
||||||
When not given a flag, runs the file given as the first argument.
|
When not given a flag, runs the file given as the first argument.]]
|
||||||
When given neither flag nor file, launches a repl.
|
|
||||||
|
|
||||||
If ~/.fennelrc exists, loads it before launching a repl.]]
|
|
||||||
|
|
||||||
local options = {
|
local options = {
|
||||||
sourcemap = true
|
sourcemap = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
local function dosafe(filename, opts, args)
|
local function dosafe(filename, opts, arg1)
|
||||||
local ok, val = xpcall(function()
|
local ok, val = xpcall(function()
|
||||||
return fennel.dofile(filename, opts, unpack(args))
|
return fennel.dofile(filename, opts, arg1)
|
||||||
end, fennel.traceback)
|
end, fennel.traceback)
|
||||||
if not ok then
|
if not ok then
|
||||||
io.stderr:write(val .. "\n")
|
print(val)
|
||||||
os.exit(1)
|
os.exit(1)
|
||||||
end
|
end
|
||||||
return val
|
return val
|
||||||
end
|
end
|
||||||
|
|
||||||
local function allowGlobals(globalNames)
|
local compileOptHandlers = {
|
||||||
options.allowedGlobals = {}
|
['--indent'] = function ()
|
||||||
for g in globalNames:gmatch("([^,]+),?") do
|
options.indent = table.remove(arg, 3)
|
||||||
table.insert(options.allowedGlobals, g)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
for i=#arg, 1, -1 do
|
|
||||||
if arg[i] == "--no-searcher" then
|
|
||||||
options.no_searcher = true
|
|
||||||
table.remove(arg, i)
|
|
||||||
elseif arg[i] == "--indent" then
|
|
||||||
options.indent = table.remove(arg, i+1)
|
|
||||||
if options.indent == "false" then options.indent = false end
|
if options.indent == "false" then options.indent = false end
|
||||||
table.remove(arg, i)
|
table.remove(arg, 2)
|
||||||
elseif arg[i] == "--add-package-path" then
|
end,
|
||||||
local entry = table.remove(arg, i+1)
|
['--sourcemap'] = function ()
|
||||||
package.path = entry .. ";" .. package.path
|
options.sourcemap = table.remove(arg, 3)
|
||||||
table.remove(arg, i)
|
|
||||||
elseif arg[i] == "--add-fennel-path" then
|
|
||||||
local entry = table.remove(arg, i+1)
|
|
||||||
fennel.path = entry .. ";" .. fennel.path
|
|
||||||
table.remove(arg, i)
|
|
||||||
elseif arg[i] == "--sourcemap" then
|
|
||||||
options.sourcemap = table.remove(arg, i+1)
|
|
||||||
if options.sourcemap == "false" then options.sourcemap = false end
|
if options.sourcemap == "false" then options.sourcemap = false end
|
||||||
table.remove(arg, i)
|
table.remove(arg, 2)
|
||||||
elseif arg[i] == "--globals" then
|
end,
|
||||||
allowGlobals(table.remove(arg, i+1))
|
['--correlate'] = function ()
|
||||||
for globalName in pairs(_G) do
|
options.correlate = true
|
||||||
table.insert(options.allowedGlobals, globalName)
|
table.remove(arg, 2)
|
||||||
end
|
end,
|
||||||
table.remove(arg, i)
|
}
|
||||||
elseif arg[i] == "--globals-only" then
|
|
||||||
allowGlobals(table.remove(arg, i+1))
|
|
||||||
table.remove(arg, i)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if not options.no_searcher then
|
|
||||||
table.insert((package.loaders or package.searchers),
|
|
||||||
fennel.make_searcher({correlate = true}))
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Try to load readline library
|
|
||||||
local function tryReadline(opts)
|
|
||||||
local ok, readline = pcall(require, "readline")
|
|
||||||
if ok then
|
|
||||||
readline.set_options({
|
|
||||||
keeplines = 1000
|
|
||||||
})
|
|
||||||
function opts.readChunk(parserState)
|
|
||||||
local prompt = parserState.stackSize > 0 and '.. ' or '>> '
|
|
||||||
local str = readline.readline(prompt)
|
|
||||||
if str then
|
|
||||||
return str .. "\n"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- completer is registered by the repl, until then returns empty list
|
|
||||||
local completer
|
|
||||||
function opts.registerCompleter(replCompleter)
|
|
||||||
completer = replCompleter
|
|
||||||
end
|
|
||||||
local function replCompleter(text, from, to)
|
|
||||||
if completer then return completer(text, from, to) else return {} end
|
|
||||||
end
|
|
||||||
readline.set_complete_function(replCompleter)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if arg[1] == "--repl" or #arg == 0 then
|
if arg[1] == "--repl" or #arg == 0 then
|
||||||
local ppok, pp = pcall(fennel.dofile, fennel_dir .. "fennelview.fnl", options)
|
local ppok, pp = pcall(fennel.dofile, fennel_dir .. "fennelview.fnl", options)
|
||||||
if ppok then
|
if ppok then
|
||||||
options.pp = pp
|
options.pp = pp
|
||||||
else
|
|
||||||
ppok, pp = pcall(require, "fennelview")
|
|
||||||
if ppok then
|
|
||||||
options.pp = pp
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
local initFilename = (os.getenv("HOME") or "") .. "/.fennelrc"
|
local initFilename = (os.getenv("HOME") or "") .. "/.fennelrc"
|
||||||
local init = io.open(initFilename, "rb")
|
local init = io.open(initFilename, "rb")
|
||||||
|
|
||||||
tryReadline(options)
|
|
||||||
|
|
||||||
if init then
|
if init then
|
||||||
init:close()
|
init:close()
|
||||||
-- pass in options so fennerlrc can make changes to it
|
-- pass in options so fennerlrc can make changes to it
|
||||||
|
@ -137,25 +60,23 @@ if arg[1] == "--repl" or #arg == 0 then
|
||||||
print("Welcome to fennel!")
|
print("Welcome to fennel!")
|
||||||
fennel.repl(options)
|
fennel.repl(options)
|
||||||
elseif arg[1] == "--compile" then
|
elseif arg[1] == "--compile" then
|
||||||
|
-- Handle options
|
||||||
|
while compileOptHandlers[arg[2]] do
|
||||||
|
compileOptHandlers[arg[2]]()
|
||||||
|
end
|
||||||
for i = 2, #arg do
|
for i = 2, #arg do
|
||||||
local f = arg[i] == "-" and io.stdin or assert(io.open(arg[i], "rb"))
|
local f = assert(io.open(arg[i], "rb"))
|
||||||
options.filename=arg[i]
|
options.filename=arg[i]
|
||||||
local ok, val = xpcall(function()
|
local ok, val = xpcall(function()
|
||||||
return fennel.compileString(f:read("*all"), options)
|
return fennel.compileString(f:read("*all"), options)
|
||||||
end, fennel.traceback)
|
end, fennel.traceback)
|
||||||
if ok then
|
|
||||||
print(val)
|
print(val)
|
||||||
else
|
if not ok then os.exit(1) end
|
||||||
io.stderr:write(val .. "\n")
|
|
||||||
os.exit(1)
|
|
||||||
end
|
|
||||||
f:close()
|
f:close()
|
||||||
end
|
end
|
||||||
elseif arg[1] == "--version" or arg[1] == "-v" then
|
elseif #arg >= 1 and arg[1] ~= "--help" then
|
||||||
print("Fennel " .. fennel.version)
|
|
||||||
elseif #arg >= 1 and arg[1] ~= "--help" and arg[1] ~= "-h" then
|
|
||||||
local filename = table.remove(arg, 1) -- let the script have remaining args
|
local filename = table.remove(arg, 1) -- let the script have remaining args
|
||||||
dosafe(filename, nil, arg)
|
dosafe(filename)
|
||||||
else
|
else
|
||||||
print(help)
|
print(help)
|
||||||
end
|
end
|
||||||
|
|
5
love-release.sh
Normal file → Executable file
5
love-release.sh
Normal file → Executable file
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/local/Cellar/bash/4.4.23/bin/bash
|
||||||
|
## #!/usr/bin/env bash
|
||||||
|
|
||||||
# LÖVE version
|
# LÖVE version
|
||||||
LOVE_DEF_VERSION=0.11.1
|
LOVE_DEF_VERSION=0.11.2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
35
makefile
35
makefile
|
@ -5,8 +5,23 @@ AUTHOR="Alexander Griffith"
|
||||||
DESCRIPTION="Minimal setup for trying out Phil Hagelberg's fennel/love game design process."
|
DESCRIPTION="Minimal setup for trying out Phil Hagelberg's fennel/love game design process."
|
||||||
|
|
||||||
LIBS := $(wildcard lib/*)
|
LIBS := $(wildcard lib/*)
|
||||||
|
LUA := $(wildcard *.lua)
|
||||||
|
SRC := $(wildcard *.fnl)
|
||||||
|
OUT := $(patsubst %.fnl,%.lua,$(SRC))
|
||||||
|
|
||||||
$(LOVEFILE): $(LUA) $(OUT) $(LIBS) assets text
|
run: $(OUT) ; love .
|
||||||
|
|
||||||
|
count: ; cloc *.fnl --force-lang=clojure
|
||||||
|
|
||||||
|
clean: ; rm -rf releases/* $(OUT)
|
||||||
|
|
||||||
|
cleansrc: ; rm -rf $(OUT)
|
||||||
|
|
||||||
|
%.lua: %.fnl; lua lib/fennel --compile --correlate $< > $@
|
||||||
|
|
||||||
|
LOVEFILE=releases/$(NAME)-$(VERSION).love
|
||||||
|
|
||||||
|
$(LOVEFILE): $(LUA) $(OUT) $(LIBS) #assets text
|
||||||
mkdir -p releases/
|
mkdir -p releases/
|
||||||
find $^ -type f | LC_ALL=C sort | env TZ=UTC zip -r -q -9 -X $@ -@
|
find $^ -type f | LC_ALL=C sort | env TZ=UTC zip -r -q -9 -X $@ -@
|
||||||
|
|
||||||
|
@ -14,31 +29,33 @@ love: $(LOVEFILE)
|
||||||
|
|
||||||
# platform-specific distributables
|
# platform-specific distributables
|
||||||
|
|
||||||
REL="$(PWD)/love-release.sh" # https://p.hagelb.org/love-release.sh
|
REL=$(PWD)/love-release.sh # https://p.hagelb.org/love-release.sh
|
||||||
FLAGS=-a "$(AUTHOR)" --description $(DESCRIPTION) \
|
FLAGS=-a "$(AUTHOR)" --description $(DESCRIPTION) \
|
||||||
--love 11.1 --url $(URL) --version $(VERSION) --lovefile $(LOVEFILE)
|
--love 11.1 --url $(URL) --version $(VERSION) --lovefile $(LOVEFILE)
|
||||||
|
|
||||||
releases/$(NAME)-$(VERSION)-x86_64.AppImage: $(LOVEFILE)
|
releases/$(NAME)-$(VERSION)-x86_64.AppImage: $(LOVEFILE)
|
||||||
cd appimage && ./build.sh 11.1 $(PWD)/$(LOVEFILE)
|
cd appimage && ./build.sh 11.1 $(PWD)/$(LOVEFILE)
|
||||||
mv appimage/game-x86_64.AppImage $@
|
#mv appimage/game-x86_64.AppImage $@
|
||||||
|
|
||||||
releases/$(NAME)-$(VERSION)-macos.zip: $(LOVEFILE)
|
releases/$(NAME)-$(VERSION)-macos.zip: $(LOVEFILE)
|
||||||
$(REL) $(FLAGS) -M
|
$(REL) $(FLAGS) -M
|
||||||
mv releases/EXO_encounter-667-macos.zip $@
|
#mv releases/$(NAME)-macos.zip $@
|
||||||
|
|
||||||
releases/$(NAME)-$(VERSION)-win.zip: $(LOVEFILE)
|
releases/$(NAME)-$(VERSION)-win.zip: $(LOVEFILE)
|
||||||
$(REL) $(FLAGS) -W32
|
$(REL) $(FLAGS) -W32
|
||||||
mv releases/EXO_encounter-667-win32.zip $@
|
#mv releases/$(NAME)-win32.zip $@
|
||||||
|
|
||||||
linux: releases/$(NAME)-$(VERSION)-x86_64.AppImage
|
linux: releases/$(NAME)-$(VERSION)-x86_64.AppImage
|
||||||
mac: releases/$(NAME)-$(VERSION)-macos.zip
|
mac: releases/$(NAME)-$(VERSION)-macos.zip
|
||||||
windows: releases/$(NAME)-$(VERSION)-win.zip
|
windows: releases/$(NAME)-$(VERSION)-win.zip
|
||||||
|
|
||||||
uploadlinux: releases/$(NAME)-$(VERSION)-x86_64.AppImage
|
uploadlinux: releases/$(NAME)-$(VERSION)-x86_64.AppImage
|
||||||
butler push $^ technomancy/exo-encounter-667:linux
|
butler push $^ alexjgriffith/action-slimes:linux --userversion $(VERSION)
|
||||||
uploadmac: releases/$(NAME)-$(VERSION)-macos.zip
|
uploadmac: releases/$(NAME)-$(VERSION)-macos.zip
|
||||||
butler push $^ technomancy/exo-encounter-667:mac
|
~/Downloads/butler-darwin-amd64/butler push $^ alexjgriffith/action-slimes:mac --userversion $(VERSION)
|
||||||
uploadwindows: releases/$(NAME)-$(VERSION)-win.zip
|
uploadwindows: releases/$(NAME)-$(VERSION)-win.zip
|
||||||
butler push $^ technomancy/exo-encounter-667:windows
|
~/Downloads/butler-darwin-amd64/butler push $^ alexjgriffith/action-slimes:windows --userversion $(VERSION)
|
||||||
|
|
||||||
upload: uploadlinux uploadmac uploadwindows
|
upload: uploadmac uploadwindows
|
||||||
|
|
||||||
|
release: mac windows upload cleansrc
|
||||||
|
|
Loading…
Reference in a new issue