From d0ff751ce25b2cb54ca48910c45975d5871823e2 Mon Sep 17 00:00:00 2001 From: actboy168 Date: Tue, 22 Jan 2019 22:35:01 +0800 Subject: =?UTF-8?q?=E5=A2=9E=E5=8A=A0c=E6=A8=A1=E5=9D=97=E7=9A=84=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + .gitmodules | 12 ++++++++++++ 3rd/bee.lua | 1 + 3rd/lni | 1 + 3rd/lpeglabel | 1 + 3rd/luamake | 1 + make.lua | 24 ++++++++++++++++++++++++ make/install.lua | 13 +++++++++++++ make/msvc_crt.lua | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ server/bee.lua | 1 - 10 files changed, 110 insertions(+), 1 deletion(-) create mode 160000 3rd/bee.lua create mode 160000 3rd/lni create mode 160000 3rd/lpeglabel create mode 160000 3rd/luamake create mode 100644 make.lua create mode 100644 make/install.lua create mode 100644 make/msvc_crt.lua delete mode 160000 server/bee.lua diff --git a/.gitignore b/.gitignore index d555d6e1..2644fdaa 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ node_modules .vscode-test /server/log /publish +/build/ !*.exe diff --git a/.gitmodules b/.gitmodules index 374b9348..1061f04d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/3rd/bee.lua b/3rd/bee.lua new file mode 160000 index 00000000..73969c85 --- /dev/null +++ b/3rd/bee.lua @@ -0,0 +1 @@ +Subproject commit 73969c8518d95c2bc55a6cf02b2ded29acce7c87 diff --git a/3rd/lni b/3rd/lni new file mode 160000 index 00000000..6d1659bf --- /dev/null +++ b/3rd/lni @@ -0,0 +1 @@ +Subproject commit 6d1659bf23bd841c7c74f68dc964f2d4622d162d diff --git a/3rd/lpeglabel b/3rd/lpeglabel new file mode 160000 index 00000000..9be59fb8 --- /dev/null +++ b/3rd/lpeglabel @@ -0,0 +1 @@ +Subproject commit 9be59fb8f4b176a16643e707c74051b243202296 diff --git a/3rd/luamake b/3rd/luamake new file mode 160000 index 00000000..597169a8 --- /dev/null +++ b/3rd/luamake @@ -0,0 +1 @@ +Subproject commit 597169a89ef1e04d9a2363b3786ac9097adb1ce2 diff --git a/make.lua b/make.lua new file mode 100644 index 00000000..5b00cb73 --- /dev/null +++ b/make.lua @@ -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", + } +} 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 diff --git a/server/bee.lua b/server/bee.lua deleted file mode 160000 index 096e330b..00000000 --- a/server/bee.lua +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 096e330b65e8d8afd25b5c344a56bbd2e6a0c2b8 -- cgit v1.2.3