changeset 6:80273969f043

- ruby binding path cleanup, previous version required bindings and dyncall be checked out in same parent directory
author cslag
date Sat, 26 Mar 2016 00:12:40 +0100
parents bf5625bb6f05
children 4fd959b3df78
files ruby/rbdc/README.txt ruby/rbdc/extconf.rb ruby/rbdc/rbdc.c ruby/rbdc/rbdc.gemspec
diffstat 4 files changed, 74 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/ruby/rbdc/README.txt	Tue Mar 22 01:49:34 2016 +0100
+++ b/ruby/rbdc/README.txt	Sat Mar 26 00:12:40 2016 +0100
@@ -2,53 +2,78 @@
 Copyright 2007-2015 Tassilo Philipp
 
 
-BUILD
+BUILD/INSTALLATION
+------------------
+
+1) The extension isn't built here, but its code along with dyncall's source is bundled
+   in a .gem file to then be built and installed on the platform where the gem is installed.
+   So, you need dyncall's full source code to be included. Unfortunately, the .gemspec isn't
+   flexible enough to pull from different paths, so building the .gem file requires dyncall
+   to be found next to rbdc.c and extconf.rb. This means either copy dyncall's base directory
+   do ./dyncall or create a symlink ./dyncall, that points to it.
+
+2) Then, build this gem with:
+   gem build rbdc.gemspec
 
-  Build and install this gem with:
-    (cd ../../../dyncall; make distclean) || (gem build rbdc.gemspec && gem install ../../../rbdc-*.gem)
+3) On the target platform, install the gem with:
+   gem install ../../../rbdc-*.gem
+
+
+API
+---
+
+l = Dyncall::ExtLib.new
+l.load(libpath)
+l.syms_init(libpath)
+l.syms_count
+l.syms_each { |sym_name| ... }
+l.exists?(:symbolname)
+l.call(:symbolname, sigstring, ...)
 
 
 SIGNATURE FORMAT
+----------------
 
-  format: "xxxxx)y"
+format: "xxxxx)y"
 
-    x is positional parameter-type charcode
+  x is positional parameter-type charcode
 
-    'B' C++: bool             <- Ruby: TrueClass, FalseClass, NilClass, Fixnum
-    'c' C: char               <- Ruby: Fixnum
-    'C' C: unsigned char      <- Ruby: Fixnum
-    's' C: short              <- Ruby: Fixnum
-    'S' C: unsigned short     <- Ruby: Fixnum
-    'i' C: int                <- Ruby: Fixnum
-    'I' C: unsigned int       <- Ruby: Fixnum
-    'j' C: long               <- Ruby: Fixnum
-    'J' C: unsigned long      <- Ruby: Fixnum
-    'l' C: long long          <- Ruby: Fixnum
-    'L' C: unsigned long long <- Ruby: Fixnum
-    'f' C: float              <- Ruby: Float
-    'd' C: double             <- Ruby: Float
-    'p' C: void*              <- Ruby: String (check if there are other pointer-convertible ruby types @@@)
-    'Z' C: void*              <- Ruby: String
+  'B' C++: bool             <- Ruby: TrueClass, FalseClass, NilClass, Fixnum
+  'c' C: char               <- Ruby: Fixnum
+  'C' C: unsigned char      <- Ruby: Fixnum
+  's' C: short              <- Ruby: Fixnum
+  'S' C: unsigned short     <- Ruby: Fixnum
+  'i' C: int                <- Ruby: Fixnum
+  'I' C: unsigned int       <- Ruby: Fixnum
+  'j' C: long               <- Ruby: Fixnum
+  'J' C: unsigned long      <- Ruby: Fixnum
+  'l' C: long long          <- Ruby: Fixnum
+  'L' C: unsigned long long <- Ruby: Fixnum
+  'f' C: float              <- Ruby: Float
+  'd' C: double             <- Ruby: Float
+  'p' C: void*              <- Ruby: String (check if there are other pointer-convertible ruby types @@@)
+  'Z' C: void*              <- Ruby: String
 
-    y is result-type charcode  
+  y is result-type charcode  
 
