summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Lock <joshua.lock@collabora.co.uk>2015-10-21 14:53:09 (GMT)
committerJoshua Lock <joshua.lock@collabora.co.uk>2015-11-20 14:23:47 (GMT)
commit38fb092b8c63d3546701d23e9f35d8cc8f2dc54b (patch)
tree1a2cc75465a9c77b074619ed0dc4ad8c38db62dd
parent554f9198d8c8da7820f9ee38d46933548adde824 (diff)
downloadpoky-contrib-joshuagl/icecc.zip
poky-contrib-joshuagl/icecc.tar.gz
poky-contrib-joshuagl/icecc.tar.bz2
icecc-create-env: merge latest changes from icecc upstreamjoshuagl/icecc
Based on the updated script from Iyad Qumei[1] this change imports the latest changes for the icecc-create-env script from the upstream icecc git repository. 1. http://patchwork.openembedded.org/patch/62997/ Signed-off-by: Joshua Lock <joshua.lock@collabora.co.uk>
-rw-r--r--[-rwxr-xr-x]meta/recipes-devtools/icecc-create-env/icecc-create-env/icecc-create-env350
1 files changed, 298 insertions, 52 deletions
diff --git a/meta/recipes-devtools/icecc-create-env/icecc-create-env/icecc-create-env b/meta/recipes-devtools/icecc-create-env/icecc-create-env/icecc-create-env
index 7e4dbc4..bababfa 100755..100644
--- a/meta/recipes-devtools/icecc-create-env/icecc-create-env/icecc-create-env
+++ b/meta/recipes-devtools/icecc-create-env/icecc-create-env/icecc-create-env
@@ -6,6 +6,18 @@
target_files=
+is_darwin=0
+if test `uname` = Darwin; then
+ is_darwin=1
+fi
+
+usage ()
+{
+ echo "usage: $0 --gcc <gcc_path> <g++_path>"
+ echo "usage: $0 --clang <clang_path>"
+ echo "usage: Use --addfile <file> to add extra files."
+}
+
is_contained ()
{
case " $target_files " in
@@ -27,9 +39,12 @@ add_file ()
# readlink is not portable enough.
path=`ls -H $path`
toadd="$name=$path"
+ if test "$name" = "$path"; then
+ toadd=$path
+ fi
is_contained "$toadd" && return
if test -z "$silent"; then
- echo "adding file $toadd"
+ echo "adding file $toadd"
fi
target_files="$target_files $toadd"
if test -x "$path"; then
@@ -43,86 +58,305 @@ add_file ()
# libc.so.6 => /lib/tls/libc.so.6 (0xb7e81000)
# /lib/ld-linux.so.2 (0xb7fe8000)
# covering both situations ( with => and without )
- for lib in `ldd "$path" | sed -n 's,^[^/]*\(/[^ ]*\).*,\1,p'`; do
+ for lib in `ldd "$path" | sed -n 's,^[^/]*\(/[^ ]*\).*,\1,p'`; do
+ test -f "$lib" || continue
+ # Check wether the same library also exists in the parent directory,
+ # and prefer that on the assumption that it is a more generic one.
+ local baselib=`echo "$lib" | sed 's,\(/[^/]*\)/.*\(/[^/]*\)$,\1\2,'`
+ test -f "$baselib" && lib=$baselib
+ add_file "$lib"
+ done
+ fi
+ elif test "$is_darwin" = 1; then
+ # this regexp parse the outputs like:
+ # $ otool -L /usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin11/4.2.1/cc1
+ # @executable_path/libllvmgcc.dylib
+ # /usr/lib/libiconv.2.dylib
+ # /usr/lib/libSystem.B.dylib
+ # /usr/lib/libstdc++.6.dylib
+ for lib in `otool -L "$path" | sed -n 's,^[^/@]*\([/@][^ ]*\).*,\1,p'`; do
+ local libinstall=""
+ if test "${lib%%/*}" = "@executable_path"; then
+ # Installs libs like @executable_path/libllvmgcc.dylib
+ # that contains @executable_path in its path in `dirname ${name}`
+ # (the same install path of the executable program)
+ libinstall="${name%/*}${lib#@executable_path}"
+ lib="${path%/*}${lib#@executable_path}"
+ fi
test -f "$lib" || continue
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
local baselib=`echo "$lib" | sed 's,\(/[^/]*\)/.*\(/[^/]*\)$,\1\2,'`
test -f "$baselib" && lib=$baselib
- add_file "$lib"
- done
- fi
+ add_file "$lib" "$libinstall"
+ done
fi
fi
}
+# returns abs path to filedir
+abs_path()
+{
+ local path=$1
+ if test -f "$path"; then
+ pushd $(dirname $path) > /dev/null 2>&1
+ dir_path=`pwd -P`
+ path=$dir_path/$(basename $path)
+ popd > /dev/null 2>&1
+ elif test -d "$path"; then
+ pushd $path > /dev/null 2>&1
+ path=`pwd -P`
+ popd > /dev/null 2>&1
+ fi
+ echo $path
+}
+
+# Search and add file to the tarball file.
+search_addfile()
+{
+ local compiler=$1
+ local file_name=$2
+ local file_installdir=$3
+ local file=""
+
+ file=$($compiler -print-prog-name=$file_name)
+
+ if test -z "$file" || test "$file" = "$file_name" || ! test -e "$file"; then
+ file=`$compiler -print-file-name=$file_name`
+ fi
+
+ if ! test -e "$file"; then
+ return 1
+ fi
+
+ if test -z "$file_installdir"; then
+ # The file is going to be added to the tarball
+ # in the same path where the compiler found it.
+
+ file_installdir=$(dirname $file)
+ abs_installdir=$(abs_path $file_installdir)
+
+ if test "$file_installdir" != "$abs_installdir"; then
+ # The path where the compiler found the file is relative!
+ # If the path where the compiler found the file is relative
+ # to compiler's path, we must change it to be relative to
+ # /usr/bin path where the compiler is going to be installed
+ # in the tarball file.
+ # Replacing relative path by abs path because the tar command
+ # used to create the tarball file doesn't work well with
+ # relative path as installdir.
+
+ compiler_basedir=$(abs_path ${compiler%/*/*})
+ file_installdir=${abs_installdir/$compiler_basedir/"/usr"}
+ fi
+ fi
+
+ add_file "$file" "$file_installdir/$file_name"
+
+ return 0
+}
+
# backward compat
if test "$1" = "--respect-path"; then
shift
fi
-#add a --silent switch to avoid "broken pipe" errors when calling this scipt from within OE
+# add a --silent switch to avoid "broken pipe" errors when calling this scipt from within OE
if test "$1" = "--silent"; then
silent=1
shift
fi
+if test "$1" != "--gcc" -a "$1" != "--clang"; then
+ # backward compat
+ added_gcc=$1
+ shift
+ added_gxx=$1
+ shift
+ added_as=$1
+ shift
+ archive_name=$1
+ shift
+ gcc=1
+else
+ if test "$1" = "--gcc"; then
+ shift
+ added_gcc=$1
+ shift
+ added_gxx=$1
+ shift
+ added_as=$1
+ shift
+ archive_name=$1
+ shift
+ gcc=1
+ elif test "$1" = "--clang"; then
+ shift
+ added_clang=$1
+ shift
+ added_compilerwrapper=$1
+ if test -n "$added_compilerwrapper"; then
+ # accept 2nd argument being the compilerwrapper binary, for backwards compatibility
+ shift
+ else
+ added_compilerwrapper=@PKGLIBEXECDIR@/compilerwrapper
+ fi
+ clang=1
+ else
+ usage
+ exit 1
+ fi
+fi
-added_gcc=$1
-shift
-added_gxx=$1
-shift
-added_as=$1
-shift
-archive_name=$1
-
-if test -z "$added_gcc" || test -z "$added_gxx" ; then
- echo "usage: $0 <gcc_path> <g++_path>"
- exit 1
+if test -n "$gcc"; then
+ if test -z "$added_gcc" || test -z "$added_gxx"; then
+ usage
+ exit 1
+ fi
+ if ! test -x "$added_gcc" ; then
+ echo "'$added_gcc' is no executable."
+ exit 1
+ fi
+ if ! test -x "$added_gxx" ; then
+ echo "'$added_gxx' is no executable."
+ exit 1
+ fi
+ if test -z "$added_as" ; then
+ add_file /usr/bin/as /usr/bin/as
+ else
+ if ! test -x "$added_as" ; then
+ echo "'$added_as' is no executable."
+ exit 1
+ fi
+ add_file $added_as /usr/bin/as
+ fi
+ if ! file --mime-type -L "$added_gcc" | grep -q ': application/'; then
+ echo "$added_gcc is not a binary file."
+ exit 1
+ fi
+ if ! file --mime-type -L "$added_gxx" | grep -q ': application/'; then
+ echo "$added_gxx is not a binary file."
+ exit 1
+ fi
+ if ! file --mime-type -L "$added_as" | grep -q ': application/'; then
+ echo "$added_as is not a binary file."
+ exit 1
+ fi
fi
-if ! test -x "$added_gcc" ; then
- echo "'$added_gcc' is no executable."
- exit 1
+if test -n "$clang"; then
+ if ! test -x "$added_clang" ; then
+ echo "'$added_clang' is no executable."
+ exit 1
+ fi
+ if ! file --mime-type -L "$added_clang" | grep -q ': application/'; then
+ echo "$added_clang is not a binary file."
+ exit 1
+ fi
+ if ! test -x "$added_compilerwrapper" ; then
+ echo "'$added_compilerwrapper' is no executable."
+ exit 1
+ fi
fi
-if ! test -x "$added_gxx" ; then
- echo "'$added_gcc' is no executable."
- exit 1
+extrafiles=
+while test "x$1" = "x--addfile"; do
+ shift
+ extrafiles="$extrafiles $1"
+ shift
+done
+
+tempdir=`mktemp -d /tmp/iceccenvXXXXXX`
+
+# for testing the environment is usable at all
+if test -x /bin/true; then
+ add_file /bin/true
+elif test -x /usr/bin/true; then
+ add_file /usr/bin/true /bin/true
fi
+if test -n "$gcc"; then
+ # getting compilers abs path
+ added_gcc=$(abs_path $added_gcc)
+ added_gxx=$(abs_path $added_gxx)
+ if test -z "$clang"; then
+ add_file $added_gcc /usr/bin/gcc
+ add_file $added_gxx /usr/bin/g++
+ else
+ # HACK: The clang case below will add a wrapper in place of gcc, so add the real
+ # gcc under a different name that the wrapper will call.
+ add_file $added_gcc /usr/bin/gcc.bin
+ add_file $added_gxx /usr/bin/g++.bin
+ fi
+ add_file `$added_gcc -print-prog-name=cc1` /usr/bin/cc1
+ add_file `$added_gxx -print-prog-name=cc1plus` /usr/bin/cc1plus
-add_file $added_gcc /usr/bin/gcc
-add_file $added_gxx /usr/bin/g++
+ gcc_as=$($added_gcc -print-prog-name=as)
+ if test "$gcc_as" = "as"; then
+ add_file /usr/bin/as
+ else
+ add_file "$gcc_as" /usr/bin/as
+ fi
-if test -z "$added_as" ; then
- add_file /usr/bin/as /usr/bin/as
-else
- if ! test -x "$added_as" ; then
- echo "'$added_as' is no executable."
- exit 1
- fi
+ search_addfile $added_gcc specs
+ search_addfile $added_gcc liblto_plugin.so
+fi
+
+if test -n "$clang"; then
+ add_file $added_clang /usr/bin/clang
+ # HACK: Older icecream remotes have /usr/bin/{gcc|g++} hardcoded and wouldn't
+ # call /usr/bin/clang at all. So include a wrapper binary that will call gcc or clang
+ # depending on an extra argument added by icecream.
+ add_file $added_compilerwrapper /usr/bin/gcc
+ add_file $added_compilerwrapper /usr/bin/g++
+
+ add_file $($added_clang -print-prog-name=as) /usr/bin/as
- add_file $added_as /usr/bin/as
+ # clang always uses its internal .h files
+ clangincludes=$(dirname $($added_clang -print-file-name=include/limits.h))
+ clangprefix=$(dirname $(dirname $added_clang))
+ for file in $(find $clangincludes -type f); do
+ # get path without ..
+ # readlink is not portable enough.
+ destfile=$(abs_path $file)
+ # and convert from <prefix> to /usr if needed
+ destfile=$(echo $destfile | sed "s#$clangprefix#/usr#" )
+ add_file "$file" "$destfile"
+ done
fi
-add_file `$added_gcc -print-prog-name=cc1` /usr/bin/cc1
-add_file `$added_gxx -print-prog-name=cc1plus` /usr/bin/cc1plus
-specfile=`$added_gcc -print-file-name=specs`
-if test -n "$specfile" && test -e "$specfile"; then
- add_file "$specfile"
+for extrafile in $extrafiles; do
+ add_file $extrafile
+done
+
+if test "$is_darwin" = 1; then
+ # add dynamic linker
+ add_file /usr/lib/dyld
+ add_file /usr/bin/gcc
+ add_file /usr/bin/g++
+ real_file=`/usr/bin/as -micha -- < /dev/null 2>&1 | sed -n 's,^[^/]*\(/[^ :]*\).*,\1,p'`
+ add_file $(abs_path "$real_file")
fi
-ltofile=`$added_gcc -print-prog-name=lto1`
-pluginfile="${ltofile%lto1}liblto_plugin.so"
-if test -r "$pluginfile"
-then
- add_file $pluginfile ${pluginfile#*usr}
- add_file $pluginfile /usr${pluginfile#*usr}
+# for ldconfig -r to work, ld.so.conf must not contain relative paths
+# in include directives. Make them absolute.
+if test -f /etc/ld.so.conf; then
+ tmp_ld_so_conf=`mktemp /tmp/icecc_ld_so_confXXXXXX`
+ while read directive path; do
+ if [ "$directive" = "include" -a "${path:0:1}" != "/" ]; then
+ path="/etc/$path"
+ fi
+ echo "$directive $path"
+ done </etc/ld.so.conf >$tmp_ld_so_conf
+ add_file $tmp_ld_so_conf /etc/ld.so.conf
fi
-tempdir=`mktemp -d /tmp/iceccenvXXXXXX`
+# special case for weird multilib setups
+for dir in /lib /lib64 /usr/lib /usr/lib64; do
+ test -L $dir && cp -p $dir $tempdir$dir
+done
+
new_target_files=
for i in $target_files; do
case $i in
@@ -144,14 +378,21 @@ for i in $target_files; do
new_target_files="$new_target_files $target"
done
-#sort the files
+if test -x /sbin/ldconfig; then
+ mkdir -p $tempdir/var/cache/ldconfig
+ /sbin/ldconfig -r $tempdir
+ new_target_files="$new_target_files etc/ld.so.cache"
+fi
+
+# now sort the files in order to make the md5sums independent
+# of ordering
target_files=`for i in $new_target_files; do echo $i; done | sort`
#test if an archive name was supplied
#if not use the md5 of all files as the archive name
if test -z "$archive_name"; then
md5sum=NONE
- for file in /usr/bin/md5sum /bin/md5 /usr/bin/md5; do
+ for file in /usr/bin/md5sum /bin/md5 /usr/bin/md5 /sbin/md5; do
if test -x $file; then
md5sum=$file
break
@@ -159,7 +400,7 @@ if test -z "$archive_name"; then
done
#calculate md5 and use it as the archive name
- archive_name=`for i in $target_files; do test -f $tempdir/$i && $md5sum $tempdir/$i; done | sed -e 's/ .*$//' | $md5sum | sed -e 's/ .*$//'`.tar.gz || {
+ archive_name=`for i in $target_files; do $md5sum $tempdir/$i; done | sed -e 's/ .*$//' | $md5sum | sed -e 's/ .*$//'`.tar.gz || {
if test -z "$silent"; then
echo "Couldn't compute MD5 sum."
fi
@@ -182,11 +423,16 @@ echo "creating $archive_name"
fi
cd $tempdir
-tar -czhf "$mydir/$archive_name" $target_files || {
- if test -z "$silent"; then
- echo "Couldn't create archive"
- fi
+tar -czh --numeric-owner -f "$mydir/$archive_name" $target_files || {
+ if test -z "$silent"; then
+ echo "Couldn't create archive"
+ fi
exit 3
}
cd ..
rm -rf $tempdir
+rm -f $tmp_ld_so_conf
+
+# Print the tarball name to fd 5 (if it's open, created by whatever has invoked this)
+( echo $archive_name >&5 ) 2>/dev/null
+exit 0