1 --[==========================================================================[
2 luac
.lua
: lua compilation module
for VLC (duplicates luac
)
3 --[==========================================================================[
4 Copyright (C
) 2010 Antoine Cellerier
7 Authors
: Antoine Cellerier
<dionoea at videolan dot org
>
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
.
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
.
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 --]==========================================================================]
26 To compile a lua script to bytecode (luac) run:
27 vlc -I luaintf --lua-intf --lua-config 'luac={input="file.lua",output="file.luac"}'
28 Output will be similar to that of the luac command line tool provided with lua with the following arguments:
29 luac -o file.luac file.lua
36 vlc
.msg
.info("About to compile lua file")
37 vlc
.msg
.info(" Input is '"..tostring(config
.input
).."'")
38 vlc
.msg
.info(" Output is '"..tostring(config
.output
).."'")
39 if not config
.input
or not config
.output
then
40 vlc
.msg
.err("Input and output config options must be set")
44 local bytecode
, msg
= loadfile(config
.input
)
46 vlc
.msg
.err("Error while loading file '"..config
.input
.."': "..msg
)
50 local output
, msg
= io
.open(config
.output
, "wb")
52 vlc
.msg
.err("Error while opening file '"..config
.output
.."' for output: "..msg
)
55 output
:write(string.dump(bytecode
))
62 for line
in string.gmatch(usage
,"([^\n]+)\n*") do