3 # Ruby script for pulling together a MacOSX app bundle.
5 # it will be either powerpc or i386
7 arch = `uname -p`.strip()
11 ppc_libdir = "lib_powerpc"
12 i386_libdir = "lib_i386"
13 ppc_bindir = "bin_powerpc"
14 i386_bindir = "bin_i386"
15 ppc_binlib = "binlib_powerpc.zip"
16 i386_binlib = "binlib_i386.zip"
18 #$stdout.print("libdir is '" + libdir + "'\n")
20 # check for the other arch's libbin.zip
21 if arch == "i386" then
23 `rm -rf #{ppc_libdir} #{ppc_bindir}`
26 `rm -rf #{i386_libdir} #{i386_bindir}`
29 if File.exist?(zipfile) then
30 $stdout.print("Found #{zipfile} : unpacking...\n")
31 `unzip -aq #{zipfile}`
35 if File.exist?(libdir) then
38 #Dir.foreach(libdir) {|x| unless ( x[0] == 46 or File.stat(libdir+"/"+x).directory?) then File.delete(libdir + "/" +x) end}
43 if File.exist?(bindir) then
44 Dir.foreach(bindir) {|x| unless x[0] == 46 then File.delete(bindir + "/" +x) end}
49 if not File.exist?(libdir+"/surfaces") then
50 Dir.mkdir(libdir + "/surfaces")
57 result = `otool -L gtk2_ardour/ardour.bin`
58 results = result.split("\n")
61 result = `otool -L libs/ardour/libardour.dylib`
62 results = results + result.split("\n").slice(1,result.size-1)
64 result = `otool -L libs/surfaces/*/*.dylib`
65 results = results + result.split("\n").slice(1,result.size-1)
69 $stdout.print("Copying libs to #{libdir} ...\n");
73 # exclude frameworks, system libraries, X11 libraries, and libjack.
74 unless s =~ /System|\/usr\/lib|\/usr\/X11R6|libjack|:$/ then
75 #$stdout.print("Copying #{s}\n")
76 `cp #{s} #{odir}/#{libdir}/`
81 result = `otool -L #{odir}/#{libdir}/*.dylib`
82 results = result.split("\n")
86 # exclude frameworks, system libraries, X11 libraries, and libjack.
87 unless s =~ /System|\/usr\/lib|\/usr\/X11R6|libjack|:$/ then
88 sbase = File.basename(s)
89 targfile = "#{odir}/#{libdir}/#{sbase}"
90 #$stdout.print("Targ is : " + targfile + "\n")
91 if not File.exist?(targfile) then
92 #$stdout.print("2nd stage Copying #{s}\n")
93 `cp #{s} #{odir}/#{libdir}/`
101 # copy ardour.bin to bindir/ardour
102 $stdout.print("Copying bin to #{bindir} ...\n");
104 if File.exist?("../../gtk2_ardour/ardour.bin") then
105 `cp ../../gtk2_ardour/ardour.bin #{bindir}/ardour`
108 `cp ../../libs/surfaces/*/*.dylib #{libdir}/surfaces`
109 # remove the basenames from libdir that are in surfaces (copied earlier)
111 Dir.foreach(libdir+"/surfaces") {|x| unless ( x[0] == 46 or x.include?("libardour_cp")) then File.delete(libdir + "/" +x) end}
116 # copy gtk and pango lib stuff
117 `cp -R /opt/local/lib/pango #{libdir}/`
118 `cp -R /opt/local/lib/gtk-2.0 #{libdir}/`
121 `rm -f #{libdir}/gtk-2.0/2.*/engines/libclearlooks.*`
122 # must use .so for it to be found :/
123 `cp ../../libs/clearlooks/libclearlooks.dylib #{libdir}/gtk-2.0/2.10.0/engines/libclearlooks.so`
126 def lipo_platforms_recurse(src1, src2, target)
128 if not File.stat(src1).directory? then
129 # normal file, lets lipo them if it doesn't already exist there
130 isbin = `file #{src1}`.include?("Mach-O")
131 if (! File.exist?(target)) and isbin then
132 if File.exist?(src2) then
133 $stdout.print("Lipo'ing " + target + "\n")
134 `lipo -create -output #{target} #{src1} #{src2}`
137 $stdout.print("Copying " + src1 + "\n")
138 `cp #{src1} #{target}`
141 #$stdout.print("Skipping " + target + "\n")
144 # directory, recurse if necessary
145 if File.exist?(src2) then
146 # other dir exists, recurse
148 # make targetdir if necessary
149 if not File.exist?(target) then
153 Dir.foreach(src1) do |file|
154 if file[0] != 46 then
155 src1file = src1 + '/' + file
156 src2file = src2 + '/' + file
157 targfile = target + '/' + file
158 lipo_platforms_recurse(src1file, src2file, targfile)
162 # just copy it recursively to target
163 $stdout.print("Copying dir " + src1 + "\n")
164 `cp -R #{src1} #{target}`
169 # lipo stuff together if both platforms libs and bins are here
171 if File.exist?(ppc_libdir) and File.exist?(i386_libdir) then
172 $stdout.print("\nBoth platforms in place, lipo'ing...\n");
174 lipo_platforms_recurse(ppc_libdir, i386_libdir, "lib")
175 lipo_platforms_recurse(i386_libdir, ppc_libdir, "lib")
176 lipo_platforms_recurse(i386_bindir+'/ardour', ppc_bindir+'/ardour', "bin/ardour")
178 # remove existing Ardour2.app
181 $stdout.print("\nRunning Playtpus to create Ardour2.app ...\n");
183 `/usr/local/bin/platypus -D -X 'ardour' -a 'Ardour2' -t 'shell' -o 'None' -u 'Paul Davis' -i '/bin/sh' -V '2.0' -s 'ArDr' -I 'org.ardour.Ardour2' -f 'bin' -f 'lib' -i 'Ardour2.icns' -f 'MenuBar.nib' -f 'ProgressWindow.nib' -f 'init' -f 'openDoc' 'script' 'Ardour2.app'`
185 $stdout.print("\nCopying other stuff to Ardour2.app ...\n");
187 if not File.exist?("Ardour2.app/Contents/Resources/etc") then
188 Dir.mkdir "Ardour2.app/Contents/Resources/etc"
191 if not File.exist?("Ardour2.app/Contents/Resources/etc/ardour2") then
192 Dir.mkdir "Ardour2.app/Contents/Resources/etc/ardour2"
194 `cp ../../gtk2_ardour/ardour.bindings ../../gtk2_ardour/ardour.colors ../../gtk2_ardour/ardour.menus Ardour2.app/Contents/Resources/etc/ardour2/`
195 `cp ../../ardour.rc ../../ardour_system.rc Ardour2.app/Contents/Resources/etc/ardour2/`
196 `cp ardour2_mac_ui.rc Ardour2.app/Contents/Resources/etc/ardour2/ardour2_ui.rc`
198 # copy other etc stuff
199 if not File.exist?("Ardour2.app/Contents/Resources/etc/gtk-2.0") then
200 `cp -R etc/gtk-2.0 Ardour2.app/Contents/Resources/etc/`
202 if not File.exist?("Ardour2.app/Contents/Resources/etc/pango") then
203 `cp -R etc/pango Ardour2.app/Contents/Resources/etc/`
205 if not File.exist?("Ardour2.app/Contents/Resources/etc/fonts") then
206 `cp -R /opt/local/etc/fonts Ardour2.app/Contents/Resources/etc/`
209 if not File.exist?("Ardour2.app/Contents/Resources/etc/profile.d") then
210 `cp -R etc/profile.d Ardour2.app/Contents/Resources/etc/`
215 if not File.exist?("Ardour2.app/Contents/Resources/share") then
216 Dir.mkdir "Ardour2.app/Contents/Resources/share"
219 if not File.exist?("Ardour2.app/Contents/Resources/share/ardour2") then
220 Dir.mkdir "Ardour2.app/Contents/Resources/share/ardour2"
221 Dir.mkdir "Ardour2.app/Contents/Resources/share/ardour2/templates"
222 `cp -R ../../gtk2_ardour/icons ../../gtk2_ardour/pixmaps ../../gtk2_ardour/splash.png Ardour2.app/Contents/Resources/share/ardour2/`
223 `cp ../../templates/*.template Ardour2.app/Contents/Resources/share/ardour2/templates/`
226 # go through and recursively remove any .svn dirs in the bundle
227 svndirs = `find Ardour2.app -name .svn -type dir`.split("\n")
228 svndirs.each do |svndir|
235 `cp -r README.rtf COPYING Ardour2.app macdist/`
236 dmgname = "Ardour2-#{version}"
237 `rm -f #{dmgname}.dmg`
238 $stdout.print("\nCreating DMG\n")
239 `hdiutil create -fs HFS+ -volname #{dmgname} -srcfolder macdist #{dmgname}.dmg`
242 $stdout.print("\nDone\n")
245 # zip up libdir and bindir
246 zipfile = "binlib_"+`uname -p`.strip() + ".zip"
247 $stdout.print("\nZipping up #{libdir} and #{bindir} into #{zipfile}\n")
248 $stdout.print("Copy #{zipfile} to other platform's osx_packaging dir and run app_build.rb\nthere to complete universal build.\n")
249 `zip -rq #{zipfile} #{libdir} #{bindir}`