From 812aba7246f74d62b04bb9b24e3c70bd6d33d523 Mon Sep 17 00:00:00 2001 From: dev2 Date: Thu, 16 May 2019 17:39:07 -0700 Subject: support linux build --- linux.sh | 41 +++++++++++++++++++++++++++++++++++++++++ make.lua | 13 +++++++++++-- make/install.lua | 12 ++++++++++-- 3 files changed, 62 insertions(+), 4 deletions(-) create mode 100755 linux.sh diff --git a/linux.sh b/linux.sh new file mode 100755 index 00000000..9603b376 --- /dev/null +++ b/linux.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +set -e + +MY_DIR=$(cd "$(dirname $0)";pwd) +cd $MY_DIR + +git submodule -q update --recursive --init + +## apt install ninja-build +## apt install clang + +echo "build luamake ..." +cd 3rd/luamake +ninja -f ninja/linux.ninja +cd $MY_DIR + +./3rd/luamake/luamake + +cd server +mv bin/*.so . + +# avoid too many file opened error +ulimit -n 4000 + +./bin/lua-language-server publish.lua +cd $MY_DIR + +# cp server/*.so publish/lua-language-server/server/ + +## nvm install stable +## nvm use stable +## npm install -g vsce + +# cd publish/lua-language-server +# vsce package + + +## example of development environment +## cp ~/lua-language-server/server/*.so ~/.vscode/extensions/sumneko.lua-0.9.4/server/ +## killall -9 lua-language-server; cp ~/lua-language-server/server/bin/lua-language-server ~/.vscode/extensions/sumneko.lua-0.9.4/server/bin/ diff --git a/make.lua b/make.lua index a9262943..7193b654 100644 --- a/make.lua +++ b/make.lua @@ -1,4 +1,6 @@ + local lm = require 'luamake' +local platform = require "bee.platform" lm:import '3rd/bee.lua/make.lua' @@ -12,6 +14,10 @@ if lm.plat == 'macos' then lua = 'lua' includes = {'bee.lua/3rd/lua/src'} lpeglabel_ldflags = nil +elseif lm.plat == 'linux' then + lua = 'lua' + includes = {'bee.lua/3rd/lua/src'} + lpeglabel_ldflags = nil end lm:shared_library 'lni' { @@ -19,7 +25,10 @@ lm:shared_library 'lni' { sources = { 'lni/src/main.cpp', }, - includes = includes + includes = includes, + links = { + platform.OS == "Linux" and "stdc++", + }, } lm:shared_library 'lpeglabel' { @@ -30,7 +39,7 @@ lm:shared_library 'lpeglabel' { } local rcedit = nil -if lm.plat ~= 'macos' then +if lm.plat ~= 'macos' and lm.plat ~= 'linux' then rcedit = 'rcedit' lm:executable 'rcedit' { diff --git a/make/install.lua b/make/install.lua index 4aa544de..3da8983d 100644 --- a/make/install.lua +++ b/make/install.lua @@ -3,6 +3,8 @@ 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' @@ -17,17 +19,23 @@ if is_macos then exc_ext = "" end +if platform.OS == "Linux" then + bindir = CWD / 'build' / 'linux' / 'bin' + lib_ext = ".so" + exc_ext = "" +end + 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) -if not is_macos then +if not is_macos and platform.OS ~= "Linux" then fs.copy_file(bindir / 'lua54'..lib_ext, output / 'lua54'..lib_ext, true) end -if not is_macos then +if not is_macos and platform.OS ~= "Linux" then local process = assert(sp.spawn { bindir / 'rcedit.exe', output / 'lua-language-server.exe', -- cgit v1.2.3