2011-11-11 20:31:21 -05:00
|
|
|
require 'bundler'
|
2011-04-15 17:19:26 -04:00
|
|
|
require 'rspec/core/rake_task'
|
|
|
|
require 'capybara_webkit_builder'
|
2011-09-30 17:55:28 -04:00
|
|
|
require 'appraisal'
|
2011-02-18 22:53:06 -05:00
|
|
|
|
2011-11-11 20:31:21 -05:00
|
|
|
Bundler::GemHelper.install_tasks
|
|
|
|
|
2011-02-18 22:53:06 -05:00
|
|
|
desc "Generate a Makefile using qmake"
|
|
|
|
file 'Makefile' do
|
2013-11-10 17:03:11 -05:00
|
|
|
CapybaraWebkitBuilder.makefile('CONFIG+=test') or exit(1)
|
2011-02-18 22:53:06 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Regenerate dependencies using qmake"
|
|
|
|
task :qmake => 'Makefile' do
|
2011-05-05 17:45:44 -04:00
|
|
|
CapybaraWebkitBuilder.qmake or exit(1)
|
2011-02-18 22:53:06 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Build the webkit server"
|
|
|
|
task :build => :qmake do
|
2011-05-05 17:45:44 -04:00
|
|
|
CapybaraWebkitBuilder.build or exit(1)
|
2011-02-18 22:53:06 -05:00
|
|
|
end
|
|
|
|
|
2013-11-10 16:52:01 -05:00
|
|
|
desc "Run QtTest unit tests for webkit server"
|
2013-11-10 17:03:11 -05:00
|
|
|
task :check => :build do
|
2013-11-10 16:52:01 -05:00
|
|
|
sh("make check") or exit(1)
|
|
|
|
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
|
|
|
|
2013-11-10 17:03:11 -05:00
|
|
|
task :spec => :build
|
|
|
|
|
2011-04-15 17:19:26 -04:00
|
|
|
desc "Default: build and run all specs"
|
2013-11-10 16:52:01 -05:00
|
|
|
task :default => [:check, :spec]
|
2011-02-26 18:28:42 -05: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
|
|
|
%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)
|
2012-02-05 10:29:58 -05:00
|
|
|
project.gsub!(/^(HEADERS = .*)/, "\\1\n #{name}.h \\")
|
|
|
|
project.gsub!(/^(SOURCES = .*)/, "\\1\n #{name}.cpp \\")
|
2011-04-15 17:19:26 -04:00
|
|
|
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|
|
2012-02-05 10:29:58 -05:00
|
|
|
file.write("CHECK_COMMAND(#{name})\n")
|
2011-02-26 18:28:42 -05:00
|
|
|
end
|
2012-02-05 10:29:58 -05:00
|
|
|
|
|
|
|
command_factory_file_name = "src/CommandFactory.cpp"
|
|
|
|
command_factory = IO.read(command_factory_file_name)
|
|
|
|
command_factory.sub!(/^$/, "#include \"#{name}.h\"\n")
|
|
|
|
File.open(command_factory_file_name, "w") { |file| file.write(command_factory) }
|
2011-02-26 18:28:42 -05:00
|
|
|
end
|