require 'rake/clean' require 'rake/packagetask' Rake::PackageTask.new('helix-web-services', :noversion) do |package| package.need_tar = true package.package_files.include('build/**/*') package.package_files.include('doc/**/*') package.package_files.include('helix_web_services/**/*') package.package_files.include('helix_web_services_client/**/*') package.package_files.include('packaging/**/*') package.package_files.include('Gemfile') package.package_files.include('Gemfile.lock') package.package_files.include('Rakefile') package.package_files.include('README.md') end namespace :nginx do desc 'Creates the nginx config in work/' task :config do Dir.mkdir('work') unless Dir.exist?('work') File.open('work/nginx.conf', 'w') do |f| f.puts <<-END.gsub(/^[ ]{8}/, '') pid #{File.absolute_path('work/nginx.pid')}; error_log #{File.absolute_path('work/nginx.errors.log')}; worker_processes 10; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] $status ' '"$request" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log #{File.absolute_path('work/nginx.access.log')} main; map $http_upgrade $connection_upgrade { default Upgrade; '' close; } server { listen 8080; location /hws { rewrite /hws/(.*) /$1 break; proxy_pass $scheme://127.0.0.1:9000; } location / { root #{File.absolute_path('helix_web_components')}; include /usr/local/etc/nginx/mime.types; } } } END end end desc 'Start nginx locally' task :start => :config do sh "nginx -c #{File.absolute_path('work/nginx.conf')}" or fail 'nginx failed' end desc 'Stop local nginx' task :stop do if File.exist?('work/nginx.pid') pid = IO.read('work/nginx.pid').to_i Process.kill('TERM', pid) end end end namespace :qt do desc 'Rebuild native tools in qt/work directory (please set CMAKE_PREFIX_PATH in environment)' task :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 :test do system('cd qt/work/p4_phoenix_services_client && ./PhoenixIntegrationTests') or fail('PhoenixIntegrationTests failed') 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') ['helix_web_services_client_qt'].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 ...#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 end