diff options
Diffstat (limited to 'meta/classes/icecc.bbclass')
-rw-r--r-- | meta/classes/icecc.bbclass | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/meta/classes/icecc.bbclass b/meta/classes/icecc.bbclass index f3e89a9747..cf3f23d93a 100644 --- a/meta/classes/icecc.bbclass +++ b/meta/classes/icecc.bbclass | |||
@@ -47,6 +47,9 @@ def get_cross_kernel_cc(bb,d): | |||
47 | kernel_cc = kernel_cc.strip() | 47 | kernel_cc = kernel_cc.strip() |
48 | return kernel_cc | 48 | return kernel_cc |
49 | 49 | ||
50 | def get_icecc(d): | ||
51 | return d.getVar('ICECC_PATH') or os.popen("which icecc").read()[:-1] | ||
52 | |||
50 | def create_path(compilers, bb, d): | 53 | def create_path(compilers, bb, d): |
51 | """ | 54 | """ |
52 | Create Symlinks for the icecc in the staging directory | 55 | Create Symlinks for the icecc in the staging directory |
@@ -56,7 +59,7 @@ def create_path(compilers, bb, d): | |||
56 | staging += "-kernel" | 59 | staging += "-kernel" |
57 | 60 | ||
58 | #check if the icecc path is set by the user | 61 | #check if the icecc path is set by the user |
59 | icecc = d.getVar('ICECC_PATH') or os.popen("which icecc").read()[:-1] | 62 | icecc = get_icecc(d) |
60 | 63 | ||
61 | # Create the dir if necessary | 64 | # Create the dir if necessary |
62 | try: | 65 | try: |
@@ -151,6 +154,11 @@ def icc_path(bb,d): | |||
151 | prefix = d.expand('${HOST_PREFIX}') | 154 | prefix = d.expand('${HOST_PREFIX}') |
152 | return create_path( [prefix+"gcc", prefix+"g++"], bb, d) | 155 | return create_path( [prefix+"gcc", prefix+"g++"], bb, d) |
153 | 156 | ||
157 | def icc_get_external_tool(bb, d, tool): | ||
158 | external_toolchain_bindir = d.expand('${EXTERNAL_TOOLCHAIN}${bindir_cross}') | ||
159 | target_prefix = d.expand('${TARGET_PREFIX}') | ||
160 | return os.path.join(external_toolchain_bindir, '%s%s' % (target_prefix, tool)) | ||
161 | |||
154 | def icc_get_tool(bb, d, tool): | 162 | def icc_get_tool(bb, d, tool): |
155 | if icc_is_native(bb, d): | 163 | if icc_is_native(bb, d): |
156 | return os.popen("which %s" % tool).read()[:-1] | 164 | return os.popen("which %s" % tool).read()[:-1] |
@@ -159,7 +167,26 @@ def icc_get_tool(bb, d, tool): | |||
159 | else: | 167 | else: |
160 | ice_dir = d.expand('${STAGING_BINDIR_TOOLCHAIN}') | 168 | ice_dir = d.expand('${STAGING_BINDIR_TOOLCHAIN}') |
161 | target_sys = d.expand('${TARGET_SYS}') | 169 | target_sys = d.expand('${TARGET_SYS}') |
162 | return os.path.join(ice_dir, "%s-%s" % (target_sys, tool)) | 170 | tool_bin = os.path.join(ice_dir, "%s-%s" % (target_sys, tool)) |
171 | if os.path.isfile(tool_bin): | ||
172 | return tool_bin | ||
173 | else: | ||
174 | external_tool_bin = icc_get_external_tool(bb, d, tool) | ||
175 | if os.path.isfile(external_tool_bin): | ||
176 | return external_tool_bin | ||
177 | else: | ||
178 | return "" | ||
179 | |||
180 | def icc_get_and_check_tool(bb, d, tool): | ||
181 | # Check that g++ or gcc is not a symbolic link to icecc binary in | ||
182 | # PATH or icecc-create-env script will silently create an invalid | ||
183 | # compiler environment package. | ||
184 | t = icc_get_tool(bb, d, tool) | ||
185 | if t and os.popen("readlink -f %s" % t).read()[:-1] == get_icecc(d): | ||
186 | bb.error("%s is a symlink to %s in PATH and this prevents icecc from working" % (t, get_icecc(d))) | ||
187 | return "" | ||
188 | else: | ||
189 | return t | ||
163 | 190 | ||
164 | set_icecc_env() { | 191 | set_icecc_env() { |
165 | if [ "x${ICECC_DISABLED}" != "x" ] | 192 | if [ "x${ICECC_DISABLED}" != "x" ] |
@@ -178,8 +205,8 @@ set_icecc_env() { | |||
178 | return | 205 | return |
179 | fi | 206 | fi |
180 | 207 | ||
181 | ICECC_CC="${@icc_get_tool(bb,d, "gcc")}" | 208 | ICECC_CC="${@icc_get_and_check_tool(bb, d, "gcc")}" |
182 | ICECC_CXX="${@icc_get_tool(bb,d, "g++")}" | 209 | ICECC_CXX="${@icc_get_and_check_tool(bb, d, "g++")}" |
183 | if [ ! -x "${ICECC_CC}" -o ! -x "${ICECC_CXX}" ] | 210 | if [ ! -x "${ICECC_CC}" -o ! -x "${ICECC_CXX}" ] |
184 | then | 211 | then |
185 | return | 212 | return |
@@ -207,6 +234,8 @@ set_icecc_env() { | |||
207 | export ICECC_VERSION ICECC_CC ICECC_CXX | 234 | export ICECC_VERSION ICECC_CC ICECC_CXX |
208 | export PATH="$ICE_PATH:$PATH" | 235 | export PATH="$ICE_PATH:$PATH" |
209 | export CCACHE_PATH="$PATH" | 236 | export CCACHE_PATH="$PATH" |
237 | |||
238 | bbnote "Using icecc" | ||
210 | } | 239 | } |
211 | 240 | ||
212 | do_configure_prepend() { | 241 | do_configure_prepend() { |