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 <[email protected]> --- classes/ruby.bbclass | 31 ++++++++++++++++++++++++ recipes-support/ruby-shadow/ruby-shadow_git.bb | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) 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 } diff --git a/recipes-support/ruby-shadow/ruby-shadow_git.bb b/recipes-support/ruby-shadow/ruby-shadow_git.bb index 72be016..75588f3 100644 --- a/recipes-support/ruby-shadow/ruby-shadow_git.bb +++ b/recipes-support/ruby-shadow/ruby-shadow_git.bb @@ -20,4 +20,4 @@ RDEPENDS_${PN} += " \ " RUBY_INSTALL_GEMS = "ruby-shadow-${PV}.gem" -FILES_${PN}-dbg += "/usr/lib64/ruby/gems/*/gems/ruby-shadow-${PV}/.debug/shadow.so" +FILES_${PN}-dbg += "/usr/lib*/ruby/gems/*/gems/ruby-shadow-${PV}/.debug/shadow.so" -- 1.7.9.5 -- _______________________________________________ meta-virtualization mailing list [email protected] https://lists.yoctoproject.org/listinfo/meta-virtualization
