summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoractboy168 <actboy168@gmail.com>2019-06-10 16:03:59 +0800
committeractboy168 <actboy168@gmail.com>2019-06-10 16:03:59 +0800
commit7d1a60dfcbffd163c56cc319bd13a51e8ff405b1 (patch)
treeffaca535468c7a019a4b19469cad49e25920b46b
parent55ec1070ea56297151f06a988322c4a8b404c607 (diff)
downloadlua-language-server-7d1a60dfcbffd163c56cc319bd13a51e8ff405b1.zip
安装脚本
-rw-r--r--.vscode/extensions.json5
-rw-r--r--.vscode/tasks.json24
-rw-r--r--make.lua1
-rw-r--r--make/copy.lua58
-rw-r--r--make/install.lua8
5 files changed, 95 insertions, 1 deletions
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
new file mode 100644
index 00000000..c6d835df
--- /dev/null
+++ b/.vscode/extensions.json
@@ -0,0 +1,5 @@
+{
+ "recommendations": [
+ "actboy168.extension-path",
+ ]
+} \ No newline at end of file
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index 0477aa2e..11a5f61e 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -5,6 +5,28 @@
"type": "shell",
"label": "编译",
"command": "cd 3rd\\luamake && tools\\ninja -f ninja\\msvc.ninja && cd ..\\.. && 3rd\\luamake\\luamake rebuild"
+ },
+ {
+ "label": "Copy Extension",
+ "command": "${workspaceFolder}/build/lua",
+ "args": [
+ "make/copy.lua",
+ "${command:extensionPath}"
+ ],
+ "type": "shell",
+ "windows": {
+ "options": {
+ "shell": {
+ "executable": "C:\\Windows\\System32\\cmd.exe",
+ "args": [
+ "/c"
+ ]
+ }
+ }
+ },
+ "options": {
+ "cwd": "${workspaceFolder}"
+ },
}
]
-}
+} \ No newline at end of file
diff --git a/make.lua b/make.lua
index fff4e5ba..c230df79 100644
--- a/make.lua
+++ b/make.lua
@@ -44,6 +44,7 @@ lm:build 'install' {
'lni',
'lpeglabel',
'bee',
+ 'bootstrap',
platform.OS == "Windows" and "rcedit"
}
}
diff --git a/make/copy.lua b/make/copy.lua
new file mode 100644
index 00000000..253c1332
--- /dev/null
+++ b/make/copy.lua
@@ -0,0 +1,58 @@
+local fs = require 'bee.filesystem'
+
+local function getExtensionDirName(packageDir)
+ local publisher,name,version
+ for line in io.lines(packageDir .. '/package.json') do
+ if not publisher then
+ publisher = line:match('"publisher": "([^"]+)"')
+ end
+ if not name then
+ name = line:match('"name": "([^"]+)"')
+ end
+ if not version then
+ version = line:match('"version": "(%d+%.%d+%.%d+)"')
+ end
+ end
+ if not publisher then
+ error 'Cannot found `publisher` in package.json.'
+ end
+ if not name then
+ error 'Cannot found `name` in package.json.'
+ end
+ if not version then
+ error 'Cannot found `version` in package.json.'
+ end
+ return ('%s.%s-%s'):format(publisher,name,version)
+end
+
+local function copy_directory(from, to, filter)
+ fs.create_directories(to)
+ for fromfile in from:list_directory() do
+ if fs.is_directory(fromfile) then
+ copy_directory(fromfile, to / fromfile:filename(), filter)
+ else
+ if (not filter) or filter(fromfile) then
+ print('copy', fromfile, to / fromfile:filename())
+ fs.copy_file(fromfile, to / fromfile:filename(), true)
+ end
+ end
+ end
+end
+
+local extensionPath = ...
+local packageDir = "."
+local sourceDir = fs.path(".")
+local extensionDirName = getExtensionDirName(packageDir)
+local extensionDir = fs.path(extensionPath) / extensionDirName
+if not fs.exists(extensionDir) then
+ error(extensionDir .. "is not installed.")
+end
+
+if pcall(fs.remove_all, extensionDir / "server" / "bin-bak") then
+ fs.rename(extensionDir / "server" / "bin", extensionDir / "server" / "bin-bak")
+else
+ fs.remove_all(extensionDir / "server" / "bin")
+end
+copy_directory(sourceDir / "server" / "bin", extensionDir / "server" / "bin")
+
+print 'ok'
diff --git a/make/install.lua b/make/install.lua
index d579cd5d..4df556e3 100644
--- a/make/install.lua
+++ b/make/install.lua
@@ -14,6 +14,14 @@ fs.copy_file(bindir / 'lpeglabel'..dll, output / 'lpeglabel'..dll, true)
fs.copy_file(bindir / 'bee'..dll, output / 'bee'..dll, true)
fs.copy_file(bindir / 'lua'..exe, output / 'lua-language-server'..exe, true)
+local bootstrap = CWD / "3rd" / "bee.lua" / "bootstrap"
+fs.copy_file(bootstrap / "main.lua", CWD / 'build' / "main.lua", true)
+fs.copy_file(bindir / ('bee'..dll), CWD / 'build' / ('bee'..dll), true)
+fs.copy_file(bindir / ('bootstrap'..exe), CWD / 'build' / ('lua'..exe), true)
+if platform == 'msvc' then
+ fs.copy_file(bindir / 'lua54.dll', CWD / 'build' / 'lua54.dll', true)
+end
+
if platform == 'msvc' then
fs.copy_file(bindir / 'lua54'..dll, output / 'lua54'..dll, true)
require 'msvc'.copy_crtdll('x64', output)