summaryrefslogtreecommitdiffstats
path: root/meta/classes/icecc.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <richard@openedhand.com>2006-07-21 10:10:31 +0000
committerRichard Purdie <richard@openedhand.com>2006-07-21 10:10:31 +0000
commitb2f192faabe412adce79534e22efe9fb69ee40e2 (patch)
tree7076c49d4286f8a1733650bd8fbc7161af200d57 /meta/classes/icecc.bbclass
parent2cf0eadf9f730027833af802d7e6c90b44248f80 (diff)
downloadpoky-b2f192faabe412adce79534e22efe9fb69ee40e2.tar.gz
Rename /openembedded/ -> /meta/
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@530 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta/classes/icecc.bbclass')
-rw-r--r--meta/classes/icecc.bbclass156
1 files changed, 156 insertions, 0 deletions
diff --git a/meta/classes/icecc.bbclass b/meta/classes/icecc.bbclass
new file mode 100644
index 0000000000..7dfcfc29a4
--- /dev/null
+++ b/meta/classes/icecc.bbclass
@@ -0,0 +1,156 @@
1# IceCream distributed compiling support
2#
3# We need to create a tar.bz2 of our toolchain and set
4# ICECC_VERSION, ICECC_CXX and ICEC_CC
5#
6
7def create_env(bb,d):
8 """
9 Create a tar.bz of the current toolchain
10 """
11
12 # Constin native-native compilation no environment needed if
13 # host prefix is empty (let us duplicate the query for ease)
14 prefix = bb.data.expand('${HOST_PREFIX}', d)
15 if len(prefix) == 0:
16 return ""
17
18 import tarfile
19 import socket
20 import time
21 import os
22 ice_dir = bb.data.expand('${CROSS_DIR}', d)
23 prefix = bb.data.expand('${HOST_PREFIX}' , d)
24 distro = bb.data.expand('${DISTRO}', d)
25 target_sys = bb.data.expand('${TARGET_SYS}', d)
26 #float = bb.data.getVar('${TARGET_FPU}', d)
27 float = "anyfloat"
28 name = socket.gethostname()
29
30 try:
31 os.stat(ice_dir + '/' + target_sys + '/lib/ld-linux.so.2')
32 os.stat(ice_dir + '/' + target_sys + '/bin/g++')
33 except:
34 return ""
35
36 VERSION = '3.4.3'
37 cross_name = prefix + distro + target_sys + float +VERSION+ name
38 tar_file = ice_dir + '/ice/' + cross_name + '.tar.bz2'
39
40 try:
41 os.stat(tar_file)
42 return tar_file
43 except:
44 try:
45 os.makedirs(ice_dir+'/ice')
46 except:
47 pass
48
49 # FIXME find out the version of the compiler
50 tar = tarfile.open(tar_file, 'w:bz2')
51 tar.add(ice_dir + '/' + target_sys + '/lib/ld-linux.so.2',
52 target_sys + 'cross/lib/ld-linux.so.2')
53 tar.add(ice_dir + '/' + target_sys + '/lib/ld-linux.so.2',
54 target_sys + 'cross/lib/ld-2.3.3.so')
55 tar.add(ice_dir + '/' + target_sys + '/lib/libc-2.3.3.so',
56 target_sys + 'cross/lib/libc-2.3.3.so')
57 tar.add(ice_dir + '/' + target_sys + '/lib/libc.so.6',
58 target_sys + 'cross/lib/libc.so.6')
59 tar.add(ice_dir + '/' + target_sys + '/bin/gcc',
60 target_sys + 'cross/usr/bin/gcc')
61 tar.add(ice_dir + '/' + target_sys + '/bin/g++',
62 target_sys + 'cross/usr/bin/g++')
63 tar.add(ice_dir + '/' + target_sys + '/bin/as',
64 target_sys + 'cross/usr/bin/as')
65 tar.add(ice_dir + '/lib/gcc/' + target_sys +'/'+ VERSION + '/specs',
66 target_sys+'cross/usr/lib/gcc/'+target_sys+'/'+VERSION+'/lib/specs')
67 tar.add(ice_dir + '/libexec/gcc/'+target_sys+'/' + VERSION + '/cc1',
68 target_sys + 'cross/usr/lib/gcc/'+target_sys+'/'+VERSION+'/lib/cc1')
69 tar.add(ice_dir + '/libexec/gcc/arm-linux/' + VERSION + '/cc1plus',
70 target_sys+'cross/usr/lib/gcc/'+target_sys+'/'+VERSION+'/lib/cc1plus')
71 tar.close()
72 return tar_file
73
74
75def create_path(compilers, type, bb, d):
76 """
77 Create Symlinks for the icecc in the staging directory
78 """
79 import os
80
81 staging = bb.data.expand('${STAGING_DIR}', d) + "/ice/" + type
82 icecc = bb.data.getVar('ICECC_PATH', d)
83
84 # Create the dir if necessary
85 try:
86 os.stat(staging)
87 except:
88 os.makedirs(staging)
89
90
91 for compiler in compilers:
92 gcc_path = staging + "/" + compiler
93 try:
94 os.stat(gcc_path)
95 except:
96 os.symlink(icecc, gcc_path)
97
98 return staging + ":"
99
100
101def use_icc_version(bb,d):
102 # Constin native native
103 prefix = bb.data.expand('${HOST_PREFIX}', d)
104 if len(prefix) == 0:
105 return "no"
106
107
108 native = bb.data.expand('${PN}', d)
109 blacklist = [ "-cross", "-native" ]
110
111 for black in blacklist:
112 if black in native:
113 return "no"
114
115 return "yes"
116
117def icc_path(bb,d,compile):
118 native = bb.data.expand('${PN}', d)
119 blacklist = [ "ulibc", "glibc", "ncurses" ]
120 for black in blacklist:
121 if black in native:
122 return ""
123
124 if "-native" in native:
125 compile = False
126 if "-cross" in native:
127 compile = False
128
129 prefix = bb.data.expand('${HOST_PREFIX}', d)
130 if compile and len(prefix) != 0:
131 return create_path( [prefix+"gcc", prefix+"g++"], "cross", bb, d )
132 elif not compile or len(prefix) == 0:
133 return create_path( ["gcc", "g++"], "native", bb, d)
134
135
136def icc_version(bb,d):
137 return create_env(bb,d)
138
139
140#
141# set the IceCream environment variables
142do_configure_prepend() {
143 export PATH=${@icc_path(bb,d,False)}$PATH
144 export ICECC_CC="gcc"
145 export ICECC_CXX="g++"
146}
147
148do_compile_prepend() {
149 export PATH=${@icc_path(bb,d,True)}$PATH
150 export ICECC_CC="${HOST_PREFIX}gcc"
151 export ICECC_CXX="${HOST_PREFIX}g++"
152
153 if [ "${@use_icc_version(bb,d)}" = "yes" ]; then
154 export ICECC_VERSION="${@icc_version(bb,d)}"
155 fi
156}