diff options
author | actboy168 <actboy168@gmail.com> | 2019-06-10 16:03:59 +0800 |
---|---|---|
committer | actboy168 <actboy168@gmail.com> | 2019-06-10 16:03:59 +0800 |
commit | 7d1a60dfcbffd163c56cc319bd13a51e8ff405b1 (patch) | |
tree | ffaca535468c7a019a4b19469cad49e25920b46b /make | |
parent | 55ec1070ea56297151f06a988322c4a8b404c607 (diff) | |
download | lua-language-server-7d1a60dfcbffd163c56cc319bd13a51e8ff405b1.zip |
安装脚本
Diffstat (limited to 'make')
-rw-r--r-- | make/copy.lua | 58 | ||||
-rw-r--r-- | make/install.lua | 8 |
2 files changed, 66 insertions, 0 deletions
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) |