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

增加c模块的构建脚本

parent 4ffc826d
No related branches found
No related tags found
No related merge requests found
......@@ -3,4 +3,5 @@ node_modules
.vscode-test
/server/log
/publish
/build/
!*.exe
[submodule "server/bee.lua"]
path = server/bee.lua
url = https://github.com/actboy168/bee.lua
[submodule "3rd/luamake"]
path = 3rd/luamake
url = https://github.com/actboy168/luamake
[submodule "3rd/lni"]
path = 3rd/lni
url = https://github.com/actboy168/lni
[submodule "3rd/bee.lua"]
path = 3rd/bee.lua
url = https://github.com/actboy168/bee.lua
[submodule "3rd/lpeglabel"]
path = 3rd/lpeglabel
url = https://github.com/sqmedeiros/lpeglabel
Subproject commit 73969c8518d95c2bc55a6cf02b2ded29acce7c87
Subproject commit 6d1659bf23bd841c7c74f68dc964f2d4622d162d
Subproject commit 9be59fb8f4b176a16643e707c74051b243202296
Subproject commit 597169a89ef1e04d9a2363b3786ac9097adb1ce2
make.lua 0 → 100644
local lm = require 'luamake'
lm.rootdir = '3rd/lni'
lm:lua_library 'lni' {
sources = "src/*.cpp"
}
lm.rootdir = '3rd/lpeglabel'
lm:lua_library 'lpeglabel' {
sources = "*.c"
}
lm:build 'bee' {
'$luamake', '-C', '3rd/bee.lua'
}
lm:build 'install' {
'$luamake', 'lua', 'make/install.lua',
deps = {
"lni",
"lpeglabel",
"bee",
}
}
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')
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
Subproject commit 096e330b65e8d8afd25b5c344a56bbd2e6a0c2b8
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment