Precompile Lua into bytecode before running it (see COMPILE)
This commit is contained in:
parent
932ee958c0
commit
a6ee41a6ab
4 changed files with 39 additions and 2 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
||||||
# Compiled Lua sources
|
# Compiled Lua sources
|
||||||
luac.out
|
luac.out
|
||||||
|
matrix-send
|
||||||
|
|
||||||
# luarocks build files
|
# luarocks build files
|
||||||
*.src.rock
|
*.src.rock
|
||||||
|
@ -38,4 +39,3 @@ luac.out
|
||||||
*.i*86
|
*.i*86
|
||||||
*.x86_64
|
*.x86_64
|
||||||
*.hex
|
*.hex
|
||||||
|
|
||||||
|
|
35
COMPILE
Normal file
35
COMPILE
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
___________________
|
||||||
|
< Manually building >
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
Since matrix-send uses Lua, an interpreted programming language,
|
||||||
|
building is not necessary; you could just move matrix-send.lua to
|
||||||
|
/usr/local/bin and be done with it. However, for additional speed,
|
||||||
|
the Makefile precompiles it to Lua bytecode using
|
||||||
|
luac <https://www.lua.org/manual/5.4/luac.html> which is included
|
||||||
|
in the Lua distribution. To do this yourself, follow these steps:
|
||||||
|
|
||||||
|
=> Create the shebang
|
||||||
|
|
||||||
|
In order to be run by a shell, the compiled bytecode needs a
|
||||||
|
shebang at the start. To do this, run this command:
|
||||||
|
|
||||||
|
printf '#!/usr/bin/env lua\n' > matrix-send
|
||||||
|
|
||||||
|
|
||||||
|
=> Precompile
|
||||||
|
|
||||||
|
Now, let's append the bytecode to the file:
|
||||||
|
|
||||||
|
luac -o - matrix-send.lua >> matrix-send
|
||||||
|
|
||||||
|
|
||||||
|
=> Mark as an executable
|
||||||
|
|
||||||
|
Finally, mark the file as executable:
|
||||||
|
|
||||||
|
chmod +x matrix-send
|
||||||
|
|
||||||
|
The file `matrix-send` is now ready to be run by a shell.
|
||||||
|
|
||||||
|
# vi: ft=txt
|
4
Makefile
4
Makefile
|
@ -11,8 +11,10 @@ install:
|
||||||
luarocks install luaposix
|
luarocks install luaposix
|
||||||
luarocks install luasocket
|
luarocks install luasocket
|
||||||
luarocks install lua-cjson
|
luarocks install lua-cjson
|
||||||
|
printf '#!/usr/bin/env lua\n' > matrix-send
|
||||||
|
luac -o - matrix-send.lua >> matrix-send
|
||||||
|
chmod +x matrix-send
|
||||||
cp -f matrix-send ${DESTDIR}${PREFIX}/bin
|
cp -f matrix-send ${DESTDIR}${PREFIX}/bin
|
||||||
chmod +x ${DESTDIR}${PREFIX}/bin/matrix-send
|
|
||||||
mkdir -p ${DESTDIR}${MANPREFIX}/man1
|
mkdir -p ${DESTDIR}${MANPREFIX}/man1
|
||||||
cp -f matrix-send.1 ${DESTDIR}${MANPREFIX}/man1
|
cp -f matrix-send.1 ${DESTDIR}${MANPREFIX}/man1
|
||||||
mkdir -p ${DESTDIR}${MANPREFIX}/man5
|
mkdir -p ${DESTDIR}${MANPREFIX}/man5
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue