Closed MisterDA closed 5 years ago
Well you install luarocks to use luajit instead of Lua
Yes but what if I want to use the luarocks that is packaged with my distribution ? I don't want to force the end-user to reinstall luarocks or to use a custom luarocks. For now I use the lua interpreter :
-- luajit :
zip_arc:add(file, "string", string.dump(loadfile(file)))
-- lua :
zip_arc:add(file, "string", bytecode(file))
function bytecode(file)
local handle = io.popen('luajit -b '..file..' -')
local result = handle:read("*a")
handle:close()
return result
end
You can't actually specifically depend on luajit for your script yet, for some reason the piece of code that would allow that is commented out: https://github.com/Alloyed/luarocks/commit/dfce4837addfe258566b6e48dd28a9e7c72bbf62 you can just use the same check the luarocks would've used to see if the user happened to use luajit, though
if package.loaded.jit then do_luajit_stuff() else do_lua_stuff() end
Thank you ! It's strange this hasn't been allowed.
For love-release it shouldn't be mandatory to depend on the same version of Lua than LÖVE's, it would be mandatory though for a future case escenario where love-release + loverocks get to compile binary modules ( #41 ), since they are dynamically (desktop) or statically (mobile) linked to lua51.dll
I'm rewriting love-release in pure Lua, and I'd like to add an option to pre-compile the lua files in luajit bytecode. Luajit overrides
loadfile
andstring.dump
functions to compile files into its bytecode and not into standard Lua byte code. Mymain.lua
(renamed tolove-release
when installed) begins with#!/usr/bin/env lua
, which is pointless because luarocks launches it with:Do you see an easy way to tell luarocks to use luajit instead of lua ? (dev branch)