Permalink
Browse files

Prepare for C parsing

  • Loading branch information...
1 parent 7f6c150 commit cbeb43ecf80cb1842d6e5a9880c212544d1eedc5 @meh committed Feb 16, 2012
Showing with 42 additions and 3 deletions.
  1. +1 −0 .gitignore
  2. +2 −2 clj.gemspec
  3. +15 −0 ext/clj/extconf.rb
  4. +7 −0 ext/clj/parser.c
  5. +11 −0 extconf.rb
  6. +6 −1 lib/clj.rb
View
@@ -0,0 +1 @@
+Makefile
View
@@ -6,8 +6,8 @@ Gem::Specification.new {|s|
s.homepage = 'http://github.com/meh/ruby-clj'
s.platform = Gem::Platform::RUBY
s.summary = 'Like json, but with clojure sexps.'
- s.files = Dir.glob('lib/**/*.rb')
- s.require_path = 'lib'
+ s.files = Dir['ext/**/*.{c,h,rb}'] + Dir['lib/**/*.rb']
+ s.extensions = 'ext/clj/extconf.rb'
s.add_development_dependency 'rake'
s.add_development_dependency 'rspec'
View
@@ -0,0 +1,15 @@
+require 'mkmf'
+
+unless $CFLAGS.gsub!(/ -O[\dsz]?/, ' -O3')
+ $CFLAGS << ' -O3'
+end
+
+if CONFIG['CC'] =~ /gcc/
+ $CFLAGS << ' -Wall'
+
+ if $DEBUG && !$CFLAGS.gsub!(/ -O[\dsz]?/, ' -O0 -ggdb')
+ $CFLAGS << ' -O0 -ggdb'
+ end
+end
+
+create_makefile 'clj/parser_ext'
View
@@ -0,0 +1,7 @@
+#include "ruby.h"
+
+void
+Init_parser_ext (void)
+{
+
+}
View
@@ -0,0 +1,11 @@
+# Loads mkmf which is used to make makefiles for Ruby extensions
+require 'mkmf'
+
+# Give it a name
+extension_name = 'parser_ext'
+
+# The destination
+dir_config(parser_ext)
+
+# Do the work
+create_makefile(parser_ext)
View
@@ -11,7 +11,12 @@
require 'date'
require 'bigdecimal'
-require 'clj/parser'
+if RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
+ require 'clj/parser_ext'
+else
+ require 'clj/parser'
+end
+
require 'clj/types'
class Clojure

0 comments on commit cbeb43e

Please sign in to comment.