1
0
Fork 0
fgmeta/compile-scripts/commands-mac.rb
James Turner 224a9a0b18 Add my Mac and Linux build helpers.
This is to save new contributors some time getting a build env, since
download-and-compile produces a slightly Baroque setup for day-to-day
development.
2016-12-11 00:18:45 +00:00

134 lines
2.9 KiB
Ruby
Executable file

#!/usr/bin/ruby
require 'fileutils'
require 'optparse'
include FileUtils
baseDir = Dir.pwd
gitArgs = ""
qtPath = ""
doPull = false
doCMake = false
doInit = false
doClean = false
doPackage = false
cmakeCommonArgs = "-G Xcode -DCMAKE_INSTALL_PREFIX=#{baseDir}/dist"
cmakeSGArgs = "-DSIMGEAR_SHARED=1 -DENABLE_CURL=0"
cmakeFGArgs = "-DSIMGEAR_SHARED=1"
sfUser = "jmturner"
OptionParser.new do |opts|
opts.banner = "Usage: commands.rb [options]"
opts.on("", "--init", "Setup empty") do |v|
doInit = v
end
opts.on("-p", "--[no-]pull", "Pull from Git") do |v|
doPull = v
end
opts.on("-c", "--cmake", "Run Cmake") do |v|
doCMake = v
end
opts.on("", "--clean", "Clean build dirs") do |v|
doClean = v
end
opts.on("-r", "--rebase", "Rebase when pulling") do |v|
gitArgs += "--rebase"
end
opts.on("", "--qt=QTPATH", "Set Qt path when running cmake") do |v|
qtPath = v
end
end.parse!(ARGV)
def cloneEverything()
puts "Initialising"
if File.exist?("#{Dir.pwd}/simgear") or File.exist?("#{Dir.pwd}/flightgear")
puts "Checkout already exists"
return
end
`git clone ssh://#{sfUser}@git.code.sf.net/p/flightgear/simgear simgear`
`git clone ssh://#{sfUser}@git.code.sf.net/p/flightgear/flightgear flightgear`
`git clone git@github.com:zakalawe/osg.git osg`
end
def createDirs()
`mkdir -p sgbuild`
`mkdir -p fgbuild`
`mkdir -p osg_mac_release_build`
end
# path is needed for Cmake & running macdeployqt
if qtPath != ""
ENV['PATH'] = "#{ENV['PATH']}:#{qtPath}/bin"
end
if doClean
puts "Cleaning build dirs"
`rm -r sgbuild`
`rm -r fgbuild`
`rm -r osg_mac_release_build`
createDirs()
end
if doInit
puts "Doing init"
cloneEverything()
createDirs();
end
if doPull
puts "Pulling from Git"
dataPull = Thread.new do
puts "Syncing FGData"
Dir.chdir "#{baseDir}/fgdata"
`git pull #{gitArgs}`
end
Dir.chdir "#{baseDir}/simgear"
`git pull #{gitArgs}`
Dir.chdir "#{baseDir}/flightgear"
`git pull #{gitArgs}`
end
Dir.chdir "#{baseDir}/osg_mac_release_build"
if doCMake or !File.exist?("#{Dir.pwd}/Makefile")
`cmake ../osg -DCMAKE_INSTALL_PREFIX=#{baseDir}/dist`
end
puts "Building OpenSceneGraph"
`make -j4`
`make install`
Dir.chdir "#{baseDir}/sgbuild"
if doCMake or !File.exist?("#{Dir.pwd}/SimGear.xcodeproj")
`cmake ../simgear #{cmakeCommonArgs} #{cmakeSGArgs}`
end
puts "Building SimGear Debug"
`xcodebuild -target install -configuration Debug`
puts "Building SimGear Release"
`xcodebuild -target install -configuration Release`
Dir.chdir "#{baseDir}/fgbuild"
if doCMake or !File.exist?("#{Dir.pwd}/FlightGear.xcodeproj")
if qtPath != ""
cmakeFGArgs = '-DENABLE_QT=1'
end
`cmake ../flightgear #{cmakeCommonArgs} #{cmakeFGArgs}`
end
puts "Building FlightGear Debug"
`xcodebuild -target fgfs -configuration Debug`
puts "Building FlightGear Release"
`xcodebuild -target fgfs -configuration Release`
puts "All done."