From cb85a21641e00c67acf698b88f76997444127710 Mon Sep 17 00:00:00 2001 From: actboy168 Date: Mon, 10 Jun 2019 14:57:28 +0800 Subject: =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=8B=A5=E5=B9=B2=E7=9A=84=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- make.lua | 2 +- make/install.lua | 43 +++++++++++------------------------------- make/msvc_crt.lua | 56 ------------------------------------------------------- 3 files changed, 12 insertions(+), 89 deletions(-) delete mode 100644 make/msvc_crt.lua diff --git a/make.lua b/make.lua index 7193b654..97210700 100644 --- a/make.lua +++ b/make.lua @@ -56,7 +56,7 @@ if lm.plat ~= 'macos' and lm.plat ~= 'linux' then end lm:build 'install' { - '$luamake', 'lua', 'make/install.lua', + '$luamake', 'lua', 'make/install.lua', lm.plat, deps = { 'lua', 'lni', diff --git a/make/install.lua b/make/install.lua index 3da8983d..d579cd5d 100644 --- a/make/install.lua +++ b/make/install.lua @@ -1,41 +1,23 @@ +local platform = ... local fs = require 'bee.filesystem' local sp = require 'bee.subprocess' -local is_macos = package.cpath:sub(-3) == '.so' - -local platform = require "bee.platform" - local CWD = fs.current_path() - local output = CWD / 'server' / 'bin' -local bindir = CWD / 'build' / 'msvc' / 'bin' - -local lib_ext = ".dll" -local exc_ext = ".exe" - -if is_macos then - bindir = CWD / 'build' / 'macos' / 'bin' - lib_ext = ".so" - exc_ext = "" -end - -if platform.OS == "Linux" then - bindir = CWD / 'build' / 'linux' / 'bin' - lib_ext = ".so" - exc_ext = "" -end +local bindir = CWD / 'build' / platform / 'bin' +local exe = platform == 'msvc' and ".exe" or "" +local dll = platform == 'msvc' and ".dll" or ".so" fs.create_directories(output) -fs.copy_file(bindir / 'lni'..lib_ext, output / 'lni'..lib_ext, true) -fs.copy_file(bindir / 'lpeglabel'..lib_ext, output / 'lpeglabel'..lib_ext, true) -fs.copy_file(bindir / 'bee'..lib_ext, output / 'bee'..lib_ext, true) -fs.copy_file(bindir / 'lua'..exc_ext, output / 'lua-language-server'..exc_ext, true) +fs.copy_file(bindir / 'lni'..dll, output / 'lni'..dll, true) +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) -if not is_macos and platform.OS ~= "Linux" then - fs.copy_file(bindir / 'lua54'..lib_ext, output / 'lua54'..lib_ext, true) -end +if platform == 'msvc' then + fs.copy_file(bindir / 'lua54'..dll, output / 'lua54'..dll, true) + require 'msvc'.copy_crtdll('x64', output) -if not is_macos and platform.OS ~= "Linux" then local process = assert(sp.spawn { bindir / 'rcedit.exe', output / 'lua-language-server.exe', @@ -43,7 +25,4 @@ if not is_macos and platform.OS ~= "Linux" then CWD / 'images' / 'icon.ico' }) assert(process:wait()) - - local msvc_crt = dofile 'make/msvc_crt.lua' - msvc_crt('x86', output) end diff --git a/make/msvc_crt.lua b/make/msvc_crt.lua deleted file mode 100644 index 31ecb0d2..00000000 --- a/make/msvc_crt.lua +++ /dev/null @@ -1,56 +0,0 @@ -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.VC142.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 -- cgit v1.2.3