require 'rake/clean' require 'rake/packagetask' namespace :test do begin require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:p4_web_api) do |t| t.pattern = 'p4_web_api/clients/ruby/p4_web_api_client/spec/*.rb' end RSpec::Core::RakeTask.new(:p4_project_services) do |t| t.pattern = 'p4_project_services/clients/ruby/p4_project_services_client/spec/*.rb' end rescue Exception => e puts "Problems setting up :test tasks, ingoring #{e.message}" end end desc 'Rebuild native tools in qt/work directory (please set CMAKE_PREFIX_PATH in environment)' task :qt_build do FileUtils.rmtree('qt/work') if Dir.exist?('qt/work') FileUtils.mkdir('qt/work') system('cd qt/work && cmake .. && make') or fail('qt build failed') end CLEAN.include('qt/work') desc 'Run all qt tests' task :qt_test do system('cd qt/work/p4_phoenix_services_client && ./PhoenixIntegrationTests') or fail('PhoenixIntegrationTests failed') end desc 'Create doc directory from docbook files (requires ant)' directory 'build/doc' => 'docbook' do FileUtils.rmtree('build/doc') if Dir.exist?('build/doc') sh 'cd docbook && ant publicsite -Ddoc.build.path=../tools/p4-doc/manuals/_build && cd ..' end desc 'Archive Qt package in build/ directory' task :publish do if Dir.exist?('build') `chmod -R +w build` end Dir.mkdir('build') unless Dir.exist?('build') ['qt/p4_project_services_client', 'qt/p4_phoenix_services_client'].each do |project| project_name = File.basename(project) puts "Preparing project #{project_name} from #{project}" Dir.glob("#{project}/**/*").each do |file| relative_path = file[(project.length+1)..-1] if File.file?(file) FileUtils.mkdir_p("build/#{project_name}/#{File.dirname(relative_path)}") changelist=`p4 changes -m1 '//web-services/p4ws-main/...#have' | awk '{print $2}'`.strip contents = nil File.open(file, 'rb') do |f| contents = f.read.gsub('DEV', changelist) end File.open("build/#{project_name}/#{relative_path}", 'wb') do |f| f.write(contents) end end end end Dir.glob('') end Rake::PackageTask.new('p4ws', :noversion) do |p| p.need_tar = true #p.need_zip = true p.package_files.include('config/**') p.package_files.include('doc/**') p.package_files.include('docbook/**/*') p.package_files.include('notification_services/**/*') p.package_files.include('p4_phoenix_services/**/*') p.package_files.include('p4_project_services/**/*') p.package_files.include('p4_web_api/**/*') p.package_files.include('p4_web_services_auth/**/*') p.package_files.include('p4init/**/*') p.package_files.include('p4ruby/**/*') p.package_files.include('qt/**/*') p.package_files.include('salt/**/*') p.package_files.include('Gemfile') p.package_files.include('Rakefile') p.package_files.include('README.md') p.package_files.include('Vagrantfile') p.package_files.include('.p4ignore') end CLEAN.include('pkg')