Updated makefile and buildtools to work with web

This commit is contained in:
Alexander Griffith 2021-09-13 01:15:26 -04:00
parent b58f85d957
commit b5e74ae246
6 changed files with 85 additions and 13 deletions

View file

@ -30,10 +30,10 @@ if [ ! -f $release_dir/$name-$version.love ]; then
fi
release="compat"
canvas_colour="197, 204, 184"
canvas_colour="62, 50, 100"
page_colour=$canvas_colour
text_colour="102, 96, 146"
initial_memory=$(du -b $release_dir/$name-$version.love | awk '{print $1}')
text_colour="223, 7, 114"
initial_memory=0 #$(du -b $release_dir/$name-$version.love | awk '{print $1}')
title=$(echo $name-$version | sed -r 's/\<./\U&/g' | sed -r 's/-/\ /g')
# echo $title " " $canvas_colour " " $text_colour " " $initial_memory
@ -54,9 +54,13 @@ cat src/love.css | \
sed "s/{{page-colour}}/${page_colour}/g" > \
$name-$version/theme/love.css
cat src/game.js | \
sed "s/{{{metadata}}}/{\"package_uuid\":\"2fd99e56-5455-45dd-86dd-7af724874d65\",\"remote_package_size\":4506139,\"files\":[{\"filename\":\"\/game.love\",\"crunched\":0,\"start\":0,\"end\":4506139,\"audio\":false}]}/" > \
$name-$version/game.js
cp src/consolewrapper.js $name-$version
cp src/game.js $name-$version
cp $release_dir/$name-$version.love $name-$version/game.data
# cp src/game.js $name-$version
cp $release_dir/$name-$version.love $name-$version/game.love
cp src/$release/love.js $name-$version
cp src/$release/love.wasm $name-$version
cp src/release/love.worker.js $name-$version

View file

@ -1,4 +1,3 @@
var Module;
if (typeof Module === 'undefined') Module = eval('(function() { try { return Module || {} } catch(e) { return {} } })()');
@ -20,8 +19,8 @@ Module.expectedDataFileDownloads++;
} else {
throw 'using preloaded data can only be done on a web page or in a web worker';
}
var PACKAGE_NAME = 'game.data';
var REMOTE_PACKAGE_BASE = 'game.data';
var PACKAGE_NAME = 'game.love';
var REMOTE_PACKAGE_BASE = 'game.love';
if (typeof Module['locateFilePackage'] === 'function' && !Module['locateFile']) {
Module['locateFile'] = Module['locateFilePackage'];
Module.printErr('warning: you defined Module.locateFilePackage, that has been renamed to Module.locateFile (using your locateFilePackage for now)');
@ -90,7 +89,7 @@ Module.expectedDataFileDownloads++;
function assert(check, msg) {
if (!check) throw msg + new Error().stack;
}
{{{create_file_paths}}}
// {{{create_file_paths}}}
function DataRequest(start, end, crunched, audio) {
this.start = start;

View file

@ -74,7 +74,7 @@
}, false);
var Module = {
arguments: ["./game.love","web"],
arguments: ["game.love","web"],
INITIAL_MEMORY: {{initial-memory}},
printErr: console.error.bind(console),
canvas: (function() {

69
lib/stdio.lua Normal file
View file

@ -0,0 +1,69 @@
require("love.event")
local function prompt(cont_3f)
local function _1_()
if cont_3f then
return ".."
else
return ">> "
end
end
io.write(_1_())
io.flush()
return (io.read() .. "\n")
end
local function looper(event, channel)
do
local _2_ = channel:demand()
if ((_G.type(_2_) == "table") and ((_2_)[1] == "write") and (nil ~= (_2_)[2])) then
local vals = (_2_)[2]
io.write(table.concat(vals, "\9"))
io.write("\n")
elseif ((_G.type(_2_) == "table") and ((_2_)[1] == "read") and (nil ~= (_2_)[2])) then
local cont_3f = (_2_)[2]
love.event.push(event, prompt(cont_3f))
end
end
return looper(event, channel)
end
do
local _4_, _5_ = ...
if ((nil ~= _4_) and (nil ~= _5_)) then
local event = _4_
local channel = _5_
looper(event, channel)
end
end
local function start_repl()
local code = love.filesystem.read("lib/stdio.fnl")
local luac
if code then
luac = love.filesystem.newFileData(fennel.compileString(code), "io")
else
luac = love.filesystem.read("lib/stdio.lua")
end
local thread = love.thread.newThread(luac)
local io_channel = love.thread.newChannel()
local coro = coroutine.create(fennel.repl)
local options
local function _10_(_8_)
local _arg_9_ = _8_
local stack_size = _arg_9_["stack-size"]
io_channel:push({"read", (0 < stack_size)})
return coroutine.yield()
end
local function _11_(vals)
return io_channel:push({"write", vals})
end
local function _12_(errtype, err)
return io_channel:push({"write", {err}})
end
options = {readChunk = _10_, onValues = _11_, onError = _12_, moduleName = "lib.fennel"}
coroutine.resume(coro, options)
thread:start("eval", io_channel)
local function _13_(input)
return coroutine.resume(coro, input)
end
love.handlers.eval = _13_
return nil
end
return {start = start_repl}

View file

@ -32,7 +32,7 @@ love: $(LOVEFILE)
# platform-specific distributables
REL=$(PWD)/love-release.sh # https://p.hagelb.org/love-release.sh
REL=$(PWD)/buildtools/love-release.sh # https://p.hagelb.org/love-release.sh
FLAGS=-a "$(AUTHOR)" --description $(DESCRIPTION) \
--love $(LOVE_VERSION) --url $(URL) --version $(VERSION) --lovefile $(LOVEFILE)

View file

@ -14,10 +14,10 @@
(match (pcall mode.activate ...)
(false msg) (print mode-name "activate error" msg))))
(fn love.load []
(fn love.load [args]
(set-mode :mode-intro)
(canvas:setFilter "nearest" "nearest")
(repl.start))
(when (~= :web (. args 1)) (repl.start)))
(fn safely [f]
(xpcall f #(set-mode :error-mode mode-name $ (fennel.traceback))))