3 # Ruby script for pulling together a MacOSX app bundle.
5 # it will be either powerpc or i386
6 versionline = `grep -m 1 '^ardour_version =' ../../SConstruct`
7 version = versionline.split(" = ")[1].chomp().slice(1..-2)
8 $stdout.printf("Version is %s\n", version)
10 arch = `uname -p`.strip()
11 libdir = "lib_" + arch
12 bindir = "bin_" + arch
14 ppc_libdir = "lib_powerpc"
15 i386_libdir = "lib_i386"
16 ppc_bindir = "bin_powerpc"
17 i386_bindir = "bin_i386"
18 ppc_binlib = "binlib_powerpc.zip"
19 i386_binlib = "binlib_i386.zip"
21 #$stdout.print("libdir is '" + libdir + "'\n")
23 # check for the other arch's libbin.zip
24 if arch == "i386" then
26 `rm -rf #{ppc_libdir} #{ppc_bindir}`
29 `rm -rf #{i386_libdir} #{i386_bindir}`
32 if File.exist?(zipfile) then
33 $stdout.print("Found #{zipfile} : unpacking...\n")
34 `unzip -aq #{zipfile}`
38 if File.exist?(libdir) then
41 #Dir.foreach(libdir) {|x| unless ( x[0] == 46 or File.stat(libdir+"/"+x).directory?) then File.delete(libdir + "/" +x) end}
46 if File.exist?(bindir) then
47 Dir.foreach(bindir) {|x| unless x[0] == 46 then File.delete(bindir + "/" +x) end}
52 if not File.exist?(libdir+"/surfaces") then
53 Dir.mkdir(libdir + "/surfaces")
60 result = `otool -L gtk2_ardour/ardour-#{version}`
61 results = result.split("\n")
64 result = `otool -L libs/ardour/libardour.dylib`
65 results = results + result.split("\n").slice(1,result.size-1)
67 result = `otool -L libs/surfaces/*/*.dylib`
68 results = results + result.split("\n").slice(1,result.size-1)
72 $stdout.print("Copying libs to #{libdir} ...\n");
76 # exclude frameworks, system libraries, X11 libraries, and libjack.
77 unless s =~ /System|\/usr\/lib|\/usr\/X11R6|libjack|:$/ then
78 #$stdout.print("Copying #{s}\n")
79 `cp #{s} #{odir}/#{libdir}/`
84 result = `otool -L #{odir}/#{libdir}/*.dylib`
85 results = result.split("\n")
89 # exclude frameworks, system libraries, X11 libraries, and libjack.
90 unless s =~ /System|\/usr\/lib|\/usr\/X11R6|libjack|:$/ then
91 sbase = File.basename(s)
92 targfile = "#{odir}/#{libdir}/#{sbase}"
93 #$stdout.print("Targ is : " + targfile + "\n")
94 if not File.exist?(targfile) then
95 #$stdout.print("2nd stage Copying #{s}\n")
96 `cp #{s} #{odir}/#{libdir}/`
104 # copy ardour binary to bindir/ardour
107 if File.exist?("../../gtk2_ardour/ardour-#{version}") then
108 $stdout.print("Copying bin to #{bindir} ...\n");
109 `cp ../../gtk2_ardour/ardour-#{version} #{bindir}/ardour`
112 `cp ../../libs/surfaces/*/*.dylib #{libdir}/surfaces`
113 # remove the basenames from libdir that are in surfaces (copied earlier)
114 `rm -f #{libdir}/surfaces/libardour_cp.dylib`
116 Dir.foreach(libdir+"/surfaces") {|x| unless ( x[0] == 46 or x.include?("libardour_cp")) then File.delete(libdir + "/" +x) end}
121 # copy gtk and pango lib stuff
122 `cp -R /opt/local/lib/pango #{libdir}/`
123 `cp -R /opt/local/lib/gtk-2.0 #{libdir}/`
126 `rm -f #{libdir}/gtk-2.0/2.*/engines/libclearlooks.*`
127 # must use .so for it to be found :/
128 `cp ../../libs/clearlooks/libclearlooks.dylib #{libdir}/gtk-2.0/2.10.0/engines/libclearlooks.so`
131 def lipo_platforms_recurse(src1, src2, target)
133 if not File.stat(src1).directory? then
134 # normal file, lets lipo them if it doesn't already exist there
135 isbin = `file #{src1}`.include?("Mach-O")
136 if (! File.exist?(target)) and isbin then
137 if File.exist?(src2) then
138 $stdout.print("Lipo'ing " + target + "\n")
139 `lipo -create -output #{target} #{src1} #{src2}`
142 $stdout.print("Copying " + src1 + "\n")
143 `cp #{src1} #{target}`
146 #$stdout.print("Skipping " + target + "\n")
149 # directory, recurse if necessary
150 if File.exist?(src2) then
151 # other dir exists, recurse
153 # make targetdir if necessary
154 if not File.exist?(target) then
158 Dir.foreach(src1) do |file|
159 if file[0] != 46 then
160 src1file = src1 + '/' + file
161 src2file = src2 + '/' + file
162 targfile = target + '/' + file
163 lipo_platforms_recurse(src1file, src2file, targfile)
167 # just copy it recursively to target
168 $stdout.print("Copying dir " + src1 + "\n")
169 `cp -R #{src1} #{target}`
174 # lipo stuff together if both platforms libs and bins are here
176 if File.exist?(ppc_libdir) and File.exist?(i386_libdir) then
177 $stdout.print("\nBoth platforms in place, lipo'ing...\n");
180 lipo_platforms_recurse(ppc_libdir, i386_libdir, "lib")
181 lipo_platforms_recurse(i386_libdir, ppc_libdir, "lib")
182 lipo_platforms_recurse(i386_bindir+'/ardour', ppc_bindir+'/ardour', "bin/ardour")
184 # remove existing Ardour2.app
187 $stdout.print("\nRunning Playtpus to create Ardour2.app ...\n");
189 `/usr/local/bin/platypus -D -X 'ardour' -a 'Ardour2' -t 'shell' -o 'None' -u 'Paul Davis' -i '/bin/sh' -V "#{version}" -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'`
191 $stdout.print("\nCopying other stuff to Ardour2.app ...\n");
193 if not File.exist?("Ardour2.app/Contents/Resources/etc") then
194 Dir.mkdir "Ardour2.app/Contents/Resources/etc"
197 if not File.exist?("Ardour2.app/Contents/Resources/etc/ardour2") then
198 Dir.mkdir "Ardour2.app/Contents/Resources/etc/ardour2"
200 `cp ../../gtk2_ardour/ardour.bindings ../../gtk2_ardour/ardour.colors ../../gtk2_ardour/ardour.menus Ardour2.app/Contents/Resources/etc/ardour2/`
201 `cp ../../ardour.rc ../../ardour_system.rc Ardour2.app/Contents/Resources/etc/ardour2/`
202 `cp ardour2_mac_ui.rc Ardour2.app/Contents/Resources/etc/ardour2/ardour2_ui.rc`
204 # copy other etc stuff
205 if not File.exist?("Ardour2.app/Contents/Resources/etc/gtk-2.0") then
206 `cp -R etc/gtk-2.0 Ardour2.app/Contents/Resources/etc/`
208 if not File.exist?("Ardour2.app/Contents/Resources/etc/pango") then
209 `cp -R etc/pango Ardour2.app/Contents/Resources/etc/`
211 if not File.exist?("Ardour2.app/Contents/Resources/etc/fonts") then
212 `cp -R /opt/local/etc/fonts Ardour2.app/Contents/Resources/etc/`
215 if not File.exist?("Ardour2.app/Contents/Resources/etc/profile.d") then
216 `cp -R etc/profile.d Ardour2.app/Contents/Resources/etc/`
221 if not File.exist?("Ardour2.app/Contents/Resources/share") then
222 Dir.mkdir "Ardour2.app/Contents/Resources/share"
225 if not File.exist?("Ardour2.app/Contents/Resources/share/ardour2") then
226 Dir.mkdir "Ardour2.app/Contents/Resources/share/ardour2"
227 Dir.mkdir "Ardour2.app/Contents/Resources/share/ardour2/templates"
228 `cp -R ../../gtk2_ardour/icons ../../gtk2_ardour/pixmaps ../../gtk2_ardour/splash.png Ardour2.app/Contents/Resources/share/ardour2/`
229 `cp ../../templates/*.template Ardour2.app/Contents/Resources/share/ardour2/templates/`
232 # go through and recursively remove any .svn dirs in the bundle
233 svndirs = `find Ardour2.app -name .svn -type dir`.split("\n")
234 svndirs.each do |svndir|
241 `cp -r README.rtf COPYING Ardour2.app macdist/`
242 dmgname = "Ardour-#{version}"
243 `rm -f #{dmgname}.dmg`
244 $stdout.print("\nCreating DMG\n")
245 `hdiutil create -fs HFS+ -volname #{dmgname} -srcfolder macdist #{dmgname}.dmg`
248 $stdout.print("\nDone\n")
251 # zip up libdir and bindir
252 zipfile = "binlib_"+`uname -p`.strip() + ".zip"
253 $stdout.print("Zipping up #{libdir} and #{bindir} into #{zipfile}...\n")
254 `zip -rq #{zipfile} #{libdir} #{bindir}`
255 $stdout.print("Copy #{zipfile} to other platform's osx_packaging dir and run app_build.rb\nthere to complete universal build.\n")