Initial launcher (again)

This commit is contained in:
Joel de Vahl 2008-10-08 16:33:08 +00:00
parent 2b6f991010
commit b74c2b7931
4 changed files with 112 additions and 8 deletions

View file

@ -316,6 +316,8 @@ function build(settings)
-- build tools (TODO: fix this so we don't get double _d_d stuff) -- build tools (TODO: fix this so we don't get double _d_d stuff)
tools_src = Collect("src/tools/*.cpp", "src/tools/*.c") tools_src = Collect("src/tools/*.cpp", "src/tools/*.c")
osxlaunch_src = Collect("src/osxlaunch/*.m")
objs = Compile(settings, tools_src) objs = Compile(settings, tools_src)
tools = {} tools = {}
for i,v in objs do for i,v in objs do
@ -337,9 +339,9 @@ function build(settings)
masterserver_exe = Link(server_settings, "mastersrv", masterserver, masterserver_exe = Link(server_settings, "mastersrv", masterserver,
engine, zlib) engine, zlib)
--if platform == "macosx" then if platform == "macosx" then
-- osxlaunch_exe = Link(client_settings, "TeeLaunch", osxlaunch) osxlaunch_exe = Link(client_settings, "osxlaunch", osxlaunch_src)
--end end
-- make targets -- make targets
c = PseudoTarget("client".."_"..settings.config_name, client_exe) c = PseudoTarget("client".."_"..settings.config_name, client_exe)
@ -355,7 +357,7 @@ function build(settings)
Target(t) Target(t)
if platform == "macosx" then if platform == "macosx" then
o = PseudoTarget("TeeLaunch".."_"..settings.config_name, osxlaunch_exe) o = PseudoTarget("osxlaunch".."_"..settings.config_name, osxlaunch_exe)
all = PseudoTarget(settings.config_name, c, s, v, m, t, o) all = PseudoTarget(settings.config_name, c, s, v, m, t, o)
else else
all = PseudoTarget(settings.config_name, c, s, v, m, t) all = PseudoTarget(settings.config_name, c, s, v, m, t)

View file

@ -37,7 +37,7 @@ if platform == 'win32':
if 'osx_' in platform: if 'osx_' in platform:
use_zip = 1 use_zip = 1
use_gz = 0 use_gz = 0
use_bundle = 0 use_bundle = 1
def copydir(src, dst, excl=[]): def copydir(src, dst, excl=[]):
for root, dirs, files in os.walk(src, topdown=True): for root, dirs, files in os.walk(src, topdown=True):
@ -90,7 +90,7 @@ if use_bundle:
shutil.copy("other/icons/Teeworlds.icns", bundle_resource_dir) shutil.copy("other/icons/Teeworlds.icns", bundle_resource_dir)
shutil.copy(name+exe_ext, bundle_bin_dir) shutil.copy(name+exe_ext, bundle_bin_dir)
shutil.copy(name+"_srv"+exe_ext, bundle_bin_dir) shutil.copy(name+"_srv"+exe_ext, bundle_bin_dir)
shutil.copy("TeeLaunch"+exe_ext, bundle_bin_dir) shutil.copy("osxlaunch"+exe_ext, bundle_bin_dir)
file(os.path.join(bundle_content_dir, "Info.plist"), "w").write(""" file(os.path.join(bundle_content_dir, "Info.plist"), "w").write("""
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
@ -99,7 +99,7 @@ if use_bundle:
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>English</string> <string>English</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>teeworlds</string> <string>osxlaunch</string>
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
<string>Teeworlds</string> <string>Teeworlds</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>

View file

@ -96,11 +96,12 @@ void _glfwChangeToResourcesDirectory( void )
} }
CFRelease( resourcesURL ); CFRelease( resourcesURL );
/*
if( chdir( resourcesPath ) != 0 ) if( chdir( resourcesPath ) != 0 )
{ {
UNBUNDLED; UNBUNDLED;
} }
*/
} }
int _glfwPlatformInit( void ) int _glfwPlatformInit( void )

101
src/osxlaunch/main.m Normal file
View file

@ -0,0 +1,101 @@
#import <Cocoa/Cocoa.h>
#include <Carbon/Carbon.h>
@interface ServerView : NSTextView
{
NSTask *task;
NSFileHandle *file;
}
- (void)listenTo: (NSTask*)t;
@end
@implementation ServerView
- (void)listenTo: (NSTask*)t;
{
NSPipe *pipe;
task = t;
pipe = [NSPipe pipe];
[task setStandardOutput: pipe];
file = [pipe fileHandleForReading];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(outputNotification:) name: NSFileHandleReadCompletionNotification object: file];
[file readInBackgroundAndNotify];
}
- (void) outputNotification: (NSNotification *) notification
{
NSData *data = [[[notification userInfo] objectForKey: NSFileHandleNotificationDataItem] retain];
NSString *string = [[NSString alloc] initWithData: data encoding: NSASCIIStringEncoding];
NSRange end = NSMakeRange([[self string] length], 0);
[self replaceCharactersInRange: end withString: string];
end.location += [string length];
[self scrollRangeToVisible: end];
[string release];
[file readInBackgroundAndNotify];
}
-(void)windowWillClose:(NSNotification *)notification
{
[task terminate];
[NSApp terminate:self];
}
@end
int main(int argc, char **argv)
{
UInt32 mod = GetCurrentKeyModifiers();
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSApp = [NSApplication sharedApplication];
NSBundle* mainBundle = [NSBundle mainBundle];
NSTask *task;
task = [[NSTask alloc] init];
[task setCurrentDirectoryPath: [mainBundle resourcePath]];
if(mod & optionKey)
{
// run server
NSWindow *window;
ServerView *view;
NSRect graphicsRect;
graphicsRect = NSMakeRect(100.0, 1000.0, 600.0, 400.0);
window = [[NSWindow alloc]
initWithContentRect: graphicsRect
styleMask: NSTitledWindowMask
| NSClosableWindowMask
| NSMiniaturizableWindowMask
backing: NSBackingStoreBuffered
defer: NO];
[window setTitle: @"Teewars Server"];
view = [[[ServerView alloc] initWithFrame: graphicsRect] autorelease];
[view setEditable: NO];
[window setContentView: view];
[window setDelegate: view];
[window makeKeyAndOrderFront: nil];
[view listenTo: task];
[task setLaunchPath: [mainBundle pathForAuxiliaryExecutable: @"teeworlds_srv"]];
[task launch];
[NSApp run];
[task terminate];
}
else
{
// run client
[task setLaunchPath: [mainBundle pathForAuxiliaryExecutable: @"teeworlds"]];
[task launch];
}
[NSApp release];
[pool release];
return(EXIT_SUCCESS);
}