Permalink
Browse files

Additional rbconfig tweaks for extconf; the included sample ext build…

…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...
1 parent 0f53c3d commit 92719607c6719170764e56a2c1edf274e9296cc9 @headius headius committed May 27, 2008
Showing with 54 additions and 11 deletions.
  1. +12 −0 samples/ext/extconf.rb
  2. +24 −0 samples/ext/mytest.c
  3. +18 −11 src/org/jruby/libraries/RbConfigLibrary.java
View
12 samples/ext/extconf.rb
@@ -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)
+
View
24 samples/ext/mytest.c
@@ -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);
+}
+
View
29 src/org/jruby/libraries/RbConfigLibrary.java
@@ -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());
@@ -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());

0 comments on commit 9271960

Please sign in to comment.