2010-11-02 09:29:12 +00:00
|
|
|
#!/usr/bin/ruby
|
|
|
|
|
|
|
|
require 'ERB'
|
|
|
|
|
|
|
|
$osgLibs = ['osgFX', 'osgParticle', 'osg', 'osgGA', 'osgText', 'osgUtil', 'osgSim', 'osgViewer', 'osgDB']
|
2010-11-09 19:09:05 +00:00
|
|
|
$osgPlugins = ['ac', 'osg', 'freetype', 'qt', 'imageio', 'rgb', 'txf', 'mdl', '3ds']
|
2010-11-04 18:47:17 +00:00
|
|
|
|
2010-11-05 08:33:17 +00:00
|
|
|
def runOsgVersion(option)
|
|
|
|
env = "export DYLD_LIBRARY_PATH=#{Dir.pwd}/dist/lib"
|
|
|
|
bin = Dir.pwd + "/dist/bin/osgversion"
|
|
|
|
return `#{env}; #{bin} --#{option}`.chomp
|
|
|
|
end
|
|
|
|
|
|
|
|
osgVersion = runOsgVersion('version-number')
|
|
|
|
$osgSoVersion=runOsgVersion('so-number')
|
|
|
|
$openThreadsSoVersion=runOsgVersion('openthreads-soversion-number')
|
|
|
|
|
|
|
|
puts "osgVersion=#{osgVersion}, so-number=#{$osgSoVersion}"
|
2010-11-04 18:47:17 +00:00
|
|
|
|
2010-11-02 09:29:12 +00:00
|
|
|
$alutSourcePath='/Library/Frameworks/ALUT.framework'
|
|
|
|
|
|
|
|
def fix_install_names(object)
|
|
|
|
#puts "fixing install names for #{object}"
|
|
|
|
|
|
|
|
$osgLibs.each do |l|
|
2010-11-04 18:47:17 +00:00
|
|
|
oldName = "lib#{l}.#{$osgSoVersion}.dylib"
|
2010-11-02 09:29:12 +00:00
|
|
|
newName = "@executable_path/../Frameworks/#{oldName}"
|
|
|
|
`install_name_tool -change #{oldName} #{newName} #{object}`
|
|
|
|
end
|
|
|
|
|
2010-11-05 08:33:17 +00:00
|
|
|
oldName = "libOpenThreads.#{$openThreadsSoVersion}.dylib"
|
2010-11-02 09:29:12 +00:00
|
|
|
newName= "@executable_path/../Frameworks/#{oldName}"
|
|
|
|
`install_name_tool -change #{oldName} #{newName} #{object}`
|
|
|
|
|
|
|
|
alutBundlePath = "@executable_path/../Frameworks/Alut.framework"
|
|
|
|
alutLib = "Versions/A/ALUT"
|
|
|
|
`install_name_tool -change #{$alutSourcePath}/#{alutLib} #{alutBundlePath}/#{alutLib} #{object}`
|
|
|
|
end
|
|
|
|
|
|
|
|
prefixDir=Dir.pwd + "/dist"
|
|
|
|
dmgDir=Dir.pwd + "/image"
|
|
|
|
srcDir=Dir.pwd + "/flightgear"
|
2010-11-14 22:58:21 +00:00
|
|
|
|
2010-11-02 09:29:12 +00:00
|
|
|
|
|
|
|
puts "Erasing previous image dir"
|
|
|
|
`rm -rf #{dmgDir}`
|
|
|
|
|
|
|
|
bundle=dmgDir + "/FlightGear.app"
|
|
|
|
contents=bundle + "/Contents"
|
|
|
|
macosDir=contents + "/MacOS"
|
|
|
|
frameworksDir=contents +"/Frameworks"
|
|
|
|
resourcesDir=contents+"/Resources"
|
2010-11-03 08:32:59 +00:00
|
|
|
osgPluginsDir=contents+"/PlugIns/osgPlugins-#{osgVersion}"
|
2010-11-02 09:29:12 +00:00
|
|
|
volName="\"FlightGear Nightly Build\""
|
|
|
|
|
2011-01-24 13:35:01 +00:00
|
|
|
fgVersion = File.read("#{srcDir}/version").strip
|
2010-11-14 18:14:23 +00:00
|
|
|
|
2011-01-24 13:48:01 +00:00
|
|
|
dmgPath = Dir.pwd + "/fg_mac_nightly_#{fgVersion}.dmg"
|
2010-11-14 22:58:21 +00:00
|
|
|
|
2010-11-02 09:29:12 +00:00
|
|
|
puts "Creating directory structure"
|
|
|
|
`mkdir -p #{macosDir}`
|
|
|
|
`mkdir -p #{frameworksDir}`
|
|
|
|
`mkdir -p #{resourcesDir}`
|
|
|
|
`mkdir -p #{osgPluginsDir}`
|
|
|
|
|
|
|
|
puts "Copying binaries"
|
|
|
|
bins = ['fgfs', 'terrasync', 'fgjs']
|
|
|
|
bins.each do |b|
|
|
|
|
`cp #{prefixDir}/bin/#{b} #{macosDir}/#{b}`
|
|
|
|
fix_install_names("#{macosDir}/#{b}")
|
|
|
|
end
|
|
|
|
|
|
|
|
puts "copying libraries"
|
|
|
|
$osgLibs.each do |l|
|
2010-11-04 18:47:17 +00:00
|
|
|
libFile = "lib#{l}.#{$osgSoVersion}.dylib"
|
2010-11-02 09:29:12 +00:00
|
|
|
`cp #{prefixDir}/lib/#{libFile} #{frameworksDir}`
|
|
|
|
fix_install_names("#{frameworksDir}/#{libFile}")
|
|
|
|
end
|
|
|
|
|
|
|
|
# and not forgetting OpenThreads
|
2010-11-05 08:33:17 +00:00
|
|
|
libFile = "libOpenThreads.#{$openThreadsSoVersion}.dylib"
|
2010-11-02 09:29:12 +00:00
|
|
|
`cp #{prefixDir}/lib/#{libFile} #{frameworksDir}`
|
|
|
|
|
|
|
|
$osgPlugins.each do |p|
|
|
|
|
pluginFile = "osgdb_#{p}.so"
|
2010-11-03 08:32:59 +00:00
|
|
|
`cp #{prefixDir}/lib/osgPlugins-#{osgVersion}/#{pluginFile} #{osgPluginsDir}`
|
2010-11-02 09:29:12 +00:00
|
|
|
fix_install_names("#{osgPluginsDir}/#{pluginFile}")
|
|
|
|
end
|
|
|
|
|
|
|
|
# custom ALUT
|
|
|
|
# must copy frameworks using ditto
|
|
|
|
`ditto #{$alutSourcePath} #{frameworksDir}/ALUT.framework`
|
|
|
|
|
|
|
|
# Info.plist
|
|
|
|
template = File.read("#{srcDir}/package/mac/nightly.plist.in")
|
|
|
|
output = ERB.new(template).result(binding)
|
|
|
|
|
|
|
|
File.open("#{contents}/Info.plist", 'w') { |f|
|
|
|
|
f.write(output)
|
|
|
|
}
|
|
|
|
|
|
|
|
`cp #{srcDir}/package/mac/nightly-readme.rtf #{dmgDir}/ReadMe.rtf`
|
|
|
|
`cp #{srcDir}/package/mac/FlightGear.icns #{resourcesDir}/FlightGear.icns`
|
|
|
|
`cp #{srcDir}/COPYING #{dmgDir}`
|
|
|
|
|
2011-01-24 13:35:01 +00:00
|
|
|
# Macflightgear launcher
|
|
|
|
puts "Copying Macflightgear launcher files"
|
|
|
|
|
|
|
|
Dir.chdir "macflightgear" do
|
|
|
|
`cp FlightGear #{macosDir}`
|
|
|
|
`rsync -a --exclude=\".svn\" *.rb *.lproj *.sh *.tiff #{resourcesDir}`
|
|
|
|
end
|
|
|
|
|
2010-11-02 09:29:12 +00:00
|
|
|
puts "Creating DMG"
|
|
|
|
|
|
|
|
createArgs = "-format UDBZ -imagekey bzip2-level=9 -quiet -volname #{volName}"
|
|
|
|
|
|
|
|
`rm #{dmgPath}`
|
|
|
|
`hdiutil create -srcfolder #{dmgDir} #{createArgs} #{dmgPath}`
|