summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-01-23 09:07:38 +0800
committerGitHub <noreply@github.com>2019-01-23 09:07:38 +0800
commit0993d310daf082331f254df423dc7a11407006bc (patch)
tree7030188ff9b6cada5c32843a80028dbf4ec69ac5
parentd6aa0dc93d014173bf6a4b45c9fcb375e722e398 (diff)
parentd0ff751ce25b2cb54ca48910c45975d5871823e2 (diff)
downloadlua-language-server-0993d310daf082331f254df423dc7a11407006bc.zip
Merge pull request #2 from actboy168/master
增加c模块的构建脚本
-rw-r--r--.gitignore1
-rw-r--r--.gitmodules12
m---------3rd/bee.lua0
m---------3rd/lni0
m---------3rd/lpeglabel0
m---------3rd/luamake0
-rw-r--r--make.lua24
-rw-r--r--make/install.lua13
-rw-r--r--make/msvc_crt.lua56
m---------server/bee.lua0
10 files changed, 106 insertions, 0 deletions
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
+Subproject 73969c8518d95c2bc55a6cf02b2ded29acce7c8
diff --git a/3rd/lni b/3rd/lni
new file mode 160000
+Subproject 6d1659bf23bd841c7c74f68dc964f2d4622d162
diff --git a/3rd/lpeglabel b/3rd/lpeglabel
new file mode 160000
+Subproject 9be59fb8f4b176a16643e707c74051b24320229
diff --git a/3rd/luamake b/3rd/luamake
new file mode 160000
+Subproject 597169a89ef1e04d9a2363b3786ac9097adb1ce
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
-Subproject 096e330b65e8d8afd25b5c344a56bbd2e6a0c2b