From 2db57284c5d5a2f6acc3bf3b468db9abbee0db3f Mon Sep 17 00:00:00 2001 From: "Philippe C.D. Robert" Date: Fri, 1 Mar 2002 15:06:47 +0000 Subject: [PATCH] This project now uses the makefile factory too. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@12934 72102866-910b-0410-8b05-ffd578937521 --- PCLibProj/GNUmakefile | 14 ++- PCLibProj/PCLibMakefileFactory.h | 38 -------- PCLibProj/PCLibMakefileFactory.m | 154 ------------------------------- PCLibProj/PCLibProj.pcproj | 2 - PCLibProj/PCLibProject.m | 40 +++++--- 5 files changed, 33 insertions(+), 215 deletions(-) delete mode 100644 PCLibProj/PCLibMakefileFactory.h delete mode 100644 PCLibProj/PCLibMakefileFactory.m diff --git a/PCLibProj/GNUmakefile b/PCLibProj/GNUmakefile index 7a32e2b..80576f3 100644 --- a/PCLibProj/GNUmakefile +++ b/PCLibProj/GNUmakefile @@ -9,11 +9,14 @@ # include $(GNUSTEP_MAKEFILES)/common.make -# + +# # Subprojects # + + # # Bundle # @@ -23,15 +26,15 @@ BUNDLE_NAME=PCLibProj BUNDLE_EXTENSION=.bundle BUNDLE_INSTALL_DIR=$(GNUSTEP_SYSTEM_ROOT)/Library/ProjectCenter PCLibProj_PRINCIPAL_CLASS=PCLibProj -# + +# # Additional libraries # PCLibProj_LIBRARIES_DEPEND_UPON += -lProjectCenter # - # Resource files # @@ -40,27 +43,22 @@ PC.proj \ Version # - # Header files # PCLibProj_HEADERS= \ -PCLibMakefileFactory.h \ PCLibProj.h \ PCLibProject.h # - # Class files # PCLibProj_OBJC_FILES= \ -PCLibMakefileFactory.m \ PCLibProj.m \ PCLibProject.m # - # C files # diff --git a/PCLibProj/PCLibMakefileFactory.h b/PCLibProj/PCLibMakefileFactory.h deleted file mode 100644 index 04f7b92..0000000 --- a/PCLibProj/PCLibMakefileFactory.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 PCLibMakefileFactory : NSObject -{ -} - -+ (PCLibMakefileFactory *)sharedFactory; - -- (NSData *)makefileForProject:(PCProject *)aProject; - -@end diff --git a/PCLibProj/PCLibMakefileFactory.m b/PCLibProj/PCLibMakefileFactory.m deleted file mode 100644 index ec0ea12..0000000 --- a/PCLibProj/PCLibMakefileFactory.m +++ /dev/null @@ -1,154 +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 "PCLibMakefileFactory.h" - -@implementation PCLibMakefileFactory - -static PCLibMakefileFactory *_factory = nil; - -+ (PCLibMakefileFactory *)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; - NSString *libName; - - // 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:@"include Version\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:@"# Library\n"]; - [string appendString:@"#\n\n"]; - - [string appendString:[NSString stringWithFormat:@"PACKAGE_NAME=%@\n",prName]]; - [string appendString:[NSString stringWithFormat:@"LIBRARY_VAR=%@\n",[prName uppercaseString]]]; - libName = [NSString stringWithFormat:@"lib%@",prName]; - [string appendString:[NSString stringWithFormat:@"LIBRARY_NAME=%@\n",libName]]; - - // Install path - [string appendString:[NSString stringWithFormat:@"%@_HEADER_FILES_DIR=.\n",libName]]; - [string appendString:[NSString stringWithFormat:@"%@_HEADER_FILES_INSTALL_DIR=/%@\n",libName,prName]]; - [string appendString:[NSString stringWithFormat:@"GNUSTEP_INSTALLATION_DIR=%@\n",[prDict objectForKey:PCInstallDir]]]; - [string appendString:[NSString stringWithFormat:@"%@_INSTALLATION_DIR=$(GNUSTEP_INSTALLATION_DIR)\n",[prName uppercaseString]]]; - [string appendString:[NSString stringWithFormat:@"%@_INSTALL_PREFIX=$(GNUSTEP_INSTALLATION_DIR)\n",[prName uppercaseString]]]; - [string appendString:@"ADDITIONAL_INCLUDE_DIRS = -I..\n"]; - [string appendString:@"srcdir = .\n"]; - - [string appendString:@"#\n\n"]; - [string appendString:@"# Additional libraries\n"]; - [string appendString:@"#\n\n"]; - - [string appendString:[NSString stringWithFormat:@"%@_LIBRARIES_DEPEND_UPON += ",libName]]; - - if ([[prDict objectForKey:PCLibraries] count]) { - enumerator = [[prDict objectForKey:PCLibraries] objectEnumerator]; - while (tmp = [enumerator nextObject]) { - if (![tmp isEqualToString:@"gnustep-base"]) { - [string appendString:[NSString stringWithFormat:@"-l%@ ",tmp]]; - } - } - } - - [string appendString:@"\n\n#\n\n"]; - [string appendString:@"# Header files\n"]; - [string appendString:@"#\n\n"]; - - [string appendString:[NSString stringWithFormat:@"%@_HEADER_FILES= ",libName]]; - - 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= ",libName]]; - - 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= ",libName]]; - - enumerator = [[prDict objectForKey:PCOtherSources] objectEnumerator]; - while (tmp = [enumerator nextObject]) { - [string appendString:[NSString stringWithFormat:@"\\\n%@ ",tmp]]; - } - - [string appendString:@"\n\n"]; - - [string appendFormat:@"HEADERS_INSTALL = $(%@_HEADER_FILES)\n\n",libName]; - - [string appendString:@"-include GNUmakefile.preamble\n"]; - [string appendString:@"-include GNUmakefile.local\n"]; - [string appendString:@"include $(GNUSTEP_MAKEFILES)/library.make\n"]; - [string appendString:@"-include GNUmakefile.postamble\n"]; - - return [string dataUsingEncoding:[NSString defaultCStringEncoding]]; -} - -@end diff --git a/PCLibProj/PCLibProj.pcproj b/PCLibProj/PCLibProj.pcproj index 2f7b1ea..765d490 100644 --- a/PCLibProj/PCLibProj.pcproj +++ b/PCLibProj/PCLibProj.pcproj @@ -4,7 +4,6 @@ APPLICATIONICON = ""; BUILDTOOL = "/usr/bin/make"; CLASS_FILES = ( - PCLibMakefileFactory.m, PCLibProj.m, PCLibProject.m ); @@ -16,7 +15,6 @@ FRAMEWORKS = ( ); HEADER_FILES = ( - PCLibMakefileFactory.h, PCLibProj.h, PCLibProject.h ); diff --git a/PCLibProj/PCLibProject.m b/PCLibProj/PCLibProject.m index 4b7e903..9e6f844 100644 --- a/PCLibProj/PCLibProject.m +++ b/PCLibProj/PCLibProject.m @@ -26,13 +26,7 @@ #import "PCLibProject.h" #import "PCLibProj.h" -#import "PCLibMakefileFactory.h" - -#import - -#if defined(GNUSTEP) -#import -#endif +#import "PCMakefileFactory.h" @interface PCLibProject (CreateUI) @@ -92,19 +86,39 @@ - (BOOL)writeMakefile { - NSFileManager *fm = [NSFileManager defaultManager]; NSData *mfd; - NSString *mf = [projectPath stringByAppendingPathComponent:@"GNUmakefile"]; + NSString *mfl = [projectPath stringByAppendingPathComponent:@"GNUmakefile"]; + NSString *tmp; + int i; + PCMakefileFactory *mf = [PCMakefileFactory sharedFactory]; + NSDictionary *dict = [self projectDict]; // Save the project file [super writeMakefile]; - if (mfd = [[PCLibMakefileFactory sharedFactory] makefileForProject:self]) { - if ([mfd writeToFile:mf atomically:YES]) { + [mf createMakefileForProject:[self projectName]]; + [mf appendString:@"include $(GNUSTEP_MAKEFILES)/common.make\n"]; + [mf appendSubprojects:[dict objectForKey:PCSubprojects]]; + + [mf appendLibrary]; + [mf appendLibraryInstallDir:[dict objectForKey:PCInstallDir]]; + [mf appendLibraryLibraries:[dict objectForKey:PCLibraries]]; + + [mf appendLibraryHeaders:[dict objectForKey:PCHeaders]]; + [mf appendLibraryClasses:[dict objectForKey:PCClasses]]; + [mf appendLibraryCFiles:[dict objectForKey:PCOtherSources]]; + + [mf appendTailForLibrary]; + + // Write the new file to disc! + if (mfd = [mf encodedMakefile]) + { + if ([mfd writeToFile:mfl atomically:YES]) + { return YES; } - } - + } + return NO; }