summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes/icecc.bbclass390
1 files changed, 144 insertions, 246 deletions
diff --git a/meta/classes/icecc.bbclass b/meta/classes/icecc.bbclass
index 715f870773..e20666b743 100644
--- a/meta/classes/icecc.bbclass
+++ b/meta/classes/icecc.bbclass
@@ -26,295 +26,193 @@
26#Error checking is kept to minimum so double check any parameters you pass to the class 26#Error checking is kept to minimum so double check any parameters you pass to the class
27########################################################################################### 27###########################################################################################
28 28
29ICECC_ENV_EXEC ?= "${STAGING_BINDIR_NATIVE}/icecc-create-env"
29 30
30def icc_determine_gcc_version(gcc): 31def icecc_dep_prepend(d):
31 """ 32 # INHIBIT_DEFAULT_DEPS doesn't apply to the patch command. Whether or not
32 Hack to determine the version of GCC 33 # we need that built is the responsibility of the patch function / class, not
33 34 # the application.
34 'i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5363)' 35 if not bb.data.getVar('INHIBIT_DEFAULT_DEPS', d):
35 """ 36 return "icecc-create-env"
36 return os.popen("%s --version" % gcc ).readline().split()[2] 37 return ""
37
38def create_cross_env(bb,d):
39 """
40 Create a tar.bz2 of the current toolchain
41 """
42 # Constin native-native compilation no environment needed if
43 # host prefix is empty (let us duplicate the query for ease)
44 prefix = bb.data.expand('${HOST_PREFIX}', d)
45 if len(prefix) == 0:
46 return ""
47
48 import tarfile, socket, time
49 prefix = bb.data.expand('${HOST_PREFIX}' , d)
50 ice_dir = bb.data.expand("${STAGING_DIR_NATIVE}${prefix_native}")
51 distro = bb.data.expand('${DISTRO}', d)
52 target_sys = bb.data.expand('${TARGET_SYS}', d)
53 target_prefix = bb.data.expand('${TARGET_PREFIX}', d)
54 float = bb.data.getVar('TARGET_FPU', d) or "hard"
55 name = socket.gethostname()
56
57 # Stupid check to determine if we have built a libc and a cross
58 # compiler.
59 try:
60 os.stat(os.path.join(ice_dir, target_sys, 'lib', 'libc.so'))
61 os.stat(os.path.join(ice_dir, target_sys, 'bin', 'g++'))
62 except: # no cross compiler built yet
63 return ""
64
65 VERSION = icc_determine_gcc_version( os.path.join(ice_dir,target_sys,"bin","g++") )
66 cross_name = prefix + distro + "-" + target_sys + "-" + float + "-" + VERSION + "-" + name
67 tar_file = os.path.join(ice_dir, 'ice', cross_name + '.tar.gz')
68
69 try:
70 os.stat(tar_file)
71 # tar file already exists
72 return tar_file
73 except:
74 try:
75 os.makedirs(os.path.join(ice_dir,'ice'))
76 except:
77 # directory already exists, continue
78 pass
79
80
81 #check if user has specified a specific icecc-create-env script
82 #if not use the OE provided one
83 cr_env_script = bb.data.getVar('ICECC_ENV_EXEC', d) or bb.data.expand('${STAGING_DIR}', d)+"/ice/icecc-create-env"
84 #call the modified create-env script
85 result=os.popen("%s %s %s %s %s %s" %(cr_env_script,
86 "--silent",
87 os.path.join(ice_dir,target_sys,'bin','gcc'),
88 os.path.join(ice_dir,target_sys,'bin','g++'),
89 os.path.join(ice_dir,target_sys,'bin','as'),
90 os.path.join(ice_dir,"ice",cross_name) ) )
91 return tar_file
92
93 38
94def create_native_env(bb,d): 39DEPENDS_prepend += "${@icecc_dep_prepend(d)} "
95 import tarfile, socket, time
96 ice_dir = bb.data.expand("${STAGING_DIR_NATIVE}${prefix_native}")
97 prefix = bb.data.expand('${HOST_PREFIX}' , d)
98 distro = bb.data.expand('${DISTRO}', d)
99 target_sys = bb.data.expand('${TARGET_SYS}', d)
100 target_prefix = bb.data.expand('${TARGET_PREFIX}', d)
101 float = bb.data.getVar('TARGET_FPU', d) or "hard"
102 name = socket.gethostname()
103 40
104 archive_name = "local-host-env" + "-" + name 41def get_cross_kernel_cc(bb,d):
105 tar_file = os.path.join(ice_dir, 'ice', archive_name + '.tar.gz')
106
107 try:
108 os.stat(tar_file)
109 # tar file already exists
110 return tar_file
111 except:
112 try:
113 #os.makedirs(os.path.join(ice_dir))
114 os.makedirs(os.path.join(ice_dir,'ice'))
115 except:
116 # directory already exists, continue
117 pass
118
119 #check if user has specified a specific icecc-create-env script
120 #if not use the OE provided one
121 cr_env_script = bb.data.getVar('ICECC_ENV_EXEC', d) or bb.data.expand('${STAGING_DIR}', d)+"/ice/icecc-create-env"
122 result=os.popen("%s %s %s %s %s %s" %(cr_env_script,
123 "--silent",
124 os.popen("%s gcc" % "which").read()[:-1],
125 os.popen("%s g++" % "which").read()[:-1],
126 os.popen("%s as" % "which").read()[:-1],
127 os.path.join(ice_dir,"ice",archive_name) ) )
128 return tar_file
129
130
131
132def create_cross_kernel_env(bb,d):
133 import tarfile, socket, time
134 ice_dir = bb.data.expand("${STAGING_DIR_NATIVE}${prefix_native}")
135 prefix = bb.data.expand('${HOST_PREFIX}' , d)
136 distro = bb.data.expand('${DISTRO}', d)
137 target_sys = bb.data.expand('${TARGET_SYS}', d)
138 target_prefix = bb.data.expand('${TARGET_PREFIX}', d)
139 float = bb.data.getVar('TARGET_FPU', d) or "hard"
140 name = socket.gethostname()
141 kernel_cc = bb.data.expand('${KERNEL_CC}', d) 42 kernel_cc = bb.data.expand('${KERNEL_CC}', d)
142 kernel_cc = kernel_cc[:-1] 43 kernel_cc = kernel_cc.replace('ccache', '').strip()
143 44 kernel_cc = kernel_cc.split(' ')[0]
144 # Stupid check to determine if we have built a libc and a cross 45 kernel_cc = kernel_cc.strip()
145 # compiler. 46 return kernel_cc
146 try:
147 os.stat(os.path.join(ice_dir, 'bin', kernel_cc))
148 except: # no cross compiler built yet
149 return ""
150
151 VERSION = icc_determine_gcc_version( os.path.join(ice_dir,"bin",kernel_cc) )
152 cross_name = prefix + distro + "-" + target_sys + "-" + float + "-" + VERSION + "-" + name
153 tar_file = os.path.join(ice_dir, 'ice', cross_name + '.tar.gz')
154
155 try:
156 os.stat(tar_file)
157 # tar file already exists
158 return tar_file
159 except:
160 try:
161 os.makedirs(os.path.join(ice_dir,'ice'))
162 except:
163 # directory already exists, continue
164 pass
165
166 47
167 #check if user has specified a specific icecc-create-env script 48def create_path(compilers, bb, d):
168 #if not use the OE provided one
169 cr_env_script = bb.data.getVar('ICECC_ENV_EXEC', d) or bb.data.expand('${STAGING_DIR}', d)+"/ice/icecc-create-env"
170 result=os.popen("%s %s %s %s %s %s" %(cr_env_script,
171 "--silent",
172 os.path.join(ice_dir,'bin',kernel_cc),
173 os.path.join(ice_dir,target_sys,'bin','g++'),
174 os.path.join(ice_dir,target_sys,'bin','as'),
175 os.path.join(ice_dir,"ice",cross_name) ) )
176 return tar_file
177
178
179def create_env(bb,d):
180
181 #return create_cross_kernel_env(bb,d)
182
183 if bb.data.inherits_class("native", d):
184 return create_native_env(bb,d)
185 elif bb.data.inherits_class("kernel", d):
186 return create_cross_kernel_env(bb,d)
187 elif bb.data.inherits_class("cross", d):
188 return create_native_env(bb,d)
189 elif bb.data.inherits_class("sdk", d):
190 return create_native_env(bb,d)
191 else:
192 return create_cross_env(bb,d)
193
194
195def create_path(compilers, type, bb, d):
196 """ 49 """
197 Create Symlinks for the icecc in the staging directory 50 Create Symlinks for the icecc in the staging directory
198 """ 51 """
199 staging = os.path.join(bb.data.expand('${STAGING_DIR}', d), "ice", type) 52 staging = os.path.join(bb.data.expand('${STAGING_BINDIR}', d), "ice")
53 if icc_is_kernel(bb, d):
54 staging += "-kernel"
200 55
201 #check if the icecc path is set by the user 56 #check if the icecc path is set by the user
202 icecc = bb.data.getVar('ICECC_PATH', d) or os.popen("%s icecc" % "which").read()[:-1] 57 icecc = bb.data.getVar('ICECC_PATH', d) or os.popen("which icecc").read()[:-1]
203 58
204 # Create the dir if necessary 59 # Create the dir if necessary
205 try: 60 try:
206 os.stat(staging) 61 os.stat(staging)
207 except: 62 except:
208 os.makedirs(staging) 63 try:
64 os.makedirs(staging)
65 except:
66 pass
209 67
210 for compiler in compilers: 68 for compiler in compilers:
211 gcc_path = os.path.join(staging, compiler) 69 gcc_path = os.path.join(staging, compiler)
212 try: 70 try:
213 os.stat(gcc_path) 71 os.stat(gcc_path)
214 except: 72 except:
215 os.symlink(icecc, gcc_path) 73 try:
74 os.symlink(icecc, gcc_path)
75 except:
76 pass
216 77
217 return staging + ":" 78 return staging
218 79
80def use_icc(bb,d):
81 package_tmp = bb.data.expand('${PN}', d)
219 82
220def use_icc_version(bb,d): 83 system_class_blacklist = [ "none" ]
221 icecc_ver = "yes" 84 user_class_blacklist = (bb.data.getVar('ICECC_USER_CLASS_BL', d) or "none").split()
222 system_class_blacklist = [ "none" ] 85 package_class_blacklist = system_class_blacklist + user_class_blacklist
223
224 for black in system_class_blacklist:
225 if bb.data.inherits_class(black, d):
226 icecc_ver = "no"
227
228 user_class_blacklist = bb.data.getVar('ICECC_USER_CLASS_BL', d) or "none"
229 user_class_blacklist = user_class_blacklist.split()
230
231 for black in user_class_blacklist:
232 if bb.data.inherits_class(black, d):
233 icecc_ver = "no"
234
235 return icecc_ver
236
237 86
238def icc_path(bb,d,compile): 87 for black in package_class_blacklist:
239 package_tmp = bb.data.expand('${PN}', d) 88 if bb.data.inherits_class(black, d):
89 #bb.note(package_tmp, ' class ', black, ' found in blacklist, disable icecc')
90 return "no"
240 91
241 #"system" package blacklist contains a list of packages that can not distribute compile tasks 92 #"system" package blacklist contains a list of packages that can not distribute compile tasks
242 #for one reason or the other 93 #for one reason or the other
243 system_package_blacklist = [ "uclibc", "glibc-intermediate", "gcc", "qemu", "bind", "u-boot", "dhcp-forwarder", "enchant" ] 94 system_package_blacklist = [ "uclibc", "glibc", "gcc", "bind", "u-boot", "dhcp-forwarder", "enchant", "connman", "orbit2" ]
244 95 user_package_blacklist = (bb.data.getVar('ICECC_USER_PACKAGE_BL', d) or "").split()
245 for black in system_package_blacklist: 96 package_blacklist = system_package_blacklist + user_package_blacklist
246 if black in package_tmp: 97
247 bb.data.setVar("PARALLEL_MAKE" , "", d) 98 for black in package_blacklist:
248 return "" 99 if black in package_tmp:
249 100 #bb.note(package_tmp, ' found in blacklist, disable icecc')
250 #user defined exclusion list 101 return "no"
251 user_package_blacklist = bb.data.getVar('ICECC_USER_PACKAGE_BL', d) or "none" 102
252 user_package_blacklist = user_package_blacklist.split() 103 if bb.data.getVar('PARALLEL_MAKE', d) == "":
253 104 bb.note(package_tmp, " ", bb.data.expand('${PV}', d), " has empty PARALLEL_MAKE, disable icecc")
254 for black in user_package_blacklist: 105 return "no"
255 if black in package_tmp: 106
256 bb.data.setVar("PARALLEL_MAKE" , "", d) 107 return "yes"
257 return "" 108
258 109def icc_is_kernel(bb, d):
259 110 return \
260 prefix = bb.data.expand('${HOST_PREFIX}', d) 111 bb.data.inherits_class("kernel", d);
261 112
262 113def icc_is_native(bb, d):
263 if compile and bb.data.inherits_class("cross", d): 114 return \
264 return create_path( ["gcc", "g++"], "native", bb, d) 115 bb.data.inherits_class("cross", d) or \
265 116 bb.data.inherits_class("cross-canadian", d) or \
266 elif compile and bb.data.inherits_class("native", d): 117 bb.data.inherits_class("native", d) or \
267 return create_path( ["gcc", "g++"], "native", bb, d) 118 bb.data.inherits_class("nativesdk", d);
268 119
269 elif compile and bb.data.inherits_class("kernel", d): 120def icc_version(bb, d):
270 return create_path( [get_cross_kernel_ver(bb,d), "foo"], "cross-kernel", bb, d) 121 if use_icc(bb, d) == "no":
122 return ""
271 123
272 elif not compile or len(prefix) == 0: 124 parallel = bb.data.getVar('ICECC_PARALLEL_MAKE', d) or ""
273 return create_path( ["gcc", "g++"], "native", bb, d) 125 bb.data.setVar("PARALLEL_MAKE", parallel, d)
274 126
127 if icc_is_native(bb, d):
128 archive_name = "local-host-env"
129 elif bb.data.expand('${HOST_PREFIX}', d) == "":
130 bb.fatal(bb.data.expand("${PN}", d), " NULL prefix")
275 else: 131 else:
276 return create_path( [prefix+"gcc", prefix+"g++"], "cross", bb, d) 132 prefix = bb.data.expand('${HOST_PREFIX}' , d)
133 distro = bb.data.expand('${DISTRO}', d)
134 target_sys = bb.data.expand('${TARGET_SYS}', d)
135 float = bb.data.getVar('TARGET_FPU', d) or "hard"
136 archive_name = prefix + distro + "-" + target_sys + "-" + float
137 if icc_is_kernel(bb, d):
138 archive_name += "-kernel"
139
140 import socket
141 ice_dir = bb.data.expand('${STAGING_DIR_NATIVE}${prefix_native}', d)
142 tar_file = os.path.join(ice_dir, 'ice', archive_name + "-@VERSION@-" + socket.gethostname() + '.tar.gz')
277 143
144 return tar_file
278 145
146def icc_path(bb,d):
147 if icc_is_kernel(bb, d):
148 return create_path( [get_cross_kernel_cc(bb,d), ], bb, d)
279 149
150 else:
151 prefix = bb.data.expand('${HOST_PREFIX}', d)
152 return create_path( [prefix+"gcc", prefix+"g++"], bb, d)
153
154def icc_get_tool(bb, d, tool):
155 if icc_is_native(bb, d):
156 return os.popen("which %s" % tool).read()[:-1]
157 elif icc_is_kernel(bb, d):
158 return os.popen("which %s" % get_cross_kernel_cc(bb, d)).read()[:-1]
159 else:
160 ice_dir = bb.data.expand('${STAGING_BINDIR_TOOLCHAIN}', d)
161 target_sys = bb.data.expand('${TARGET_SYS}', d)
162 return os.path.join(ice_dir, "%s-%s" % (target_sys, tool))
163
164set_icecc_env() {
165 ICECC_VERSION="${@icc_version(bb, d)}"
166 if [ "x${ICECC_VERSION}" = "x" ]
167 then
168 return
169 fi
280 170
281def icc_version(bb,d): 171 ICE_PATH="${@icc_path(bb, d)}"
282 return create_env(bb,d) 172 if [ "x${ICE_PATH}" = "x" ]
173 then
174 return
175 fi
283 176
177 ICECC_CC="${@icc_get_tool(bb,d, "gcc")}"
178 ICECC_CXX="${@icc_get_tool(bb,d, "g++")}"
179 if [ ! -x "${ICECC_CC}" -o ! -x "${ICECC_CXX}" ]
180 then
181 return
182 fi
284 183
285def check_for_kernel(bb,d): 184 ICE_VERSION=`$ICECC_CC -dumpversion`
286 if bb.data.inherits_class("kernel", d): 185 ICECC_VERSION=`echo ${ICECC_VERSION} | sed -e "s/@VERSION@/$ICE_VERSION/g"`
287 return "yes" 186 if [ ! -x "${ICECC_ENV_EXEC}" ]
288 return "no" 187 then
188 return
189 fi
289 190
191 ICECC_AS="`${ICECC_CC} -print-prog-name=as`"
192 if [ "`dirname "${ICECC_AS}"`" = "." ]
193 then
194 ICECC_AS="`which as`"
195 fi
290 196
291def get_cross_kernel_ver(bb,d): 197 if [ ! -r "${ICECC_VERSION}" ]
198 then
199 mkdir -p "`dirname "${ICECC_VERSION}"`"
200 ${ICECC_ENV_EXEC} "${ICECC_CC}" "${ICECC_CXX}" "${ICECC_AS}" "${ICECC_VERSION}"
201 fi
292 202
293 return bb.data.expand('${KERNEL_CC}', d).strip() or "gcc" 203 export ICECC_VERSION ICECC_CC ICECC_CXX
204 export PATH="$ICE_PATH:$PATH"
205 export CCACHE_PATH="$PATH"
206}
294 207
295# set the icecream environment variables
296do_configure_prepend() { 208do_configure_prepend() {
297 export PATH=${@icc_path(bb,d,False)}$PATH 209 set_icecc_env
298 export ICECC_CC="gcc"
299 export ICECC_CXX="g++"
300} 210}
301 211
302do_compile_prepend() { 212do_compile_prepend() {
303 213 set_icecc_env
304 export PATH=${@icc_path(bb,d,True)}$PATH
305
306 #check if we are building a kernel and select gcc-cross-kernel
307 if [ "${@check_for_kernel(bb,d)}" = "yes" ]; then
308 export ICECC_CC="${@get_cross_kernel_ver(bb,d)}"
309 export ICECC_CXX="${HOST_PREFIX}g++"
310 else
311 export ICECC_CC="${HOST_PREFIX}gcc"
312 export ICECC_CXX="${HOST_PREFIX}g++"
313 fi
314
315 if [ "${@use_icc_version(bb,d)}" = "yes" ]; then
316 export ICECC_VERSION="${@icc_version(bb,d)}"
317 else
318 export ICECC_VERSION="NONE"
319 fi
320} 214}
215
216#do_install_prepend() {
217# set_icecc_env
218#}