Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ node_modules
.vscode-test
/server/log
/publish
/build/
!*.exe
12 changes: 12 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
[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
1 change: 1 addition & 0 deletions 3rd/bee.lua
Submodule bee.lua added at 73969c
1 change: 1 addition & 0 deletions 3rd/lni
Submodule lni added at 6d1659
1 change: 1 addition & 0 deletions 3rd/lpeglabel
Submodule lpeglabel added at 9be59f
1 change: 1 addition & 0 deletions 3rd/luamake
Submodule luamake added at 597169
24 changes: 24 additions & 0 deletions make.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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",
}
}
13 changes: 13 additions & 0 deletions make/install.lua
Original file line number Diff line number Diff line change
@@ -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')
56 changes: 56 additions & 0 deletions make/msvc_crt.lua
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion server/bee.lua
Submodule bee.lua deleted from 096e33