summaryrefslogtreecommitdiffstats
path: root/meta/classes/toolchain-scripts.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/toolchain-scripts.bbclass')
-rw-r--r--meta/classes/toolchain-scripts.bbclass116
1 files changed, 116 insertions, 0 deletions
diff --git a/meta/classes/toolchain-scripts.bbclass b/meta/classes/toolchain-scripts.bbclass
new file mode 100644
index 0000000..b9f2aea9
--- /dev/null
+++ b/meta/classes/toolchain-scripts.bbclass
@@ -0,0 +1,116 @@
1inherit 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
5REAL_MULTIMACH_TARGET_SYS ?= "${MULTIMACH_TARGET_SYS}"
6
7# This function creates an environment-setup-script for use in a deployable SDK
8toolchain_create_sdk_env_script () {
9 # Create environment setup script
10 libdir=${4:-${libdir}}
11 sysroot=${3:-${SDKTARGETSYSROOT}}
12 multimach_target_sys=${2:-${REAL_MULTIMACH_TARGET_SYS}}
13 script=${1:-${SDK_OUTPUT}/${SDKPATH}/environment-setup-$multimach_target_sys}
14 rm -f $script
15 touch $script
16 echo 'export SDKTARGETSYSROOT='"$sysroot" >> $script
17 echo 'export PATH=${SDKPATHNATIVE}${bindir_nativesdk}:${SDKPATHNATIVE}${bindir_nativesdk}/${TARGET_SYS}:$PATH' >> $script
18 echo 'export PKG_CONFIG_SYSROOT_DIR=$SDKTARGETSYSROOT' >> $script
19 echo 'export PKG_CONFIG_PATH=$SDKTARGETSYSROOT'"$libdir"'/pkgconfig' >> $script
20 echo 'export CONFIG_SITE=${SDKPATH}/site-config-'"${multimach_target_sys}" >> $script
21 echo 'export OECORE_NATIVE_SYSROOT="${SDKPATHNATIVE}"' >> $script
22 echo 'export OECORE_TARGET_SYSROOT="$SDKTARGETSYSROOT"' >> $script
23 echo 'export OECORE_ACLOCAL_OPTS="-I ${SDKPATHNATIVE}/usr/share/aclocal"' >> $script
24 echo 'export PYTHONHOME=${SDKPATHNATIVE}${prefix_nativesdk}' >> $script
25
26 toolchain_shared_env_script
27}
28
29# This function creates an environment-setup-script in the TMPDIR which enables
30# a OE-core IDE to integrate with the build tree
31toolchain_create_tree_env_script () {
32 script=${TMPDIR}/environment-setup-${REAL_MULTIMACH_TARGET_SYS}
33 rm -f $script
34 touch $script
35 echo 'export PATH=${STAGING_DIR_NATIVE}/usr/bin:${PATH}' >> $script
36 echo 'export PKG_CONFIG_SYSROOT_DIR=${PKG_CONFIG_SYSROOT_DIR}' >> $script
37 echo 'export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}' >> $script
38 echo 'export CONFIG_SITE="${@siteinfo_get_files(d)}"' >> $script
39 echo 'export SDKTARGETSYSROOT=${STAGING_DIR_TARGET}' >> $script
40 echo 'export OECORE_NATIVE_SYSROOT="${STAGING_DIR_NATIVE}"' >> $script
41 echo 'export OECORE_TARGET_SYSROOT="${STAGING_DIR_TARGET}"' >> $script
42 echo 'export OECORE_ACLOCAL_OPTS="-I ${STAGING_DIR_NATIVE}/usr/share/aclocal"' >> $script
43
44 toolchain_shared_env_script
45}
46
47toolchain_shared_env_script () {
48 echo 'export CC="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script
49 echo 'export CXX="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script
50 echo 'export CPP="${TARGET_PREFIX}gcc -E ${TARGET_CC_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script
51 echo 'export AS="${TARGET_PREFIX}as ${TARGET_AS_ARCH}"' >> $script
52 echo 'export LD="${TARGET_PREFIX}ld ${TARGET_LD_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script
53 echo 'export GDB=${TARGET_PREFIX}gdb' >> $script
54 echo 'export STRIP=${TARGET_PREFIX}strip' >> $script
55 echo 'export RANLIB=${TARGET_PREFIX}ranlib' >> $script
56 echo 'export OBJCOPY=${TARGET_PREFIX}objcopy' >> $script
57 echo 'export OBJDUMP=${TARGET_PREFIX}objdump' >> $script
58 echo 'export AR=${TARGET_PREFIX}ar' >> $script
59 echo 'export NM=${TARGET_PREFIX}nm' >> $script
60 echo 'export M4=m4' >> $script
61 echo 'export TARGET_PREFIX=${TARGET_PREFIX}' >> $script
62 echo 'export CONFIGURE_FLAGS="--target=${TARGET_SYS} --host=${TARGET_SYS} --build=${SDK_ARCH}-linux --with-libtool-sysroot=$SDKTARGETSYSROOT"' >> $script
63 echo 'export CFLAGS="${TARGET_CFLAGS}"' >> $script
64 echo 'export CXXFLAGS="${TARGET_CXXFLAGS}"' >> $script
65 echo 'export LDFLAGS="${TARGET_LDFLAGS}"' >> $script
66 echo 'export CPPFLAGS="${TARGET_CPPFLAGS}"' >> $script
67 echo 'export OECORE_DISTRO_VERSION="${DISTRO_VERSION}"' >> $script
68 echo 'export OECORE_SDK_VERSION="${SDK_VERSION}"' >> $script
69 echo 'export ARCH=${ARCH}' >> $script
70 echo 'export CROSS_COMPILE=${TARGET_PREFIX}' >> $script
71}
72
73#we get the cached site config in the runtime
74TOOLCHAIN_CONFIGSITE_NOCACHE = "${@siteinfo_get_files(d, True)}"
75TOOLCHAIN_CONFIGSITE_SYSROOTCACHE = "${STAGING_DATADIR}/${TARGET_SYS}_config_site.d"
76TOOLCHAIN_NEED_CONFIGSITE_CACHE = "${TCLIBC} ncurses"
77
78#This function create a site config file
79toolchain_create_sdk_siteconfig () {
80 local siteconfig=$1
81
82 rm -f $siteconfig
83 touch $siteconfig
84
85 for sitefile in ${TOOLCHAIN_CONFIGSITE_NOCACHE} ; do
86 cat $sitefile >> $siteconfig
87 done
88
89 #get cached site config
90 for sitefile in ${TOOLCHAIN_NEED_CONFIGSITE_CACHE}; do
91 if [ -r ${TOOLCHAIN_CONFIGSITE_SYSROOTCACHE}/${sitefile}_config ]; then
92 cat ${TOOLCHAIN_CONFIGSITE_SYSROOTCACHE}/${sitefile}_config >> $siteconfig
93 fi
94 done
95}
96# The immediate expansion above can result in unwanted path dependencies here
97toolchain_create_sdk_siteconfig[vardepsexclude] = "TOOLCHAIN_CONFIGSITE_SYSROOTCACHE"
98
99#This function create a version information file
100toolchain_create_sdk_version () {
101 local versionfile=$1
102 rm -f $versionfile
103 touch $versionfile
104 echo 'Distro: ${DISTRO}' >> $versionfile
105 echo 'Distro Version: ${DISTRO_VERSION}' >> $versionfile
106 echo 'Metadata Revision: ${METADATA_REVISION}' >> $versionfile
107 echo 'Timestamp: ${DATETIME}' >> $versionfile
108}
109toolchain_create_sdk_version[vardepsexclude] = "DATETIME"
110
111python __anonymous () {
112 deps = ""
113 for dep in (d.getVar('TOOLCHAIN_NEED_CONFIGSITE_CACHE', True) or "").split():
114 deps += " %s:do_populate_sysroot" % dep
115 d.appendVarFlag('do_configure', 'depends', deps)
116}