1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
import("lib.detect.find_tool")
import("core.tool.toolchain")
function test_config(t)
if xmake.is_embed() then
return
end
-- xmake
os.tryrm("build")
os.tryrm(".xmake")
local xmake_dt = os.mclock()
os.runv("xmake", {"config", "-c"})
xmake_dt = os.mclock() - xmake_dt
print("config targets/1k: xmake: %d ms", xmake_dt)
-- cmake
local cmake = find_tool("cmake")
if cmake then
os.tryrm("build")
os.mkdir("build")
local cmake_default_dt = os.mclock()
os.runv(cmake.program, {".."}, {curdir = "build"})
cmake_default_dt = os.mclock() - cmake_default_dt
print("config targets/1k: cmake/default: %d ms", cmake_default_dt)
t:require((cmake_default_dt > xmake_dt) or (cmake_default_dt + 2000 > xmake_dt))
local ninja = find_tool("ninja")
if ninja then
os.tryrm("build")
os.mkdir("build")
local configs = {}
local envs
if is_host("windows") then
table.insert(configs, "-DCMAKE_MAKE_PROGRAM=" .. ninja.program)
local msvc = toolchain.load("msvc")
if msvc:check() then
table.insert(configs, "-DCMAKE_CXX_COMPILER=" .. (msvc:tool("cxx")))
table.insert(configs, "-DCMAKE_C_COMPILER=" .. (msvc:tool("cc")))
envs = os.joinenvs(msvc:runenvs())
end
end
local cmake_ninja_dt = os.mclock()
os.runv(cmake.program, table.join("..", "-G", "Ninja", configs), {curdir = "build", envs = envs})
cmake_ninja_dt = os.mclock() - cmake_ninja_dt
print("config targets/1k: cmake/ninja: %d ms", cmake_ninja_dt)
t:require((cmake_ninja_dt > xmake_dt) or (cmake_ninja_dt + 2000 > xmake_dt))
end
if find_tool("make") and not is_subhost("windows") then
os.tryrm("build")
os.mkdir("build")
local cmake_makefile_dt = os.mclock()
os.runv(cmake.program, {"..", "-G", "Unix Makefiles"}, {curdir = "build"})
cmake_makefile_dt = os.mclock() - cmake_makefile_dt
print("config targets/1k: cmake/makefile: %d ms", cmake_makefile_dt)
t:require((cmake_makefile_dt > xmake_dt) or (cmake_makefile_dt + 2000 > xmake_dt))
end
end
-- meson
local meson = find_tool("meson")
if meson then
os.tryrm("build")
local meson_dt = os.mclock()
os.runv(meson.program, {"setup", "build"})
meson_dt = os.mclock() - meson_dt
print("config targets/1k: meson: %d ms", meson_dt)
t:require((meson_dt > xmake_dt) or (meson_dt + 2000 > xmake_dt))
end
end
|