#!/usr/bin/env ruby # DISCLAIMER: this is not Mozilla's mach require 'optparse' options = { :settingsDir => "../build/config", :profile => 'qt5', :build => 'release', :buildDir => '../build', } OptionParser.new do |opts| opts.banner = "Usage: ./mach [options]" opts.on("-h", "--help", "Prints this help") do puts opts puts "Options: #{options}" puts 'Commands: setup, run, clean, build' exit end opts.on("--profile", "Set profile") do |profile| options[:profile] = profile end opts.on("-d", "--build DIRECTORY", "Build location") do |dir| options[:buildDir] = dir end opts.on("-i", "--install DIRECTORY", "Install location") do |dir| options[:installDir] = dir end opts.on("--debug", "Debug build") do options[:build] = 'debug' end opts.on("--release", "Release build") do options[:build] = 'release' end end.parse! if not ARGV.empty? then ARGV.each do|arg| case arg when 'setup' system "qbs-setup-toolchains --settings-dir #{options[:settingsDir]} --detect" system "qbs-setup-qt --settings-dir #{options[:settingsDir]} /usr/bin/qmake-qt5 #{options[:profile]}" when 'run' system "qbs run --settings-dir #{options[:settingsDir]} -d #{options[:buildDir]} -p poi profile:#{options[:profile]} #{options[:build]}" when 'clean' system "qbs clean --settings-dir #{options[:settingsDir]} -d #{options[:buildDir]} profile:#{options[:profile]} #{options[:build]}" when 'build' system "qbs build --settings-dir #{options[:settingsDir]} -d #{options[:buildDir]} --force-probe-execution profile:#{options[:profile]} #{options[:build]}" else puts "Unknown argument #{arg}; use ./mach -h for more details" end end else puts 'No arguments; use ./mach -h for more details' end