diff --git a/PCBundleProj/GNUmakefile b/PCBundleProj/GNUmakefile index d5186d6..1cba23a 100644 --- a/PCBundleProj/GNUmakefile +++ b/PCBundleProj/GNUmakefile @@ -45,8 +45,7 @@ PC.proj PCBundleProj_HEADERS= \ PCBundleProject.h \ -PCBundleProj.h \ -PCBundleMakefileFactory.h +PCBundleProj.h # @@ -55,8 +54,7 @@ PCBundleMakefileFactory.h PCBundleProj_OBJC_FILES= \ PCBundleProject.m \ -PCBundleProj.m \ -PCBundleMakefileFactory.m +PCBundleProj.m # diff --git a/PCBundleProj/PCBundleMakefileFactory.h b/PCBundleProj/PCBundleMakefileFactory.h deleted file mode 100644 index 59df42c..0000000 --- a/PCBundleProj/PCBundleMakefileFactory.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - GNUstep ProjectCenter - http://www.gnustep.org - - Copyright (C) 2001 Free Software Foundation - - Author: Philippe C.D. Robert - - This file is part of GNUstep. - - This application is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This application is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. - - $Id$ -*/ - -#import -#import - -@interface PCBundleMakefileFactory : NSObject -{ -} - -+ (PCBundleMakefileFactory *)sharedFactory; - -- (NSData *)makefileForProject:(PCProject *)aProject; - -@end diff --git a/PCBundleProj/PCBundleMakefileFactory.m b/PCBundleProj/PCBundleMakefileFactory.m deleted file mode 100644 index a9e0999..0000000 --- a/PCBundleProj/PCBundleMakefileFactory.m +++ /dev/null @@ -1,176 +0,0 @@ -/* - GNUstep ProjectCenter - http://www.gnustep.org - - Copyright (C) 2001 Free Software Foundation - - Author: Philippe C.D. Robert - - This file is part of GNUstep. - - This application is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This application is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. - - $Id$ -*/ - -#import "PCBundleMakefileFactory.h" - -@implementation PCBundleMakefileFactory - -static PCBundleMakefileFactory *_factory = nil; - -+ (PCBundleMakefileFactory *)sharedFactory -{ - if (!_factory) { - _factory = [[[self class] alloc] init]; - } - return _factory; -} - -- (NSData *)makefileForProject:(PCProject *)aProject; -{ - NSMutableString *string = [NSMutableString string]; - NSString *prName = [aProject projectName]; - NSDictionary *prDict = [aProject projectDict]; - NSString *tmp; - NSEnumerator *enumerator; - int i; - NSString *installDir; - - installDir = [prDict objectForKey:PCInstallDir]; - if( [installDir isEqualToString:@""] ) - { - installDir = [NSString stringWithString:@"$(GNUSTEP_LOCAL_ROOT)/Library/Bundles"]; - } - - // Header information - [string appendString:@"#\n"]; - [string appendString:@"# GNUmakefile - Generated by ProjectCenter\n"]; - [string appendString:@"# Written by Philippe C.D. Robert \n"]; - [string appendString:@"#\n"]; - [string appendString:@"# NOTE: Do NOT change this file -- ProjectCenter maintains it!\n"]; - [string appendString:@"#\n"]; - [string appendString:@"# Put all of your customisations in GNUmakefile.preamble and\n"]; - [string appendString:@"# GNUmakefile.postamble\n"]; - [string appendString:@"#\n\n"]; - - // The 'real' thing - [string appendString:@"include $(GNUSTEP_MAKEFILES)/common.make\n"]; - - [string appendString:@"#\n\n"]; - [string appendString:@"# Subprojects\n"]; - [string appendString:@"#\n\n"]; - - if ([[aProject subprojects] count]) { - enumerator = [[prDict objectForKey:PCSubprojects] objectEnumerator]; - while (tmp = [enumerator nextObject]) { - [string appendString:[NSString stringWithFormat:@"\\\n%@ ",tmp]]; - } - } - - [string appendString:@"#\n"]; - [string appendString:@"# Bundle\n"]; - [string appendString:@"#\n\n"]; - - [string appendString:[NSString stringWithFormat:@"PACKAGE_NAME=%@\n",prName]]; - [string appendString:[NSString stringWithFormat:@"BUNDLE_NAME=%@\n",prName]]; - [string appendString:[NSString stringWithFormat:@"BUNDLE_EXTENSION=.bundle\n"]]; - [string appendString:[NSString stringWithFormat:@"BUNDLE_INSTALL_DIR=%@\n",installDir]]; - if ((tmp = [prDict objectForKey:PCPrincipalClass]) && - [tmp isEqualToString:@""] == NO) { - } - else if (([[prDict objectForKey:PCClasses] count])) { - tmp = [[[prDict objectForKey:PCClasses] objectAtIndex:0] stringByDeletingPathExtension]; - } - else { - tmp = [NSString string]; - } - - [string appendString:[NSString stringWithFormat:@"%@_PRINCIPAL_CLASS=%@\n",prName,tmp]]; - - [string appendString:@"#\n\n"]; - [string appendString:@"# Additional libraries\n"]; - [string appendString:@"#\n\n"]; - - [string appendString:[NSString stringWithFormat:@"%@_LIBRARIES_DEPEND_UPON += ",prName]]; - - if ([[prDict objectForKey:PCLibraries] count]) { - enumerator = [[prDict objectForKey:PCLibraries] objectEnumerator]; - while (tmp = [enumerator nextObject]) { - if (![tmp isEqualToString:@"gnustep-base"] && - ![tmp isEqualToString:@"gnustep-gui"]) { - [string appendString:[NSString stringWithFormat:@"-l%@ ",tmp]]; - } - } - } - - [string appendString:@"\n\n#\n\n"]; - [string appendString:@"# Resource files\n"]; - [string appendString:@"#\n\n"]; - - [string appendString:[NSString stringWithFormat:@"%@_RESOURCE_FILES= ",prName]]; - - for (i=0;i<[[aProject resourceFileKeys] count];i++) { - NSString *k = [[aProject resourceFileKeys] objectAtIndex:i]; - - enumerator = [[prDict objectForKey:k] objectEnumerator]; - while (tmp = [enumerator nextObject]) { - [string appendString:[NSString stringWithFormat:@"\\\n%@ ",tmp]]; - } - } - - [string appendString:@"\n\n#\n\n"]; - [string appendString:@"# Header files\n"]; - [string appendString:@"#\n\n"]; - - [string appendString:[NSString stringWithFormat:@"%@_HEADERS= ",prName]]; - - enumerator = [[prDict objectForKey:PCHeaders] objectEnumerator]; - while (tmp = [enumerator nextObject]) { - [string appendString:[NSString stringWithFormat:@"\\\n%@ ",tmp]]; - } - - [string appendString:@"\n\n#\n\n"]; - [string appendString:@"# Class files\n"]; - [string appendString:@"#\n\n"]; - - [string appendString:[NSString stringWithFormat:@"%@_OBJC_FILES= ",prName]]; - - enumerator = [[prDict objectForKey:PCClasses] objectEnumerator]; - while (tmp = [enumerator nextObject]) { - [string appendString:[NSString stringWithFormat:@"\\\n%@ ",tmp]]; - } - - [string appendString:@"\n\n#\n\n"]; - [string appendString:@"# C files\n"]; - [string appendString:@"#\n\n"]; - - [string appendString:[NSString stringWithFormat:@"%@_C_FILES= ",prName]]; - - enumerator = [[prDict objectForKey:PCOtherSources] objectEnumerator]; - while (tmp = [enumerator nextObject]) { - [string appendString:[NSString stringWithFormat:@"\\\n%@ ",tmp]]; - } - - [string appendString:@"\n\n"]; - - [string appendString:@"-include GNUmakefile.preamble\n"]; - [string appendString:@"-include GNUmakefile.local\n"]; - [string appendString:@"include $(GNUSTEP_MAKEFILES)/bundle.make\n"]; - [string appendString:@"-include GNUmakefile.postamble\n"]; - - return [string dataUsingEncoding:[NSString defaultCStringEncoding]]; -} - -@end diff --git a/PCBundleProj/PCBundleProj.pcproj b/PCBundleProj/PCBundleProj.pcproj index 6b7798e..269331d 100644 --- a/PCBundleProj/PCBundleProj.pcproj +++ b/PCBundleProj/PCBundleProj.pcproj @@ -5,8 +5,7 @@ BUILDTOOL = "/usr/bin/make"; CLASS_FILES = ( PCBundleProject.m, - PCBundleProj.m, - PCBundleMakefileFactory.m + PCBundleProj.m ); COMPILEROPTIONS = ""; CREATION_DATE = ""; @@ -17,8 +16,7 @@ ); HEADER_FILES = ( PCBundleProject.h, - PCBundleProj.h, - PCBundleMakefileFactory.h + PCBundleProj.h ); IMAGES = ( ); diff --git a/PCBundleProj/PCBundleProject.m b/PCBundleProj/PCBundleProject.m index d38fa88..e4e31b1 100644 --- a/PCBundleProj/PCBundleProject.m +++ b/PCBundleProj/PCBundleProject.m @@ -26,10 +26,12 @@ #import "PCBundleProject.h" #import "PCBundleProj.h" -#import "PCBundleMakefileFactory.h" +#import "PCMakefileFactory.h" #import +#define BUNDLE_INSTALL @"$(GNUSTEP_LOCAL_ROOT)/Library/Bundles/" + @interface PCBundleProject (CreateUI) - (void)_initUI; @@ -117,19 +119,66 @@ - (BOOL)writeMakefile { - NSFileManager *fm = [NSFileManager defaultManager]; + NSString *tmp; NSData *mfd; - NSString *mf = [projectPath stringByAppendingPathComponent:@"GNUmakefile"]; + NSString *mfl = [projectPath stringByAppendingPathComponent:@"GNUmakefile"]; + int i; + PCMakefileFactory *mf = [PCMakefileFactory sharedFactory]; + NSDictionary *dict = [self projectDict]; + NSArray *classes = [dict objectForKey:PCClasses]; + NSString *iDir = [dict objectForKey:PCInstallDir]; // Save the project file [super writeMakefile]; - if(mfd = [[PCBundleMakefileFactory sharedFactory] makefileForProject:self]){ - if ([mfd writeToFile:mf atomically:YES]) { + if( [iDir isEqualToString:@""] ) + { + iDir = [NSString stringWithString:BUNDLE_INSTALL]; + } + + if ((tmp = [dict objectForKey:PCPrincipalClass]) && + [tmp isEqualToString:@""] == NO) + { + } + else if ([classes count]) + { + tmp = [[classes objectAtIndex:0] stringByDeletingPathExtension]; + } + else tmp = [NSString string]; + + [mf createMakefileForProject:[self projectName]]; + + [mf appendString:@"include $(GNUSTEP_MAKEFILES)/common.make\n"]; + + [mf appendSubprojects:[dict objectForKey:PCSubprojects]]; + + [mf appendBundle]; + [mf appendBundleInstallDir:iDir]; + [mf appendPrincipalClass:tmp]; + [mf appendLibraries:[dict objectForKey:PCLibraries]]; + + [mf appendResources]; + for (i=0;i<[[self resourceFileKeys] count];i++) + { + NSString *k = [[self resourceFileKeys] objectAtIndex:i]; + [mf appendResourceItems:[dict objectForKey:k]]; + } + + [mf appendHeaders:[dict objectForKey:PCHeaders]]; + [mf appendClasses:[dict objectForKey:PCClasses]]; + [mf appendCFiles:[dict objectForKey:PCOtherSources]]; + + [mf appendTailForBundle]; + + // Write the new file to disc! + if (mfd = [mf encodedMakefile]) + { + if ([mfd writeToFile:mfl atomically:YES]) + { return YES; } - } - + } + return NO; }