From fec0b28f14b900f1d011bd76b7b384aff9c2bcad Mon Sep 17 00:00:00 2001
From: James Turner <zakalawe@mac.com>
Date: Mon, 24 Jan 2011 13:35:01 +0000
Subject: [PATCH] Include Macflightgear files, and the build helper.

---
 package/mac/build-mac-nightly-dmg.rb     | 10 +++++++++-
 package/mac/hudson_mac_build_launcher.sh | 15 +++++++++++++++
 package/mac/nightly.plist.in             |  2 +-
 3 files changed, 25 insertions(+), 2 deletions(-)
 create mode 100755 package/mac/hudson_mac_build_launcher.sh

diff --git a/package/mac/build-mac-nightly-dmg.rb b/package/mac/build-mac-nightly-dmg.rb
index 2930ab305..39f170aa8 100755
--- a/package/mac/build-mac-nightly-dmg.rb
+++ b/package/mac/build-mac-nightly-dmg.rb
@@ -53,7 +53,7 @@ resourcesDir=contents+"/Resources"
 osgPluginsDir=contents+"/PlugIns/osgPlugins-#{osgVersion}"
 volName="\"FlightGear Nightly Build\""
 
-VERSION = File.read("#{srcDir}/version").strip
+fgVersion = File.read("#{srcDir}/version").strip
 
 dmgPath = Dir.pwd + "/fg_mac_nightly_#{VERSION}.dmg"
 
@@ -103,6 +103,14 @@ File.open("#{contents}/Info.plist", 'w') { |f|
 `cp #{srcDir}/package/mac/FlightGear.icns #{resourcesDir}/FlightGear.icns`
 `cp #{srcDir}/COPYING #{dmgDir}`
 
+# Macflightgear launcher
+puts "Copying Macflightgear launcher files"
+
+Dir.chdir "macflightgear" do
+  `cp FlightGear #{macosDir}`
+  `rsync -a --exclude=\".svn\" *.rb *.lproj *.sh *.tiff #{resourcesDir}`
+end
+
 puts "Creating DMG"
 
 createArgs = "-format UDBZ -imagekey bzip2-level=9 -quiet -volname #{volName}"
diff --git a/package/mac/hudson_mac_build_launcher.sh b/package/mac/hudson_mac_build_launcher.sh
new file mode 100755
index 000000000..4cf8e541b
--- /dev/null
+++ b/package/mac/hudson_mac_build_launcher.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+SDK_PATH="/Developer/SDKs/MacOSX10.5.sdk"
+OSX_TARGET="10.5"
+
+svn co https://macflightgear.svn.sourceforge.net/svnroot/macflightgear/trunk/FlightGearOSX  macflightgear
+
+pushd macflightgear
+
+# compile the stub executable
+gcc -o FlightGear -mmacosx-version-min=$OSX_TARGET -isysroot $SDK_PATH -arch i386 main.m \
+    -framework Cocoa -framework RubyCocoa -framework Foundation -framework AppKit
+
+popd
+
diff --git a/package/mac/nightly.plist.in b/package/mac/nightly.plist.in
index 0565abe93..fd9fe1892 100644
--- a/package/mac/nightly.plist.in
+++ b/package/mac/nightly.plist.in
@@ -15,7 +15,7 @@
 	<key>CFBundleIdentifier</key>
 	<string>org.flightgear.FlightGear</string>
 	<key>CFBundleVersion</key>
-	<string><%= VERSION %></string>
+	<string><%= fgVersion %></string>
 	<key>CFBundleShortVersionString</key>
 	<string>unstable nightly build</string>
 	<key>LSMinimumSystemVersion</key>