Skip to content
Snippets Groups Projects
Commit cb85a216 authored by actboy168's avatar actboy168
Browse files

修正若干的编译问题

parent d3f8aa2f
No related branches found
No related tags found
No related merge requests found
......@@ -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',
......
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
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment