@@ -33,6 +33,15 @@ def mock_distcc_path(self):
33
33
executable = 'mock-distcc'
34
34
return os .path .join (os .path .dirname (__file__ ), executable )
35
35
36
+ def mock_sccache_path (self ):
37
+ """Return a path string of a mock sccache executable
38
+ """
39
+ if platform .system () == 'Windows' :
40
+ executable = 'sccache.cmd'
41
+ else :
42
+ executable = 'sccache'
43
+ return os .path .join (os .path .dirname (__file__ ), executable )
44
+
36
45
def default_args (self ):
37
46
"""Return new args object with default values
38
47
"""
@@ -46,6 +55,7 @@ def default_args(self):
46
55
enable_sanitize_coverage = False ,
47
56
export_compile_commands = False ,
48
57
distcc = False ,
58
+ sccache = False ,
49
59
cmake_generator = "Ninja" ,
50
60
cmake_c_launcher = None ,
51
61
cmake_cxx_launcher = None ,
@@ -73,6 +83,8 @@ def cmake(self, args):
73
83
toolchain .libtool = args .host_libtool
74
84
if args .distcc :
75
85
toolchain .distcc = self .mock_distcc_path ()
86
+ if args .sccache :
87
+ toolchain .sccache = self .mock_sccache_path ()
76
88
toolchain .ninja = self .which_ninja (args )
77
89
return CMake (args = args , toolchain = toolchain )
78
90
@@ -120,7 +132,7 @@ def test_common_options_tsan(self):
120
132
self .assertEqual (
121
133
list (cmake .common_options ()),
122
134
["-G" , "Ninja" ,
123
- "-DLLVM_USE_SANITIZER=Thread" ,
135
+ "-DLLVM_USE_SANITIZER=Thread" ,
124
136
"-DCMAKE_C_COMPILER:PATH=/path/to/clang" ,
125
137
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++" ,
126
138
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool" ,
@@ -222,6 +234,20 @@ def test_common_options_distcc(self):
222
234
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool" ,
223
235
"-DCMAKE_MAKE_PROGRAM=" + self .which_ninja (args )])
224
236
237
+ def test_common_options_sccache (self ):
238
+ args = self .default_args ()
239
+ args .sccache = True
240
+ cmake = self .cmake (args )
241
+ self .assertEqual (
242
+ list (cmake .common_options ()),
243
+ ["-G" , "Ninja" ,
244
+ "-DCMAKE_C_COMPILER_LAUNCHER:PATH=" + self .mock_sccache_path (),
245
+ "-DCMAKE_CXX_COMPILER_LAUNCHER:PATH=" + self .mock_sccache_path (),
246
+ "-DCMAKE_C_COMPILER:PATH=/path/to/clang" ,
247
+ "-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++" ,
248
+ "-DCMAKE_LIBTOOL:PATH=/path/to/libtool" ,
249
+ "-DCMAKE_MAKE_PROGRAM=" + self .which_ninja (args )])
250
+
225
251
def test_common_options_launcher (self ):
226
252
args = self .default_args ()
227
253
cmake_c_launcher = "/path/to/c_launcher"
0 commit comments