-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathnattlua.lua
More file actions
executable file
·64 lines (53 loc) · 1.77 KB
/
nattlua.lua
File metadata and controls
executable file
·64 lines (53 loc) · 1.77 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env luajit
_G.EARLY_STARTUP_TIME = os.clock()
if select(1, ...) == "profile" and select(2, ...) ~= "trace" then
_G.REUSE_BASE_ENV = true
local profiler = require("test.helpers.profiler").New({id = select(2, ...)})
profiler:StartSection("startup")
_G.STARTUP_PROFILE = true
elseif select(1, ...) == "test" then
_G.REUSE_BASE_ENV = true
local profiler = require("test.helpers.profiler").New()
profiler:StartSection("startup")
_G.STARTUP_PROFILE = true
end
if jit then
if not package.searchpath("nattlua.cli.init", package.path) then
local current_path
local ffi = require("ffi")
if jit.os ~= "Windows" then
ffi.cdef("char *getcwd(char *buf, size_t size);")
local buf = ffi.new("uint8_t[256]")
ffi.C.getcwd(buf, 256)
current_path = ffi.string(buf)
else
ffi.cdef("unsigned long GetCurrentDirectoryA(unsigned long length, char *buffer);")
local buf = ffi.new("uint8_t[256]")
ffi.C.GetCurrentDirectoryA(256, buf)
current_path = ffi.string(buf):gsub("\\", "/")
end
local nattlua_path = assert(assert(debug.getinfo(1, "S")).source:match("^@(.+)$"))
nattlua_path = assert(nattlua_path:match("(.+)/nattlua%.lua$"))
local dir = current_path .. "/" .. nattlua_path .. "/"
_G.ROOT_PATH = dir
package.path = package.path .. ";" .. dir .. "?.lua" .. ";" .. dir .. "?/init.lua"
end
end
require("nattlua.other.lua_compat")
require("nattlua.other.jit_options").SetOptimized()
local m = require("nattlua.init")
package.loaded.nattlua = m
if _G.gmod then
local pairs = pairs
local getfenv = getfenv
module("nattlua")
local _G = getfenv(1)
for k, v in pairs(m) do
_G[k] = v
end
end
local ARGS = _G.ARGS or {...}
if ARGS[1] and ARGS[1] ~= "nattlua" and ARGS[1] ~= "temp_build_output" then
require("nattlua.cli.init").main(table.unpack(ARGS))
end
return m