Permalink
Browse files

Replaced build.sh with rakefiles; Removed some platform dependencies;…

… added license
  • Loading branch information...
1 parent cf3c54c commit 63ac7a5c3350c2504af974c99cc2f98dc75f43ad pbm committed Aug 27, 2006
Showing with 167 additions and 191 deletions.
  1. +18 −0 MIT-LICENSE
  2. +14 −7 README.rdoc
  3. +0 −40 ext/gl/build.sh
  4. +6 −0 ext/gl/extconf.rb
  5. +14 −22 ext/gl/gl.i
  6. +3 −20 ext/gl/gl_untyped.i
  7. +43 −0 ext/gl/rakefile
  8. +0 −40 ext/glut/build.sh
  9. +6 −0 ext/glut/extconf.rb
  10. +15 −21 ext/glut/glut.i
  11. +2 −21 ext/glut/glut_callbacks.i
  12. +3 −20 ext/glut/glut_init.i
  13. +43 −0 ext/glut/rakefile
View
18 MIT-LICENSE
@@ -0,0 +1,18 @@
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
View
21 README.rdoc
@@ -1,16 +1,23 @@
-== ruby-opengl
+= ruby-opengl
-ruby-opengl is a Ruby extension for the OpenGL, GLU and GLUT libraries
-using SWIG. Currently, it compiles and runs on Mac OS X.
+ruby-opengl[http://rubyforge.org/projects/ruby-opengl/] is a Ruby extension
+for the OpenGL, GLU and GLUT libraries using SWIG. Currently, it compiles
+and runs on Mac OS X.
+
+== Building ruby-opengl
+
+=== Pre-requisites
+
+SWIG[http://www.swig.org/] must be installed on the build machine.
=== Build on Mac OS X
The current build is manual, and we intend to update to Rake real soon
now. To build:
-* cd ext/gl
-* ./build.sh
-* cd ../glut
-* ./build.sh
+1. <tt>cd ext/gl</tt>
+2. <tt>./build.sh</tt>
+3. <tt>cd ../glut</tt>
+4. <tt>./build.sh</tt>
=== Running the tests
View
40 ext/gl/build.sh
@@ -1,40 +0,0 @@
-#!/bin/bash -x
-#
-# Copyright (C) 2006 Peter McLain <peter.mclain@gmail.com>
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-# This is just a place-holder build script until we decide on a full
-# make/mkmf based build or a Rake/mkrf
-
-GENERATED_FILES="Makefile gl_wrap.c *.o gl.bundle"
-
-# Clean all the junk out
-rm -f $GENERATED_FILES
-
-# This has to come before the extconf line, since mkmf won't make a target
-# for glut unless there is a glut_wrap.c file lying around....
-swig -ruby gl.i
-
-# Generate the makefile
-ruby extconf.rb --with-ldflags='-framework OpenGL'
-
-# Now compile it up into a bundle
-make
View
6 ext/gl/extconf.rb
@@ -1,3 +1,9 @@
+#-*-ruby-*-
+#--
+# Copyright 2006 by Peter McLain
+# All rights reserved.
+# See MIT-LICENSE for permissions.
+#++
require 'mkmf'
$objs = %w( rbogl.o gl_wrap.o )
create_makefile('gl')
View
36 ext/gl/gl.i
@@ -1,33 +1,25 @@
/*
- * Copyright (C) 2006 Peter McLain <peter.mclain@gmail.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * Copyright (C) 2006 Peter McLain
+ * All rights reserved.
+ * See MIT-LICENSE for permissions.
*/
%module GL
-%{
-/* This puts a #include ...gl.h in the gl_wrap.c code*/
+#ifdef SWIGMAC
+%header %{
#include "/System/Library/Frameworks/OpenGL.framework/Headers/gl.h"
%}
+#else
+%header %{
+#include <GL/gl.h>
+%}
+#endif
/* This is what SWIG parses to generate the wrapper */
+#ifdef SWIGMAC
%include "/System/Library/Frameworks/OpenGL.framework/Headers/gl.h"
+#else
+%include "GL/gl.h"
+#endif
%include "gl_untyped.i"
View
23 ext/gl/gl_untyped.i
@@ -1,24 +1,7 @@
/*
- * Copyright (C) 2006 Peter McLain <peter.mclain@gmail.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * Copyright (C) 2006 Peter McLain
+ * All rights reserved.
+ * See MIT-LICENSE for permissions.
*/
%wrapper %{
View
43 ext/gl/rakefile
@@ -0,0 +1,43 @@
+#-*-ruby-*-
+#--
+# Copyright 2006 by Peter McLain
+# All rights reserved.
+# See MIT-LICENSE for permissions.
+#++
+
+require 'rake/clean'
+require 'rbconfig'
+
+case RUBY_PLATFORM
+when /darwin/
+ extconf_args = "--with-ldflags='-framework OpenGL'"
+ # Don't understand why swig doesn't define this...
+ swig_args = "-DSWIGMAC"
+else
+ extconf_args = ""
+end
+
+# The module we are trying to build
+ext_name = 'gl'
+# The library name, e.g., "gl.bundle" or "gl.so"
+ext = "#{ext_name}.#{Config::CONFIG['DLEXT']}"
+
+CLEAN.include('*_wrap.*', 'rbogl.o')
+CLOBBER.include('Makefile', "*.#{Config::CONFIG['DLEXT']}")
+
+# This rule tells rake how to use swig to make foo_wrap.c from foo.i
+rule '.c' => [ proc { |tn| tn.sub(/_wrap\.[^.]+$/, '.i') } ] do |t|
+ sh "swig #{swig_args} -ruby #{t.source}"
+end
+
+task :default => [ ext ]
+
+# we create the makefile using mkmf, but mkmf doesn't want to work unless
+# glut_wrap.c exists, so...
+file 'Makefile' => [ "#{ext_name}_wrap.c", 'extconf.rb' ] do |t|
+ ruby "extconf.rb #{extconf_args}"
+end
+
+file ext => [ 'Makefile', "#{ext_name}_wrap.c" ] do |t|
+ sh 'make'
+end
View
40 ext/glut/build.sh
@@ -1,40 +0,0 @@
-#!/bin/bash -x
-#
-# Copyright (C) 2006 Peter McLain <peter.mclain@gmail.com>
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-# This is just a place-holder build script until we decide on a full
-# make/mkmf based build or a Rake/mkrf
-
-GENERATED_FILES="Makefile glut_wrap.c glut_wrap.o glut.bundle"
-
-# Clean all the junk out
-rm -f $GENERATED_FILES
-
-# This has to come before the extconf line, since mkmf won't make a target
-# for glut unless there is a glut_wrap.c file lying around....
-swig -ruby glut.i
-
-# Generate the makefile
-ruby extconf.rb --with-ldflags='-framework GLUT'
-
-# Now compile it up into a bundle
-make
View
6 ext/glut/extconf.rb
@@ -1,2 +1,8 @@
+#-*-ruby-*-
+#--
+# Copyright 2006 by Peter McLain
+# All rights reserved.
+# See MIT-LICENSE for permissions.
+#++
require 'mkmf'
create_makefile('glut')
View
36 ext/glut/glut.i
@@ -1,33 +1,27 @@
/*
- * Copyright (C) 2006 Peter McLain <peter.mclain@gmail.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * Copyright (C) 2006 Peter McLain
+ * All rights reserved.
+ * See MIT-LICENSE for permissions.
*/
%module GLUT
-%{
+%module GL
+#ifdef SWIGMAC
+%header %{
#include "/System/Library/Frameworks/GLUT.framework/Headers/glut.h"
%}
+#else
+%header %{
+#include <GL/glut.h>
+%}
+#endif
%include "glut_init.i"
%include "glut_callbacks.i"
+#ifdef SWIGMAC
%include "/System/Library/Frameworks/GLUT.framework/Headers/glut.h"
+#else
+%include "GL/glut.h"
+#endif
View
23 ext/glut/glut_callbacks.i
@@ -1,26 +1,7 @@
/*
- * Copyright (C) 1999 - 2005 Yoshi <yoshi@giganet.net>
- * Copyright (C) 2006 John M. Gabriele <jmg3000@gmail.com>
* Copyright (C) 2006 Peter McLain <peter.mclain@gmail.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * All rights reserved.
+ * See MIT-LICENSE for permissions.
*/
/*
View
23 ext/glut/glut_init.i
@@ -1,26 +1,9 @@
/*
* Copyright (C) 1999 - 2005 Yoshi <yoshi@giganet.net>
* Copyright (C) 2006 John M. Gabriele <jmg3000@gmail.com>
- * Copyright (C) 2006 Peter McLain <peter.mclain@gmail.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * Copyright (C) 2006 Peter McLain
+ * All rights reserved.
+ * See MIT-LICENSE for permissions.
*/
%wrapper %{
View
43 ext/glut/rakefile
@@ -0,0 +1,43 @@
+#-*-ruby-*-
+#--
+# Copyright 2006 by Peter McLain
+# All rights reserved.
+# See MIT-LICENSE for permissions.
+#++
+
+require 'rake/clean'
+require 'rbconfig'
+
+case RUBY_PLATFORM
+when /darwin/
+ extconf_args = "--with-ldflags='-framework GLUT'"
+ # Don't understand why swig doesn't define this...
+ swig_args = "-DSWIGMAC"
+else
+ extconf_args = ""
+end
+
+# The module we are trying to build
+ext_name = 'glut'
+# The library name, e.g., "gl.bundle" or "gl.so"
+ext = "#{ext_name}.#{Config::CONFIG['DLEXT']}"
+
+CLEAN.include('*_wrap.*')
+CLOBBER.include('Makefile', "*.#{Config::CONFIG['DLEXT']}")
+
+# This rule tells rake how to use swig to make foo_wrap.c from foo.i
+rule '.c' => [ proc { |tn| tn.sub(/_wrap\.[^.]+$/, '.i') } ] do |t|
+ sh "swig #{swig_args} -ruby #{t.source}"
+end
+
+task :default => [ ext ]
+
+# we create the makefile using mkmf, but mkmf doesn't want to work unless
+# glut_wrap.c exists, so...
+file 'Makefile' => [ "#{ext_name}_wrap.c", 'extconf.rb' ] do |t|
+ ruby "extconf.rb #{extconf_args}"
+end
+
+file ext => [ 'Makefile', "#{ext_name}_wrap.c" ] do |t|
+ sh 'make'
+end

0 comments on commit 63ac7a5

Please sign in to comment.