@@ -7,10 +7,13 @@ function test_build(t)
7
7
return
8
8
end
9
9
10
+ local jobs = tostring (os .default_njob ())
11
+
10
12
-- xmake
11
13
os .tryrm (" build" )
14
+ os .tryrm (" .xmake" )
12
15
local xmake_dt = os .mclock ()
13
- os .run (" xmake" )
16
+ os .runv (" xmake" , { " -j " .. jobs } )
14
17
xmake_dt = os .mclock () - xmake_dt
15
18
print (" build targets/30: xmake: %d ms" , xmake_dt )
16
19
@@ -21,10 +24,10 @@ function test_build(t)
21
24
os .mkdir (" build" )
22
25
local cmake_default_dt = os .mclock ()
23
26
os .runv (cmake .program , {" .." }, {curdir = " build" })
24
- os .runv (cmake .program , {" --build" , " ." }, {curdir = " build" })
27
+ os .runv (cmake .program , {" --build" , " ." , " -j " .. jobs }, {curdir = " build" })
25
28
cmake_default_dt = os .mclock () - cmake_default_dt
26
29
print (" build targets/30: cmake/default: %d ms" , cmake_default_dt )
27
- -- t:require((cmake_default_dt > xmake_dt) or (cmake_default_dt + 2000 > xmake_dt))
30
+ t :require ((cmake_default_dt > xmake_dt ) or (cmake_default_dt + 2000 > xmake_dt ))
28
31
29
32
local ninja = find_tool (" ninja" )
30
33
if ninja then
@@ -43,11 +46,10 @@ function test_build(t)
43
46
end
44
47
local cmake_ninja_dt = os .mclock ()
45
48
os .runv (cmake .program , table .join (" .." , " -G" , " Ninja" , configs ), {curdir = " build" , envs = envs })
46
- os .runv (cmake .program , {" --build" , " ." }, {curdir = " build" , envs = envs })
49
+ os .runv (cmake .program , {" --build" , " ." , " -j " .. jobs }, {curdir = " build" , envs = envs })
47
50
cmake_ninja_dt = os .mclock () - cmake_ninja_dt
48
51
print (" build targets/30: cmake/ninja: %d ms" , cmake_ninja_dt )
49
- -- TODO we need to improve it
50
- -- t:require((cmake_ninja_dt > xmake_dt) or (cmake_ninja_dt + 2000 > xmake_dt))
52
+ t :require ((cmake_ninja_dt > xmake_dt ) or (cmake_ninja_dt + 2000 > xmake_dt ))
51
53
end
52
54
53
55
local make = find_tool (" make" )
@@ -56,7 +58,7 @@ function test_build(t)
56
58
os .mkdir (" build" )
57
59
local cmake_makefile_dt = os .mclock ()
58
60
os .runv (cmake .program , {" .." , " -G" , " Unix Makefiles" }, {curdir = " build" })
59
- os .runv (cmake .program , {" --build" , " ." }, {curdir = " build" })
61
+ os .runv (cmake .program , {" --build" , " ." , " -j " .. jobs }, {curdir = " build" })
60
62
cmake_makefile_dt = os .mclock () - cmake_makefile_dt
61
63
print (" build targets/30: cmake/makefile: %d ms" , cmake_makefile_dt )
62
64
t :require ((cmake_makefile_dt > xmake_dt ) or (cmake_makefile_dt + 2000 > xmake_dt ))
@@ -67,12 +69,19 @@ function test_build(t)
67
69
local meson = find_tool (" meson" )
68
70
if meson then
69
71
os .tryrm (" build" )
70
- local meson_dt = os .mclock ()
72
+ local meson_setup_dt = os .mclock ()
71
73
os .runv (meson .program , {" setup" , " build" })
72
- os .runv (meson .program , {" compile" , " -C" , " build" })
73
- meson_dt = os .mclock () - meson_dt
74
+ meson_setup_dt = os .mclock () - meson_setup_dt
75
+
76
+ -- ccache will cache object files globally, which may affect the results of the second run.
77
+ io .replace (" build/build.ninja" , " ccache" , " " )
78
+
79
+ local meson_build_dt = os .mclock ()
80
+ os .runv (meson .program , {" compile" , " -j" , jobs , " -C" , " build" })
81
+ meson_build_dt = os .mclock () - meson_build_dt
82
+ local meson_dt = meson_setup_dt + meson_build_dt
74
83
print (" build targets/30: meson: %d ms" , meson_dt )
75
- -- t:require((meson_dt > xmake_dt) or (meson_dt + 2000 > xmake_dt))
84
+ t :require ((meson_dt > xmake_dt ) or (meson_dt + 2000 > xmake_dt ))
76
85
end
77
86
end
78
87
0 commit comments