-    'v' C: void               -> Ruby: NilClass
-    'B' C: bool               -> Ruby: TrueClass, FalseClass
-    'c' C: char               -> Ruby: Fixnum
-    'C' C: unsigned char      -> Ruby: Fixnum
-    's' C: short              -> Ruby: Fixnum
-    'S' C: unsigned short     -> Ruby: Fixnum
-    'i' C: int                -> Ruby: Fixnum
-    'I' C: unsigned int       -> Ruby: Fixnum
-    'j' C: long               -> Ruby: Fixnum
-    'J' C: unsigned long      -> Ruby: Fixnum
-    'l' C: long long          -> Ruby: Fixnum
-    'L' C: unsigned long long -> Ruby: Fixnum
-    'f' C: float              -> Ruby: Float
-    'd' C: double             -> Ruby: Float
-    'p' C: void*              -> unsupported at the moment @@@
-    'Z' C: void*              -> Ruby: String
+  'v' C: void               -> Ruby: NilClass
+  'B' C: bool               -> Ruby: TrueClass, FalseClass
+  'c' C: char               -> Ruby: Fixnum
+  'C' C: unsigned char      -> Ruby: Fixnum
+  's' C: short              -> Ruby: Fixnum
+  'S' C: unsigned short     -> Ruby: Fixnum
+  'i' C: int                -> Ruby: Fixnum
+  'I' C: unsigned int       -> Ruby: Fixnum
+  'j' C: long               -> Ruby: Fixnum
+  'J' C: unsigned long      -> Ruby: Fixnum
+  'l' C: long long          -> Ruby: Fixnum
+  'L' C: unsigned long long -> Ruby: Fixnum
+  'f' C: float              -> Ruby: Float
+  'd' C: double             -> Ruby: Float
+  'p' C: void*              -> unsupported at the moment @@@
+  'Z' C: void*              -> Ruby: String
 
 
 -> Note that signature suffixes used to indicate calling
 -> conventions, are not supported yet! @@@
+
--- a/ruby/rbdc/extconf.rb	Tue Mar 22 01:49:34 2016 +0100
+++ b/ruby/rbdc/extconf.rb	Sat Mar 26 00:12:40 2016 +0100
@@ -26,9 +26,9 @@
 require 'mkmf'
 
 dir_config 'rbdc'
-base_dir = '../../../dyncall/'
+base_dir = 'dyncall/'
 
-$CFLAGS << ' -I../../../dyncall/dyncall '
+$CFLAGS << ' -Idyncall/dyncall '
 
 # Build dyncall libs.
 puts 'Building dyncall libraries:'
--- a/ruby/rbdc/rbdc.c	Tue Mar 22 01:49:34 2016 +0100
+++ b/ruby/rbdc/rbdc.c	Sat Mar 26 00:12:40 2016 +0100
@@ -22,10 +22,10 @@
 
 
 #include <ruby.h>
-#include "../../../dyncall/dyncall/dyncall.h"
-#include "../../../dyncall/dyncallback/dyncall_callback.h"
-#include "../../../dyncall/dynload/dynload.h"
-#include "../../../dyncall/dyncall/dyncall_signature.h"
+#include "dyncall/dyncall/dyncall.h"
+#include "dyncall/dyncallback/dyncall_callback.h"
+#include "dyncall/dynload/dynload.h"
+#include "dyncall/dyncall/dyncall_signature.h"
 
 /* Our ruby module and its classes. */
 static VALUE rb_dcModule;
--- a/ruby/rbdc/rbdc.gemspec	Tue Mar 22 01:49:34 2016 +0100
+++ b/ruby/rbdc/rbdc.gemspec	Sat Mar 26 00:12:40 2016 +0100
@@ -21,8 +21,8 @@
 #///////////////////////////////////////////////////////////////////////
 
 require 'rake'
-base_dir = '../../..'
-Dir.chdir(base_dir)
+#dyncall_dir = ENV['DC_DIR']
+#FileUtils.symlink dyncall_dir, 'dyncall'#, :force => true
 
 Gem::Specification.new do |spec|
 	spec.name                  = 'rbdc'
@@ -37,6 +37,8 @@
 	spec.required_ruby_version = '>= 1.9.1'
 	spec.license               = 'ISC'
 
-	spec.files                 = FileList['dyncall/**/*', 'dyncall-bindings/ruby/rbdc/rbdc.c'].exclude('dyncall/doc/**/*').exclude('dyncall/test/**/*').to_a
-	spec.extensions            << 'dyncall-bindings/ruby/rbdc/extconf.rb'
+	# Note that this requires dyncall to live in this directory, create a symlink to the dyncall directory.
+	spec.files                 = FileList['dyncall/**/*', 'rbdc.c'].exclude('dyncall/doc/**/*').exclude('dyncall/test/**/*').to_a
+	spec.extensions            << 'extconf.rb'
 end
+