2005-08-31 10:45:47 +00:00
|
|
|
# IceCream distributed compiling support
|
2006-08-27 16:01:33 +00:00
|
|
|
#
|
2005-08-31 10:45:47 +00:00
|
|
|
# We need to create a tar.bz2 of our toolchain and set
|
|
|
|
# ICECC_VERSION, ICECC_CXX and ICEC_CC
|
|
|
|
#
|
|
|
|
|
2006-08-27 16:01:33 +00:00
|
|
|
def icc_determine_gcc_version(gcc):
|
|
|
|
"""
|
|
|
|
Hack to determine the version of GCC
|
|
|
|
|
|
|
|
'i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5363)'
|
|
|
|
"""
|
2006-11-20 15:19:39 +00:00
|
|
|
return os.popen("%s --version" % gcc ).readline().split()[2]
|
2006-08-27 16:01:33 +00:00
|
|
|
|
2005-08-31 10:45:47 +00:00
|
|
|
def create_env(bb,d):
|
|
|
|
"""
|
|
|
|
Create a tar.bz of the current toolchain
|
|
|
|
"""
|
|
|
|
|
|
|
|
# Constin native-native compilation no environment needed if
|
|
|
|
# host prefix is empty (let us duplicate the query for ease)
|
|
|
|
prefix = bb.data.expand('${HOST_PREFIX}', d)
|
|
|
|
if len(prefix) == 0:
|
2006-08-27 16:01:33 +00:00
|
|
|
return ""
|
2005-08-31 10:45:47 +00:00
|
|
|
|
|
|
|
import tarfile
|
|
|
|
import socket
|
|
|
|
import time
|
|
|
|
import os
|
|
|
|
ice_dir = bb.data.expand('${CROSS_DIR}', d)
|
|
|
|
prefix = bb.data.expand('${HOST_PREFIX}' , d)
|
|
|
|
distro = bb.data.expand('${DISTRO}', d)
|
|
|
|
target_sys = bb.data.expand('${TARGET_SYS}', d)
|
2006-08-27 16:01:33 +00:00
|
|
|
float = bb.data.getVar('${TARGET_FPU}', d) or "hard"
|
2005-08-31 10:45:47 +00:00
|
|
|
name = socket.gethostname()
|
|
|
|
|
2006-08-27 16:01:33 +00:00
|
|
|
# Stupid check to determine if we have built a libc and a cross
|
|
|
|
# compiler.
|
2005-08-31 10:45:47 +00:00
|
|
|
try:
|
2006-08-27 16:01:33 +00:00
|
|
|
os.stat(os.path.join(ice_dir, target_sys, 'lib', 'ld-linux.so.2'))
|
|
|
|
os.stat(os.path.join(ice_dir, target_sys, 'bin', 'g++'))
|
2005-08-31 10:45:47 +00:00
|
|
|
except:
|
2006-08-27 16:01:33 +00:00
|
|
|
return ""
|
2005-08-31 10:45:47 +00:00
|
|
|
|
2006-08-27 16:01:33 +00:00
|
|
|
VERSION = icc_determine_gcc_version( os.path.join(ice_dir,target_sys,"bin","g++") )
|
2005-08-31 10:45:47 +00:00
|
|
|
cross_name = prefix + distro + target_sys + float +VERSION+ name
|
2006-08-27 16:01:33 +00:00
|
|
|
tar_file = os.path.join(ice_dir, 'ice', cross_name + '.tar.bz2')
|
2005-08-31 10:45:47 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
os.stat(tar_file)
|
|
|
|
return tar_file
|
|
|
|
except:
|
2006-08-27 16:01:33 +00:00
|
|
|
try:
|
|
|
|
os.makedirs(os.path.join(ice_dir,'ice'))
|
|
|
|
except:
|
|
|
|
pass
|
2005-08-31 10:45:47 +00:00
|
|
|
|
|
|
|
# FIXME find out the version of the compiler
|
2006-08-27 16:01:33 +00:00
|
|
|
# Consider using -print-prog-name={cc1,cc1plus}
|
|
|
|
# and -print-file-name=specs
|
|
|
|
|
|
|
|
# We will use the GCC to tell us which tools to use
|
|
|
|
# What we need is:
|
|
|
|
# -gcc
|
|
|
|
# -g++
|
|
|
|
# -as
|
|
|
|
# -cc1
|
|
|
|
# -cc1plus
|
|
|
|
# and we add them to /usr/bin
|
|
|
|
|
2005-08-31 10:45:47 +00:00
|
|
|
tar = tarfile.open(tar_file, 'w:bz2')
|
2006-08-27 16:01:33 +00:00
|
|
|
|
|
|
|
# Now add the required files
|
|
|
|
tar.add(os.path.join(ice_dir,target_sys,'bin','gcc'),
|
|
|
|
os.path.join("usr","bin","gcc") )
|
|
|
|
tar.add(os.path.join(ice_dir,target_sys,'bin','g++'),
|
|
|
|
os.path.join("usr","bin","g++") )
|
|
|
|
tar.add(os.path.join(ice_dir,target_sys,'bin','as'),
|
|
|
|
os.path.join("usr","bin","as") )
|
|
|
|
|
|
|
|
# Now let us find cc1 and cc1plus
|
|
|
|
cc1 = os.popen("%s -print-prog-name=cc1" % data.getVar('CC', d, True)).read()[:-1]
|
|
|
|
cc1plus = os.popen("%s -print-prog-name=cc1plus" % data.getVar('CC', d, True)).read()[:-1]
|
|
|
|
spec = os.popen("%s -print-file-name=specs" % data.getVar('CC', d, True)).read()[:-1]
|
|
|
|
|
|
|
|
# CC1 and CC1PLUS should be there...
|
|
|
|
tar.add(cc1, os.path.join('usr', 'bin', 'cc1'))
|
|
|
|
tar.add(cc1plus, os.path.join('usr', 'bin', 'cc1plus'))
|
|
|
|
|
|
|
|
# spec - if it exists
|
|
|
|
if os.path.exists(spec):
|
|
|
|
tar.add(spec)
|
|
|
|
|
2005-08-31 10:45:47 +00:00
|
|
|
tar.close()
|
|
|
|
return tar_file
|
|
|
|
|
|
|
|
|
|
|
|
def create_path(compilers, type, bb, d):
|
|
|
|
"""
|
|
|
|
Create Symlinks for the icecc in the staging directory
|
|
|
|
"""
|
|
|
|
import os
|
|
|
|
|
2006-08-27 16:01:33 +00:00
|
|
|
staging = os.path.join(bb.data.expand('${STAGING_DIR}', d), "ice", type)
|
2005-08-31 10:45:47 +00:00
|
|
|
icecc = bb.data.getVar('ICECC_PATH', d)
|
|
|
|
|
|
|
|
# Create the dir if necessary
|
|
|
|
try:
|
|
|
|
os.stat(staging)
|
|
|
|
except:
|
|
|
|
os.makedirs(staging)
|
|
|
|
|
|
|
|
|
|
|
|
for compiler in compilers:
|
2006-08-27 16:01:33 +00:00
|
|
|
gcc_path = os.path.join(staging, compiler)
|
2005-08-31 10:45:47 +00:00
|
|
|
try:
|
|
|
|
os.stat(gcc_path)
|
|
|
|
except:
|
|
|
|
os.symlink(icecc, gcc_path)
|
|
|
|
|
|
|
|
return staging + ":"
|
|
|
|
|
|
|
|
|
|
|
|
def use_icc_version(bb,d):
|
|
|
|
# Constin native native
|
|
|
|
prefix = bb.data.expand('${HOST_PREFIX}', d)
|
|
|
|
if len(prefix) == 0:
|
2006-08-27 16:01:33 +00:00
|
|
|
return "no"
|
|
|
|
|
|
|
|
|
|
|
|
blacklist = [ "cross", "native" ]
|
2005-08-31 10:45:47 +00:00
|
|
|
|
|
|
|
for black in blacklist:
|
2006-08-27 16:01:33 +00:00
|
|
|
if bb.data.inherits_class(black, d):
|
|
|
|
return "no"
|
2005-08-31 10:45:47 +00:00
|
|
|
|
|
|
|
return "yes"
|
|
|
|
|
|
|
|
def icc_path(bb,d,compile):
|
|
|
|
native = bb.data.expand('${PN}', d)
|
|
|
|
blacklist = [ "ulibc", "glibc", "ncurses" ]
|
|
|
|
for black in blacklist:
|
2006-08-27 16:01:33 +00:00
|
|
|
if black in native:
|
|
|
|
return ""
|
2005-08-31 10:45:47 +00:00
|
|
|
|
2006-08-27 16:01:33 +00:00
|
|
|
blacklist = [ "cross", "native" ]
|
|
|
|
for black in blacklist:
|
|
|
|
if bb.data.inherits_class(black, d):
|
|
|
|
compile = False
|
2005-08-31 10:45:47 +00:00
|
|
|
|
|
|
|
prefix = bb.data.expand('${HOST_PREFIX}', d)
|
|
|
|
if compile and len(prefix) != 0:
|
|
|
|
return create_path( [prefix+"gcc", prefix+"g++"], "cross", bb, d )
|
|
|
|
elif not compile or len(prefix) == 0:
|
|
|
|
return create_path( ["gcc", "g++"], "native", bb, d)
|
|
|
|
|
|
|
|
|
|
|
|
def icc_version(bb,d):
|
|
|
|
return create_env(bb,d)
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# set the IceCream environment variables
|
|
|
|
do_configure_prepend() {
|
|
|
|
export PATH=${@icc_path(bb,d,False)}$PATH
|
|
|
|
export ICECC_CC="gcc"
|
|
|
|
export ICECC_CXX="g++"
|
|
|
|
}
|
|
|
|
|
|
|
|
do_compile_prepend() {
|
|
|
|
export PATH=${@icc_path(bb,d,True)}$PATH
|
|
|
|
export ICECC_CC="${HOST_PREFIX}gcc"
|
|
|
|
export ICECC_CXX="${HOST_PREFIX}g++"
|
|
|
|
|
|
|
|
if [ "${@use_icc_version(bb,d)}" = "yes" ]; then
|
2006-08-27 16:01:33 +00:00
|
|
|
export ICECC_VERSION="${@icc_version(bb,d)}"
|
2005-08-31 10:45:47 +00:00
|
|
|
fi
|
|
|
|
}
|