diff options
author | Richard Purdie <richard@openedhand.com> | 2007-08-08 20:41:55 +0000 |
---|---|---|
committer | Richard Purdie <richard@openedhand.com> | 2007-08-08 20:41:55 +0000 |
commit | 720e0b144cabc48c65dc831b61602a10a2da5f90 (patch) | |
tree | 005b5aac27800b94d730580e49d59582938790ad /meta/classes/icecc.bbclass | |
parent | fe553f406dda1c495d285c650846c9509f0c7e19 (diff) | |
download | poky-720e0b144cabc48c65dc831b61602a10a2da5f90.tar.gz |
classes: Sync various classes with OE for various bugfixes
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@2407 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta/classes/icecc.bbclass')
-rw-r--r-- | meta/classes/icecc.bbclass | 309 |
1 files changed, 233 insertions, 76 deletions
diff --git a/meta/classes/icecc.bbclass b/meta/classes/icecc.bbclass index 2f34d408d2..446e78ae1a 100644 --- a/meta/classes/icecc.bbclass +++ b/meta/classes/icecc.bbclass | |||
@@ -1,8 +1,30 @@ | |||
1 | # IceCream distributed compiling support | 1 | # IceCream distributed compiling support |
2 | # | 2 | # |
3 | # We need to create a tar.bz2 of our toolchain and set | 3 | # Stages directories with symlinks from gcc/g++ to icecc, for both |
4 | # ICECC_VERSION, ICECC_CXX and ICEC_CC | 4 | # native and cross compilers. Depending on each configure or compile, |
5 | # the directories are added at the head of the PATH list and ICECC_CXX | ||
6 | # and ICEC_CC are set. | ||
5 | # | 7 | # |
8 | # For the cross compiler, creates a tar.gz of our toolchain and sets | ||
9 | # ICECC_VERSION accordingly. | ||
10 | # | ||
11 | #The class now handles all 3 different compile 'stages' (i.e native ,cross-kernel and target) creating the | ||
12 | #necessary enviroment tar.gz file to be used by the remote machines | ||
13 | # | ||
14 | #If ICECC_PATH is not set in local.conf then the class will try to locate it using 'which' | ||
15 | #but nothing is sure ;) | ||
16 | # | ||
17 | #If ICECC_ENV_EXEC is set in local.conf should point to the icecc-create-env script provided by the user | ||
18 | #or the default one provided by icecc-create-env.bb will be used | ||
19 | #(NOTE that this is a modified version of the script need it and *not the one that comes with icecc* | ||
20 | # | ||
21 | #User can specify if specific packages or packages belonging to class should not use icecc to distribute | ||
22 | #compile jobs to remote machines, but handled localy, by defining ICECC_USER_CLASS_BL and ICECC_PACKAGE_BL | ||
23 | #with the appropriate values in local.conf | ||
24 | ######################################################################################### | ||
25 | #Error checking is kept to minimum so double check any parameters you pass to the class | ||
26 | ########################################################################################### | ||
27 | |||
6 | 28 | ||
7 | def icc_determine_gcc_version(gcc): | 29 | def icc_determine_gcc_version(gcc): |
8 | """ | 30 | """ |
@@ -10,11 +32,12 @@ def icc_determine_gcc_version(gcc): | |||
10 | 32 | ||
11 | 'i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5363)' | 33 | 'i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5363)' |
12 | """ | 34 | """ |
35 | import os | ||
13 | return os.popen("%s --version" % gcc ).readline().split()[2] | 36 | return os.popen("%s --version" % gcc ).readline().split()[2] |
14 | 37 | ||
15 | def create_env(bb,d): | 38 | def create_cross_env(bb,d): |
16 | """ | 39 | """ |
17 | Create a tar.bz of the current toolchain | 40 | Create a tar.bz2 of the current toolchain |
18 | """ | 41 | """ |
19 | 42 | ||
20 | # Constin native-native compilation no environment needed if | 43 | # Constin native-native compilation no environment needed if |
@@ -23,78 +46,156 @@ def create_env(bb,d): | |||
23 | if len(prefix) == 0: | 46 | if len(prefix) == 0: |
24 | return "" | 47 | return "" |
25 | 48 | ||
26 | import tarfile | 49 | import tarfile, socket, time, os |
27 | import socket | ||
28 | import time | ||
29 | import os | ||
30 | ice_dir = bb.data.expand('${CROSS_DIR}', d) | 50 | ice_dir = bb.data.expand('${CROSS_DIR}', d) |
31 | prefix = bb.data.expand('${HOST_PREFIX}' , d) | 51 | prefix = bb.data.expand('${HOST_PREFIX}' , d) |
32 | distro = bb.data.expand('${DISTRO}', d) | 52 | distro = bb.data.expand('${DISTRO}', d) |
33 | target_sys = bb.data.expand('${TARGET_SYS}', d) | 53 | target_sys = bb.data.expand('${TARGET_SYS}', d) |
34 | float = bb.data.getVar('${TARGET_FPU}', d) or "hard" | 54 | target_prefix = bb.data.expand('${TARGET_PREFIX}', d) |
55 | float = bb.data.getVar('TARGET_FPU', d) or "hard" | ||
35 | name = socket.gethostname() | 56 | name = socket.gethostname() |
57 | |||
36 | 58 | ||
37 | # Stupid check to determine if we have built a libc and a cross | 59 | # Stupid check to determine if we have built a libc and a cross |
38 | # compiler. | 60 | # compiler. |
39 | try: | 61 | try: |
40 | os.stat(os.path.join(ice_dir, target_sys, 'lib', 'ld-linux.so.2')) | 62 | os.stat(os.path.join(ice_dir, target_sys, 'lib', 'libc.so')) |
41 | os.stat(os.path.join(ice_dir, target_sys, 'bin', 'g++')) | 63 | os.stat(os.path.join(ice_dir, target_sys, 'bin', 'g++')) |
42 | except: | 64 | except: # no cross compiler built yet |
43 | return "" | 65 | return "" |
44 | 66 | ||
45 | VERSION = icc_determine_gcc_version( os.path.join(ice_dir,target_sys,"bin","g++") ) | 67 | VERSION = icc_determine_gcc_version( os.path.join(ice_dir,target_sys,"bin","g++") ) |
46 | cross_name = prefix + distro + target_sys + float +VERSION+ name | 68 | cross_name = prefix + distro + "-" + target_sys + "-" + float + "-" + VERSION + "-" + name |
47 | tar_file = os.path.join(ice_dir, 'ice', cross_name + '.tar.bz2') | 69 | tar_file = os.path.join(ice_dir, 'ice', cross_name + '.tar.gz') |
48 | 70 | ||
49 | try: | 71 | try: |
50 | os.stat(tar_file) | 72 | os.stat(tar_file) |
73 | # tar file already exists | ||
51 | return tar_file | 74 | return tar_file |
52 | except: | 75 | except: |
53 | try: | 76 | try: |
54 | os.makedirs(os.path.join(ice_dir,'ice')) | 77 | os.makedirs(os.path.join(ice_dir,'ice')) |
55 | except: | 78 | except: |
79 | # directory already exists, continue | ||
56 | pass | 80 | pass |
57 | 81 | ||
58 | # FIXME find out the version of the compiler | 82 | |
59 | # Consider using -print-prog-name={cc1,cc1plus} | 83 | #check if user has specified a specific icecc-create-env script |
60 | # and -print-file-name=specs | 84 | #if not use the OE provided one |
61 | 85 | cr_env_script = bb.data.getVar('ICECC_ENV_EXEC', d) or bb.data.expand('${STAGING_DIR}', d)+"/ice/icecc-create-env" | |
62 | # We will use the GCC to tell us which tools to use | 86 | #call the modified create-env script |
63 | # What we need is: | 87 | result=os.popen("%s %s %s %s %s %s" %(cr_env_script, |
64 | # -gcc | 88 | "--silent", |
65 | # -g++ | 89 | os.path.join(ice_dir,target_sys,'bin','gcc'), |
66 | # -as | 90 | os.path.join(ice_dir,target_sys,'bin','g++'), |
67 | # -cc1 | 91 | os.path.join(ice_dir,target_sys,'bin','as'), |
68 | # -cc1plus | 92 | os.path.join(ice_dir,"ice",cross_name) ) ) |
69 | # and we add them to /usr/bin | ||
70 | |||
71 | tar = tarfile.open(tar_file, 'w:bz2') | ||
72 | |||
73 | # Now add the required files | ||
74 | tar.add(os.path.join(ice_dir,target_sys,'bin','gcc'), | ||
75 | os.path.join("usr","bin","gcc") ) | ||
76 | tar.add(os.path.join(ice_dir,target_sys,'bin','g++'), | ||
77 | os.path.join("usr","bin","g++") ) | ||
78 | tar.add(os.path.join(ice_dir,target_sys,'bin','as'), | ||
79 | os.path.join("usr","bin","as") ) | ||
80 | |||
81 | # Now let us find cc1 and cc1plus | ||
82 | cc1 = os.popen("%s -print-prog-name=cc1" % data.getVar('CC', d, True)).read()[:-1] | ||
83 | cc1plus = os.popen("%s -print-prog-name=cc1plus" % data.getVar('CC', d, True)).read()[:-1] | ||
84 | spec = os.popen("%s -print-file-name=specs" % data.getVar('CC', d, True)).read()[:-1] | ||
85 | |||
86 | # CC1 and CC1PLUS should be there... | ||
87 | tar.add(cc1, os.path.join('usr', 'bin', 'cc1')) | ||
88 | tar.add(cc1plus, os.path.join('usr', 'bin', 'cc1plus')) | ||
89 | |||
90 | # spec - if it exists | ||
91 | if os.path.exists(spec): | ||
92 | tar.add(spec) | ||
93 | |||
94 | tar.close() | ||
95 | return tar_file | 93 | return tar_file |
96 | 94 | ||
97 | 95 | ||
96 | def create_native_env(bb,d): | ||
97 | |||
98 | import tarfile, socket, time, os | ||
99 | ice_dir = bb.data.expand('${CROSS_DIR}', d) | ||
100 | prefix = bb.data.expand('${HOST_PREFIX}' , d) | ||
101 | distro = bb.data.expand('${DISTRO}', d) | ||
102 | target_sys = bb.data.expand('${TARGET_SYS}', d) | ||
103 | target_prefix = bb.data.expand('${TARGET_PREFIX}', d) | ||
104 | float = bb.data.getVar('TARGET_FPU', d) or "hard" | ||
105 | name = socket.gethostname() | ||
106 | |||
107 | |||
108 | archive_name = "local-host-env" + "-" + name | ||
109 | tar_file = os.path.join(ice_dir, 'ice', archive_name + '.tar.gz') | ||
110 | |||
111 | try: | ||
112 | os.stat(tar_file) | ||
113 | # tar file already exists | ||
114 | return tar_file | ||
115 | except: | ||
116 | try: | ||
117 | #os.makedirs(os.path.join(ice_dir)) | ||
118 | os.makedirs(os.path.join(ice_dir,'ice')) | ||
119 | except: | ||
120 | # directory already exists, continue | ||
121 | pass | ||
122 | |||
123 | |||
124 | #check if user has specified a specific icecc-create-env script | ||
125 | #if not use the OE provided one | ||
126 | cr_env_script = bb.data.getVar('ICECC_ENV_EXEC', d) or bb.data.expand('${STAGING_DIR}', d)+"/ice/icecc-create-env" | ||
127 | result=os.popen("%s %s %s %s %s %s" %(cr_env_script, | ||
128 | "--silent", | ||
129 | os.popen("%s gcc" % "which").read()[:-1], | ||
130 | os.popen("%s g++" % "which").read()[:-1], | ||
131 | os.popen("%s as" % "which").read()[:-1], | ||
132 | os.path.join(ice_dir,"ice",archive_name) ) ) | ||
133 | return tar_file | ||
134 | |||
135 | |||
136 | |||
137 | def create_cross_kernel_env(bb,d): | ||
138 | |||
139 | import tarfile, socket, time, os | ||
140 | ice_dir = bb.data.expand('${CROSS_DIR}', d) | ||
141 | prefix = bb.data.expand('${HOST_PREFIX}' , d) | ||
142 | distro = bb.data.expand('${DISTRO}', d) | ||
143 | target_sys = bb.data.expand('${TARGET_SYS}', d) | ||
144 | target_prefix = bb.data.expand('${TARGET_PREFIX}', d) | ||
145 | float = bb.data.getVar('TARGET_FPU', d) or "hard" | ||
146 | name = socket.gethostname() | ||
147 | kernel_cc = bb.data.expand('${KERNEL_CC}', d) | ||
148 | kernel_cc = kernel_cc[:-1] | ||
149 | |||
150 | |||
151 | # Stupid check to determine if we have built a libc and a cross | ||
152 | # compiler. | ||
153 | try: | ||
154 | os.stat(os.path.join(ice_dir, 'bin', kernel_cc)) | ||
155 | except: # no cross compiler built yet | ||
156 | return "" | ||
157 | |||
158 | VERSION = icc_determine_gcc_version( os.path.join(ice_dir,"bin",kernel_cc) ) | ||
159 | cross_name = prefix + distro + "-" + target_sys + "-" + float + "-" + VERSION + "-" + name | ||
160 | tar_file = os.path.join(ice_dir, 'ice', cross_name + '.tar.gz') | ||
161 | |||
162 | try: | ||
163 | os.stat(tar_file) | ||
164 | # tar file already exists | ||
165 | return tar_file | ||
166 | except: | ||
167 | try: | ||
168 | os.makedirs(os.path.join(ice_dir,'ice')) | ||
169 | except: | ||
170 | # directory already exists, continue | ||
171 | pass | ||
172 | |||
173 | |||
174 | #check if user has specified a specific icecc-create-env script | ||
175 | #if not use the OE provided one | ||
176 | cr_env_script = bb.data.getVar('ICECC_ENV_EXEC', d) or bb.data.expand('${STAGING_DIR}', d)+"/ice/icecc-create-env" | ||
177 | result=os.popen("%s %s %s %s %s %s" %(cr_env_script, | ||
178 | "--silent", | ||
179 | os.path.join(ice_dir,'bin',kernel_cc), | ||
180 | os.path.join(ice_dir,target_sys,'bin','g++'), | ||
181 | os.path.join(ice_dir,target_sys,'bin','as'), | ||
182 | os.path.join(ice_dir,"ice",cross_name) ) ) | ||
183 | return tar_file | ||
184 | |||
185 | |||
186 | def create_env(bb,d): | ||
187 | |||
188 | #return create_cross_kernel_env(bb,d) | ||
189 | if bb.data.inherits_class("native", d): | ||
190 | return create_native_env(bb,d) | ||
191 | elif bb.data.inherits_class("kernel", d): | ||
192 | return create_cross_kernel_env(bb,d) | ||
193 | elif bb.data.inherits_class("cross", d): | ||
194 | return create_native_env(bb,d) | ||
195 | else: | ||
196 | return create_cross_env(bb,d) | ||
197 | |||
198 | |||
98 | def create_path(compilers, type, bb, d): | 199 | def create_path(compilers, type, bb, d): |
99 | """ | 200 | """ |
100 | Create Symlinks for the icecc in the staging directory | 201 | Create Symlinks for the icecc in the staging directory |
@@ -102,15 +203,17 @@ def create_path(compilers, type, bb, d): | |||
102 | import os | 203 | import os |
103 | 204 | ||
104 | staging = os.path.join(bb.data.expand('${STAGING_DIR}', d), "ice", type) | 205 | staging = os.path.join(bb.data.expand('${STAGING_DIR}', d), "ice", type) |
105 | icecc = bb.data.getVar('ICECC_PATH', d) | ||
106 | 206 | ||
207 | #check if the icecc path is set by the user | ||
208 | icecc = bb.data.getVar('ICECC_PATH', d) or os.popen("%s icecc" % "which").read()[:-1] | ||
209 | |||
210 | |||
107 | # Create the dir if necessary | 211 | # Create the dir if necessary |
108 | try: | 212 | try: |
109 | os.stat(staging) | 213 | os.stat(staging) |
110 | except: | 214 | except: |
111 | os.makedirs(staging) | 215 | os.makedirs(staging) |
112 | 216 | ||
113 | |||
114 | for compiler in compilers: | 217 | for compiler in compilers: |
115 | gcc_path = os.path.join(staging, compiler) | 218 | gcc_path = os.path.join(staging, compiler) |
116 | try: | 219 | try: |
@@ -121,46 +224,89 @@ def create_path(compilers, type, bb, d): | |||
121 | return staging + ":" | 224 | return staging + ":" |
122 | 225 | ||
123 | 226 | ||
227 | |||
228 | |||
229 | |||
124 | def use_icc_version(bb,d): | 230 | def use_icc_version(bb,d): |
125 | # Constin native native | 231 | |
126 | prefix = bb.data.expand('${HOST_PREFIX}', d) | 232 | icecc_ver = "yes" |
127 | if len(prefix) == 0: | 233 | system_class_blacklist = [ "none" ] |
128 | return "no" | 234 | |
235 | for black in system_class_blacklist: | ||
236 | if bb.data.inherits_class(black, d): | ||
237 | icecc_ver = "no" | ||
129 | 238 | ||
130 | 239 | ||
131 | blacklist = [ "cross", "native" ] | 240 | user_class_blacklist = bb.data.getVar('ICECC_USER_CLASS_BL', d) or "none" |
241 | user_class_blacklist = user_class_blacklist.split() | ||
242 | |||
243 | for black in user_class_blacklist: | ||
244 | if bb.data.inherits_class(black, d): | ||
245 | icecc_ver = "no" | ||
246 | |||
247 | return icecc_ver | ||
132 | 248 | ||
133 | for black in blacklist: | ||
134 | if bb.data.inherits_class(black, d): | ||
135 | return "no" | ||
136 | 249 | ||
137 | return "yes" | ||
138 | 250 | ||
139 | def icc_path(bb,d,compile): | 251 | def icc_path(bb,d,compile): |
140 | native = bb.data.expand('${PN}', d) | 252 | package_tmp = bb.data.expand('${PN}', d) |
141 | blacklist = [ "ulibc", "glibc", "ncurses" ] | 253 | |
142 | for black in blacklist: | 254 | #"system" package blacklist contains a list of packages that can not distribute compile tasks |
143 | if black in native: | 255 | #for one reason or the other |
144 | return "" | 256 | system_package_blacklist = [ "uclibc", "glibc-intermediate", "qemu" ] |
257 | |||
258 | for black in system_package_blacklist: | ||
259 | if black in package_tmp: | ||
260 | bb.data.setVar('PARALLEL_MAKE' , '', d) | ||
261 | return "" | ||
262 | |||
263 | #user defined exclusion list | ||
264 | user_package_blacklist = bb.data.getVar('ICECC_USER_PACKAGE_BL', d) or "none" | ||
265 | user_package_blacklist = user_package_blacklist.split() | ||
266 | |||
267 | for black in user_package_blacklist: | ||
268 | if black in package_tmp: | ||
269 | bb.data.setVar('PARALLEL_MAKE' , '', d) | ||
270 | return "" | ||
145 | 271 | ||
146 | blacklist = [ "cross", "native" ] | ||
147 | for black in blacklist: | ||
148 | if bb.data.inherits_class(black, d): | ||
149 | compile = False | ||
150 | 272 | ||
151 | prefix = bb.data.expand('${HOST_PREFIX}', d) | 273 | prefix = bb.data.expand('${HOST_PREFIX}', d) |
152 | if compile and len(prefix) != 0: | 274 | |
153 | return create_path( [prefix+"gcc", prefix+"g++"], "cross", bb, d ) | 275 | |
276 | if compile and bb.data.inherits_class("cross", d): | ||
277 | return create_path( ["gcc", "g++"], "native", bb, d) | ||
278 | |||
279 | elif compile and bb.data.inherits_class("native", d): | ||
280 | return create_path( ["gcc", "g++"], "native", bb, d) | ||
281 | |||
282 | elif compile and bb.data.inherits_class("kernel", d): | ||
283 | #kernel_cc = bb.data.expand('${KERNEL_CC}', d) | ||
284 | return create_path( [get_cross_kernel_ver(bb,d), "foo"], "cross-kernel", bb, d) | ||
285 | |||
154 | elif not compile or len(prefix) == 0: | 286 | elif not compile or len(prefix) == 0: |
155 | return create_path( ["gcc", "g++"], "native", bb, d) | 287 | return create_path( ["gcc", "g++"], "native", bb, d) |
288 | |||
289 | else: | ||
290 | return create_path( [prefix+"gcc", prefix+"g++"], "cross", bb, d) | ||
291 | |||
292 | |||
156 | 293 | ||
157 | 294 | ||
158 | def icc_version(bb,d): | 295 | def icc_version(bb,d): |
159 | return create_env(bb,d) | 296 | return create_env(bb,d) |
160 | 297 | ||
298 | def check_for_kernel(bb,d): | ||
299 | if bb.data.inherits_class("kernel", d): | ||
300 | return "yes" | ||
161 | 301 | ||
162 | # | 302 | return "no" |
163 | # set the IceCream environment variables | 303 | |
304 | |||
305 | def get_cross_kernel_ver(bb,d): | ||
306 | |||
307 | return bb.data.expand('${KERNEL_CC}', d).strip() or "gcc" | ||
308 | |||
309 | # set the icecream environment variables | ||
164 | do_configure_prepend() { | 310 | do_configure_prepend() { |
165 | export PATH=${@icc_path(bb,d,False)}$PATH | 311 | export PATH=${@icc_path(bb,d,False)}$PATH |
166 | export ICECC_CC="gcc" | 312 | export ICECC_CC="gcc" |
@@ -168,11 +314,22 @@ do_configure_prepend() { | |||
168 | } | 314 | } |
169 | 315 | ||
170 | do_compile_prepend() { | 316 | do_compile_prepend() { |
317 | |||
171 | export PATH=${@icc_path(bb,d,True)}$PATH | 318 | export PATH=${@icc_path(bb,d,True)}$PATH |
319 | |||
320 | #check if we are building a kernel and select gcc-cross-kernel | ||
321 | if [ "${@check_for_kernel(bb,d)}" = "yes" ]; then | ||
322 | export ICECC_CC="${@get_cross_kernel_ver(bb,d)}" | ||
323 | export ICECC_CXX="${HOST_PREFIX}g++" | ||
324 | else | ||
172 | export ICECC_CC="${HOST_PREFIX}gcc" | 325 | export ICECC_CC="${HOST_PREFIX}gcc" |
173 | export ICECC_CXX="${HOST_PREFIX}g++" | 326 | export ICECC_CXX="${HOST_PREFIX}g++" |
327 | fi | ||
174 | 328 | ||
175 | if [ "${@use_icc_version(bb,d)}" = "yes" ]; then | 329 | if [ "${@use_icc_version(bb,d)}" = "yes" ]; then |
176 | export ICECC_VERSION="${@icc_version(bb,d)}" | 330 | export ICECC_VERSION="${@icc_version(bb,d)}" |
331 | else | ||
332 | export ICECC_VERSION="NONE" | ||
177 | fi | 333 | fi |
178 | } | 334 | } |
335 | |||