3 require 'rubygems' # needed for Ruby 1.8
6 $osgLibs = ['osgFX', 'osgParticle', 'osg', 'osgGA', 'osgText', 'osgUtil', 'osgSim', 'osgViewer', 'osgDB']
7 $osgPlugins = ['ac', 'osg', 'freetype', 'imageio', 'rgb', 'txf', 'mdl', '3ds', 'dds']
9 def runOsgVersion(option)
10 env = "export DYLD_LIBRARY_PATH=#{Dir.pwd}/dist/lib"
11 bin = Dir.pwd + "/dist/bin/osgversion"
12 return `#{env}; #{bin} --#{option}`.chomp
15 osgVersion = runOsgVersion('version-number')
16 $osgSoVersion=runOsgVersion('so-number')
17 $openThreadsSoVersion=runOsgVersion('openthreads-soversion-number')
19 $codeSignIdentity = ENV['FG_CODESIGN_IDENTITY']
20 puts "Code signing identity is #{$codeSignIdentity}"
22 puts "osgVersion=#{osgVersion}, so-number=#{$osgSoVersion}"
24 def fix_install_names(object)
25 puts "fixing install names for #{object}"
28 oldName = "lib#{l}.#{$osgSoVersion}.dylib"
29 newName = "@executable_path/../Frameworks/#{oldName}"
30 `install_name_tool -change #{oldName} #{newName} #{object}`
33 oldName = "libOpenThreads.#{$openThreadsSoVersion}.dylib"
34 newName= "@executable_path/../Frameworks/#{oldName}"
35 `install_name_tool -change #{oldName} #{newName} #{object}`
38 $prefixDir=Dir.pwd + "/dist"
39 dmgDir=Dir.pwd + "/image"
40 srcDir=Dir.pwd + "/flightgear"
42 puts "Erasing previous image dir"
45 bundle=dmgDir + "/FlightGear.app"
47 puts "Moving & renaming app bundle"
49 `mv #{$prefixDir}/fgfs.app #{bundle}`
51 contents=bundle + "/Contents"
52 macosDir=contents + "/MacOS"
53 $frameworksDir=contents +"/Frameworks"
54 resourcesDir=contents+"/Resources"
55 osgPluginsDir=contents+"/PlugIns/osgPlugins-#{osgVersion}"
56 volName="\"FlightGear Nightly Build\""
59 puts "Signing #{path}"
60 `codesign -s "#{$codeSignIdentity}" #{path}`
63 fgVersion = File.read("#{srcDir}/version").strip
65 dmgPath = Dir.pwd + "/fg_mac_nightly_#{fgVersion}.dmg"
67 puts "Creating directory structure"
68 `mkdir -p #{$frameworksDir}`
69 `mkdir -p #{resourcesDir}`
70 `mkdir -p #{osgPluginsDir}`
72 # fix install names on the primary executable
73 fix_install_names("#{macosDir}/fgfs")
75 puts "Copying auxilliary binaries"
76 bins = ['fgjs', 'fgcom']
78 if !File.exist?("#{$prefixDir}/bin/#{b}")
82 outPath = "#{macosDir}/#{b}"
83 `cp #{$prefixDir}/bin/#{b} #{outPath}`
84 fix_install_names(outPath)
87 puts "copying libraries"
89 libFile = "lib#{l}.#{$osgSoVersion}.dylib"
90 `cp #{$prefixDir}/lib/#{libFile} #{$frameworksDir}`
91 fix_install_names("#{$frameworksDir}/#{libFile}")
94 # and not forgetting OpenThreads
95 libFile = "libOpenThreads.#{$openThreadsSoVersion}.dylib"
96 `cp #{$prefixDir}/lib/#{libFile} #{$frameworksDir}`
98 $osgPlugins.each do |p|
99 pluginFile = "osgdb_#{p}.so"
100 `cp #{$prefixDir}/lib/osgPlugins-#{osgVersion}/#{pluginFile} #{osgPluginsDir}`
101 fix_install_names("#{osgPluginsDir}/#{pluginFile}")
104 `cp #{srcDir}/package/mac/nightly-readme.rtf #{dmgDir}/ReadMe.rtf`
105 `cp #{srcDir}/package/mac/FlightGear.icns #{resourcesDir}/FlightGear.icns`
106 `cp #{srcDir}/COPYING #{dmgDir}`
108 # Macflightgear launcher
109 if File.exist?("FlightGearOSX")
110 puts "Copying Macflightgear launcher files"
111 Dir.chdir "FlightGearOSX" do
112 `cp FlightGear #{macosDir}`
113 `rsync -a *.rb *.lproj *.sh *.tiff #{resourcesDir}`
116 # change CFBundleExecutable in to the Info.plist
117 puts "Adjusting CFBundle executable - needs Ruby plist gem installed"
118 plist = Plist::parse_xml("#{contents}/Info.plist")
119 plist["CFBundleExecutable"] = "FlightGear"
120 plist.save_plist("#{contents}/Info.plist")
123 if File.exist?("#{$prefixDir}/share/flightgear")
124 puts "Copying FGCom data files"
125 `ditto #{$prefixDir}/share/flightgear #{resourcesDir}`
128 # code sign all executables in MacOS dir. Do this last since reource
129 # changes will invalidate the signature!
130 Dir.foreach(macosDir) do |b|
131 if b == '.' or b == '..' then
134 code_sign("#{macosDir}/#{b}")
139 createArgs = "-format UDBZ -imagekey bzip2-level=9 -quiet -volname #{volName}"
142 `hdiutil create -srcfolder #{dmgDir} #{createArgs} #{dmgPath}`