Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | inherit siteinfo kernel-arch |
| 2 | |
| 3 | # We want to be able to change the value of MULTIMACH_TARGET_SYS, because it |
| 4 | # doesn't always match our expectations... but we default to the stock value |
| 5 | REAL_MULTIMACH_TARGET_SYS ?= "${MULTIMACH_TARGET_SYS}" |
| 6 | TARGET_CC_ARCH_append_libc-uclibc = " -muclibc" |
| 7 | TARGET_CC_ARCH_append_libc-musl = " -mmusl" |
| 8 | |
| 9 | # This function creates an environment-setup-script for use in a deployable SDK |
| 10 | toolchain_create_sdk_env_script () { |
| 11 | # Create environment setup script |
| 12 | sdkpathnative=${7:-${SDKPATHNATIVE}} |
| 13 | prefix=${6:-${prefix_nativesdk}} |
| 14 | bindir=${5:-${bindir_nativesdk}} |
| 15 | libdir=${4:-${libdir}} |
| 16 | sysroot=${3:-${SDKTARGETSYSROOT}} |
| 17 | multimach_target_sys=${2:-${REAL_MULTIMACH_TARGET_SYS}} |
| 18 | script=${1:-${SDK_OUTPUT}/${SDKPATH}/environment-setup-$multimach_target_sys} |
| 19 | rm -f $script |
| 20 | touch $script |
| 21 | echo 'export SDKTARGETSYSROOT='"$sysroot" >> $script |
| 22 | EXTRAPATH="" |
| 23 | for i in ${CANADIANEXTRAOS}; do |
| 24 | EXTRAPATH="$EXTRAPATH:$sdkpathnative$bindir/${TARGET_ARCH}${TARGET_VENDOR}-$i" |
| 25 | done |
| 26 | echo "export PATH=$sdkpathnative$bindir:$sdkpathnative$bindir/../${HOST_SYS}/bin:$sdkpathnative$bindir/${TARGET_SYS}"$EXTRAPATH':$PATH' >> $script |
| 27 | echo "export CCACHE_PATH=$sdkpathnative$bindir:$sdkpathnative$bindir/../${HOST_SYS}/bin:$sdkpathnative$bindir/${TARGET_SYS}"$EXTRAPATH':$CCACHE_PATH' >> $script |
| 28 | echo 'export PKG_CONFIG_SYSROOT_DIR=$SDKTARGETSYSROOT' >> $script |
| 29 | echo 'export PKG_CONFIG_PATH=$SDKTARGETSYSROOT'"$libdir"'/pkgconfig' >> $script |
| 30 | echo 'export CONFIG_SITE=${SDKPATH}/site-config-'"${multimach_target_sys}" >> $script |
| 31 | echo "export OECORE_NATIVE_SYSROOT=\"$sdkpathnative\"" >> $script |
| 32 | echo 'export OECORE_TARGET_SYSROOT="$SDKTARGETSYSROOT"' >> $script |
| 33 | echo "export OECORE_ACLOCAL_OPTS=\"-I $sdkpathnative/usr/share/aclocal\"" >> $script |
| 34 | echo "export PYTHONHOME=$sdkpathnative$prefix" >> $script |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 35 | echo 'unset command_not_found_handle' >> $script |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 36 | |
| 37 | toolchain_shared_env_script |
| 38 | } |
| 39 | |
| 40 | # This function creates an environment-setup-script in the TMPDIR which enables |
| 41 | # a OE-core IDE to integrate with the build tree |
| 42 | toolchain_create_tree_env_script () { |
| 43 | script=${TMPDIR}/environment-setup-${REAL_MULTIMACH_TARGET_SYS} |
| 44 | rm -f $script |
| 45 | touch $script |
| 46 | echo 'export PATH=${STAGING_DIR_NATIVE}/usr/bin:${PATH}' >> $script |
| 47 | echo 'export CCACHE_PATH=${STAGING_DIR_NATIVE}/usr/bin:${CCACHE_PATH}' >> $script |
| 48 | echo 'export PKG_CONFIG_SYSROOT_DIR=${PKG_CONFIG_SYSROOT_DIR}' >> $script |
| 49 | echo 'export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}' >> $script |
| 50 | echo 'export CONFIG_SITE="${@siteinfo_get_files(d)}"' >> $script |
| 51 | echo 'export SDKTARGETSYSROOT=${STAGING_DIR_TARGET}' >> $script |
| 52 | echo 'export OECORE_NATIVE_SYSROOT="${STAGING_DIR_NATIVE}"' >> $script |
| 53 | echo 'export OECORE_TARGET_SYSROOT="${STAGING_DIR_TARGET}"' >> $script |
| 54 | echo 'export OECORE_ACLOCAL_OPTS="-I ${STAGING_DIR_NATIVE}/usr/share/aclocal"' >> $script |
| 55 | |
| 56 | toolchain_shared_env_script |
| 57 | } |
| 58 | |
| 59 | toolchain_shared_env_script () { |
| 60 | echo 'export CC="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script |
| 61 | echo 'export CXX="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script |
| 62 | echo 'export CPP="${TARGET_PREFIX}gcc -E ${TARGET_CC_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script |
| 63 | echo 'export AS="${TARGET_PREFIX}as ${TARGET_AS_ARCH}"' >> $script |
| 64 | echo 'export LD="${TARGET_PREFIX}ld ${TARGET_LD_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script |
| 65 | echo 'export GDB=${TARGET_PREFIX}gdb' >> $script |
| 66 | echo 'export STRIP=${TARGET_PREFIX}strip' >> $script |
| 67 | echo 'export RANLIB=${TARGET_PREFIX}ranlib' >> $script |
| 68 | echo 'export OBJCOPY=${TARGET_PREFIX}objcopy' >> $script |
| 69 | echo 'export OBJDUMP=${TARGET_PREFIX}objdump' >> $script |
| 70 | echo 'export AR=${TARGET_PREFIX}ar' >> $script |
| 71 | echo 'export NM=${TARGET_PREFIX}nm' >> $script |
| 72 | echo 'export M4=m4' >> $script |
| 73 | echo 'export TARGET_PREFIX=${TARGET_PREFIX}' >> $script |
| 74 | echo 'export CONFIGURE_FLAGS="--target=${TARGET_SYS} --host=${TARGET_SYS} --build=${SDK_ARCH}-linux --with-libtool-sysroot=$SDKTARGETSYSROOT"' >> $script |
| 75 | echo 'export CFLAGS="${TARGET_CFLAGS}"' >> $script |
| 76 | echo 'export CXXFLAGS="${TARGET_CXXFLAGS}"' >> $script |
| 77 | echo 'export LDFLAGS="${TARGET_LDFLAGS}"' >> $script |
| 78 | echo 'export CPPFLAGS="${TARGET_CPPFLAGS}"' >> $script |
| 79 | echo 'export KCFLAGS="--sysroot=$SDKTARGETSYSROOT"' >> $script |
| 80 | echo 'export OECORE_DISTRO_VERSION="${DISTRO_VERSION}"' >> $script |
| 81 | echo 'export OECORE_SDK_VERSION="${SDK_VERSION}"' >> $script |
| 82 | echo 'export ARCH=${ARCH}' >> $script |
| 83 | echo 'export CROSS_COMPILE=${TARGET_PREFIX}' >> $script |
| 84 | |
| 85 | cat >> $script <<EOF |
| 86 | |
| 87 | # Append environment subscripts |
| 88 | if [ -d "\$OECORE_TARGET_SYSROOT/environment-setup.d" ]; then |
| 89 | for envfile in \$OECORE_TARGET_SYSROOT/environment-setup.d/*.sh; do |
| 90 | source \$envfile |
| 91 | done |
| 92 | fi |
| 93 | if [ -d "\$OECORE_NATIVE_SYSROOT/environment-setup.d" ]; then |
| 94 | for envfile in \$OECORE_NATIVE_SYSROOT/environment-setup.d/*.sh; do |
| 95 | source \$envfile |
| 96 | done |
| 97 | fi |
| 98 | EOF |
| 99 | } |
| 100 | |
| 101 | #we get the cached site config in the runtime |
| 102 | TOOLCHAIN_CONFIGSITE_NOCACHE = "${@siteinfo_get_files(d, True)}" |
| 103 | TOOLCHAIN_CONFIGSITE_SYSROOTCACHE = "${STAGING_DIR}/${MLPREFIX}${MACHINE}/${target_datadir}/${TARGET_SYS}_config_site.d" |
| 104 | TOOLCHAIN_NEED_CONFIGSITE_CACHE ??= "virtual/${MLPREFIX}libc ncurses" |
| 105 | |
| 106 | #This function create a site config file |
| 107 | toolchain_create_sdk_siteconfig () { |
| 108 | local siteconfig=$1 |
| 109 | |
| 110 | rm -f $siteconfig |
| 111 | touch $siteconfig |
| 112 | |
| 113 | for sitefile in ${TOOLCHAIN_CONFIGSITE_NOCACHE} ; do |
| 114 | cat $sitefile >> $siteconfig |
| 115 | done |
| 116 | |
| 117 | #get cached site config |
| 118 | for sitefile in ${TOOLCHAIN_NEED_CONFIGSITE_CACHE}; do |
| 119 | # Resolve virtual/* names to the real recipe name using sysroot-providers info |
| 120 | case $sitefile in virtual/*) |
| 121 | sitefile=`echo $sitefile | tr / _` |
| 122 | sitefile=`cat ${STAGING_DIR_TARGET}/sysroot-providers/$sitefile` |
| 123 | esac |
| 124 | |
| 125 | if [ -r ${TOOLCHAIN_CONFIGSITE_SYSROOTCACHE}/${sitefile}_config ]; then |
| 126 | cat ${TOOLCHAIN_CONFIGSITE_SYSROOTCACHE}/${sitefile}_config >> $siteconfig |
| 127 | fi |
| 128 | done |
| 129 | } |
| 130 | # The immediate expansion above can result in unwanted path dependencies here |
| 131 | toolchain_create_sdk_siteconfig[vardepsexclude] = "TOOLCHAIN_CONFIGSITE_SYSROOTCACHE" |
| 132 | |
| 133 | #This function create a version information file |
| 134 | toolchain_create_sdk_version () { |
| 135 | local versionfile=$1 |
| 136 | rm -f $versionfile |
| 137 | touch $versionfile |
| 138 | echo 'Distro: ${DISTRO}' >> $versionfile |
| 139 | echo 'Distro Version: ${DISTRO_VERSION}' >> $versionfile |
| 140 | echo 'Metadata Revision: ${METADATA_REVISION}' >> $versionfile |
| 141 | echo 'Timestamp: ${DATETIME}' >> $versionfile |
| 142 | } |
| 143 | toolchain_create_sdk_version[vardepsexclude] = "DATETIME" |
| 144 | |
| 145 | python __anonymous () { |
| 146 | import oe.classextend |
| 147 | deps = "" |
| 148 | for dep in (d.getVar('TOOLCHAIN_NEED_CONFIGSITE_CACHE', True) or "").split(): |
| 149 | deps += " %s:do_populate_sysroot" % dep |
| 150 | for variant in (d.getVar('MULTILIB_VARIANTS', True) or "").split(): |
| 151 | clsextend = oe.classextend.ClassExtender(variant, d) |
| 152 | newdep = clsextend.extend_name(dep) |
| 153 | deps += " %s:do_populate_sysroot" % newdep |
| 154 | d.appendVarFlag('do_configure', 'depends', deps) |
| 155 | } |