@@ -32,62 +32,25 @@ class Toolchain(object):
32
32
"""Represents native host toolchain
33
33
"""
34
34
35
- def find_tool (self , tool , versioned = False ):
35
+ def find_tool (self , * names ):
36
36
raise NotImplementedError ('Subclasses must implement this method' )
37
37
38
- # NOTE: We are declaring attribute for each tools because we need
39
- # them be assignable. For example, `toolchain.cc` can be
40
- # overriden by user supplied argument: --host-cc=/path/to/clang
41
- # And we don't want to override __getattr__ because that would need
42
- # heuristic command name inference. e.g. llvm_cov -> llvm-cov
43
-
44
- @cache_util .reify
45
- def cc (self ):
46
- '''Return Clang host tool path if found. `None` otherwise.
47
- '''
48
- return self .find_tool ('clang' )
49
-
50
- @cache_util .reify
51
- def cxx (self ):
52
- '''Return Clang host tool path if found. `None` otherwise.
53
- '''
54
- return self .find_tool ('clang++' )
55
-
56
- @cache_util .reify
57
- def cmake (self ):
58
- '''Return CMake host tool path if found. `None` otherwise.
59
- '''
60
- return self .find_tool ('cmake' )
61
-
62
- @cache_util .reify
63
- def ninja (self ):
64
- '''Return Ninja host tool path if found. `None` otherwise.
65
- '''
66
- return self .find_tool ('ninja' , 'ninja-build' )
67
-
68
- @cache_util .reify
69
- def distcc (self ):
70
- '''Return distcc host tool path if found. `None` otherwise.
71
- '''
72
- return self .find_tool ('distcc' )
73
-
74
- @cache_util .reify
75
- def distcc_pump (self ):
76
- '''Return distcc-pump host tool path if found. `None` otherwise.
77
- '''
78
- return self .find_tool ('distcc-pump' , 'pump' )
79
-
80
- @cache_util .reify
81
- def llvm_profdata (self ):
82
- '''Return llvm-profdata host tool path if found. `None` otherwise.
83
- '''
84
- return self .find_tool ('llvm-profdata' )
85
38
86
- @cache_util .reify
87
- def llvm_cov (self ):
88
- '''Return llvm-cov host tool path if found. `None` otherwise.
89
- '''
90
- return self .find_tool ('llvm-cov' )
39
+ # Declare properties for each tools.
40
+ # These properties are loaded lazily and assignable.
41
+ def _register (name , * tool ):
42
+ def _getter (self ):
43
+ return self .find_tool (* tool )
44
+ _getter .__name__ = name
45
+ setattr (Toolchain , name , cache_util .reify (_getter ))
46
+ _register ("cc" , "clang" )
47
+ _register ("cxx" , "clang++" )
48
+ _register ("ninja" , "ninja" , "ninja-build" )
49
+ _register ("cmake" , "cmake" )
50
+ _register ("distcc" , "distcc" )
51
+ _register ("distcc_pump" , "distcc-pump" , "pump" )
52
+ _register ("llvm_profdata" , "llvm-profdata" )
53
+ _register ("llvm_cov" , "llvm-cov" )
91
54
92
55
93
56
class Darwin (Toolchain ):
@@ -198,9 +161,7 @@ def _release_date():
198
161
199
162
200
163
class Cygwin (Linux ):
201
- # FIXME: Currently, Cygwin is considered as the same as Linux.
202
- # I'm not sure it's correct or not.
203
- # Please some Cygwin user could confirm this or fix it.
164
+ # Currently, Cygwin is considered as the same as Linux.
204
165
pass
205
166
206
167
0 commit comments