Message: previous - next
Month: April 2012

How to support ruby 1.9.x?

From: Darrell Anderson <humanreadable@...>
Date: Sat, 28 Apr 2012 16:41:07 -0700 (PDT)
I have some patches that I apply for my builds when using ruby 1.9.x rather than 1.8.x. Amarok, tdebindings, and koffice, although the latter has additional problems with ruby 1.9.x.

I want to push these patches to GIT but I can't change code one-way because the ruby 1.9 patches will cause build failures for those folks still building against ruby 1.8.x. I need to add preprocessor checks in the patches to test the ruby version, similar to what we have been doing for building against libpng 1.4/1.5.

Normally there is an APP_MAJOR_VERSION and APP_MINOR_VERSION variable defined in an app header. The ruby people feel the need to be different and don't do this. At least not with the latest versions.

There are two basic methods to extract the version:

RUBY_MAJOR_VERSION="`ruby --version | awk '{print $2}' | awk -F '.' '{print $1}'`"
RUBY_MINOR_VERSION="`ruby --version | awk '{print $2}' | awk -F '.' '{print $2}'`"


RUBY_MAJOR_VERSION=ruby -rrbconfig -e "puts Config.expand( Config::MAKEFILE_CONFIG['MAJOR'] )"
RUBY_MINOR_VERSION=ruby -rrbconfig -e "puts Config.expand( Config::MAKEFILE_CONFIG['MINOR'] )"

How do I get the cpp code to recognize those variables? Can I do this through the configure process?