capybara-webkit/Rakefile

92 lines
2.3 KiB
Ruby
Raw Normal View History

2011-02-19 03:53:06 +00:00
require 'fileutils'
unless ENV["BUILD"]
require 'rubygems'
require 'bundler/setup'
require 'rspec/core/rake_task'
require 'rake/gempackagetask'
end
2011-02-19 03:53:06 +00:00
desc "Generate a Makefile using qmake"
file 'Makefile' do
sh("qmake -spec macx-g++")
end
desc "Regenerate dependencies using qmake"
task :qmake => 'Makefile' do
sh("make qmake")
end
desc "Build the webkit server"
task :build => :qmake do
sh("make")
FileUtils.mkdir("bin") unless File.directory?("bin")
if File.exist?("src/webkit_server.app")
FileUtils.cp("src/webkit_server.app/Contents/MacOS/webkit_server", "bin", :preserve => true)
2011-02-19 03:53:06 +00:00
else
FileUtils.cp("src/webkit_server", "bin", :preserve => true)
2011-02-19 03:53:06 +00:00
end
end
2011-02-26 23:28:42 +00:00
file 'bin/webkit_server' => :build
unless ENV["BUILD"]
RSpec::Core::RakeTask.new do |t|
t.pattern = "spec/**/*_spec.rb"
2011-02-26 23:28:42 +00:00
t.rspec_opts = "--format progress"
end
2011-02-19 03:53:06 +00:00
2011-02-26 23:28:42 +00:00
desc "Default: build and run all specs"
task :default => [:build, :spec]
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-04-13 18:30:17 +00:00
gem_file = "pkg/#{$specification.name}-#{$specification.version}.gem"
desc "Build and install the latest gem"
task :install => :gem do
sh("gem install --local #{gem_file}")
end
desc "Build and release the latest gem"
task :release => :gem do
sh("gem push #{gem_file}")
end
2011-02-26 23:28:42 +00:00
desc "Generate a new command called NAME"
task :generate_command do
name = ENV['NAME'] or raise "Provide a name with NAME="
header = "src/#{name}.h"
source = "src/#{name}.cpp"
%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)
end
end
end
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
File.open("src/find_command.h", "a") do |file|
file.write("CHECK_COMMAND(#{name})")
end
end
end
2011-02-19 03:53:06 +00:00