Skip to content

Commit f4b84ee

Browse files
committed
clean build scripts
1 parent 9fa031a commit f4b84ee

File tree

3 files changed

+73
-73
lines changed

3 files changed

+73
-73
lines changed

make.lua

Lines changed: 9 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
local lm = require 'luamake'
2-
local platform = require 'bee.platform'
3-
local exe = platform.OS == 'Windows' and ".exe" or ""
1+
local lm = require 'luamake'
42

53
lm.bindir = "bin"
64
lm.c = lm.compiler == 'msvc' and 'c89' or 'c11'
@@ -11,35 +9,9 @@ lm.EXE_DIR = ""
119

1210
local includeCodeFormat = true
1311

14-
if platform.OS == 'macOS' then
15-
if lm.platform == nil then
16-
elseif lm.platform == "darwin-arm64" then
17-
lm.target = "arm64-apple-macos11"
18-
elseif lm.platform == "darwin-x64" then
19-
lm.target = "x86_64-apple-macos10.12"
20-
else
21-
error "unknown platform"
22-
end
23-
elseif platform.OS == 'Windows' then
24-
if lm.platform == nil then
25-
elseif lm.platform == "win32-ia32" then
26-
lm.arch = "x86"
27-
elseif lm.platform == "win32-x64" then
28-
lm.arch = "x86_64"
29-
else
30-
error "unknown platform"
31-
end
32-
elseif platform.OS == 'Linux' then
33-
if lm.platform == nil then
34-
elseif lm.platform == "linux-x64" then
35-
elseif lm.platform == "linux-arm64" then
36-
lm.cc = 'aarch64-linux-gnu-gcc'
37-
else
38-
error "unknown platform"
39-
end
40-
end
12+
require "make.detect_platform"
4113

42-
lm:import "3rd/bee.lua/make.lua"
14+
lm:import "3rd/bee.lua"
4315
lm:import "make/code_format.lua"
4416

4517
lm:source_set 'lpeglabel' {
@@ -80,8 +52,8 @@ lm:copy "copy_bootstrap" {
8052
output = lm.bindir .. "/main.lua",
8153
}
8254

83-
lm:build 'copy_vcrt' {
84-
'$luamake', 'lua', 'make/copy_vcrt.lua', lm.bindir, lm.arch,
55+
lm:msvc_copy_vcrt 'copy_vcrt' {
56+
output = lm.bindir,
8557
}
8658

8759
lm:phony "all" {
@@ -96,46 +68,16 @@ lm:phony "all" {
9668
}
9769
}
9870

99-
local function detectWindowsArch()
100-
if os.getenv "PROCESSOR_ARCHITECTURE" == "ARM64" then
101-
return "arm64"
102-
end
103-
if os.getenv "PROCESSOR_ARCHITECTURE" == "AMD64" or os.getenv "PROCESSOR_ARCHITEW6432" == "AMD64" then
104-
return "x64"
105-
end
106-
return "ia32"
107-
end
108-
109-
local function detectPosixArch()
110-
local f <close> = assert(io.popen("uname -m", 'r'))
111-
return f:read 'l':lower()
112-
end
113-
114-
local function detectArch()
115-
if platform.OS == 'Windows' then
116-
return detectWindowsArch()
117-
end
118-
return detectPosixArch()
119-
end
120-
121-
local function targetPlatformArch()
122-
if lm.platform == nil then
123-
return detectArch()
124-
end
125-
return lm.platform:match "^[^-]*-(.*)$"
126-
end
127-
128-
local notest = (platform.OS == 'macOS' or platform.OS == 'Linux')
129-
and targetPlatformArch() == "arm64"
130-
and detectArch() == "x86_64"
131-
132-
if notest then
71+
if lm.notest then
13372
lm:default {
13473
"all",
13574
}
13675
return
13776
end
13877

78+
local platform = require 'bee.platform'
79+
local exe = platform.OS == 'Windows' and ".exe" or ""
80+
13981
lm:build "bee-test" {
14082
lm.bindir .. "/lua-language-server" .. exe, "3rd/bee.lua/test/test.lua",
14183
pool = "console",

make/copy_vcrt.lua

Lines changed: 0 additions & 6 deletions
This file was deleted.

make/detect_platform.lua

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
local lm = require 'luamake'
2+
3+
local platform = require 'bee.platform'
4+
5+
if platform.OS == 'macOS' then
6+
if lm.platform == nil then
7+
elseif lm.platform == "darwin-arm64" then
8+
lm.target = "arm64-apple-macos11"
9+
elseif lm.platform == "darwin-x64" then
10+
lm.target = "x86_64-apple-macos10.12"
11+
else
12+
error "unknown platform"
13+
end
14+
elseif platform.OS == 'Windows' then
15+
if lm.platform == nil then
16+
elseif lm.platform == "win32-ia32" then
17+
lm.arch = "x86"
18+
elseif lm.platform == "win32-x64" then
19+
lm.arch = "x86_64"
20+
else
21+
error "unknown platform"
22+
end
23+
elseif platform.OS == 'Linux' then
24+
if lm.platform == nil then
25+
elseif lm.platform == "linux-x64" then
26+
elseif lm.platform == "linux-arm64" then
27+
lm.cc = 'aarch64-linux-gnu-gcc'
28+
else
29+
error "unknown platform"
30+
end
31+
end
32+
33+
local function detectWindowsArch()
34+
if os.getenv "PROCESSOR_ARCHITECTURE" == "ARM64" then
35+
return "arm64"
36+
end
37+
if os.getenv "PROCESSOR_ARCHITECTURE" == "AMD64" or os.getenv "PROCESSOR_ARCHITEW6432" == "AMD64" then
38+
return "x64"
39+
end
40+
return "ia32"
41+
end
42+
43+
local function detectPosixArch()
44+
local f <close> = assert(io.popen("uname -m", 'r'))
45+
return f:read 'l':lower()
46+
end
47+
48+
local function detectArch()
49+
if platform.OS == 'Windows' then
50+
return detectWindowsArch()
51+
end
52+
return detectPosixArch()
53+
end
54+
55+
local function targetPlatformArch()
56+
if lm.platform == nil then
57+
return detectArch()
58+
end
59+
return lm.platform:match "^[^-]*-(.*)$"
60+
end
61+
62+
if not lm.notest then
63+
lm.notest = (platform.OS ~= 'Windows' and targetPlatformArch() ~= detectArch())
64+
end

0 commit comments

Comments
 (0)