Skip to content

Commit

Permalink
[CHANGE] build ruby bindings per architecture; useful for Ohloh since…
Browse files Browse the repository at this point in the history
… we run different plaforms on Server and Dev machine
  • Loading branch information
Andy Verprauskus committed Jul 10, 2009
1 parent f8bbd3e commit e5bb762
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
8 changes: 5 additions & 3 deletions build
Expand Up @@ -105,9 +105,11 @@ run_test_suite()

build_ruby_bindings()
{
echo "Generating Ruby bindings"
sh -c "swig -ruby -o ruby/ohcount_wrap.c ruby/ohcount.i" || exit 1
sh -c "$cc $RB_SHARED ruby/ohcount_wrap.c $files -o ruby/$RB_SHARED_NAME \
arch=`ruby -rmkmf -e 'print Config::expand(CONFIG["arch"])'`
echo "Generating Ruby bindings for $arch"
sh -c "swig -ruby -o ruby/ohcount_wrap.c ruby/ohcount.i" || exit 1
mkdir -p ruby/$arch
sh -c "$cc $RB_SHARED ruby/ohcount_wrap.c $files -o ruby/$arch/$RB_SHARED_NAME \
-I`ruby -rmkmf -e 'print Config::expand(CONFIG["archdir"])'` \
-lpcre" || exit 1
sh -c "cd test/unit/ruby && ruby ruby_test.rb" || exit 1
Expand Down
9 changes: 8 additions & 1 deletion ruby/ohcount.rb
Expand Up @@ -3,7 +3,14 @@
# Ohcount module tweaked for use by Ohloh.

$: << File.expand_path(File.dirname(__FILE__))
require 'ohcount.so'

begin
require 'ohcount.so'
rescue LoadError
require 'rbconfig'
include Config
require "#{Config::CONFIG['arch']}/ohcount.so"
end

module Ohcount
class SourceFile
Expand Down
5 changes: 4 additions & 1 deletion test/unit/parser_test.h
Expand Up @@ -168,7 +168,10 @@ void test_parser_callback(const char *language, const char *entity,
line2[strlen(language) + strlen(entity) + 2 + (end - start)] = '\0';
if (strcmp(line, line2) != 0) {
fprintf(stderr, "lines didn't match:\n1: '%s'\n2: '%s'\n", line, line2);
assert(strcmp(line, line2) == 0);
if (strcmp(line, line2) != 0) {
fprintf(stderr, "lines didn't match:\n1: '%s'\n2: '%s'\n", line, line2);
assert(strcmp(line, line2) == 0);
}
}
}

Expand Down

0 comments on commit e5bb762

Please sign in to comment.