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