]> git.sesse.net Git - vlc/blob - share/lua/intf/luac.lua
Provide luac compilation script. See vlc -I lua --lua-intf luac to get usage.
[vlc] / share / lua / intf / luac.lua
1 --[==========================================================================[
2  luac.lua: lua compilation module for VLC (duplicates luac)
3 --[==========================================================================[
4  Copyright (C) 2010 the VideoLAN team
5  $Id$
6
7  Authors: Antoine Cellerier <dionoea at videolan dot org>
8
9  This program is free software; you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation; either version 2 of the License, or
12  (at your option) any later version.
13
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  GNU General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 --]==========================================================================]
23
24 usage = 
25 [[ To compile a lua script to luac run:
26  vlc -I lua --lua-intf --lua-config 'luac={input="file.lua",output="file.luac"}'
27 ]]
28
29 require "string"
30 require "io"
31
32 vlc.msg.info("About to compile lua file")
33 vlc.msg.info("  Input is '"..tostring(config.input).."'")
34 vlc.msg.info("  Output is '"..tostring(config.output).."'")
35
36 if not config.input or not config.output then
37     vlc.msg.err("Input and output config options must be set")
38     for line in string.gmatch(usage,"([^\n]+)\n*") do
39         vlc.msg.err(line)
40     end
41 else
42     local bytecode = loadfile(config.input)
43     local output = io.open(config.output, "wb")
44     output:write(string.dump(bytecode))
45 end
46
47 vlc.misc.quit()
48