diff options
author | actboy168 <actboy168@gmail.com> | 2019-01-22 22:35:01 +0800 |
---|---|---|
committer | actboy168 <actboy168@gmail.com> | 2019-01-22 22:35:01 +0800 |
commit | d0ff751ce25b2cb54ca48910c45975d5871823e2 (patch) | |
tree | d1462d45d5160af86ef98aa8c2ac08ae5dd28181 /make | |
parent | 4ffc826d7ce5ca57c2929e040ed5eefb53f9d115 (diff) | |
download | lua-language-server-d0ff751ce25b2cb54ca48910c45975d5871823e2.zip |
增加c模块的构建脚本
Diffstat (limited to 'make')
-rw-r--r-- | make/install.lua | 13 | ||||
-rw-r--r-- | make/msvc_crt.lua | 56 |
2 files changed, 69 insertions, 0 deletions
diff --git a/make/install.lua b/make/install.lua new file mode 100644 index 00000000..f492932b --- /dev/null +++ b/make/install.lua @@ -0,0 +1,13 @@ +local fs = require 'bee.filesystem' + +local CWD = fs.current_path() + +fs.create_directories(CWD / 'server' / 'bin') +fs.copy_file(CWD / 'build' / 'msvc' / 'bin' / 'lni.dll', CWD / 'server' / 'bin' / 'lni.dll', true) +fs.copy_file(CWD / 'build' / 'msvc' / 'bin' / 'lpeglabel.dll', CWD / 'server' / 'bin' / 'lpeglabel.dll', true) +fs.copy_file(CWD / '3rd' / 'bee.lua' / 'bin' / 'msvc_x86_release' / 'bee.dll', CWD / 'server' / 'bin' / 'bee.dll', true) +fs.copy_file(CWD / '3rd' / 'bee.lua' / 'bin' / 'msvc_x86_release' / 'lua54.dll', CWD / 'server' / 'bin' / 'lua54.dll', true) +fs.copy_file(CWD / '3rd' / 'bee.lua' / 'bin' / 'msvc_x86_release' / 'lua.exe', CWD / 'server' / 'bin' / 'lua-language-server.exe', true) + +local msvc_crt = dofile 'make/msvc_crt.lua' +msvc_crt('x86', CWD / 'server' / 'bin') diff --git a/make/msvc_crt.lua b/make/msvc_crt.lua new file mode 100644 index 00000000..70523827 --- /dev/null +++ b/make/msvc_crt.lua @@ -0,0 +1,56 @@ +require 'bee' +local sp = require 'bee.subprocess' +local fs = require 'bee.filesystem' +local registry = require 'bee.registry' + +local vswhere = fs.path(os.getenv('ProgramFiles(x86)')) / 'Microsoft Visual Studio' / 'Installer' / 'vswhere.exe' + +local function strtrim(str) + return str:gsub("^%s*(.-)%s*$", "%1") +end + +local InstallDir = (function () + local process = assert(sp.spawn { + vswhere, + '-latest', + '-products', '*', + '-requires', 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64', + '-property', 'installationPath', + stdout = true, + }) + local result = strtrim(process.stdout:read 'a') + process.stdout:close() + process:wait() + assert(result ~= "", "can't find msvc.") + return fs.path(result) +end)() + +local RedistVersion = (function () + local verfile = InstallDir / 'VC' / 'Auxiliary' / 'Build' / 'Microsoft.VCRedistVersion.default.txt' + local f = assert(io.open(verfile:string(), 'r')) + local r = f:read 'a' + f:close() + return strtrim(r) +end)() + +local function crtpath(platform) + return InstallDir / 'VC' / 'Redist' / 'MSVC' / RedistVersion / platform / 'Microsoft.VC141.CRT' +end + +local function sdkpath() + local reg = registry.open [[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots]] + return fs.path(reg.KitsRoot10) +end + +local function ucrtpath(platform) + return sdkpath() / 'Redist' / 'ucrt' / 'DLLs' / platform +end + +return function (platform, target) + fs.create_directories(target) + fs.copy_file(crtpath(platform) / 'msvcp140.dll', target / 'msvcp140.dll', true) + fs.copy_file(crtpath(platform) / 'vcruntime140.dll', target / 'vcruntime140.dll', true) + for dll in ucrtpath(platform):list_directory() do + fs.copy_file(dll, target / dll:filename(), true) + end +end |