Patchwork [1/2] image: populate site config files into roootfs.

login
register
mail settings
Submitter Lianhao Lu
Date Aug. 11, 2011, 2:31 p.m.
Message ID <a536443a01f8059b9a11418ea7b812e3286b7576.1313072334.git.lianhao.lu@intel.com>
Download mbox | patch
Permalink /patch/9603/
State New, archived
Headers show

Comments

Lianhao Lu - Aug. 11, 2011, 2:31 p.m.
[YOCTO #892] populate the site config files content into the file in
{target}/cross_site_config in rootfs, which can be used by the cross
toolchain in meta-toolchain when the rootfs is used as sysroot.

Signed-off-by: Lianhao Lu <lianhao.lu@intel.com>
---
 meta/classes/image.bbclass             |    1 +
 meta/classes/siteinfo.bbclass          |    4 +++-
 meta/classes/toolchain-scripts.bbclass |   26 ++++++++++++++++++++------
 3 files changed, 24 insertions(+), 7 deletions(-)
Phil Blundell - Aug. 11, 2011, 2:39 p.m.
On Thu, 2011-08-11 at 22:31 +0800, Lianhao Lu wrote:
> [YOCTO #892] populate the site config files content into the file in
> {target}/cross_site_config in rootfs, which can be used by the cross
> toolchain in meta-toolchain when the rootfs is used as sysroot.

Is that going to cause ${datadir}/cross_site_config to get created in
all rootfs images?  That would be undesirable, but I couldn't obviously
see a flag to turn it on and off.

p.
Lianhao Lu - Aug. 12, 2011, 1:09 a.m.
Phil Blundell wrote on 2011-08-11:
> On Thu, 2011-08-11 at 22:31 +0800, Lianhao Lu wrote:
>> [YOCTO #892] populate the site config files content into the file in
>> {target}/cross_site_config in rootfs, which can be used by the cross
>> toolchain in meta-toolchain when the rootfs is used as sysroot.
> 
> Is that going to cause ${datadir}/cross_site_config to get created in
> all rootfs images?  That would be undesirable, but I couldn't
> obviously see a flag to turn it on and off.
> 

We can add flag to turn it on and off. But the problem is that in that case, the user need to build 2 image rootfs, one for running and one for cross compiling.

Best Regards,
Lianhao
Saul Wold - Aug. 12, 2011, 2:05 a.m.
On 08/11/2011 06:09 PM, Lu, Lianhao wrote:
> Phil Blundell wrote on 2011-08-11:
>> On Thu, 2011-08-11 at 22:31 +0800, Lianhao Lu wrote:
>>> [YOCTO #892] populate the site config files content into the file in
>>> {target}/cross_site_config in rootfs, which can be used by the cross
>>> toolchain in meta-toolchain when the rootfs is used as sysroot.
>>
>> Is that going to cause ${datadir}/cross_site_config to get created in
>> all rootfs images?  That would be undesirable, but I couldn't
>> obviously see a flag to turn it on and off.
>>
>
> We can add flag to turn it on and off. But the problem is that in that case, the user need to build 2 image rootfs, one for running and one for cross compiling.
>
Lianhao,

This is only required for toolchain, is there a way to create the 
externally from the rootfs and package it with the ADT?  The problem 
here is that you will add space to the image (not sure how big), maybe 
this only make set to be and IMAGE_FEATURE for -dev or -sdk images, just 
as we add the -dev and -dbg packages to only those images?

SaU!

> Best Regards,
> Lianhao
>
>
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
>
Lianhao Lu - Aug. 12, 2011, 2:22 a.m.
Saul Wold wrote on 2011-08-12:
> On 08/11/2011 06:09 PM, Lu, Lianhao wrote:
>> Phil Blundell wrote on 2011-08-11:
>>> On Thu, 2011-08-11 at 22:31 +0800, Lianhao Lu wrote:
>>>> [YOCTO #892] populate the site config files content into the file
>>>> in {target}/cross_site_config in rootfs, which can be used by the
>>>> cross toolchain in meta-toolchain when the rootfs is used as sysroot.
>>> 
>>> Is that going to cause ${datadir}/cross_site_config to get created
>>> in all rootfs images?  That would be undesirable, but I couldn't
>>> obviously see a flag to turn it on and off.
>>> 
>> 
>> We can add flag to turn it on and off. But the problem is that in that
>> case, the user need to build 2 image rootfs, one for running and one
>> for cross compiling.
>> 
> Lianhao,
> 
> This is only required for toolchain, is there a way to create the
> externally from the rootfs and package it with the ADT?  The problem
> here is that you will add space to the image (not sure how big), maybe
> this only make set to be and IMAGE_FEATURE for -dev or -sdk images,
> just as we add the -dev and -dbg packages to only those images?
> 

Its about 50KB for core-image-sato-sdk. Having them in a separate package seems not feasible now, because we can't make sure the package is generated after all other packages have finished their populate-sysroot tasks. But it's a good idea to populate the site config files only into the -dev or -sdk images. I'll rework the patch.

Best Regards,
Lianhao

Patch

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 54eb78b..1104693 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -1,4 +1,5 @@ 
 inherit rootfs_${IMAGE_PKGTYPE}
+inherit toolchain-scripts
 
 IMAGETEST ?= "dummy"
 inherit imagetest-${IMAGETEST}
diff --git a/meta/classes/siteinfo.bbclass b/meta/classes/siteinfo.bbclass
index a61b5e5..02294c4 100644
--- a/meta/classes/siteinfo.bbclass
+++ b/meta/classes/siteinfo.bbclass
@@ -118,7 +118,7 @@  python () {
         bb.fatal("Please add your architecture to siteinfo.bbclass")
 }
 
-def siteinfo_get_files(d):
+def siteinfo_get_files(d, no_cache = False):
     sitedata = siteinfo_data(d)
     sitefiles = ""
     for path in d.getVar("BBPATH", True).split(":"):
@@ -127,6 +127,8 @@  def siteinfo_get_files(d):
             if os.path.exists(filename):
                 sitefiles += filename + " "
 
+    if no_cache: return sitefiles
+
     # Now check for siteconfig cache files
     path_siteconfig = bb.data.getVar('SITECONFIG_SYSROOTCACHE', d, 1)
     if os.path.isdir(path_siteconfig):
diff --git a/meta/classes/toolchain-scripts.bbclass b/meta/classes/toolchain-scripts.bbclass
index f7b52be..96c8968 100644
--- a/meta/classes/toolchain-scripts.bbclass
+++ b/meta/classes/toolchain-scripts.bbclass
@@ -9,7 +9,9 @@  toolchain_create_sdk_env_script () {
 	echo 'export PATH=${SDKPATHNATIVE}${bindir_nativesdk}:${SDKPATHNATIVE}${bindir_nativesdk}/${MULTIMACH_TARGET_SYS}:$PATH' >> $script
 	echo 'export PKG_CONFIG_SYSROOT_DIR=${SDKTARGETSYSROOT}' >> $script
 	echo 'export PKG_CONFIG_PATH=${SDKTARGETSYSROOT}${libdir}/pkgconfig' >> $script
-	echo 'export CONFIG_SITE=${SDKPATH}/site-config-${MULTIMACH_TARGET_SYS}' >> $script
+	echo 'export OECORE_NATIVE_SYSROOT="${SDKPATHNATIVE}"' >> $script
+	echo 'export OECORE_TARGET_SYSROOT="${SDKTARGETSYSROOT}"' >> $script
+	echo 'export CONFIG_SITE="$OECORE_TARGET_SYSROOT${target_datadir}/cross_site_config"' >> $script
 	echo 'export CC=${TARGET_PREFIX}gcc' >> $script
 	echo 'export CXX=${TARGET_PREFIX}g++' >> $script
 	echo 'export GDB=${TARGET_PREFIX}gdb' >> $script
@@ -26,8 +28,6 @@  toolchain_create_sdk_env_script () {
 	echo 'export CXXFLAGS="${TARGET_CC_ARCH} --sysroot=${SDKTARGETSYSROOT}"' >> $script
 	echo 'export LDFLAGS="${TARGET_LD_ARCH} --sysroot=${SDKTARGETSYSROOT}"' >> $script
 	echo 'export CPPFLAGS="${TARGET_CC_ARCH} --sysroot=${SDKTARGETSYSROOT}"' >> $script
-	echo 'export OECORE_NATIVE_SYSROOT="${SDKPATHNATIVE}"' >> $script
-	echo 'export OECORE_TARGET_SYSROOT="${SDKTARGETSYSROOT}"' >> $script
 	echo 'export OECORE_ACLOCAL_OPTS="-I ${SDKPATHNATIVE}/usr/share/aclocal"' >> $script
 	echo 'export POKY_DISTRO_VERSION="${DISTRO_VERSION}"' >> $script
 	echo 'export POKY_SDK_VERSION="${SDK_VERSION}"' >> $script
@@ -77,7 +77,9 @@  toolchain_create_sdk_env_script_for_installer () {
 	echo 'export PATH=${SDKPATHNATIVE}${bindir_nativesdk}:${SDKPATHNATIVE}${bindir_nativesdk}/'"${multimach_target_sys}"':$PATH' >> $script
 	echo 'export PKG_CONFIG_SYSROOT_DIR=##SDKTARGETSYSROOT##' >> $script
 	echo 'export PKG_CONFIG_PATH=##SDKTARGETSYSROOT##${target_libdir}/pkgconfig' >> $script
-	echo 'export CONFIG_SITE=${SDKPATH}/site-config-'"${multimach_target_sys}" >> $script
+	echo 'export OECORE_NATIVE_SYSROOT="${SDKPATHNATIVE}"' >> $script
+	echo 'export OECORE_TARGET_SYSROOT="##SDKTARGETSYSROOT##"' >> $script
+	echo 'export CONFIG_SITE="$OECORE_TARGET_SYSROOT${target_datadir}/cross_site_config"' >> $script
 	echo 'export CC=${TARGET_PREFIX}gcc' >> $script
 	echo 'export CXX=${TARGET_PREFIX}g++' >> $script
 	echo 'export GDB=${TARGET_PREFIX}gdb' >> $script
@@ -94,8 +96,6 @@  toolchain_create_sdk_env_script_for_installer () {
 	echo 'export CXXFLAGS="${TARGET_CC_ARCH} --sysroot=##SDKTARGETSYSROOT##"' >> $script
 	echo 'export LDFLAGS="${TARGET_LD_ARCH} --sysroot=##SDKTARGETSYSROOT##"' >> $script
 	echo 'export CPPFLAGS="${TARGET_CC_ARCH} --sysroot=##SDKTARGETSYSROOT##"' >> $script
-	echo 'export OECORE_NATIVE_SYSROOT="${SDKPATHNATIVE}"' >> $script
-	echo 'export OECORE_TARGET_SYSROOT="##SDKTARGETSYSROOT##"' >> $script
         echo 'export OECORE_ACLOCAL_OPTS="-I ${SDKPATHNATIVE}/usr/share/acloal"' >> $script
 	echo 'export POKY_DISTRO_VERSION="${DISTRO_VERSION}"' >> $script
 	echo 'export POKY_SDK_VERSION="${SDK_VERSION}"' >> $script
@@ -124,3 +124,17 @@  toolchain_create_sdk_version () {
 	echo 'Metadata Revision: ${METADATA_REVISION}' >> $versionfile
 	echo 'Timestamp: ${DATETIME}' >> $versionfile
 }
+
+IMAGE_PREPROCESS_COMMAND += "toolchain_create_rootfs_siteconfig ${IMAGE_ROOTFS}; "
+#Use := to avoid cross-canadian polution
+COMMON_CONFIG_SITE := "${@siteinfo_get_files(d,True)}"
+# create the site config file in the rootfs 
+toolchain_create_rootfs_siteconfig () {
+	local allfiles='${COMMON_CONFIG_SITE}'
+	for file in ${SITECONFIG_SYSROOTCACHE}/*; do
+		if [ -f $file ]; then
+			allfiles="$allfiles $file"
+		fi
+	done
+	toolchain_create_sdk_siteconfig $1${datadir}/cross_site_config $allfiles
+}