forked from moai/moai-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
48 lines (35 loc) · 1.44 KB
/
Copy pathmain.lua
File metadata and controls
48 lines (35 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
----------------------------------------------------------------
-- Copyright (c) 2010-2017 Zipline Games, Inc.
-- All Rights Reserved.
-- http://getmoai.com
----------------------------------------------------------------
function dumpBytecodeAsHeader ( filename, headername, outname )
print ( filename )
print ( headername )
print ( outname )
-- dump the function to Lua bytecode
local compiled = string.dump ( loadfile ( filename ))
-- convert the Lua bytecode to a cpp header called 'bundled_lua' with 12 columns
local header = MOAIDataBuffer.toCppHeader ( compiled, headername, 12 )
-- write the header to a file
local file = io.open ( outname, 'wb' )
file:write ( header )
file:close ()
end
function dumpZippedTextAsHeader ( filename, headername, outname )
print ( filename )
print ( headername )
print ( outname )
-- dump the function to Lua bytecode
local data = io.open ( filename, "r" ):read ( '*all' )
data = data .. string.char ( 0 ) -- null terminate the string
data = MOAIDataBuffer.deflate ( data, 9 )
-- convert the Lua bytecode to a cpp header called 'bundled_lua' with 12 columns
local header = MOAIDataBuffer.toCppHeader ( data, headername, 12 )
-- write the header to a file
local file = io.open ( outname, 'wb' )
file:write ( header )
file:close ()
end
dumpZippedTextAsHeader ( 'moai.lua', 'moai_lua', 'moai_lua.h' )
dumpZippedTextAsHeader ( 'moai_test_mgr.lua', 'moai_test_mgr_lua', 'moai_test_mgr_lua.h' )