Fix for nonstandard mono paths.

This commit is contained in:
Paul Chote
2011-01-05 15:26:47 +13:00
parent 22bf9e7aff
commit 2e9a0b8162
11 changed files with 48 additions and 45 deletions

View File

@@ -21,6 +21,7 @@
NSMutableArray *httpRequests;
NSMutableDictionary *downloads;
BOOL hasMono;
NSString *monoPath;
IBOutlet NSWindow *window;
IBOutlet NSOutlineView *outlineView;
@@ -37,5 +38,5 @@
- (void)fetchURL:(NSString *)url withCallback:(NSString *)cb;
- (BOOL)registerDownload:(NSString *)key withURL:(NSString *)url filePath:(NSString *)path;
- (Download *)downloadWithKey:(NSString *)key;
- (BOOL)hasSupportedMono;
- (BOOL)initMono;
@end

View File

@@ -30,13 +30,16 @@
{
NSString *gamePath = [[NSUserDefaults standardUserDefaults] stringForKey:@"gamepath"];
game = [[GameInstall alloc] initWithPath:gamePath];
[[JSBridge sharedInstance] setController:self];
downloads = [[NSMutableDictionary alloc] init];
httpRequests = [[NSMutableArray alloc] init];
hasMono = [self hasSupportedMono];
hasMono = [self initMono];
NSLog(@"%d, %@",hasMono, monoPath);
if (hasMono)
{
game = [[GameInstall alloc] initWithGamePath:gamePath monoPath:monoPath];
[[JSBridge sharedInstance] setController:self];
downloads = [[NSMutableDictionary alloc] init];
httpRequests = [[NSMutableArray alloc] init];
NSTableColumn *col = [outlineView tableColumnWithIdentifier:@"mods"];
ImageAndTextCell *imageAndTextCell = [[[ImageAndTextCell alloc] init] autorelease];
[col setDataCell:imageAndTextCell];
@@ -88,15 +91,13 @@
[[NSApplication sharedApplication] terminate:self];
}
- (BOOL)hasSupportedMono
- (BOOL)initMono
{
if (![[NSFileManager defaultManager] fileExistsAtPath:@"/Library/Frameworks/Mono.framework/Commands/mono"])
return NO;
// Find the users mono
NSPipe *outPipe = [NSPipe pipe];
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/Library/Frameworks/Mono.framework/Commands/mono"];
[task setArguments:[NSMutableArray arrayWithObject:@"--version"]];
[task setLaunchPath:@"/usr/bin/which"];
[task setArguments:[NSMutableArray arrayWithObject:@"mono"]];
[task setStandardOutput:outPipe];
[task setStandardError:[task standardOutput]];
[task launch];
@@ -105,6 +106,27 @@
[task waitUntilExit];
[task release];
NSString *temp = [[[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding] autorelease];
// Remove whitespace and resolve symlinks
monoPath = [[[temp stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]
stringByResolvingSymlinksInPath] retain];
if (![monoPath length])
return NO;
// Find the mono version
outPipe = [NSPipe pipe];
task = [[NSTask alloc] init];
[task setLaunchPath:monoPath];
[task setArguments:[NSMutableArray arrayWithObject:@"--version"]];
[task setStandardOutput:outPipe];
[task setStandardError:[task standardOutput]];
[task launch];
data = [[outPipe fileHandleForReading] readDataToEndOfFile];
[task waitUntilExit];
[task release];
NSString *ret = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
int major = 0;
@@ -112,6 +134,7 @@
int point = 0;
sscanf([ret UTF8String], "Mono JIT compiler version %d.%d.%d", &major, &minor, &point);
[ret release];
NSLog(@"mono %d.%d.%d: %@",major,minor,point,monoPath);
return (major > 2 ||
(major == 2 && minor > 6) ||
@@ -123,6 +146,7 @@
[sidebarItems release]; sidebarItems = nil;
[downloads release]; downloads = nil;
[httpRequests release]; httpRequests = nil;
[monoPath release]; monoPath = nil;
[super dealloc];
}

View File

@@ -12,12 +12,12 @@
@class Controller;
@interface GameInstall : NSObject {
NSString *gamePath;
Controller *controller;
NSString *monoPath;
NSMutableDictionary *downloadTasks;
}
@property(readonly) NSString *gamePath;
-(id)initWithPath:(NSString *)path;
-(id)initWithGamePath:(NSString *)gamepath monoPath:(NSString *)monopath;
-(void)launchMod:(NSString *)mod;
- (NSString *)runUtilityQuery:(NSString *)arg;
- (NSArray *)installedMods;

View File

@@ -13,12 +13,13 @@
@implementation GameInstall
@synthesize gamePath;
-(id)initWithPath:(NSString *)path
-(id)initWithGamePath:(NSString *)gamepath monoPath:(NSString *)monopath
{
self = [super init];
if (self != nil)
{
gamePath = [path retain];
gamePath = [gamepath retain];
monoPath = [monopath retain];
downloadTasks = [[NSMutableDictionary alloc] init];
}
return self;
@@ -27,6 +28,7 @@
- (void)dealloc
{
[gamePath release]; gamePath = nil;
[monoPath release]; monoPath = nil;
[downloadTasks release]; downloadTasks = nil;
[super dealloc];
}
@@ -98,7 +100,7 @@
// First argument is the directory to run in
// Second...Nth arguments are passed to OpenRA.Game.exe
// Launcher wrapper sets mono --debug, gl renderer and support dir.
NSArray *args = [NSArray arrayWithObjects:@"--launch", gamePath,
NSArray *args = [NSArray arrayWithObjects:@"--launch", gamePath, monoPath,
[NSString stringWithFormat:@"SupportDir=%@",[@"~/Library/Application Support/OpenRA" stringByExpandingTildeInPath]],
[NSString stringWithFormat:@"Game.Mods=%@",mod],
nil];
@@ -132,7 +134,7 @@
NSTask *task = [[NSTask alloc] init];
[task setCurrentDirectoryPath:gamePath];
[task setLaunchPath:@"/Library/Frameworks/Mono.framework/Commands/mono"];
[task setLaunchPath:monoPath];
[task setArguments:taskArgs];
[task setStandardOutput:outPipe];
[task setStandardError:[task standardOutput]];
@@ -156,7 +158,7 @@
[taskArgs addObject:arg];
[task setCurrentDirectoryPath:gamePath];
[task setLaunchPath:@"/Library/Frameworks/Mono.framework/Commands/mono"];
[task setLaunchPath:monoPath];
[task setArguments:taskArgs];
[task setStandardOutput:pipe];

Binary file not shown.

View File

@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>OpenRA</string>
<key>CFBundleExecutable</key>
<string>OpenRA</string>
<key>CFBundleIconFile</key>
<string>OpenRA.icns</string>
</dict>
</plist>

View File

@@ -1,11 +0,0 @@
#!/bin/bash
# Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
# This file is part of OpenRA, which is free software. It is made
# available to you under the terms of the GNU General Public License
# as published by the Free Software Foundation. For more information,
# see LICENSE.
export DYLD_LIBRARY_PATH="$1:$DYLD_LIBRARY_PATH"
echo "Launching OpenRA from $1"
cd $1
mono --debug OpenRA.Game.exe SupportDir=~/Library/"Application Support"/OpenRA ${@:2}

View File

@@ -1 +0,0 @@
../../../OpenRA.icns

View File

@@ -20,11 +20,11 @@ int main(int argc, char *argv[])
/* Command line args for mono */
char *args[] = {
"/Library/Frameworks/Mono.framework/Commands/mono",
argv[3],
"--debug",
"OpenRA.Game.exe",
argv[3],
argv[4],
argv[5],
NULL
};