2011-04-15 17:19:26 -04:00
|
|
|
require 'rubygems'
|
|
|
|
require 'bundler/setup'
|
|
|
|
require 'rspec/core/rake_task'
|
|
|
|
require 'rake/gempackagetask'
|
|
|
|
require 'capybara_webkit_builder'
|
2011-02-18 22:53:06 -05:00
|
|
|
|
|
|
|
desc "Generate a Makefile using qmake"
|
|
|
|
file 'Makefile' do
|
2011-04-15 17:19:26 -04:00
|
|
|
CapybaraWebkitBuilder.makefile
|
2011-02-18 22:53:06 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Regenerate dependencies using qmake"
|
|
|
|
task :qmake => 'Makefile' do
|
2011-04-15 17:19:26 -04:00
|
|
|
CapybaraWebkitBuilder.qmake
|
2011-02-18 22:53:06 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Build the webkit server"
|
|
|
|
task :build => :qmake do
|
2011-04-15 17:19:26 -04:00
|
|
|
CapybaraWebkitBuilder.build
|
2011-02-18 22:53:06 -05:00
|
|
|
end
|
|
|
|
|
2011-02-26 18:28:42 -05:00
|
|
|
file 'bin/webkit_server' => :build
|
|
|
|
|
2011-04-15 17:19:26 -04:00
|
|
|
RSpec::Core::RakeTask.new do |t|
|
|
|
|
t.pattern = "spec/**/*_spec.rb"
|
|
|
|
t.rspec_opts = "--format progress"
|
|
|
|
end
|
2011-02-18 22:53:06 -05:00
|
|
|
|
2011-04-15 17:19:26 -04:00
|
|
|
desc "Default: build and run all specs"
|
|
|
|
task :default => [:build, :spec]
|
2011-02-26 18:28:42 -05:00
|
|
|
|
2011-04-15 17:19:26 -04:00
|
|
|
eval("$specification = begin; #{IO.read('capybara-webkit.gemspec')}; end")
|
|
|
|
Rake::GemPackageTask.new($specification) do |package|
|
|
|
|
package.need_zip = true
|
|
|
|
package.need_tar = true
|
|
|
|
end
|
2011-02-26 18:28:42 -05:00
|
|
|
|
2011-04-15 17:19:26 -04:00
|
|
|
gem_file = "pkg/#{$specification.name}-#{$specification.version}.gem"
|
2011-04-13 14:30:17 -04:00
|
|
|
|
2011-04-15 17:19:26 -04:00
|
|
|
desc "Build and install the latest gem"
|
|
|
|
task :install => :gem do
|
|
|
|
sh("gem install --local #{gem_file}")
|
|
|
|
end
|
2011-04-13 14:30:17 -04:00
|
|
|
|
2011-04-15 17:19:26 -04:00
|
|
|
desc "Build and release the latest gem"
|
|
|
|
task :release => :gem do
|
|
|
|
sh("gem push #{gem_file}")
|
|
|
|
end
|
2011-04-13 14:30:17 -04:00
|
|
|
|
2011-04-15 17:19:26 -04:00
|
|
|
desc "Generate a new command called NAME"
|
|
|
|
task :generate_command do
|
|
|
|
name = ENV['NAME'] or raise "Provide a name with NAME="
|
2011-02-26 18:28:42 -05:00
|
|
|
|
2011-04-15 17:19:26 -04:00
|
|
|
header = "src/#{name}.h"
|
|
|
|
source = "src/#{name}.cpp"
|
2011-02-26 18:28:42 -05:00
|
|
|
|
2011-04-15 17:19:26 -04:00
|
|
|
%w(h cpp).each do |extension|
|
|
|
|
File.open("templates/Command.#{extension}", "r") do |source_file|
|
|
|
|
contents = source_file.read
|
|
|
|
contents.gsub!("NAME", name)
|
|
|
|
File.open("src/#{name}.#{extension}", "w") do |target_file|
|
|
|
|
target_file.write(contents)
|
2011-02-26 18:28:42 -05:00
|
|
|
end
|
|
|
|
end
|
2011-04-15 17:19:26 -04:00
|
|
|
end
|
2011-02-26 18:28:42 -05:00
|
|
|
|
2011-04-15 17:19:26 -04:00
|
|
|
Dir.glob("src/*.pro").each do |project_file_name|
|
|
|
|
project = IO.read(project_file_name)
|
|
|
|
project.gsub!(/^(HEADERS = .*)/, "\\1 #{name}.h")
|
|
|
|
project.gsub!(/^(SOURCES = .*)/, "\\1 #{name}.cpp")
|
|
|
|
File.open(project_file_name, "w") { |file| file.write(project) }
|
|
|
|
end
|
2011-02-26 18:28:42 -05:00
|
|
|
|
2011-04-15 17:19:26 -04:00
|
|
|
File.open("src/find_command.h", "a") do |file|
|
|
|
|
file.write("CHECK_COMMAND(#{name})")
|
2011-02-26 18:28:42 -05:00
|
|
|
end
|
|
|
|
end
|