summaryrefslogtreecommitdiff
path: root/make/bootstrap.lua
diff options
context:
space:
mode:
authoractboy168 <actboy168@gmail.com>2021-10-02 12:40:35 +0800
committeractboy168 <actboy168@gmail.com>2021-10-02 12:40:35 +0800
commit754b69b88f8f1053e6452261e30cae9e10ca122c (patch)
treee13c56ed89e2d998b876a43a7ba9556a87f25d5c /make/bootstrap.lua
parent70335a4e87c2d8b82a30926c2560efde94d2587b (diff)
downloadlua-language-server-754b69b88f8f1053e6452261e30cae9e10ca122c.zip
更新编译脚本
Diffstat (limited to 'make/bootstrap.lua')
-rw-r--r--make/bootstrap.lua38
1 files changed, 38 insertions, 0 deletions
diff --git a/make/bootstrap.lua b/make/bootstrap.lua
new file mode 100644
index 00000000..2bbd64f0
--- /dev/null
+++ b/make/bootstrap.lua
@@ -0,0 +1,38 @@
+local i = 1
+while true do
+ if arg[i] == '-E' then
+ elseif arg[i] == '-e' then
+ i = i + 1
+ local expr = assert(arg[i], "'-e' needs argument")
+ assert(load(expr, "=(command line)"))()
+ else
+ break
+ end
+ i = i + 1
+end
+
+if arg[i] == nil then
+ return
+end
+
+for j = -1, #arg do
+ arg[j - i] = arg[j]
+end
+for j = #arg - i + 1, #arg do
+ arg[j] = nil
+end
+
+local root; do
+ local sep = package.config:sub(1,1)
+ local pattern = "["..sep.."][^"..sep.."]+"
+ root = package.cpath:match("(.+)"..pattern..pattern..pattern.."$")
+end
+
+local fs = require "bee.filesystem"
+fs.current_path(fs.path(root))
+
+package.path = table.concat({
+ root .. "/script/?.lua",
+ root .. "/script/?/init.lua",
+}, ";")
+assert(loadfile(arg[0]))(table.unpack(arg))