Skip to content

Commit

Permalink
Additional rbconfig tweaks for extconf; the included sample ext build…
Browse files Browse the repository at this point in the history
…s and loads correctly with jruby-loadmod.

git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@6841 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information
headius committed May 27, 2008
1 parent 0f53c3d commit 9271960
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 11 deletions.
12 changes: 12 additions & 0 deletions samples/ext/extconf.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Loads mkmf which is used to make makefiles for Ruby extensions
require 'mkmf'

# Give it a name
extension_name = 'mytest'

# The destination
dir_config(extension_name)

# Do the work
create_makefile(extension_name)

24 changes: 24 additions & 0 deletions samples/ext/mytest.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Include the Ruby headers and goodies
#include "ruby.h"

// Defining a space for information and references about the module to be stored internally
VALUE MyTest = Qnil;

// Prototype for the initialization method - Ruby calls this, not you
void Init_mytest();

// Prototype for our method 'test1' - methods are prefixed by 'method_' here
VALUE method_test1(VALUE self);

// The initialization method for this module
void Init_mytest() {
MyTest = rb_define_module("MyTest");
rb_define_method(MyTest, "test1", method_test1, 0);
}

// Our 'test1' method.. it simply returns a value of '10' for now.
VALUE method_test1(VALUE self) {
int x = 10;
return INT2NUM(x);
}

29 changes: 18 additions & 11 deletions src/org/jruby/libraries/RbConfigLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,19 @@ public void load(Ruby runtime, boolean wrap) {
libdir = new NormalizedFile(libdir).getAbsolutePath();
}
}
String rubyLibDir = new NormalizedFile(libdir, "ruby/1.8").getPath();
String siteDir = new NormalizedFile(libdir, "ruby/site_ruby").getPath();
String siteLibDir = new NormalizedFile(libdir, "ruby/site_ruby/1.8").getPath();
String siteArchDir = new NormalizedFile(libdir, "ruby/site_ruby/1.8/java").getPath();
String archDir = new NormalizedFile(libdir, "ruby/1.8/java").getPath();

setConfig(configHash, "libdir", libdir);
setConfig(configHash, "rubylibdir", new NormalizedFile(libdir, "ruby/1.8").getPath());
setConfig(configHash, "sitedir", new NormalizedFile(libdir, "ruby/site_ruby").getPath());
setConfig(configHash, "sitelibdir", new NormalizedFile(libdir, "ruby/site_ruby/1.8").getPath());
setConfig(configHash, "sitearchdir", new NormalizedFile(libdir, "ruby/site_ruby/1.8/java").getPath());
setConfig(configHash, "archdir", new NormalizedFile(libdir, "ruby/site_ruby/1.8/java").getPath());
setConfig(configHash, "rubylibdir", rubyLibDir);
setConfig(configHash, "sitedir", siteDir);
setConfig(configHash, "sitelibdir", siteLibDir);
setConfig(configHash, "sitearchdir", siteArchDir);
setConfig(configHash, "archdir", archDir);
setConfig(configHash, "topdir", archDir);
setConfig(configHash, "configure_args", "");
setConfig(configHash, "datadir", new NormalizedFile(normalizedHome, "share").getPath());
setConfig(configHash, "mandir", new NormalizedFile(normalizedHome, "man").getPath());
Expand All @@ -182,13 +188,14 @@ public void load(Ruby runtime, boolean wrap) {


setConfig(mkmfHash, "libdir", libdir);
setConfig(mkmfHash, "arch", "universal-java" + System.getProperty("java.specification.version"));
setConfig(mkmfHash, "rubylibdir", "$(libdir)/ruby/$(ruby_version)");
setConfig(mkmfHash, "sitedir", "$(libdir)/ruby/site_ruby");
setConfig(mkmfHash, "sitelibdir", "$(sitedir)/1.8");
setConfig(mkmfHash, "arch", "java");
setConfig(mkmfHash, "rubylibdir", rubyLibDir);
setConfig(mkmfHash, "sitedir", siteDir);
setConfig(mkmfHash, "sitelibdir", siteLibDir);
setConfig(mkmfHash, "sitearch", "java");
setConfig(mkmfHash, "sitearchdir", "$(sitelibdir)/$(sitearch)");
setConfig(mkmfHash, "archdir", "$(rubylibdir)/$(arch)");
setConfig(mkmfHash, "sitearchdir", siteArchDir);
setConfig(mkmfHash, "archdir", archDir);
setConfig(mkmfHash, "topdir", archDir);
setConfig(mkmfHash, "configure_args", "");
setConfig(mkmfHash, "datadir", new NormalizedFile(normalizedHome, "share").getPath());
setConfig(mkmfHash, "mandir", new NormalizedFile(normalizedHome, "man").getPath());
Expand Down

0 comments on commit 9271960

Please sign in to comment.