require "bundler/gem_tasks"
require "rake/extensiontask"
require "rake/testtask"

Rake::ExtensionTask.new do |ext|
  ext.name  = "cext"
  ext.ext_dir = "ext/trilogy-ruby"
  ext.lib_dir = "lib/trilogy"
end

# When any of the parent library's files change, we need to re-run extconf
vendored_c_lib = FileList["ext/trilogy-ruby/src/**/*.c", "ext/trilogy-ruby/inc/**/*.h"]
if extconf_task = Rake.application.tasks.find { |t| t.name =~ /Makefile/ }
  task extconf_task => vendored_c_lib
end

Rake::TestTask.new do |t|
  t.libs << "test"
  t.test_files = FileList['test/*_test.rb']
  t.verbose = true
end
task :test => :compile

task :default => :test

task :console => :compile do
  sh "ruby -I lib -r trilogy -S irb"
end
