aboutsummaryrefslogtreecommitdiffstats
path: root/classes
diff options
context:
space:
mode:
authorJason Wessel <jason.wessel@windriver.com>2016-01-15 15:31:11 -0600
committerBruce Ashfield <bruce.ashfield@windriver.com>2016-01-19 08:50:53 -0500
commit9ed0aef7b244773a9db644090b4e361fa7b3eea8 (patch)
treee778acbd212338bbcfb2ea63fb711694d1c69276 /classes
parent850d27022a3685ee6821bf5856b02f54c58204a8 (diff)
downloadmeta-cloud-services-9ed0aef7b244773a9db644090b4e361fa7b3eea8.tar.gz
meta-cloud-services-9ed0aef7b244773a9db644090b4e361fa7b3eea8.tar.bz2
meta-cloud-services-9ed0aef7b244773a9db644090b4e361fa7b3eea8.zip
ruby-shadow: Work around cross compile gem problem
Prior to this commit it is not possible to cross build a ruby gem. In fact even on the x86 system the object files for the native gem are generated with the wrong compiler (the host compiler instead of the cross compiler). A better way to fix this in the future would be to use only gems that supported cross compile tool called rake. For now the bbclass can modify the extconf.rb just before creating the gem and insert some code into the Makefile so as to honor the cross compile environment. Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Diffstat (limited to 'classes')
-rw-r--r--classes/ruby.bbclass31
1 files changed, 31 insertions, 0 deletions
diff --git a/classes/ruby.bbclass b/classes/ruby.bbclass
index 0c842d5..92226f6 100644
--- a/classes/ruby.bbclass
+++ b/classes/ruby.bbclass
@@ -83,10 +83,41 @@ RUBY_INSTALL_GEMS ?= "${BPN}-${BPV}.gem"
RUBY_COMPILE_FLAGS ?= 'LANG="en_US.UTF-8" LC_ALL="en_US.UTF-8"'
+ruby_gen_extconf_fix() {
+ cat<<EOF>append
+ RbConfig::MAKEFILE_CONFIG['CPPFLAGS'] = ENV['CPPFLAGS'] if ENV['CPPFLAGS']
+ \$CPPFLAGS = ENV['CPPFLAGS'] if ENV['CPPFLAGS']
+ RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
+ RbConfig::MAKEFILE_CONFIG['LD'] = ENV['LD'] if ENV['LD']
+ RbConfig::MAKEFILE_CONFIG['CFLAGS'] = ENV['CFLAGS'] if ENV['CFLAGS']
+ RbConfig::MAKEFILE_CONFIG['CXXFLAGS'] = ENV['CXXFLAGS'] if ENV['CXXFLAGS']
+EOF
+ cat append2>>append
+ sysroot_ruby=${STAGING_INCDIR}/ruby-${RUBY_GEM_VERSION}
+ ruby_arch=`ls -1 ${sysroot_ruby} |grep -v ruby |tail -1 2> /dev/null`
+ cat<<EOF>>append
+ system("perl -p -i -e 's#^topdir.*#topdir = ${sysroot_ruby}#' Makefile")
+ system("perl -p -i -e 's#^hdrdir.*#hdrdir = ${sysroot_ruby}#' Makefile")
+ system("perl -p -i -e 's#^arch_hdrdir.*#arch_hdrdir = ${sysroot_ruby}/\\\\\$(arch)#' Makefile")
+ system("perl -p -i -e 's#^arch =.*#arch = ${ruby_arch}#' Makefile")
+ system("perl -p -i -e 's#^LIBPATH =.*#LIBPATH = -L.#' Makefile")
+EOF
+}
+
ruby_do_compile() {
+ if [ -f extconf.rb -a ! -f extconf.rb.orig ] ; then
+ grep create_makefile extconf.rb > append2 || (exit 0)
+ ruby_gen_extconf_fix
+ cp extconf.rb extconf.rb.orig
+ # Patch extconf.rb for cross compile
+ cat append >> extconf.rb
+ fi
for gem in ${RUBY_BUILD_GEMS}; do
${RUBY_COMPILE_FLAGS} gem build $gem
done
+ if [ -f extconf.rb.orig ] ; then
+ mv extconf.rb.orig extconf.rb
+ fi
}