Permalink
Browse files

add jeweler, tests for multi args

  • Loading branch information...
1 parent 023230b commit 37cf5463699bbfa8aa598bba514831154c78bf6b @mwotton committed Aug 29, 2010
Showing with 244 additions and 73 deletions.
  1. +3 −0 Gemfile
  2. +118 −26 Rakefile
  3. +1 −1 VERSION
  4. 0 bin/ghc_builder
  5. +61 −29 hubris.gemspec
  6. +7 −8 lib/hubris.rb
  7. +54 −9 spec/hubris_spec.rb
View
@@ -0,0 +1,3 @@
+source 'http://rubygems.org'
+
+gemspec
View
144 Rakefile
@@ -1,41 +1,133 @@
require 'rubygems'
-#gem 'hoe', '>= 2.1.0'
-require 'hoe'
+require 'rake'
+
require 'fileutils'
-# require './lib/hubris'
-Hoe.plugin :newgem
+begin
+ require 'jeweler'
+
+ jeweler_tasks = Jeweler::Tasks.new do |gem|
+ gem.name = "hubris"
+ gem.summary = "a bridge between Haskell and Ruby"
+ gem.description = "a bridge between Haskell and Ruby"
+ gem.email = "mwotton@gmail.com"
+ gem.homepage = "http://github.com/mwotton/hubris"
+ gem.add_development_dependency("rspec", ">= 1.2.9")
+ gem.add_dependency("open4")
+ gem.extensions = FileList["ext/**/extconf.rb"]
+ gem.authors = ["Mark Wotton", "Josh Price", "James Britt"]
+ gem.files.include('lib/stub.*')
+ end
+
+ $gemspec = jeweler_tasks.gemspec
+ # black magic: http://karottenreibe.github.com/2009/10/25/jeweler-interlude/
+ $gemspec.version = jeweler_tasks.jeweler.version
+ Jeweler::GemcutterTasks.new
+
+rescue LoadError
+ puts "Jeweler not available. Install it with: gem install jeweler"
+end
+
+# require 'rake-compiler'
+require 'rake/extensiontask'
+# require 'rake/extensiontesttask'
+
+Rake::ExtensionTask.new('stub', $gemspec) do |ext|
+ # ext.cross_compile = true
+ # ext.cross_platform = 'x86-mswin32'
+ # ext.test_files = FileList['test/c/*']
+end
+
+# CLEAN.include 'lib/**/*.so'
+
+Rake::Task.tasks.each do |task_name|
+ case task_name.to_s
+ when /^native/
+ task_name.prerequisites.unshift("fix_rake_compiler_gemspec_dump")
+ end
+end
+
+task :fix_rake_compiler_gemspec_dump do
+ %w{files extra_rdoc_files test_files}.each do |accessor|
+ $gemspec.send(accessor).instance_eval {
+ @exclude_procs = Array.new
+ }
+ end
+end
+
+desc("Build linux and windows specific gems")
+task :gems do
+ sh "rake clean build:native"
+ sh "rake clean build:cross"
+ sh "rake clean build"
+end
+
+task "build:native" => [:no_extconf, :native, :build] do
+ file = "pkg/stub-#{`cat VERSION`.chomp}.gem"
+ mv file, "#{file.ext}-i686-linux.gem"
+end
+
+task :no_extconf do
+ $gemspec.extensions = []
+end
+
+begin
+ require 'spec/rake/spectask'
+ Spec::Rake::SpecTask.new(:spec) do |spec|
+ spec.libs << 'lib' << 'spec'
+ spec.spec_files = FileList['spec/**/*_spec.rb']
+ end
+
+
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
+ spec.libs << 'lib' << 'spec'
+ spec.pattern = 'spec/**/*_spec.rb'
+ spec.rcov = true
+ end
+ rescue LoadError
-$hoe = Hoe.spec 'hubris' do
- self.developer 'Mark Wotton', 'mwotton@gmail.com'
- self.rubyforge_name = "hubris"
- self.summary = 'tool to help build .so files from haskell code for use in Ruby via dl'
- self.post_install_message = 'PostInstall.txt'
- self.readme_file = "README.markdown"
- self.history_file = "HISTORY.markdown"
end
-require 'newgem/tasks'
-Dir['tasks/**/*.rake'].each { |t| load t }
+task :spec => :check_dependencies
+begin
+ require 'reek/adapters/rake_task'
+ Reek::RakeTask.new do |t|
+ t.fail_on_error = true
+ t.verbose = false
+ t.source_files = 'lib/**/*.rb'
+ end
+rescue LoadError
+ task :reek do
+ abort "Reek is not available. In order to run reek, you must: sudo gem install reek"
+ end
+end
+
+begin
+ require 'roodi'
+ require 'roodi_task'
+ RoodiTask.new do |t|
+ t.verbose = false
+ end
+rescue LoadError
+ task :roodi do
+ abort "Roodi is not available. In order to run roodi, you must: sudo gem install roodi"
+ end
+end
-#file "lib/RubyMap.hs" => ["lib/RubyMap.chs"] do
-# str = "c2hs -v --cppopts='-I" + Hubris::RubyHeader + "' --cpp=gcc --cppopts=-E --cppopts=-xc lib/RubyMap.chs"
-# # print str
-# system(str)
-#end
+task :default => :spec
-require 'spec'
-require 'spec/rake/spectask'
+require 'rake/rdoctask'
+Rake::RDocTask.new do |rdoc|
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
-# desc "Run the specs under spec/"
-# all_examples = Spec::Rake::SpecTask.new do |t|
-# t.spec_opts = ['--options', "spec/spec.opts"]
-# t.spec_files = FileList['spec/*.rb']
-# end
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = "mygem #{version}"
+ rdoc.rdoc_files.include('README*')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
-# task :spec => ["lib/RubyMap.hs"]
task :clean do
FileList[File.expand_path("~/.hubris_cache/*"),
View
@@ -1 +1 @@
-0.0.0
+0.0.3
View
0 bin/ghc_builder 100644 → 100755
No changes.
View
@@ -1,47 +1,79 @@
+# Generated by jeweler
+# DO NOT EDIT THIS FILE DIRECTLY
+# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{hubris}
s.version = "0.0.3"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Mark Wotton"]
- s.date = %q{2010-04-07}
- s.description = %q{Hubris is a bridge between Ruby and Haskell, between love and bondage,
-between slothful indolence and raw, blazing speed. Hubris will wash
-your car, lie to your boss, and salvage your love life. If you are
-very, very lucky, it might also let you get some functional goodness
-into your ruby programs through the back door.
-
-I probably don't have to say this, but patches are very much
-welcome. If you have trouble installing it, tell me, and help me
-improve the docs.}
- s.email = ["mwotton@gmail.com"]
- s.extra_rdoc_files = ["Manifest.txt", "PostInstall.txt"]
- s.files = ["HISTORY.markdown", "Manifest.txt", "PostInstall.txt", "README.markdown", "Rakefile", "lib/hubris.rb", "sample/Fibonacci.hs", "sample/config.ru", "spec/spec.opts", "spec/spec_helper.rb"]
- s.post_install_message = %q{PostInstall.txt}
- s.rdoc_options = ["--main", "README.markdown"]
- s.require_paths = ["lib", "ext"]
- s.rubyforge_project = %q{hubris}
- s.rubygems_version = %q{1.3.5}
- s.summary = %q{tool to help build .so files from haskell code for use in Ruby via dl}
+ s.authors = ["Mark Wotton", "Josh Price", "James Britt"]
+ s.date = %q{2010-08-25}
+ s.description = %q{a bridge between Haskell and Ruby}
+ s.email = %q{mwotton@gmail.com}
+ s.executables = ["ghc_builder", "jhc_builder"]
+ s.extra_rdoc_files = [
+ "README.markdown"
+ ]
+ s.files = [
+ ".gitignore",
+ "CommonErrors.txt",
+ "HISTORY.markdown",
+ "Manifest.txt",
+ "PostInstall.txt",
+ "README.markdown",
+ "Rakefile",
+ "VERSION",
+ "bin-scripts/ghc_builder",
+ "bin-scripts/jhc_builder",
+ "bin/ghc_builder",
+ "bin/jhc_builder",
+ "examples/simple_inline/clean_and_run.sh",
+ "examples/simple_inline/haskell_math.rb",
+ "examples/simple_rack_app/Test.hs",
+ "examples/simple_rack_app/config.ru",
+ "examples/simple_rack_app/hsload.rb",
+ "ext/stub/extconf.rb",
+ "ext/stub/stub.c",
+ "hubris.gemspec",
+ "lib/Makefile",
+ "lib/hubris.rb",
+ "lib/stub.bundle",
+ "lib/stub.so",
+ "rspec.rake",
+ "sample/Fibonacci.hs",
+ "sample/config.ru",
+ "script/console",
+ "script/destroy",
+ "script/generate",
+ "spec/hubris_spec.rb",
+ "spec/spec.opts",
+ "spec/spec_helper.rb"
+ ]
+ s.homepage = %q{http://github.com/mwotton/hubris}
+ s.rdoc_options = ["--charset=UTF-8"]
+ s.require_paths = ["lib"]
+ s.rubygems_version = %q{1.3.6}
+ s.summary = %q{a bridge between Haskell and Ruby}
+ s.test_files = [
+ "spec/spec_helper.rb",
+ "spec/hubris_spec.rb",
+ "examples/simple_inline/haskell_math.rb",
+ "examples/simple_rack_app/hsload.rb"
+ ]
if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 3
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
- s.add_development_dependency(%q<rubyforge>, [">= 2.0.4"])
- s.add_development_dependency(%q<gemcutter>, [">= 0.5.0"])
- s.add_development_dependency(%q<hoe>, [">= 2.5.0"])
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
else
- s.add_dependency(%q<rubyforge>, [">= 2.0.4"])
- s.add_dependency(%q<gemcutter>, [">= 0.5.0"])
- s.add_dependency(%q<hoe>, [">= 2.5.0"])
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
end
else
- s.add_dependency(%q<rubyforge>, [">= 2.0.4"])
- s.add_dependency(%q<gemcutter>, [">= 0.5.0"])
- s.add_dependency(%q<hoe>, [">= 2.5.0"])
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
end
end
+
View
@@ -86,26 +86,25 @@ def hubrify(mod, args, src,packages=[])
if @always_rebuild or !File.exists?(libFile)
status,msg = Hubris.noisy("Hubrify #{headers} #{libraries} -v --module #{mod} --output #{libFile} #{args.join(' ')} " +
(packages+@@basepackages).collect{|x| "--package #{x}"}.join(' ') + ' ' + src)
- # if Hubrify's not installed, we throw an exception. just as good as explicitly checking a flag.
+ # if Hubrify's not installed, we throw an exception. just as
+ # good as explicitly checking a flag.
+ puts msg
raise HaskellError.new("Hubrify error:\n#{msg + status.exitstatus.to_s}") unless status.exitstatus == 0
end
return libFile
end
def dylib_suffix
case Config::CONFIG['target_os']
- when /darwin/
- "bundle"
- when /linux/
- "so"
- else
- "so" #take a punt
+ when /darwin/; "bundle"
+ when /linux/; "so"
+ else; "so" #take a punt
end
end
def self.noisy(str)
pid, stdin, stdout, stderr = Open4.popen4 str
- # puts "running #{str}\n"
+ puts "running #{str}\n"
# puts "Status: #{status.exitstatus}"
Oops, something went wrong.

0 comments on commit 37cf546

Please sign in to comment.