Created
September 13, 2016 00:19
-
-
Save sw17ch/ac5eb089353c7ceef25a41370c0fab59 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local a = function () | |
print("i am a") | |
end | |
error("no") | |
return a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local a = require('a') | |
local b = {} | |
function b.begin() | |
a() | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local input = arg | |
-- This line defines the addition of a chunk to a preload entry. | |
local function fpreload(mod, func, strip) | |
local s = 'package.preload["%s"] = load(%q)();' | |
return s:format(mod, string.dump(func, strip)) | |
end | |
local function fload(func, strip) | |
local s = 'load(%q)();' | |
return s:format(string.dump(func, strip)) | |
end | |
local preloads = {} | |
for ix, mod in ipairs(arg) do | |
local file = mod .. ".lua" | |
local chunk = assert(loadfile(file)) | |
local s | |
if ix < #arg then | |
s = fpreload(mod, chunk, false) | |
else | |
s = fload(chunk, false) | |
end | |
table.insert(preloads, s) | |
end | |
local final = table.concat(preloads, "\n") | |
local out = io.open("../out.luac", "w") | |
-- Dump the combined preload chunk. Strip debugging information out of | |
-- this final piece. User-defined files above maintain their debugging | |
-- information for now. | |
out:write(string.dump(assert(load(final)), true)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example usage: