diff options
author | AlexCai2019 <89138532+AlexCai2019@users.noreply.github.com> | 2022-05-08 01:43:28 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-08 01:43:28 +0800 |
commit | 0fd83c4ca9f82a02becab6c304a8a7de75098507 (patch) | |
tree | be9790d9d4823fe728c5b36e94093fe5f42b7725 /make | |
parent | 89203efad8c9b5513e05ca4d5696107924865b10 (diff) | |
parent | 67b4c574849d1667e0ecb39c51aeed8e30b43056 (diff) | |
download | lua-language-server-0fd83c4ca9f82a02becab6c304a8a7de75098507.zip |
Merge branch 'sumneko:master' into master
Diffstat (limited to 'make')
-rw-r--r-- | make/bootstrap.lua | 3 | ||||
-rw-r--r-- | make/copy_vcrt.lua | 6 | ||||
-rw-r--r-- | make/detect_platform.lua | 64 |
3 files changed, 67 insertions, 6 deletions
diff --git a/make/bootstrap.lua b/make/bootstrap.lua index 6c27cf95..00036f34 100644 --- a/make/bootstrap.lua +++ b/make/bootstrap.lua @@ -69,6 +69,9 @@ package.searchers[2] = function (name) return err
end
local f = io.open(filename)
+ if not f then
+ return 'cannot open file:' .. filename
+ end
local buf = f:read '*a'
f:close()
local relative = filename:sub(1, #root) == root and filename:sub(#root + 2) or filename
diff --git a/make/copy_vcrt.lua b/make/copy_vcrt.lua deleted file mode 100644 index bd08a9fa..00000000 --- a/make/copy_vcrt.lua +++ /dev/null @@ -1,6 +0,0 @@ -local output, arch = ... -local fs = require 'bee.filesystem' -require 'msvc'.copy_vcrt( - arch == "x86" and 'x86' or 'x64', - fs.current_path() / output -) diff --git a/make/detect_platform.lua b/make/detect_platform.lua new file mode 100644 index 00000000..8dba298c --- /dev/null +++ b/make/detect_platform.lua @@ -0,0 +1,64 @@ +local lm = require 'luamake' + +local platform = require 'bee.platform' + +if platform.OS == 'macOS' then + if lm.platform == nil then + elseif lm.platform == "darwin-arm64" then + lm.target = "arm64-apple-macos11" + elseif lm.platform == "darwin-x64" then + lm.target = "x86_64-apple-macos10.12" + else + error "unknown platform" + end +elseif platform.OS == 'Windows' then + if lm.platform == nil then + elseif lm.platform == "win32-ia32" then + lm.arch = "x86" + elseif lm.platform == "win32-x64" then + lm.arch = "x86_64" + else + error "unknown platform" + end +elseif platform.OS == 'Linux' then + if lm.platform == nil then + elseif lm.platform == "linux-x64" then + elseif lm.platform == "linux-arm64" then + lm.cc = 'aarch64-linux-gnu-gcc' + else + error "unknown platform" + end +end + +local function detectWindowsArch() + if os.getenv "PROCESSOR_ARCHITECTURE" == "ARM64" then + return "arm64" + end + if os.getenv "PROCESSOR_ARCHITECTURE" == "AMD64" or os.getenv "PROCESSOR_ARCHITEW6432" == "AMD64" then + return "x64" + end + return "ia32" +end + +local function detectPosixArch() + local f <close> = assert(io.popen("uname -m", 'r')) + return f:read 'l':lower() +end + +local function detectArch() + if platform.OS == 'Windows' then + return detectWindowsArch() + end + return detectPosixArch() +end + +local function targetPlatformArch() + if lm.platform == nil then + return detectArch() + end + return lm.platform:match "^[^-]*-(.*)$" +end + +if not lm.notest then + lm.notest = (platform.OS ~= 'Windows' and targetPlatformArch() ~= detectArch()) +end |