diff options
author | Jason Wessel <jason.wessel@windriver.com> | 2016-01-15 15:31:11 -0600 |
---|---|---|
committer | Bruce Ashfield <bruce.ashfield@windriver.com> | 2016-01-19 08:50:53 -0500 |
commit | 9ed0aef7b244773a9db644090b4e361fa7b3eea8 (patch) | |
tree | e778acbd212338bbcfb2ea63fb711694d1c69276 | |
parent | 850d27022a3685ee6821bf5856b02f54c58204a8 (diff) | |
download | meta-cloud-services-9ed0aef7b244773a9db644090b4e361fa7b3eea8.tar.gz |
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>
-rw-r--r-- | classes/ruby.bbclass | 31 | ||||
-rw-r--r-- | recipes-support/ruby-shadow/ruby-shadow_git.bb | 2 |
2 files changed, 32 insertions, 1 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" | |||
83 | 83 | ||
84 | RUBY_COMPILE_FLAGS ?= 'LANG="en_US.UTF-8" LC_ALL="en_US.UTF-8"' | 84 | RUBY_COMPILE_FLAGS ?= 'LANG="en_US.UTF-8" LC_ALL="en_US.UTF-8"' |
85 | 85 | ||
86 | ruby_gen_extconf_fix() { | ||
87 | cat<<EOF>append | ||
88 | RbConfig::MAKEFILE_CONFIG['CPPFLAGS'] = ENV['CPPFLAGS'] if ENV['CPPFLAGS'] | ||
89 | \$CPPFLAGS = ENV['CPPFLAGS'] if ENV['CPPFLAGS'] | ||
90 | RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC'] | ||
91 | RbConfig::MAKEFILE_CONFIG['LD'] = ENV['LD'] if ENV['LD'] | ||
92 | RbConfig::MAKEFILE_CONFIG['CFLAGS'] = ENV['CFLAGS'] if ENV['CFLAGS'] | ||
93 | RbConfig::MAKEFILE_CONFIG['CXXFLAGS'] = ENV['CXXFLAGS'] if ENV['CXXFLAGS'] | ||
94 | EOF | ||
95 | cat append2>>append | ||
96 | sysroot_ruby=${STAGING_INCDIR}/ruby-${RUBY_GEM_VERSION} | ||
97 | ruby_arch=`ls -1 ${sysroot_ruby} |grep -v ruby |tail -1 2> /dev/null` | ||
98 | cat<<EOF>>append | ||
99 | system("perl -p -i -e 's#^topdir.*#topdir = ${sysroot_ruby}#' Makefile") | ||
100 | system("perl -p -i -e 's#^hdrdir.*#hdrdir = ${sysroot_ruby}#' Makefile") | ||
101 | system("perl -p -i -e 's#^arch_hdrdir.*#arch_hdrdir = ${sysroot_ruby}/\\\\\$(arch)#' Makefile") | ||
102 | system("perl -p -i -e 's#^arch =.*#arch = ${ruby_arch}#' Makefile") | ||
103 | system("perl -p -i -e 's#^LIBPATH =.*#LIBPATH = -L.#' Makefile") | ||
104 | EOF | ||
105 | } | ||
106 | |||
86 | ruby_do_compile() { | 107 | ruby_do_compile() { |
108 | if [ -f extconf.rb -a ! -f extconf.rb.orig ] ; then | ||
109 | grep create_makefile extconf.rb > append2 || (exit 0) | ||
110 | ruby_gen_extconf_fix | ||
111 | cp extconf.rb extconf.rb.orig | ||
112 | # Patch extconf.rb for cross compile | ||
113 | cat append >> extconf.rb | ||
114 | fi | ||
87 | for gem in ${RUBY_BUILD_GEMS}; do | 115 | for gem in ${RUBY_BUILD_GEMS}; do |
88 | ${RUBY_COMPILE_FLAGS} gem build $gem | 116 | ${RUBY_COMPILE_FLAGS} gem build $gem |
89 | done | 117 | done |
118 | if [ -f extconf.rb.orig ] ; then | ||
119 | mv extconf.rb.orig extconf.rb | ||
120 | fi | ||
90 | } | 121 | } |
91 | 122 | ||
92 | 123 | ||
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} += " \ | |||
20 | " | 20 | " |
21 | 21 | ||
22 | RUBY_INSTALL_GEMS = "ruby-shadow-${PV}.gem" | 22 | RUBY_INSTALL_GEMS = "ruby-shadow-${PV}.gem" |
23 | FILES_${PN}-dbg += "/usr/lib64/ruby/gems/*/gems/ruby-shadow-${PV}/.debug/shadow.so" | 23 | FILES_${PN}-dbg += "/usr/lib*/ruby/gems/*/gems/ruby-shadow-${PV}/.debug/shadow.so" |