Skip to content

Latest commit

 

History

History
61 lines (46 loc) · 2.44 KB

File metadata and controls

61 lines (46 loc) · 2.44 KB

Lua static battery

This is a static version of lua in the sense that it should run without requiring any external library. It lets you to embed a script in the executable and provides also some useful libraries.

All the softwares is released under MIT-style license.

Usage

This application behaves like a standard lua command line tool, you can refer to the Official documentation. The difference is that lua_static_batteries embeds also some libraries. You can found the library documentation at the following links:

  • Lua File System, it is enabled with local lfs = require "lfs"
  • Lua Socket, it is enabled with local socket = require "socket"
  • Lua Child, it is enabled with local child = require "luachild"
  • LuaProc, it is enabled with local proc = require "luaproc"
  • Lua TUI mode, it is enabled with local tui = require "lua_tui_mode"
  • Glua, it is enabled with local glua_pack = require "glua_pack"

Embed a script

As explained in its documentation, the glua_pack function can be used to create a new standalone executable taht embeds a lua script. It will be run instead of the standard lua interpreter, an obviously it can use all the emebeded libraries.

As example:

echo 'require"glua_pack"(argv[1], "glued.exe")' > embed.lua
./lua_static_battery.exe -e 'require"glua_pack"("embed.lua", "lsb.exe")'
chmod ugo+x lsb.exe

Will generate the application lsb.exe that run require"glua_pack"(argv[1], "glued.exe") when launched. So you can use itself to embed other script more easly:

echo "print'hello world!" > hello_world.lua
./lsb.exe hello_world.lua
chmod ugo+x glued.exe

(or drag hello_world.lua on lsb.exe). It will create glued.exe that contain the script. Launch it and the message hello world! will be displayed in the console.

Please, be aware that lua_static_library.exe is (deliberately) an extremly simple tool. It does not try to reduce size, or to embed other lua modules. For such advanced operation you can use something like lua squish and then use glua.exe on the input file.