mirror of
https://github.com/yawut/SDL.git
synced 2026-09-09 01:26:24 -05:00
Added Max's patches for building MacOS X apps on command line
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
# This is necessary because some platforms have special program
|
||||
# entry points, which require special application initialization.
|
||||
|
||||
SUBDIRS = macosx
|
||||
|
||||
ARCH_SUBDIRS = $(srcdir)/beos $(srcdir)/linux \
|
||||
$(srcdir)/macos $(srcdir)/macosx $(srcdir)/win32
|
||||
|
||||
|
||||
22
src/main/macosx/Info.plist
Normal file
22
src/main/macosx/Info.plist
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
|
||||
<plist version="0.9">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>dummy</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>dummy</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>SDLMain.nib</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
</dict>
|
||||
</plist>
|
||||
17
src/main/macosx/Makefile.am
Normal file
17
src/main/macosx/Makefile.am
Normal file
@@ -0,0 +1,17 @@
|
||||
# On OS X, install the SDLMain.nib.
|
||||
# We use an ugly hack to force the creation of the
|
||||
# destination dir, maybe somebody with more automake
|
||||
# experience knows how to do this properly?
|
||||
|
||||
if TARGET_MACOSX
|
||||
masternibdatadir = $(datadir)/sdl/SDLMain.nib
|
||||
masternibdata_DATA = \
|
||||
SDLMain.nib
|
||||
|
||||
nibdatadir = $(datadir)/sdl
|
||||
nibdata_DATA = \
|
||||
SDLMain.nib/classes.nib \
|
||||
SDLMain.nib/info.nib \
|
||||
SDLMain.nib/objects.nib \
|
||||
Info.plist
|
||||
endif
|
||||
@@ -10,5 +10,6 @@
|
||||
{
|
||||
}
|
||||
- (IBAction)quit:(id)sender;
|
||||
- (IBAction)makeFullscreen:(id)sender;
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification;
|
||||
@end
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
static int gArgc;
|
||||
static char **gArgv;
|
||||
static NSString *gAppName = 0;
|
||||
static BOOL gFinderLaunch;
|
||||
|
||||
@interface NSString (ReplaceSubString)
|
||||
- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString;
|
||||
@@ -29,15 +30,21 @@ static NSString *gAppName = 0;
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
|
||||
/* Invoked from the Make Full-Screen menu item */
|
||||
- (void) makeFullscreen:(id)sender
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
/* Set the working directory to the .app's parent directory */
|
||||
- (void) setupWorkingDirectory
|
||||
- (void) setupWorkingDirectory:(BOOL)shouldChdir
|
||||
{
|
||||
char parentdir[MAXPATHLEN];
|
||||
char *c;
|
||||
|
||||
strncpy ( parentdir, gArgv[0], sizeof(parentdir) );
|
||||
c = (char*) parentdir;
|
||||
|
||||
|
||||
while (*c != '\0') /* go to end */
|
||||
c++;
|
||||
|
||||
@@ -45,11 +52,13 @@ static NSString *gAppName = 0;
|
||||
c--;
|
||||
|
||||
*c++ = '\0'; /* cut off last part (binary name) */
|
||||
|
||||
assert ( chdir (parentdir) == 0 ); /* chdir to the binary app's parent */
|
||||
assert ( chdir ("../../../") == 0 ); /* chdir to the .app's parent */
|
||||
|
||||
gAppName = [ NSString stringWithCString: c ];
|
||||
|
||||
if (shouldChdir)
|
||||
{
|
||||
assert ( chdir (parentdir) == 0 ); /* chdir to the binary app's parent */
|
||||
assert ( chdir ("../../../") == 0 ); /* chdir to the .app's parent */
|
||||
}
|
||||
/* gAppName = [ NSString stringWithCString: c ]; */
|
||||
}
|
||||
|
||||
/* Fix menu to contain the real app name instead of "SDL App" */
|
||||
@@ -81,9 +90,10 @@ static NSString *gAppName = 0;
|
||||
int status;
|
||||
|
||||
/* Set the working directory to the .app's parent directory */
|
||||
[ self setupWorkingDirectory ];
|
||||
[ self setupWorkingDirectory: gFinderLaunch ];
|
||||
|
||||
/* Set the main menu to contain the real app name instead of "SDL App" */
|
||||
gAppName = [ [ NSBundle mainBundle ] bundleIdentifier ];
|
||||
[ self fixMenu: [ NSApp mainMenu ] ];
|
||||
|
||||
/* Hand off to main application code */
|
||||
@@ -148,8 +158,10 @@ int main (int argc, char **argv) {
|
||||
/* This is passed if we are launched by double-clicking */
|
||||
if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
|
||||
gArgc = 1;
|
||||
gFinderLaunch = YES;
|
||||
} else {
|
||||
gArgc = argc;
|
||||
gFinderLaunch = NO;
|
||||
}
|
||||
gArgv = (char**) malloc (sizeof(*gArgv) * (gArgc+1));
|
||||
assert (gArgv != NULL);
|
||||
|
||||
12
src/main/macosx/SDLMain.nib/classes.nib
generated
Normal file
12
src/main/macosx/SDLMain.nib/classes.nib
generated
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
IBClasses = (
|
||||
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
|
||||
{
|
||||
ACTIONS = {makeFullscreen = id; quit = id; };
|
||||
CLASS = SDLMain;
|
||||
LANGUAGE = ObjC;
|
||||
SUPERCLASS = NSObject;
|
||||
}
|
||||
);
|
||||
IBVersion = 1;
|
||||
}
|
||||
12
src/main/macosx/SDLMain.nib/info.nib
generated
Normal file
12
src/main/macosx/SDLMain.nib/info.nib
generated
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
|
||||
<plist version="0.9">
|
||||
<dict>
|
||||
<key>IBDocumentLocation</key>
|
||||
<string>49 97 356 240 0 0 987 746 </string>
|
||||
<key>IBMainMenuLocation</key>
|
||||
<string>20 515 195 44 0 46 800 532 </string>
|
||||
<key>IBUserGuides</key>
|
||||
<dict/>
|
||||
</dict>
|
||||
</plist>
|
||||
BIN
src/main/macosx/SDLMain.nib/objects.nib
generated
Normal file
BIN
src/main/macosx/SDLMain.nib/objects.nib
generated
Normal file
Binary file not shown.
Reference in New Issue
Block a user