mirror of
https://github.com/gnustep/apps-projectcenter.git
synced 2025-02-22 19:31:56 +00:00
PCLib moved to Framework
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/branches/UNSTABLE_0_4@17997 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b3be7d02c4
commit
d7e538c3d7
78 changed files with 1464 additions and 1400 deletions
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
GNUstep ProjectCenter - http://www.gnustep.org
|
||||
|
||||
Copyright (C) 2000-2002 Free Software Foundation
|
||||
Copyright (C) 2001 Free Software Foundation
|
||||
|
||||
Author: Philippe C.D. Robert <probert@siggraph.org>
|
||||
Author: Philippe C.D. Robert <phr@3dkit.org>
|
||||
|
||||
This file is part of GNUstep.
|
||||
|
||||
|
@ -24,21 +24,32 @@
|
|||
$Id$
|
||||
*/
|
||||
|
||||
#include <Foundation/Foundation.h>
|
||||
#ifndef _PCFileCreator_h
|
||||
#define _PCFileCreator_h
|
||||
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
@class PCProject;
|
||||
|
||||
@protocol FileCreator
|
||||
@interface PCFileCreator : NSObject
|
||||
{
|
||||
NSMutableString *file;
|
||||
}
|
||||
|
||||
+ (id)sharedCreator;
|
||||
|
||||
- (NSString *)name;
|
||||
- (NSDictionary *)creatorDictionary;
|
||||
// Object is the creator and key is the type of the file to be created
|
||||
|
||||
- (NSDictionary *)createFileOfType:(NSString *)type path:(NSString *)path project:(PCProject *)aProject;
|
||||
// Creates the file and returns a dictionary containing the full path of it as the key and the type as object (and perhaps other files that have been added during this process!); including path extensions etc!
|
||||
// The implementation needs some heavy cleanup!
|
||||
- (NSDictionary *)createFileOfType:(NSString *)type
|
||||
path:(NSString *)path
|
||||
project:(PCProject *)aProject;
|
||||
|
||||
- (void)replaceTagsInFileAtPath:(NSString *)newFile
|
||||
withProject:(PCProject *)aProject
|
||||
type:(NSString *)aType;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#endif
|
330
Framework/PCFileCreator.m
Normal file
330
Framework/PCFileCreator.m
Normal file
|
@ -0,0 +1,330 @@
|
|||
/*
|
||||
GNUstep ProjectCenter - http://www.gnustep.org
|
||||
|
||||
Copyright (C) 2001 Free Software Foundation
|
||||
|
||||
Author: Philippe C.D. Robert <phr@3dkit.org>
|
||||
|
||||
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$
|
||||
*/
|
||||
|
||||
#include "PCFileCreator.h"
|
||||
#include "PCProject.h"
|
||||
|
||||
#define ProtocolFile @"Objective-C Protocol"
|
||||
#define ObjCClass @"Objective-C Class"
|
||||
#define ObjCHeader @"Objective-C Header"
|
||||
#define CFile @"C File"
|
||||
#define CHeader @"C Header"
|
||||
#define GSMarkupFile @"GNUstep Markup"
|
||||
|
||||
@implementation PCFileCreator
|
||||
|
||||
static PCFileCreator *_creator = nil;
|
||||
static NSString *_name = @"FileCreator";
|
||||
static NSDictionary *dict = nil;
|
||||
|
||||
+ (id)sharedCreator
|
||||
{
|
||||
if (!_creator)
|
||||
{
|
||||
NSDictionary *classDict;
|
||||
NSDictionary *headerDict;
|
||||
NSDictionary *ccDict;
|
||||
NSDictionary *chDict;
|
||||
NSDictionary *protocolDict;
|
||||
NSDictionary *gsmarkupDict;
|
||||
NSString *descr;
|
||||
|
||||
_creator = [[[self class] alloc] init];
|
||||
|
||||
// Setting up the dictionary needed for registration!
|
||||
descr = [NSString stringWithString:@"Generic Objective-C class.\n\nThis is a plain subclass of NSObject which includes only Foundation.h."];
|
||||
classDict = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
_creator,@"Creator",
|
||||
PCClasses,@"ProjectKey",
|
||||
descr,@"TypeDescription",
|
||||
nil];
|
||||
|
||||
descr = [NSString stringWithString:@"Generic Objective-C header.\n\nThis is a plain interface subclassing NSObject. The file includes Foundation.h"];
|
||||
headerDict =[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
_creator,@"Creator",
|
||||
PCHeaders,@"ProjectKey",
|
||||
descr,@"TypeDescription",
|
||||
nil];
|
||||
|
||||
descr = [NSString stringWithString:@"Generic ANSI-C implementation file.\n\nThis file contains no Objective-C dependency in any form."];
|
||||
ccDict = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
_creator,@"Creator",
|
||||
PCOtherSources,@"ProjectKey",
|
||||
descr,@"TypeDescription",
|
||||
nil];
|
||||
|
||||
descr = [NSString stringWithString:@"Generic ANSI-C header.\n\nThis file contains no Objective-C dependency in any form."];
|
||||
chDict = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
_creator,@"Creator",
|
||||
PCHeaders,@"ProjectKey",
|
||||
descr,@"TypeDescription",
|
||||
nil];
|
||||
|
||||
descr = [NSString stringWithString:@"Generic Objective-C protocol.\n\nThis is common Objective-C protocol, comparable i.e. to a Java interface."];
|
||||
protocolDict = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
_creator,@"Creator",
|
||||
PCHeaders,@"ProjectKey",
|
||||
descr,@"TypeDescription",
|
||||
nil];
|
||||
|
||||
descr = [NSString stringWithString:@"Generic GSMarkup File.\n\nThis is the interface description of GNUstep Renaissance."];
|
||||
gsmarkupDict =[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
_creator,@"Creator",
|
||||
PCGSMarkupFiles,@"ProjectKey",
|
||||
descr,@"TypeDescription",
|
||||
nil];
|
||||
|
||||
|
||||
dict = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||
ccDict,CFile,
|
||||
chDict,CHeader,
|
||||
protocolDict,ProtocolFile,
|
||||
headerDict,ObjCHeader,
|
||||
classDict,ObjCClass,
|
||||
gsmarkupDict,GSMarkupFile,
|
||||
nil];
|
||||
}
|
||||
|
||||
return _creator;
|
||||
}
|
||||
|
||||
- (NSString *)name
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
- (NSDictionary *)creatorDictionary
|
||||
{
|
||||
return dict;
|
||||
}
|
||||
|
||||
- (NSDictionary *)createFileOfType:(NSString *)type
|
||||
path:(NSString *)path
|
||||
project:(PCProject *)aProject
|
||||
{
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
NSString *_file;
|
||||
NSString *newFile = nil;
|
||||
NSMutableDictionary *files;
|
||||
NSBundle *bundle;
|
||||
|
||||
// A class and possibly a header
|
||||
files = [NSMutableDictionary dictionaryWithCapacity:2];
|
||||
|
||||
NSLog(@"<%@ %x>: create %@ at %@",[self class],self,type,path);
|
||||
|
||||
bundle = [NSBundle bundleForLibrary:@"ProjectCenter"];
|
||||
newFile = [path copy];
|
||||
|
||||
/*
|
||||
* Objective-C Class
|
||||
*/
|
||||
if ([type isEqualToString:ObjCClass])
|
||||
{
|
||||
_file = [bundle pathForResource:@"class" ofType:@"template"];
|
||||
if ([[path pathExtension] isEqual: @"m"] == NO)
|
||||
{
|
||||
newFile = [path stringByAppendingPathExtension:@"m"];
|
||||
}
|
||||
[fm copyPath:_file toPath:newFile handler:nil];
|
||||
[files setObject:ObjCClass forKey:newFile];
|
||||
|
||||
[self replaceTagsInFileAtPath:newFile withProject:aProject type:type];
|
||||
|
||||
// Should a header be created as well?
|
||||
newFile = [path stringByAppendingPathExtension:@"h"];
|
||||
if (NSRunAlertPanel(@"Attention!",
|
||||
@"Should %@ be created and inserted into the project?",
|
||||
@"Yes",@"No",nil,[newFile lastPathComponent]))
|
||||
{
|
||||
_file = [bundle pathForResource:@"header" ofType:@"template"];
|
||||
[fm copyPath:_file toPath:newFile handler:nil];
|
||||
|
||||
[self replaceTagsInFileAtPath:newFile
|
||||
withProject:aProject
|
||||
type:ObjCHeader];
|
||||
[files setObject:ObjCHeader forKey:newFile];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* C File
|
||||
*/
|
||||
else if ([type isEqualToString:CFile])
|
||||
{
|
||||
_file = [bundle pathForResource:@"cfile" ofType:@"template"];
|
||||
if ([[path pathExtension] isEqual: @"c"] == NO)
|
||||
{
|
||||
newFile = [path stringByAppendingPathExtension:@"c"];
|
||||
}
|
||||
[fm copyPath:_file toPath:newFile handler:nil];
|
||||
[files setObject:CFile forKey:newFile];
|
||||
|
||||
[self replaceTagsInFileAtPath:newFile withProject:aProject type:type];
|
||||
|
||||
// Should a header be created as well?
|
||||
newFile = [path stringByAppendingPathExtension:@"h"];
|
||||
if (NSRunAlertPanel(@"Attention!",
|
||||
@"Should %@ be created and inserted in the project as well?",
|
||||
@"Yes",@"No",nil,[newFile lastPathComponent])) {
|
||||
_file = [bundle pathForResource:@"cheader" ofType:@"template"];
|
||||
[fm copyPath:_file toPath:newFile handler:nil];
|
||||
|
||||
[self replaceTagsInFileAtPath:newFile
|
||||
withProject:aProject
|
||||
type:CHeader];
|
||||
[files setObject:CHeader forKey:newFile];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Objective-C Header
|
||||
*/
|
||||
else if ([type isEqualToString:ObjCHeader])
|
||||
{
|
||||
_file = [bundle pathForResource:@"header" ofType:@"template"];
|
||||
if ([[path pathExtension] isEqual: @"h"] == NO)
|
||||
{
|
||||
newFile = [path stringByAppendingPathExtension:@"h"];
|
||||
}
|
||||
[fm copyPath:_file toPath:newFile handler:nil];
|
||||
[self replaceTagsInFileAtPath:newFile withProject:aProject type:type];
|
||||
[files setObject:ObjCHeader forKey:newFile];
|
||||
}
|
||||
|
||||
/*
|
||||
* GSMarkup
|
||||
*/
|
||||
else if ([type isEqualToString:GSMarkupFile])
|
||||
{
|
||||
_file = [bundle pathForResource:@"gsmarkup" ofType:@"template"];
|
||||
if ([[path pathExtension] isEqual: @"gsmarkup"] == NO)
|
||||
{
|
||||
newFile = [path stringByAppendingPathExtension:@"gsmarkup"];
|
||||
}
|
||||
[fm copyPath:_file toPath:newFile handler:nil];
|
||||
[files setObject:GSMarkupFile forKey:newFile];
|
||||
}
|
||||
|
||||
/*
|
||||
* C Header
|
||||
*/
|
||||
else if ([type isEqualToString:CHeader])
|
||||
{
|
||||
_file = [bundle pathForResource:@"cheader" ofType:@"template"];
|
||||
if ([[path pathExtension] isEqual: @"h"] == NO)
|
||||
{
|
||||
newFile = [path stringByAppendingPathExtension:@"h"];
|
||||
}
|
||||
[fm copyPath:_file toPath:newFile handler:nil];
|
||||
[self replaceTagsInFileAtPath:newFile withProject:aProject type:type];
|
||||
[files setObject:CHeader forKey:newFile];
|
||||
}
|
||||
|
||||
/*
|
||||
* Objective-C Protocol
|
||||
*/
|
||||
else if ([type isEqualToString:ProtocolFile])
|
||||
{
|
||||
_file = [bundle pathForResource:@"protocol" ofType:@"template"];
|
||||
if ([[path pathExtension] isEqual: @"h"] == NO)
|
||||
{
|
||||
newFile = [path stringByAppendingPathExtension:@"h"];
|
||||
}
|
||||
[fm copyPath:_file toPath:newFile handler:nil];
|
||||
[self replaceTagsInFileAtPath:newFile withProject:aProject type:type];
|
||||
[files setObject:ProtocolFile forKey:newFile];
|
||||
}
|
||||
|
||||
/*
|
||||
* Notify the browser!
|
||||
*/
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:@"ProjectDictDidChangeNotification"
|
||||
object:self];
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
- (void)replaceTagsInFileAtPath:(NSString *)newFile
|
||||
withProject:(PCProject *)aProject
|
||||
type:(NSString *)aType
|
||||
{
|
||||
NSString *user = NSUserName();
|
||||
NSString *pname = [aProject projectName];
|
||||
NSString *date = [[NSCalendarDate calendarDate] description];
|
||||
NSString *aFile = [newFile lastPathComponent];
|
||||
|
||||
file = [[NSMutableString stringWithContentsOfFile:newFile] retain];
|
||||
|
||||
[file replaceCharactersInRange:
|
||||
[file rangeOfString:@"$FILENAME$"] withString:aFile];
|
||||
|
||||
[file replaceCharactersInRange:
|
||||
[file rangeOfString:@"$USERNAME$"] withString:user];
|
||||
|
||||
[file replaceCharactersInRange:
|
||||
[file rangeOfString:@"$PROJECTNAME$"] withString:pname];
|
||||
|
||||
[file replaceCharactersInRange:
|
||||
[file rangeOfString:@"$DATE$"] withString:date];
|
||||
|
||||
if ([aType isEqualToString:ObjCHeader] || [aType isEqualToString:CHeader])
|
||||
{
|
||||
NSString *nm = [[aFile stringByDeletingPathExtension] uppercaseString];
|
||||
|
||||
[file replaceCharactersInRange:
|
||||
[file rangeOfString:@"$UCFILENAMESANSEXTENSION$"] withString:nm];
|
||||
[file replaceCharactersInRange:
|
||||
[file rangeOfString:@"$UCFILENAMESANSEXTENSION$"] withString:nm];
|
||||
[file replaceCharactersInRange:
|
||||
[file rangeOfString:@"$UCFILENAMESANSEXTENSION$"] withString:nm];
|
||||
}
|
||||
|
||||
if ([aType isEqualToString:ObjCClass] ||
|
||||
[aType isEqualToString:CFile] ||
|
||||
[aType isEqualToString:ProtocolFile] ||
|
||||
[aType isEqualToString:ObjCHeader])
|
||||
{
|
||||
NSString *name = [aFile stringByDeletingPathExtension];
|
||||
|
||||
[file replaceCharactersInRange:
|
||||
[file rangeOfString:@"$FILENAMESANSEXTENSION$"] withString:name];
|
||||
|
||||
if ([aType isEqualToString:ObjCClass])
|
||||
{
|
||||
[file replaceCharactersInRange:
|
||||
[file rangeOfString:@"$FILENAMESANSEXTENSION$"] withString:name];
|
||||
}
|
||||
}
|
||||
|
||||
[file writeToFile:newFile atomically:YES];
|
||||
[file autorelease];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
@ -29,6 +29,8 @@
|
|||
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
@class PCProject;
|
||||
|
||||
@interface PCFileManager : NSObject
|
||||
{
|
||||
id newFileWindow;
|
||||
|
@ -68,7 +70,14 @@
|
|||
// ==== File stuff
|
||||
// ===========================================================================
|
||||
|
||||
- (void)showAddFileWindow;
|
||||
// Shows NSOpenPanel and return selected files if any
|
||||
- (NSMutableArray *)selectFilesOfType:(NSArray *)types multiple:(BOOL)yn;
|
||||
|
||||
// Return NO if coping of any file failed
|
||||
- (BOOL)copyFiles:(NSArray *)files intoDirectory:(NSString *)directory;
|
||||
|
||||
// Return NO if removing of any file failed
|
||||
- (BOOL)removeFiles:(NSArray *)files fromDirectory:(NSString *)directory;
|
||||
|
||||
- (void)showNewFileWindow;
|
||||
- (void)buttonsPressed:(id)sender;
|
||||
|
@ -76,23 +85,20 @@
|
|||
|
||||
- (void)createFile;
|
||||
|
||||
- (void)registerCreatorsWithObjectsAndKeys:(NSDictionary *)dict;
|
||||
- (void)registerCreators;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSObject (FileManagerDelegates)
|
||||
|
||||
- (NSString *)fileManager:(id)sender willCreateFile:(NSString *)aFile withKey:(NSString *)key;
|
||||
// Returns the correct, full path - or nil!
|
||||
|
||||
- (void)fileManager:(id)sender didCreateFile:(NSString *)aFile withKey:(NSString *)key;
|
||||
|
||||
- (id)fileManagerWillAddFiles:(id)sender;
|
||||
// Is invoked to get the currently active project!
|
||||
|
||||
- (BOOL)fileManager:(id)sender shouldAddFile:(NSString *)file forKey:(NSString *)key;
|
||||
- (void)fileManager:(id)sender didAddFile:(NSString *)file forKey:(NSString *)key;
|
||||
// Returns the correct, full path - or nil!
|
||||
- (NSString *)fileManager:(id)sender
|
||||
willCreateFile:(NSString *)aFile
|
||||
withKey:(NSString *)key;
|
||||
|
||||
- (void)fileManager:(id)sender
|
||||
didCreateFile:(NSString *)aFile
|
||||
withKey:(NSString *)key;
|
||||
@end
|
||||
|
||||
#endif
|
308
Framework/PCFileManager.m
Normal file
308
Framework/PCFileManager.m
Normal file
|
@ -0,0 +1,308 @@
|
|||
/*
|
||||
GNUstep ProjectCenter - http://www.gnustep.org
|
||||
|
||||
Copyright (C) 2000-2002 Free Software Foundation
|
||||
|
||||
Author: Philippe C.D. Robert <probert@siggraph.org>
|
||||
|
||||
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$
|
||||
*/
|
||||
|
||||
#include "PCFileManager.h"
|
||||
#include "PCFileCreator.h"
|
||||
#include "PCDefines.h"
|
||||
#include "PCProject.h"
|
||||
#include "PCServer.h"
|
||||
|
||||
#include "PCFileManager+UInterface.h"
|
||||
|
||||
@implementation PCFileManager
|
||||
|
||||
//==============================================================================
|
||||
// ==== Class methods
|
||||
//==============================================================================
|
||||
|
||||
static PCFileManager *_mgr = nil;
|
||||
|
||||
+ (PCFileManager *)fileManager
|
||||
{
|
||||
if (!_mgr)
|
||||
{
|
||||
_mgr = [[PCFileManager alloc] init];
|
||||
}
|
||||
|
||||
return _mgr;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// ==== Init and free
|
||||
//==============================================================================
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
creators = [[NSMutableDictionary alloc] init];
|
||||
typeDescr = [[NSMutableDictionary alloc] init];
|
||||
[self _initUI];
|
||||
[self registerCreators];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
RELEASE(creators);
|
||||
RELEASE(newFileWindow);
|
||||
RELEASE(typeDescr);
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
[fileTypePopup removeAllItems];
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// ==== Delegate
|
||||
// ===========================================================================
|
||||
|
||||
- (id)delegate
|
||||
{
|
||||
return delegate;
|
||||
}
|
||||
|
||||
- (void)setDelegate:(id)aDelegate
|
||||
{
|
||||
delegate = aDelegate;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// ==== File stuff
|
||||
// ===========================================================================
|
||||
|
||||
- (NSMutableArray *)selectFilesOfType:(NSArray *)types multiple:(BOOL)yn
|
||||
{
|
||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||
NSOpenPanel *openPanel = nil;
|
||||
int retval;
|
||||
|
||||
openPanel = [NSOpenPanel openPanel];
|
||||
[openPanel setAllowsMultipleSelection:yn];
|
||||
[openPanel setCanChooseFiles:YES];
|
||||
[openPanel setCanChooseDirectories:NO];
|
||||
[openPanel setTitle:@"Add Files"];
|
||||
|
||||
retval = [openPanel
|
||||
runModalForDirectory:[ud objectForKey:@"LastOpenDirectory"]
|
||||
file:nil
|
||||
types:types];
|
||||
if (retval == NSOKButton)
|
||||
{
|
||||
[ud setObject:[openPanel directory] forKey:@"LastOpenDirectory"];
|
||||
return [[[openPanel filenames] mutableCopy] autorelease];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL)copyFiles:(NSArray *)files intoDirectory:(NSString *)directory
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
NSString *file = nil;
|
||||
NSString *fileName = nil;
|
||||
NSString *path = nil;
|
||||
|
||||
if (!files)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
enumerator = [files objectEnumerator];
|
||||
while ((file = [enumerator nextObject]))
|
||||
{
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
|
||||
fileName = [file lastPathComponent];
|
||||
path = [directory stringByAppendingPathComponent:fileName];
|
||||
|
||||
if (![fm fileExistsAtPath:path])
|
||||
{
|
||||
if (![fm copyPath:file toPath:path handler:nil])
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)removeFiles:(NSArray *)files fromDirectory:(NSString *)directory
|
||||
{
|
||||
NSEnumerator *filesEnum = nil;
|
||||
NSString *file = nil;
|
||||
NSString *path = nil;
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
|
||||
if (!files)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
filesEnum = [files objectEnumerator];
|
||||
while ((file = [filesEnum nextObject]))
|
||||
{
|
||||
path = [directory stringByAppendingPathComponent:file];
|
||||
if (![fm removeFileAtPath:path handler:nil])
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)showNewFileWindow
|
||||
{
|
||||
[self popupChanged:fileTypePopup];
|
||||
|
||||
[newFileWindow center];
|
||||
[newFileWindow makeKeyAndOrderFront:self];
|
||||
}
|
||||
|
||||
- (void)buttonsPressed:(id)sender
|
||||
{
|
||||
switch ([[sender selectedCell] tag])
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
[self createFile];
|
||||
break;
|
||||
}
|
||||
[newFileWindow orderOut:self];
|
||||
[newFileName setStringValue:@""];
|
||||
}
|
||||
|
||||
- (void)popupChanged:(id)sender
|
||||
{
|
||||
NSString *k = [sender titleOfSelectedItem];
|
||||
|
||||
if( k )
|
||||
{
|
||||
#ifdef GNUSTEP_BASE_VERSION
|
||||
[descrView setText:[typeDescr objectForKey:k]];
|
||||
#else
|
||||
[descrView setString:[typeDescr objectForKey:k]];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
- (void)createFile
|
||||
{
|
||||
NSString *path = nil;
|
||||
NSString *fileName = [newFileName stringValue];
|
||||
NSString *fileType = [fileTypePopup titleOfSelectedItem];
|
||||
NSString *key = [[creators objectForKey:fileType] objectForKey:@"ProjectKey"];
|
||||
|
||||
if (delegate)
|
||||
{
|
||||
path = [delegate fileManager:self willCreateFile:fileName withKey:key];
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
NSLog(@"<%@ %x>: creating file at %@", [self class], self, path);
|
||||
#endif //DEBUG
|
||||
|
||||
// Create file
|
||||
if (path)
|
||||
{
|
||||
NSDictionary *newFiles;
|
||||
PCFileCreator *creator = [[creators objectForKey:fileType] objectForKey:@"Creator"];
|
||||
PCProject *p = [delegate activeProject];
|
||||
|
||||
if (!creator)
|
||||
{
|
||||
NSRunAlertPanel(@"Attention!",
|
||||
@"Could not create %@. The creator is missing!",
|
||||
@"OK",nil,nil,fileName);
|
||||
return;
|
||||
}
|
||||
|
||||
// Do it finally...
|
||||
newFiles = [creator createFileOfType:fileType path:path project:p];
|
||||
if (delegate
|
||||
&& [delegate respondsToSelector:@selector(fileManager:didCreateFile:withKey:)])
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
NSString *aFile;
|
||||
|
||||
enumerator = [[newFiles allKeys] objectEnumerator]; // Key: name of file
|
||||
while ((aFile = [enumerator nextObject]))
|
||||
{
|
||||
NSString *theType = [newFiles objectForKey:aFile];
|
||||
NSString *theKey = [[creators objectForKey:theType] objectForKey:@"ProjectKey"];
|
||||
|
||||
[delegate fileManager:self didCreateFile:aFile withKey:theKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)registerCreators
|
||||
{
|
||||
NSDictionary *dict = [[PCFileCreator sharedCreator] creatorDictionary];
|
||||
NSEnumerator *enumerator = [dict keyEnumerator];
|
||||
id type;
|
||||
|
||||
while ((type = [enumerator nextObject]))
|
||||
{
|
||||
NSDictionary *cd = [dict objectForKey:type];
|
||||
id creator = [cd objectForKey:@"Creator"];
|
||||
|
||||
if (!creator)
|
||||
{
|
||||
[NSException raise:@"FileManagerGenericException"
|
||||
format:@"The target does not conform to the FileCreator protocol!"];
|
||||
return;
|
||||
}
|
||||
|
||||
if ([creators objectForKey:type])
|
||||
{
|
||||
[NSException raise:@"FileManagerGenericException"
|
||||
format:@"There is already a creator registered for this type!"];
|
||||
return;
|
||||
}
|
||||
|
||||
// Register the creator!
|
||||
[creators setObject:[dict objectForKey:type] forKey:type];
|
||||
[fileTypePopup addItemWithTitle:type];
|
||||
|
||||
if ([cd objectForKey:@"TypeDescription"])
|
||||
{
|
||||
[typeDescr setObject:[cd objectForKey:@"TypeDescription"] forKey:type];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
470
Framework/PCMakefileFactory.m
Normal file
470
Framework/PCMakefileFactory.m
Normal file
|
@ -0,0 +1,470 @@
|
|||
/*
|
||||
* PCMakefileFactory.m created by probert on 2002-02-28 22:16:25 +0000
|
||||
*
|
||||
* Project ProjectCenter
|
||||
*
|
||||
* Created with ProjectCenter - http://www.gnustep.org
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "PCMakefileFactory.h"
|
||||
#include "PCDefines.h"
|
||||
|
||||
#define COMMENT_HEADERS @"\n\n#\n# Header files\n#\n\n"
|
||||
#define COMMENT_RESOURCES @"\n\n#\n# Resource files\n#\n\n"
|
||||
#define COMMENT_CLASSES @"\n\n#\n# Class files\n#\n\n"
|
||||
#define COMMENT_CFILES @"\n\n#\n# C files\n#\n\n"
|
||||
#define COMMENT_SUBPROJECTS @"\n\n#\n# Subprojects\n#\n\n"
|
||||
#define COMMENT_APP @"\n\n#\n# Main application\n#\n\n"
|
||||
#define COMMENT_LIBRARIES @"\n\n#\n# Additional libraries\n#\n\n"
|
||||
#define COMMENT_BUNDLE @"\n\n#\n# Bundle\n#\n\n"
|
||||
#define COMMENT_LIBRARY @"\n\n#\n# Library\n#\n\n"
|
||||
#define COMMENT_TOOL @"\n\n#\n# Tool\n#\n\n"
|
||||
|
||||
@interface PCMakefileFactory (Private)
|
||||
- (void)appendHeaders:(NSArray *)array forTarget: (NSString *)target;
|
||||
- (void)appendClasses:(NSArray *)array forTarget: (NSString *)target;
|
||||
- (void)appendOtherSources:(NSArray *)array forTarget: (NSString *)target;
|
||||
@end
|
||||
|
||||
@implementation PCMakefileFactory
|
||||
|
||||
static PCMakefileFactory *_factory = nil;
|
||||
|
||||
+ (PCMakefileFactory *)sharedFactory
|
||||
{
|
||||
static BOOL isInitialised = NO;
|
||||
|
||||
if( isInitialised == NO )
|
||||
{
|
||||
_factory = [[PCMakefileFactory alloc] init];
|
||||
|
||||
isInitialised = YES;
|
||||
}
|
||||
|
||||
return _factory;
|
||||
}
|
||||
|
||||
- (void)createMakefileForProject:(NSString *)prName
|
||||
{
|
||||
NSAssert( prName, @"No project name given!");
|
||||
|
||||
AUTORELEASE( mfile );
|
||||
mfile = [[NSMutableString alloc] init];
|
||||
|
||||
AUTORELEASE( pnme );
|
||||
pnme = [prName copy];
|
||||
|
||||
[mfile appendString:@"#\n"];
|
||||
[mfile appendString:@"# GNUmakefile - Generated by ProjectCenter\n"];
|
||||
[mfile appendString:@"#\n"];
|
||||
[mfile appendString:@"# NOTE: Do NOT change this file -- ProjectCenter maintains it!\n"];
|
||||
[mfile appendString:@"# Put all of your customisations in GNUmakefile.preamble and\n"];
|
||||
[mfile appendString:@"# GNUmakefile.postamble\n"];
|
||||
[mfile appendString:@"#\n\n"];
|
||||
}
|
||||
|
||||
- (void)appendString:(NSString *)aString
|
||||
{
|
||||
NSAssert( mfile, @"No valid makefile available!");
|
||||
NSAssert( aString, @"No valid string!");
|
||||
|
||||
[mfile appendString:aString];
|
||||
}
|
||||
|
||||
- (void)appendHeaders:(NSArray *)array forTarget: (NSString *)target
|
||||
{
|
||||
[self appendString:COMMENT_HEADERS];
|
||||
[self appendString:[NSString stringWithFormat:@"%@_HEADER_FILES= ",
|
||||
target]];
|
||||
|
||||
if( array && [array count] )
|
||||
{
|
||||
NSString *tmp;
|
||||
NSEnumerator *enumerator = [array objectEnumerator];
|
||||
|
||||
while ( (tmp = [enumerator nextObject]) )
|
||||
{
|
||||
[self appendString:[NSString stringWithFormat:@"\\\n%@ ",tmp]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)appendHeaders:(NSArray *)array
|
||||
{
|
||||
[self appendHeaders: array forTarget: pnme];
|
||||
}
|
||||
|
||||
- (void)appendClasses:(NSArray *)array forTarget: (NSString *)target
|
||||
{
|
||||
[self appendString:COMMENT_CLASSES];
|
||||
[self appendString:[NSString stringWithFormat:@"%@_OBJC_FILES= ", target]];
|
||||
|
||||
if( array && [array count] )
|
||||
{
|
||||
NSString *tmp;
|
||||
NSEnumerator *enumerator = [array objectEnumerator];
|
||||
|
||||
while ( (tmp = [enumerator nextObject] ))
|
||||
{
|
||||
[self appendString:[NSString stringWithFormat:@"\\\n%@ ",tmp]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)appendClasses:(NSArray *)array
|
||||
{
|
||||
[self appendClasses: array forTarget: pnme];
|
||||
}
|
||||
|
||||
- (void)appendOtherSources:(NSArray *)array forTarget: (NSString *)target
|
||||
{
|
||||
NSMutableArray *marray = nil;
|
||||
NSEnumerator *oenum;
|
||||
NSString *file;
|
||||
|
||||
[self appendString:COMMENT_CFILES];
|
||||
[self appendString:[NSString stringWithFormat:@"%@_C_FILES= ", target]];
|
||||
if ( array == nil || [array count] == 0)
|
||||
return;
|
||||
|
||||
/* Other Sources can have both m files and c files (possibly others?). */
|
||||
oenum = [array objectEnumerator];
|
||||
while ((file = [oenum nextObject]))
|
||||
{
|
||||
if ([file hasSuffix: @".m"])
|
||||
{
|
||||
if (marray == nil)
|
||||
marray = [NSMutableArray arrayWithCapacity: 2];
|
||||
[marray addObject: file];
|
||||
}
|
||||
else /* if ([f hasSuffix: @".c"]) */
|
||||
{
|
||||
[self appendString:[NSString stringWithFormat:@"\\\n%@ ",file]];
|
||||
}
|
||||
}
|
||||
|
||||
[self appendString: @"\n"];
|
||||
[self appendString:[NSString stringWithFormat:@"%@_OBJC_FILES += ",pnme]];
|
||||
if ( marray )
|
||||
{
|
||||
NSString *file;
|
||||
NSEnumerator *enumerator = [marray objectEnumerator];
|
||||
|
||||
while ( (file = [enumerator nextObject]) )
|
||||
{
|
||||
[self appendString:[NSString stringWithFormat:@"\\\n%@ ", file]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)appendOtherSources:(NSArray *)array
|
||||
{
|
||||
[self appendOtherSources: array forTarget: pnme];
|
||||
}
|
||||
|
||||
- (void)appendInstallDir:(NSString*)dir
|
||||
{
|
||||
[self appendString:
|
||||
[NSString stringWithFormat:@"GNUSTEP_INSTALLATION_DIR=%@\n",dir]];
|
||||
}
|
||||
|
||||
- (void)appendResources
|
||||
{
|
||||
[self appendString:COMMENT_RESOURCES];
|
||||
[self appendString:[NSString stringWithFormat:@"%@_RESOURCE_FILES= ",pnme]];
|
||||
}
|
||||
|
||||
- (void)appendResourceItems:(NSArray *)array
|
||||
{
|
||||
NSString *tmp;
|
||||
NSEnumerator *enumerator = [array objectEnumerator];
|
||||
|
||||
while ((tmp = [enumerator nextObject]))
|
||||
{
|
||||
[self appendString:[NSString stringWithFormat:@"\\\n%@ ",tmp]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)appendSubprojects:(NSArray*)array
|
||||
{
|
||||
[self appendString:COMMENT_SUBPROJECTS];
|
||||
|
||||
if (array && [array count])
|
||||
{
|
||||
NSString *tmp;
|
||||
NSEnumerator *enumerator = [array objectEnumerator];
|
||||
|
||||
while ((tmp = [enumerator nextObject]))
|
||||
{
|
||||
[self appendString:[NSString stringWithFormat:@"\\\n%@ ",tmp]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)appendTailForApp
|
||||
{
|
||||
[self appendString:@"\n\n"];
|
||||
|
||||
[self appendString:@"-include GNUmakefile.preamble\n"];
|
||||
[self appendString:@"-include GNUmakefile.local\n"];
|
||||
[self appendString:@"include $(GNUSTEP_MAKEFILES)/aggregate.make\n"];
|
||||
[self appendString:@"include $(GNUSTEP_MAKEFILES)/application.make\n"];
|
||||
[self appendString:@"-include GNUmakefile.postamble\n"];
|
||||
}
|
||||
|
||||
- (void)appendTailForLibrary
|
||||
{
|
||||
NSString *libnme = [NSString stringWithFormat:@"lib%@",pnme];
|
||||
NSString *hinst;
|
||||
|
||||
[self appendString:@"\n\n"];
|
||||
|
||||
hinst = [NSString stringWithFormat:@"HEADERS_INSTALL = $(%@_HEADER_FILES)\n\n",libnme];
|
||||
[self appendString:hinst];
|
||||
|
||||
[self appendString:@"-include GNUmakefile.preamble\n"];
|
||||
[self appendString:@"-include GNUmakefile.local\n"];
|
||||
[self appendString:@"include $(GNUSTEP_MAKEFILES)/library.make\n"];
|
||||
[self appendString:@"-include GNUmakefile.postamble\n"];
|
||||
}
|
||||
|
||||
- (void)appendTailForTool
|
||||
{
|
||||
[self appendString:@"\n\n"];
|
||||
|
||||
[self appendString:@"-include GNUmakefile.preamble\n"];
|
||||
[self appendString:@"-include GNUmakefile.local\n"];
|
||||
[self appendString:@"include $(GNUSTEP_MAKEFILES)/aggregate.make\n"];
|
||||
[self appendString:@"include $(GNUSTEP_MAKEFILES)/tool.make\n"];
|
||||
[self appendString:@"-include GNUmakefile.postamble\n"];
|
||||
}
|
||||
|
||||
- (void)appendTailForBundle
|
||||
{
|
||||
[self appendString:@"\n\n"];
|
||||
|
||||
[self appendString:@"-include GNUmakefile.preamble\n"];
|
||||
[self appendString:@"-include GNUmakefile.local\n"];
|
||||
[self appendString:@"include $(GNUSTEP_MAKEFILES)/bundle.make\n"];
|
||||
[self appendString:@"-include GNUmakefile.postamble\n"];
|
||||
}
|
||||
|
||||
- (void)appendTailForGormApp
|
||||
{
|
||||
[self appendString:@""];
|
||||
}
|
||||
|
||||
- (NSData *)encodedMakefile
|
||||
{
|
||||
NSAssert( mfile, @"No valid makefile available!");
|
||||
|
||||
return [mfile dataUsingEncoding:[NSString defaultCStringEncoding]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation PCMakefileFactory (ApplicationProject)
|
||||
|
||||
- (void)appendApplication
|
||||
{
|
||||
[self appendString:COMMENT_APP];
|
||||
|
||||
[self appendString:[NSString stringWithFormat:@"PACKAGE_NAME=%@\n",pnme]];
|
||||
[self appendString:[NSString stringWithFormat:@"APP_NAME=%@\n",pnme]];
|
||||
|
||||
// TODO: proper support for localisation!!!
|
||||
//[self appendString:[NSString stringWithFormat:@"%@_LANGUAGES=English\n",pnme]];
|
||||
//[self appendString:[NSString stringWithFormat:@"%@_LOCALIZED_RESOURCE_FILES=Localizable.strings\n",pnme]];
|
||||
}
|
||||
|
||||
- (void)appendAppIcon:(NSString*)icn
|
||||
{
|
||||
[self appendString:
|
||||
[NSString stringWithFormat:@"%@_APPLICATION_ICON=%@\n",pnme, icn]];
|
||||
}
|
||||
|
||||
- (void)appendGuiLibraries:(NSArray*)array
|
||||
{
|
||||
[self appendString:COMMENT_LIBRARIES];
|
||||
[self appendString:@"ADDITIONAL_GUI_LIBS += "];
|
||||
|
||||
if( array && [array count] )
|
||||
{
|
||||
NSString *tmp;
|
||||
NSEnumerator *enumerator = [array objectEnumerator];
|
||||
|
||||
while ((tmp = [enumerator nextObject]))
|
||||
{
|
||||
if (![tmp isEqualToString:@"gnustep-base"]
|
||||
&& ![tmp isEqualToString:@"gnustep-gui"])
|
||||
{
|
||||
[self appendString:[NSString stringWithFormat:@"-l%@ ",tmp]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation PCMakefileFactory (BundleProject)
|
||||
|
||||
- (void)appendBundle
|
||||
{
|
||||
[self appendString:COMMENT_BUNDLE];
|
||||
|
||||
[self appendString:[NSString stringWithFormat:@"PACKAGE_NAME=%@\n",pnme]];
|
||||
[self appendString:[NSString stringWithFormat:@"BUNDLE_NAME=%@\n",pnme]];
|
||||
[self appendString:[NSString stringWithFormat:@"BUNDLE_EXTENSION=.bundle\n"]];
|
||||
|
||||
}
|
||||
|
||||
- (void)appendPrincipalClass:(NSString *)cname
|
||||
{
|
||||
[self appendString:
|
||||
[NSString stringWithFormat:@"%@_PRINCIPAL_CLASS=%@\n",pnme,cname]];
|
||||
|
||||
}
|
||||
|
||||
- (void)appendBundleInstallDir:(NSString*)dir
|
||||
{
|
||||
[self appendString:
|
||||
[NSString stringWithFormat:@"BUNDLE_INSTALL_DIR=%@\n",dir]];
|
||||
}
|
||||
|
||||
- (void)appendLibraries:(NSArray*)array
|
||||
{
|
||||
[self appendString:COMMENT_LIBRARIES];
|
||||
|
||||
[self appendString:
|
||||
[NSString stringWithFormat:@"%@_LIBRARIES_DEPEND_UPON += ",pnme]];
|
||||
|
||||
if( array && [array count] )
|
||||
{
|
||||
NSString *tmp;
|
||||
NSEnumerator *enumerator = [array objectEnumerator];
|
||||
|
||||
while ((tmp = [enumerator nextObject]))
|
||||
{
|
||||
if (![tmp isEqualToString:@"gnustep-base"] &&
|
||||
![tmp isEqualToString:@"gnustep-gui"])
|
||||
{
|
||||
[self appendString:[NSString stringWithFormat:@"-l%@ ",tmp]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation PCMakefileFactory (LibraryProject)
|
||||
|
||||
- (void)appendLibrary
|
||||
{
|
||||
NSString *libnme;
|
||||
|
||||
[self appendString:COMMENT_LIBRARY];
|
||||
|
||||
[self appendString:[NSString stringWithFormat:@"PACKAGE_NAME=%@\n",pnme]];
|
||||
[self appendString:[NSString stringWithFormat:@"LIBRARY_VAR=%@\n",[pnme uppercaseString]]];
|
||||
|
||||
libnme = [NSString stringWithFormat:@"lib%@",pnme];
|
||||
[self appendString:[NSString stringWithFormat:@"LIBRARY_NAME=%@\n",libnme]];
|
||||
|
||||
[self appendString:[NSString stringWithFormat:@"%@_HEADER_FILES_DIR=.\n",libnme]];
|
||||
[self appendString:[NSString stringWithFormat:@"%@_HEADER_FILES_INSTALL_DIR=/%@\n",libnme,pnme]];
|
||||
|
||||
[self appendString:@"ADDITIONAL_INCLUDE_DIRS = -I..\n"];
|
||||
[self appendString:@"srcdir = .\n"];
|
||||
}
|
||||
|
||||
- (void)appendLibraryInstallDir:(NSString*)dir
|
||||
{
|
||||
[self appendString:[NSString stringWithFormat:@"%@_INSTALLATION_DIR=$(GNUSTEP_INSTALLATION_DIR)\n",[pnme uppercaseString]]];
|
||||
[self appendString:[NSString stringWithFormat:@"%@_INSTALL_PREFIX=$(GNUSTEP_INSTALLATION_DIR)\n",[pnme uppercaseString]]];
|
||||
}
|
||||
|
||||
- (void)appendLibraryLibraries:(NSArray*)array
|
||||
{
|
||||
NSString *libnme = [NSString stringWithFormat:@"lib%@",pnme];
|
||||
|
||||
[self appendString:COMMENT_LIBRARIES];
|
||||
|
||||
[self appendString:
|
||||
[NSString stringWithFormat:@"%@_LIBRARIES_DEPEND_UPON += ",libnme]];
|
||||
|
||||
if( array && [array count] )
|
||||
{
|
||||
NSString *tmp;
|
||||
NSEnumerator *enumerator = [array objectEnumerator];
|
||||
|
||||
while ((tmp = [enumerator nextObject]))
|
||||
{
|
||||
if (![tmp isEqualToString:@"gnustep-base"])
|
||||
{
|
||||
[self appendString:[NSString stringWithFormat:@"-l%@ ",tmp]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)appendLibraryHeaders:(NSArray*)array
|
||||
{
|
||||
NSString *libnme = [NSString stringWithFormat:@"lib%@",pnme];
|
||||
[self appendHeaders: array forTarget: libnme];
|
||||
}
|
||||
|
||||
- (void)appendLibraryClasses:(NSArray *)array
|
||||
{
|
||||
NSString *libnme = [NSString stringWithFormat:@"lib%@",pnme];
|
||||
[self appendClasses: array forTarget: libnme];
|
||||
}
|
||||
|
||||
- (void)appendLibraryOtherSources:(NSArray *)array
|
||||
{
|
||||
NSString *libnme = [NSString stringWithFormat:@"lib%@",pnme];
|
||||
[self appendOtherSources: array forTarget: libnme];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation PCMakefileFactory (ToolProject)
|
||||
|
||||
- (void)appendTool
|
||||
{
|
||||
[self appendString:COMMENT_TOOL];
|
||||
|
||||
[self appendString:[NSString stringWithFormat:@"PACKAGE_NAME=%@\n",pnme]];
|
||||
[self appendString:[NSString stringWithFormat:@"TOOL_NAME=%@\n",pnme]];
|
||||
}
|
||||
|
||||
- (void)appendToolIcon:(NSString*)icn
|
||||
{
|
||||
[self appendString:
|
||||
[NSString stringWithFormat:@"%@_TOOL_ICON=%@\n",pnme, icn]];
|
||||
}
|
||||
|
||||
- (void)appendToolLibraries:(NSArray*)array
|
||||
{
|
||||
[self appendString:COMMENT_LIBRARIES];
|
||||
|
||||
[self appendString:[NSString stringWithFormat:@"%@_TOOL_LIBS += ",pnme]];
|
||||
|
||||
if( array && [array count] )
|
||||
{
|
||||
NSString *tmp;
|
||||
NSEnumerator *enumerator = [array objectEnumerator];
|
||||
|
||||
while ((tmp = [enumerator nextObject]) )
|
||||
{
|
||||
if (![tmp isEqualToString:@"gnustep-base"])
|
||||
{
|
||||
[self appendString:[NSString stringWithFormat:@"-l%@ ",tmp]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -83,7 +83,7 @@ typedef int PCProjInfoBits;
|
|||
static NSString * const PCClasses = @"CLASS_FILES";
|
||||
static NSString * const PCHeaders = @"HEADER_FILES";
|
||||
static NSString * const PCOtherSources = @"OTHER_SOURCES";
|
||||
static NSString * const PCGModels = @"INTERFACES";
|
||||
static NSString * const PCInterfaces = @"INTERFACES";
|
||||
static NSString * const PCImages = @"IMAGES";
|
||||
static NSString * const PCOtherResources = @"OTHER_RESOURCES";
|
||||
static NSString * const PCSubprojects = @"SUBPROJECTS";
|
||||
|
@ -191,8 +191,6 @@ extern NSString *ProjectDictDidSaveNotification;
|
|||
- (PCProjectEditor *)projectEditor;
|
||||
- (PCEditorController *)editorController;
|
||||
|
||||
- (NSArray *)fileExtensionsForCategory:(NSString *)key;
|
||||
|
||||
- (NSString *)projectName;
|
||||
- (void)setProjectName:(NSString *)aName;
|
||||
- (BOOL)isProjectChanged;
|
||||
|
@ -217,6 +215,9 @@ extern NSString *ProjectDictDidSaveNotification;
|
|||
// Subclasses need to call this before their customised implementation!
|
||||
- (BOOL)writeMakefile;
|
||||
|
||||
- (NSArray *)fileTypesForCategory:(NSString *)category;
|
||||
- (NSString *)dirForCategory:(NSString *)category;
|
||||
|
||||
- (NSArray *)sourceFileKeys;
|
||||
- (NSArray *)resourceFileKeys;
|
||||
- (NSArray *)otherKeys;
|
||||
|
@ -235,15 +236,18 @@ extern NSString *ProjectDictDidSaveNotification;
|
|||
- (void)browserDidClickFile:(NSString *)fileName category:(NSString*)c;
|
||||
- (void)browserDidDblClickFile:(NSString *)fileName category:(NSString*)c;
|
||||
|
||||
// Remove path from "file" and handle special cases like libraries
|
||||
- (NSString *)projectFileFromFile:(NSString *)file forKey:(NSString *)type;
|
||||
|
||||
// Returns YES if type is a valid key and file is not contained in the
|
||||
// project already
|
||||
- (BOOL)doesAcceptFile:(NSString *)file forKey:(NSString *)key;
|
||||
|
||||
- (void)addFile:(NSString *)file forKey:(NSString *)key;
|
||||
- (void)addFile:(NSString *)file forKey:(NSString *)key copy:(BOOL)yn;
|
||||
- (BOOL)addAndCopyFiles:(NSArray *)files forKey:(NSString *)key;
|
||||
- (void)addFiles:(NSArray *)files forKey:(NSString *)key;
|
||||
|
||||
- (void)removeFiles:(NSArray *)files forKey:(NSString *)key;
|
||||
|
||||
- (void)removeFile:(NSString *)file forKey:(NSString *)key;
|
||||
- (BOOL)removeSelectedFilesPermanently:(BOOL)yn;
|
||||
- (void)renameFile:(NSString *)aFile;
|
||||
|
||||
- (BOOL)assignProjectDict:(NSDictionary *)aDict;
|
|
@ -24,6 +24,7 @@
|
|||
$Id$
|
||||
*/
|
||||
|
||||
#include "PCFileManager.h"
|
||||
#include "PCProjectManager.h"
|
||||
#include "PCProject.h"
|
||||
#include "PCDefines.h"
|
||||
|
@ -111,7 +112,6 @@ NSString *ProjectDictDidSaveNotification = @"ProjectDictDidSaveNotification";
|
|||
- (void)close
|
||||
{
|
||||
[editorController closeAllEditors];
|
||||
|
||||
[projectManager closeProject:self];
|
||||
}
|
||||
|
||||
|
@ -196,36 +196,6 @@ NSString *ProjectDictDidSaveNotification = @"ProjectDictDidSaveNotification";
|
|||
return [self projectKeyForKeyPath:_path];
|
||||
}
|
||||
|
||||
- (NSArray *)fileExtensionsForCategory:(NSString *)key
|
||||
{
|
||||
if ([key isEqualToString:PCGModels]) {
|
||||
return [NSArray arrayWithObjects:@"gmodel",@"gorm",nil];
|
||||
}
|
||||
if ([key isEqualToString:PCGSMarkupFiles]) {
|
||||
return [NSArray arrayWithObjects:@"gsmarkup",nil];
|
||||
}
|
||||
else if ([key isEqualToString:PCClasses]) {
|
||||
return [NSArray arrayWithObjects:@"m",nil];
|
||||
}
|
||||
else if ([key isEqualToString:PCHeaders]) {
|
||||
return [NSArray arrayWithObjects:@"h",nil];
|
||||
}
|
||||
else if ([key isEqualToString:PCOtherSources]) {
|
||||
return [NSArray arrayWithObjects:@"c",@"C",nil];
|
||||
}
|
||||
else if ([key isEqualToString:PCLibraries]) {
|
||||
return [NSArray arrayWithObjects:@"so",@"a",@"lib",nil];
|
||||
}
|
||||
else if ([key isEqualToString:PCSubprojects]) {
|
||||
return [NSArray arrayWithObjects:@"subproj",nil];
|
||||
}
|
||||
else if ([key isEqualToString:PCImages]) {
|
||||
return [NSImage imageFileTypes];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)setProjectName:(NSString *)aName
|
||||
{
|
||||
AUTORELEASE(projectName);
|
||||
|
@ -310,6 +280,16 @@ NSString *ProjectDictDidSaveNotification = @"ProjectDictDidSaveNotification";
|
|||
return YES;
|
||||
}
|
||||
|
||||
- (NSArray *)fileTypesForCategory:(NSString *)category
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSString *)dirForCategory:(NSString *)category
|
||||
{
|
||||
return projectPath;
|
||||
}
|
||||
|
||||
- (NSArray *)sourceFileKeys
|
||||
{
|
||||
return nil;
|
||||
|
@ -381,177 +361,121 @@ NSString *ProjectDictDidSaveNotification = @"ProjectDictDidSaveNotification";
|
|||
}
|
||||
}
|
||||
|
||||
- (BOOL)doesAcceptFile:(NSString *)file forKey:(NSString *)type
|
||||
- (NSString *)projectFileFromFile:(NSString *)file forKey:(NSString *)type
|
||||
{
|
||||
if ([[projectDict allKeys] containsObject:type]) {
|
||||
NSArray *files = [projectDict objectForKey:type];
|
||||
NSMutableString *projectFile = nil;
|
||||
|
||||
if (![files containsObject:file]) {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)addFile:(NSString *)file forKey:(NSString *)type
|
||||
{
|
||||
[self addFile:file forKey:type copy:NO];
|
||||
}
|
||||
|
||||
- (void)addFile:(NSString *)file forKey:(NSString *)type copy:(BOOL)yn
|
||||
{
|
||||
NSArray *types = [projectDict objectForKey:type];
|
||||
NSMutableArray *files = [NSMutableArray arrayWithArray:types];
|
||||
NSString *lpc = [file lastPathComponent];
|
||||
NSMutableString *newFile = [NSMutableString stringWithString:lpc];
|
||||
projectFile = [NSMutableString stringWithString:[file lastPathComponent]];
|
||||
|
||||
if ([type isEqualToString:PCLibraries])
|
||||
{
|
||||
[newFile deleteCharactersInRange:NSMakeRange(0,3)];
|
||||
newFile = (NSMutableString*)[newFile stringByDeletingPathExtension];
|
||||
[projectFile deleteCharactersInRange:NSMakeRange(0,3)];
|
||||
projectFile =
|
||||
(NSMutableString*)[projectFile stringByDeletingPathExtension];
|
||||
}
|
||||
|
||||
if ([files containsObject:newFile])
|
||||
return projectFile;
|
||||
}
|
||||
|
||||
- (BOOL)doesAcceptFile:(NSString *)file forKey:(NSString *)type
|
||||
{
|
||||
NSArray *projectFiles = [projectDict objectForKey:type];
|
||||
NSString *pFile = [self projectFileFromFile:file forKey:type];
|
||||
|
||||
if ([[projectDict allKeys] containsObject:type])
|
||||
{
|
||||
NSRunAlertPanel(@"Attention!",
|
||||
@"The file %@ is already part of this project!",
|
||||
@"OK",nil,nil,newFile);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
NSLog(@"<%@ %x>: adding file %@ for key %@",[self class],self,newFile,type);
|
||||
#endif// DEBUG
|
||||
|
||||
// Add the new file
|
||||
[files addObject:newFile];
|
||||
[projectDict setObject:files forKey:type];
|
||||
|
||||
if (yn)
|
||||
{
|
||||
NSFileManager *manager = [NSFileManager defaultManager];
|
||||
NSString *destination = [[self projectPath]
|
||||
stringByAppendingPathComponent:newFile];
|
||||
|
||||
if (![manager copyPath:file toPath:destination handler:nil])
|
||||
if (![projectFiles containsObject:pFile])
|
||||
{
|
||||
NSRunAlertPanel(@"Attention!",
|
||||
@"The file %@ could not be copied to %@!",
|
||||
@"OK",nil,nil,newFile,destination);
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:ProjectDictDidChangeNotification
|
||||
object:self];
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)removeFile:(NSString *)file forKey:(NSString *)key
|
||||
- (BOOL)addAndCopyFiles:(NSArray *)files forKey:(NSString *)key
|
||||
{
|
||||
NSMutableArray *array;
|
||||
NSMutableString *filePath;
|
||||
NSEnumerator *fileEnum = [files objectEnumerator];
|
||||
NSString *file = nil;
|
||||
NSMutableArray *fileList = [[files mutableCopy] autorelease];
|
||||
PCFileManager *fileManager = [projectManager fileManager];
|
||||
NSString *directory = [self dirForCategory:key];
|
||||
|
||||
if (!file || !key)
|
||||
// Validate files
|
||||
while ((file = [fileEnum nextObject]))
|
||||
{
|
||||
return;
|
||||
if (![self doesAcceptFile:file forKey:key])
|
||||
{
|
||||
[fileList removeObject:file];
|
||||
}
|
||||
}
|
||||
|
||||
// Close editor
|
||||
filePath = [[NSMutableString alloc] initWithString:projectPath];
|
||||
[filePath appendString:@"/"];
|
||||
[filePath appendString:file];
|
||||
[editorController closeEditorForFile:filePath];
|
||||
[filePath release];
|
||||
|
||||
array = [NSMutableArray arrayWithArray:[projectDict objectForKey:key]];
|
||||
[array removeObject:file];
|
||||
[projectDict setObject:array forKey:key];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:ProjectDictDidChangeNotification
|
||||
object:self];
|
||||
}
|
||||
|
||||
- (BOOL)removeSelectedFilesPermanently:(BOOL)yn
|
||||
{
|
||||
NSEnumerator *files = [[[self projectBrowser] selectedFiles] objectEnumerator];
|
||||
NSString *file = nil;
|
||||
NSString *key = nil;
|
||||
NSString *otherKey = nil;
|
||||
NSString *ext = nil;
|
||||
NSString *fn = nil;
|
||||
BOOL ret = NO;
|
||||
|
||||
if (!files)
|
||||
// Copy files
|
||||
if (![fileManager copyFiles:fileList intoDirectory:directory])
|
||||
{
|
||||
NSRunAlertPanel(@"Alert",
|
||||
@"Error adding files to project %@!",
|
||||
@"OK", nil, nil, projectName);
|
||||
return NO;
|
||||
}
|
||||
|
||||
key = [self projectKeyForKeyPath:[[self projectBrowser] pathOfSelectedFile]];
|
||||
// Add files to project
|
||||
[self addFiles:fileList forKey:key];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
while ((file = [files nextObject]))
|
||||
- (void)addFiles:(NSArray *)files forKey:(NSString *)type
|
||||
{
|
||||
NSEnumerator *enumerator = nil;
|
||||
NSString *file = nil;
|
||||
NSString *pFile = nil;
|
||||
NSArray *types = [projectDict objectForKey:type];
|
||||
NSMutableArray *projectFiles = [NSMutableArray arrayWithArray:types];
|
||||
|
||||
enumerator = [files objectEnumerator];
|
||||
while ((file = [enumerator nextObject]))
|
||||
{
|
||||
[self removeFile:file forKey:key];
|
||||
|
||||
if ([key isEqualToString:PCClasses])
|
||||
{
|
||||
otherKey = PCHeaders;
|
||||
ext = [NSString stringWithString:@"h"];
|
||||
|
||||
fn = [file stringByDeletingPathExtension];
|
||||
fn = [fn stringByAppendingPathExtension:ext];
|
||||
|
||||
if ([self doesAcceptFile:fn forKey:otherKey] == NO)
|
||||
{
|
||||
ret = NSRunAlertPanel(@"Removing Header?",
|
||||
@"Should %@ be removed from the project %@ as well?",
|
||||
@"Yes", @"No", nil,
|
||||
fn, [self projectName]);
|
||||
}
|
||||
}
|
||||
else if ([key isEqualToString:PCHeaders])
|
||||
{
|
||||
otherKey = PCClasses;
|
||||
ext = [NSString stringWithString:@"m"];
|
||||
|
||||
fn = [file stringByDeletingPathExtension];
|
||||
fn = [fn stringByAppendingPathExtension:ext];
|
||||
|
||||
if ([self doesAcceptFile:fn forKey:otherKey] == NO)
|
||||
{
|
||||
ret = NSRunAlertPanel(@"Removing Class?",
|
||||
@"Should %@ be removed from the project %@ as well?",
|
||||
@"Yes", @"No", nil,
|
||||
fn, [self projectName]);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret)
|
||||
{
|
||||
[self removeFile:fn forKey:otherKey];
|
||||
}
|
||||
|
||||
// Remove the file permanently?!
|
||||
if (yn)
|
||||
{
|
||||
NSString *pth = [projectPath stringByAppendingPathComponent:file];
|
||||
|
||||
[[NSFileManager defaultManager] removeFileAtPath:pth handler:nil];
|
||||
|
||||
if (ret)
|
||||
{
|
||||
pth = [projectPath stringByAppendingPathComponent:fn];
|
||||
[[NSFileManager defaultManager] removeFileAtPath:pth handler:nil];
|
||||
}
|
||||
}
|
||||
pFile = [self projectFileFromFile:file forKey:type];
|
||||
[projectFiles addObject:pFile];
|
||||
}
|
||||
|
||||
[projectDict setObject:projectFiles forKey:type];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:ProjectDictDidChangeNotification
|
||||
object:self];
|
||||
}
|
||||
|
||||
return YES;
|
||||
- (void)removeFiles:(NSArray *)files forKey:(NSString *)key
|
||||
{
|
||||
NSEnumerator *enumerator = nil;
|
||||
NSString *filePath = nil;
|
||||
NSString *file = nil;
|
||||
NSMutableArray *projectFiles = nil;
|
||||
|
||||
if (!files || !key)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove files from project
|
||||
projectFiles = [NSMutableArray arrayWithArray:[projectDict objectForKey:key]];
|
||||
enumerator = [files objectEnumerator];
|
||||
while ((file = [enumerator nextObject]))
|
||||
{
|
||||
[projectFiles removeObject:file];
|
||||
|
||||
// Close editor
|
||||
filePath = [projectPath stringByAppendingPathComponent:file];
|
||||
[editorController closeEditorForFile:filePath];
|
||||
}
|
||||
|
||||
[projectDict setObject:projectFiles forKey:key];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:ProjectDictDidChangeNotification
|
||||
object:self];
|
||||
}
|
||||
|
||||
- (void)renameFile:(NSString *)aFile
|
||||
|
@ -600,8 +524,7 @@ NSString *ProjectDictDidSaveNotification = @"ProjectDictDidSaveNotification";
|
|||
|
||||
- (BOOL)save
|
||||
{
|
||||
NSString *file = [[projectPath stringByAppendingPathComponent:projectName]
|
||||
stringByAppendingPathExtension:@"pcproj"];
|
||||
NSString *file = [projectPath stringByAppendingPathComponent:@"PC.project"];
|
||||
NSString *backup = [file stringByAppendingPathExtension:@"backup"];
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
|
||||
#include "PCFileManager.h"
|
||||
#include "PCProjectManager.h"
|
||||
#include "PCProject.h"
|
||||
#include "PCEditorController.h"
|
||||
#include "PCProjectBrowser.h"
|
||||
|
@ -214,7 +215,7 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification";
|
|||
}
|
||||
else
|
||||
{
|
||||
[[PCFileManager fileManager] showAddFileWindow];
|
||||
[[project projectManager] addProjectFiles];
|
||||
}
|
||||
}
|
||||
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
@class PCFileManager;
|
||||
@class PCProject;
|
||||
@class PCProjectInspector;
|
||||
@class PCProjectBuilder;
|
||||
|
@ -50,6 +51,7 @@ extern NSString *ActiveProjectDidChangeNotification;
|
|||
{
|
||||
id delegate;
|
||||
|
||||
PCFileManager *fileManager;
|
||||
PCProjectInspector *projectInspector;
|
||||
|
||||
NSPanel *buildPanel;
|
||||
|
@ -84,9 +86,11 @@ extern NSString *ActiveProjectDidChangeNotification;
|
|||
// ============================================================================
|
||||
// ==== Accessory methods
|
||||
// ============================================================================
|
||||
- (PCFileManager *)fileManager;
|
||||
- (PCProjectInspector *)projectInspector;
|
||||
- (void)showProjectInspector:(id)sender;
|
||||
- (NSPanel *)historyPanel;
|
||||
- (void)showProjectHistory:(id)sender;
|
||||
- (NSPanel *)buildPanel;
|
||||
- (NSPanel *)launchPanel;
|
||||
- (NSPanel *)projectFinderPanel;
|
||||
|
@ -118,6 +122,10 @@ extern NSString *ActiveProjectDidChangeNotification;
|
|||
// ==== Project actions
|
||||
// ============================================================================
|
||||
|
||||
// Before project is loaded fetch project's name from project path
|
||||
// Change this to remove dependency from project path
|
||||
- (NSString *)projectNameAtPath:(NSString *)aPath;
|
||||
|
||||
// Returns the loaded project if the builder class is known, nil else.
|
||||
- (PCProject *)loadProjectAt:(NSString *)aPath;
|
||||
|
||||
|
@ -139,7 +147,6 @@ extern NSString *ActiveProjectDidChangeNotification;
|
|||
|
||||
- (BOOL)saveProjectAs:(NSString *)projName;
|
||||
|
||||
// Reverts the currently active project
|
||||
- (void)revertToSaved;
|
||||
|
||||
- (BOOL)newSubproject;
|
||||
|
@ -147,22 +154,23 @@ extern NSString *ActiveProjectDidChangeNotification;
|
|||
- (void)removeSubproject;
|
||||
|
||||
- (void)closeProject:(PCProject *)aProject;
|
||||
// Closes the currently active project
|
||||
- (void)closeProject;
|
||||
|
||||
// ============================================================================
|
||||
// ==== File actions
|
||||
// ============================================================================
|
||||
|
||||
- (BOOL)saveAllFiles;
|
||||
- (void)newFile;
|
||||
- (BOOL)saveFile;
|
||||
- (BOOL)saveFileAs:(NSString *)path;
|
||||
- (BOOL)saveFileTo:(NSString *)path;
|
||||
- (BOOL)revertFileToSaved;
|
||||
- (BOOL)renameFileTo:(NSString *)path;
|
||||
- (void)closeFile;
|
||||
|
||||
- (BOOL)renameFileTo:(NSString *)path;
|
||||
- (BOOL)removeFilesPermanently:(BOOL)yn;
|
||||
- (BOOL)addProjectFiles;
|
||||
- (BOOL)saveProjectFiles;
|
||||
- (BOOL)removeProjectFiles;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -178,18 +186,6 @@ extern NSString *ActiveProjectDidChangeNotification;
|
|||
didCreateFile:(NSString *)aFile
|
||||
withKey:(NSString *)key;
|
||||
|
||||
// Returns the active project
|
||||
- (id)fileManagerWillAddFiles:(id)sender;
|
||||
|
||||
- (BOOL)fileManager:(id)sender
|
||||
shouldAddFile:(NSString *)file
|
||||
forKey:(NSString *)key;
|
||||
|
||||
// Adds the file to the project and update the makefile!
|
||||
- (void)fileManager:(id)sender
|
||||
didAddFile:(NSString *)file
|
||||
forKey:(NSString *)key;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSObject (PCProjectManagerDelegates)
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "PCDefines.h"
|
||||
|
||||
#include "PCFileManager.h"
|
||||
#include "PCProjectManager.h"
|
||||
#include "PCHistoryPanel.h"
|
||||
#include "PCBuildPanel.h"
|
||||
|
@ -83,12 +84,10 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange";
|
|||
selector:spdc
|
||||
name:SavePeriodDCN
|
||||
object:nil];
|
||||
/* projectInspector = nil;
|
||||
buildPan = nil;
|
||||
projectDebugger = nil;
|
||||
projectHistory = nil;
|
||||
projectFinder = nil;*/
|
||||
|
||||
fileManager = [PCFileManager fileManager];
|
||||
[fileManager setDelegate:self];
|
||||
|
||||
_needsReleasing = NO;
|
||||
}
|
||||
|
||||
|
@ -139,6 +138,11 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange";
|
|||
// ============================================================================
|
||||
// ==== Accessory methods
|
||||
// ============================================================================
|
||||
- (PCFileManager *)fileManager
|
||||
{
|
||||
return fileManager;
|
||||
}
|
||||
|
||||
- (PCProjectInspector *)projectInspector
|
||||
{
|
||||
if (!projectInspector)
|
||||
|
@ -165,6 +169,15 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange";
|
|||
return historyPanel;
|
||||
}
|
||||
|
||||
- (void)showProjectHistory:(id)sender
|
||||
{
|
||||
if (![[[[NSUserDefaults standardUserDefaults] dictionaryRepresentation]
|
||||
objectForKey: SeparateBuilder] isEqualToString: @"YES"])
|
||||
{
|
||||
[[activeProject projectWindow] showProjectHistory:self];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSPanel *)buildPanel
|
||||
{
|
||||
if (!buildPanel)
|
||||
|
@ -273,6 +286,11 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange";
|
|||
// ==== Project actions
|
||||
// ============================================================================
|
||||
|
||||
- (NSString *)projectNameAtPath:(NSString *)aPath
|
||||
{
|
||||
return [[aPath stringByDeletingLastPathComponent] lastPathComponent];
|
||||
}
|
||||
|
||||
- (PCProject *)loadProjectAt:(NSString *)aPath
|
||||
{
|
||||
NSDictionary *projectFile;
|
||||
|
@ -301,13 +319,16 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange";
|
|||
|
||||
- (BOOL)openProjectAt:(NSString *)aPath
|
||||
{
|
||||
BOOL isDir = NO;
|
||||
BOOL isDir = NO;
|
||||
NSString *projectName = nil;
|
||||
|
||||
if ([loadedProjects objectForKey:aPath])
|
||||
projectName = [self projectNameAtPath:aPath];
|
||||
|
||||
if ([loadedProjects objectForKey:projectName])
|
||||
{
|
||||
NSRunAlertPanel(@"Attention!",
|
||||
@"Project '%@' has already been opened!",
|
||||
@"OK",nil,nil,aPath);
|
||||
@"OK",nil,nil,projectName);
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
@ -322,7 +343,7 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange";
|
|||
}
|
||||
|
||||
[project setProjectManager:self];
|
||||
[loadedProjects setObject:project forKey:aPath];
|
||||
[loadedProjects setObject:project forKey:projectName];
|
||||
[self setActiveProject:project];
|
||||
|
||||
[project validateProjectDict];
|
||||
|
@ -352,9 +373,7 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange";
|
|||
|
||||
[project setProjectManager:self];
|
||||
|
||||
aPath = [aPath stringByAppendingPathComponent: [aPath lastPathComponent]];
|
||||
aPath = [aPath stringByAppendingPathExtension: @"pcproj"];
|
||||
[loadedProjects setObject:project forKey:aPath];
|
||||
[loadedProjects setObject:project forKey:[self projectNameAtPath:aPath]];
|
||||
|
||||
[self setActiveProject:project];
|
||||
|
||||
|
@ -388,6 +407,7 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange";
|
|||
{
|
||||
}
|
||||
|
||||
// subprojects
|
||||
- (BOOL)newSubproject
|
||||
{
|
||||
return NO;
|
||||
|
@ -401,18 +421,14 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange";
|
|||
- (void)removeSubproject
|
||||
{
|
||||
}
|
||||
//
|
||||
|
||||
- (void)closeProject:(PCProject *)aProject
|
||||
{
|
||||
PCProject *currentProject = nil;
|
||||
NSString *path = [aProject projectPath];
|
||||
NSString *projectName = [path lastPathComponent];
|
||||
NSString *key;
|
||||
NSString *projectName = [aProject projectName];
|
||||
|
||||
key = [path stringByAppendingPathComponent:projectName];
|
||||
key = [key stringByAppendingPathExtension:@"pcproj"];
|
||||
|
||||
currentProject = RETAIN([loadedProjects objectForKey:key]);
|
||||
currentProject = RETAIN([loadedProjects objectForKey:projectName]);
|
||||
if (!currentProject)
|
||||
{
|
||||
return;
|
||||
|
@ -420,7 +436,7 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange";
|
|||
|
||||
// Remove it from the loaded projects! This is the only place it
|
||||
// is retained, so it should dealloc after this.
|
||||
[loadedProjects removeObjectForKey:key];
|
||||
[loadedProjects removeObjectForKey:projectName];
|
||||
|
||||
if ([loadedProjects count] == 0)
|
||||
{
|
||||
|
@ -440,16 +456,16 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange";
|
|||
|
||||
- (void)closeProject
|
||||
{
|
||||
[[[self activeProject] projectWindow] performClose:self];
|
||||
[[activeProject projectWindow] performClose:self];
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// ==== File actions
|
||||
// ============================================================================
|
||||
|
||||
- (BOOL)saveAllFiles
|
||||
- (void)newFile
|
||||
{
|
||||
return [[activeProject editorController] saveAllFiles];
|
||||
[fileManager showNewFileWindow];
|
||||
}
|
||||
|
||||
- (BOOL)saveFile
|
||||
|
@ -482,83 +498,109 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange";
|
|||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)removeFilesPermanently:(BOOL)yn
|
||||
// Project menu
|
||||
- (BOOL)addProjectFiles
|
||||
{
|
||||
NSString *category = nil;
|
||||
NSString *directory = nil;
|
||||
NSArray *fileTypes = nil;
|
||||
NSMutableArray *files = nil;
|
||||
|
||||
category = [activeProject selectedRootCategory];
|
||||
directory = [activeProject dirForCategory:category];
|
||||
fileTypes = [activeProject fileTypesForCategory:category];
|
||||
|
||||
// Order Open panel and return selected files
|
||||
files = [fileManager selectFilesOfType:fileTypes multiple:YES];
|
||||
|
||||
// No files was selected
|
||||
if (!files)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Copy and add files
|
||||
[activeProject addAndCopyFiles:files forKey:category];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)saveProjectFiles
|
||||
{
|
||||
return [[activeProject editorController] saveAllFiles];
|
||||
}
|
||||
|
||||
- (BOOL)removeProjectFiles
|
||||
{
|
||||
NSArray *files = nil;
|
||||
NSString *category = nil;
|
||||
NSString *directory = nil;
|
||||
|
||||
if (!activeProject)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
return [activeProject removeSelectedFilesPermanently:yn];
|
||||
files = [[activeProject projectBrowser] selectedFiles];
|
||||
category = [activeProject selectedRootCategory];
|
||||
directory = [activeProject dirForCategory:category];
|
||||
|
||||
if (files)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = NSRunAlertPanel(@"Remove",
|
||||
@"Remove files...",
|
||||
@"Cancel",
|
||||
@"...from Project only",
|
||||
@"...from Project and Disk");
|
||||
|
||||
if (ret == NSAlertAlternateReturn || ret == NSAlertOtherReturn)
|
||||
{
|
||||
BOOL flag = (ret == NSAlertOtherReturn) ? YES : NO;
|
||||
|
||||
if (flag
|
||||
&& ![fileManager removeFiles:files fromDirectory:directory])
|
||||
{
|
||||
NSRunAlertPanel(@"Alert",
|
||||
@"Error removing files from project %@!",
|
||||
@"OK", nil, nil, [activeProject projectName]);
|
||||
return NO;
|
||||
}
|
||||
|
||||
[activeProject removeFiles:files forKey:category];
|
||||
}
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation PCProjectManager (FileManagerDelegates)
|
||||
|
||||
- (NSString *)fileManager:(id)sender willCreateFile:(NSString *)aFile withKey:(NSString *)key
|
||||
// willCreateFile
|
||||
- (NSString *)fileManager:(id)sender
|
||||
willCreateFile:(NSString *)aFile
|
||||
withKey:(NSString *)key
|
||||
{
|
||||
NSString *path = nil;
|
||||
|
||||
#ifdef DEBUG
|
||||
NSLog(@"%@ %x: will create file %@ for key %@",[self class],self,aFile,key);
|
||||
#endif // DEBUG
|
||||
NSString *path = nil;
|
||||
|
||||
if ([activeProject doesAcceptFile:aFile forKey:key] )
|
||||
if ([activeProject doesAcceptFile:aFile forKey:key])
|
||||
{
|
||||
path = [[activeProject projectPath] stringByAppendingPathComponent:aFile];
|
||||
path = [[activeProject projectPath] stringByAppendingPathComponent:aFile];
|
||||
}
|
||||
|
||||
return path;
|
||||
return path;
|
||||
}
|
||||
|
||||
- (void)fileManager:(id)sender didCreateFile:(NSString *)aFile withKey:(NSString *)key
|
||||
// didCreateFiles
|
||||
- (void)fileManager:(id)sender
|
||||
didCreateFile:(NSString *)aFile
|
||||
withKey:(NSString *)key
|
||||
{
|
||||
#ifdef DEBUG
|
||||
NSLog(@"%@ %x: did create file %@ for key %@",[self class],self,aFile,key);
|
||||
#endif // DEBUG
|
||||
|
||||
[activeProject addFile:aFile forKey:key];
|
||||
}
|
||||
|
||||
- (id)fileManagerWillAddFiles:(id)sender
|
||||
{
|
||||
return activeProject;
|
||||
}
|
||||
|
||||
- (BOOL)fileManager:(id)sender shouldAddFile:(NSString *)file forKey:(NSString *)key
|
||||
{
|
||||
NSMutableString *fn = [NSMutableString stringWithString:[file lastPathComponent]];
|
||||
|
||||
#ifdef DEBUG
|
||||
NSLog(@"%@ %x: should add file %@ for key %@",[self class],self,file,key);
|
||||
#endif // DEBUG
|
||||
|
||||
if ([key isEqualToString:PCLibraries])
|
||||
{
|
||||
[fn deleteCharactersInRange:NSMakeRange(1,3)];
|
||||
fn = (NSMutableString *)[fn stringByDeletingPathExtension];
|
||||
}
|
||||
|
||||
if ([[[activeProject projectDict] objectForKey:key] containsObject:fn])
|
||||
{
|
||||
NSRunAlertPanel(@"Attention!",
|
||||
@"The file %@ is already part of project %@!",
|
||||
@"OK",nil,nil,fn,[activeProject projectName]);
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)fileManager:(id)sender didAddFile:(NSString *)file forKey:(NSString *)key
|
||||
{
|
||||
#ifdef DEBUG
|
||||
NSLog(@"%@ %x: did add file %@ for key %@",[self class],self,file,key);
|
||||
#endif // DEBUG
|
||||
|
||||
[activeProject addFile:file forKey:key];
|
||||
[activeProject addFiles:[NSArray arrayWithObject:aFile] forKey:key];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
@ -54,7 +54,6 @@
|
|||
#include <ProjectCenter/ProjectComponent.h>
|
||||
#include <ProjectCenter/PreferenceController.h>
|
||||
#include <ProjectCenter/ProjectBuilder.h>
|
||||
#include <ProjectCenter/FileCreator.h>
|
||||
|
||||
#endif
|
||||
|
9
Framework/Resources/cfile.template
Normal file
9
Framework/Resources/cfile.template
Normal file
|
@ -0,0 +1,9 @@
|
|||
/*
|
||||
* $FILENAME$ created by $USERNAME$ on $DATE$
|
||||
*
|
||||
* Project name: $PROJECTNAME$
|
||||
*
|
||||
* Created with ProjectCenter - http://www.gnustep.org
|
||||
*/
|
||||
|
||||
#include "$FILENAMESANSEXTENSION$.h"
|
13
Framework/Resources/cheader.template
Normal file
13
Framework/Resources/cheader.template
Normal file
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* $FILENAME$ created by $USERNAME$ on $DATE$
|
||||
*
|
||||
* Project $PROJECTNAME$
|
||||
*
|
||||
* Created with ProjectCenter - http://www.gnustep.org
|
||||
*/
|
||||
|
||||
#ifndef _$UCFILENAMESANSEXTENSION$_H_
|
||||
#define _$UCFILENAMESANSEXTENSION$_H_
|
||||
|
||||
#endif // _$UCFILENAMESANSEXTENSION$_H_
|
||||
|
13
Framework/Resources/class.template
Normal file
13
Framework/Resources/class.template
Normal file
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* $FILENAME$ created by $USERNAME$ on $DATE$
|
||||
*
|
||||
* Project $PROJECTNAME$
|
||||
*
|
||||
* Created with ProjectCenter - http://www.gnustep.org
|
||||
*/
|
||||
|
||||
#include "$FILENAMESANSEXTENSION$.h"
|
||||
|
||||
@implementation $FILENAMESANSEXTENSION$
|
||||
|
||||
@end
|
8
Framework/Resources/gsmarkup.template
Normal file
8
Framework/Resources/gsmarkup.template
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE gsmarkup>
|
||||
<gsmarkup>
|
||||
|
||||
<objects>
|
||||
<window/>
|
||||
</objects>
|
||||
</gsmarkup>
|
22
Framework/Resources/header.template
Normal file
22
Framework/Resources/header.template
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* $FILENAME$ created by $USERNAME$ on $DATE$
|
||||
*
|
||||
* Project $PROJECTNAME$
|
||||
*
|
||||
* Created with ProjectCenter - http://www.gnustep.org
|
||||
*/
|
||||
|
||||
#ifndef _$UCFILENAMESANSEXTENSION$_H_
|
||||
#define _$UCFILENAMESANSEXTENSION$_H_
|
||||
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
@interface $FILENAMESANSEXTENSION$ : NSObject
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif // _$UCFILENAMESANSEXTENSION$_H_
|
||||
|
11
Framework/Resources/protocol.template
Normal file
11
Framework/Resources/protocol.template
Normal file
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* $FILENAME$ created by $USERNAME$ on $DATE$
|
||||
*
|
||||
* Project $PROJECTNAME$
|
||||
*
|
||||
* Created with ProjectCenter - http://www.gnustep.org
|
||||
*/
|
||||
|
||||
@protocol $FILENAMESANSEXTENSION$ <NSObject>
|
||||
|
||||
@end
|
|
@ -1,136 +0,0 @@
|
|||
#
|
||||
# GNUmakefile - Generated by ProjectCenter
|
||||
# Written by Philippe C.D. Robert <probert@siggraph.org>
|
||||
#
|
||||
# NOTE: Do NOT change this file -- ProjectCenter maintains it!
|
||||
#
|
||||
# Put all of your customisations in GNUmakefile.preamble and
|
||||
# GNUmakefile.postamble
|
||||
#
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
include Version
|
||||
|
||||
|
||||
#
|
||||
# Subprojects
|
||||
#
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Library
|
||||
#
|
||||
|
||||
PACKAGE_NAME = ProjectCenter
|
||||
LIBRARY_VAR = PROJECTCENTER
|
||||
LIBRARY_NAME = libProjectCenter
|
||||
libProjectCenter_HEADER_FILES_DIR = .
|
||||
libProjectCenter_HEADER_FILES_INSTALL_DIR = /ProjectCenter
|
||||
ADDITIONAL_INCLUDE_DIRS = -I..
|
||||
srcdir = .
|
||||
PROJECTCENTER_INSTALLATION_DIR=$(GNUSTEP_INSTALLATION_DIR)
|
||||
PROJECTCENTER_INSTALL_PREFIX=$(GNUSTEP_INSTALLATION_DIR)
|
||||
|
||||
|
||||
#
|
||||
# Additional libraries
|
||||
#
|
||||
|
||||
libProjectCenter_LIBRARIES_DEPEND_UPON += -lgnustep-gui
|
||||
|
||||
#
|
||||
# Header files
|
||||
#
|
||||
|
||||
libProjectCenter_HEADER_FILES = \
|
||||
PCBundleLoader.h \
|
||||
PCFileManager.h \
|
||||
PCServer.h \
|
||||
PCMakefileFactory.h \
|
||||
PCSplitView.h \
|
||||
PCButton.h \
|
||||
\
|
||||
PCProjectManager.h \
|
||||
PCHistoryPanel.h \
|
||||
PCBuildPanel.h \
|
||||
PCLaunchPanel.h \
|
||||
PCProject.h \
|
||||
PCProject+ComponentHandling.h \
|
||||
PCProjectWindow.h \
|
||||
PCProjectInspector.h \
|
||||
PCProjectBuilder.h \
|
||||
PCProjectLauncher.h \
|
||||
PCProjectEditor.h \
|
||||
\
|
||||
PCProjectBrowser.h \
|
||||
PCProjectHistory.h \
|
||||
\
|
||||
PCEditor.h \
|
||||
PCEditor+UInterface.h \
|
||||
PCEditorView.h \
|
||||
PCEditorView+Highlighting.h \
|
||||
PCEditorController.h \
|
||||
PCTextFinder.h \
|
||||
PCTextFinder+UInterface.h \
|
||||
\
|
||||
PCDefines.h \
|
||||
FileCreator.h \
|
||||
PreferenceController.h \
|
||||
ProjectBuilder.h \
|
||||
ProjectCenter.h \
|
||||
ProjectLauncher.h \
|
||||
ProjectEditor.h \
|
||||
ProjectType.h \
|
||||
Server.h \
|
||||
ProjectComponent.h
|
||||
|
||||
#
|
||||
# Class files
|
||||
#
|
||||
|
||||
libProjectCenter_OBJC_FILES = \
|
||||
PCBundleLoader.m \
|
||||
PCFileManager.m \
|
||||
PCFileManager+UInterface.m \
|
||||
PCServer.m \
|
||||
PCMakefileFactory.m \
|
||||
PCSplitView.m \
|
||||
PCButton.m \
|
||||
\
|
||||
PCProjectManager.m \
|
||||
PCHistoryPanel.m \
|
||||
PCBuildPanel.m \
|
||||
PCLaunchPanel.m \
|
||||
PCProject.m \
|
||||
PCProject+ComponentHandling.m \
|
||||
PCProjectWindow.m \
|
||||
PCProjectInspector.m \
|
||||
PCProjectBuilder.m \
|
||||
PCProjectLauncher.m \
|
||||
PCProjectEditor.m \
|
||||
\
|
||||
PCProjectBrowser.m \
|
||||
PCProjectHistory.m \
|
||||
\
|
||||
PCEditor.m \
|
||||
PCEditor+UInterface.m \
|
||||
PCEditorView.m \
|
||||
PCEditorView+Highlighting.m \
|
||||
PCEditorController.m \
|
||||
PCTextFinder.m \
|
||||
PCTextFinder+UInterface.m
|
||||
|
||||
|
||||
#
|
||||
# C files
|
||||
#
|
||||
|
||||
libProjectCenter_C_FILES =
|
||||
|
||||
HEADERS_INSTALL = $(libProjectCenter_HEADER_FILES)
|
||||
|
||||
-include GNUmakefile.preamble
|
||||
-include GNUmakefile.local
|
||||
include $(GNUSTEP_MAKEFILES)/library.make
|
||||
-include GNUmakefile.postamble
|
|
@ -1,30 +0,0 @@
|
|||
#
|
||||
# GNUmakefile.postamble
|
||||
#
|
||||
# Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
#
|
||||
# Author: Philippe C.D. Robert <probert@siggraph.org>
|
||||
#
|
||||
# This file is part of GNUstep
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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 Library General Public
|
||||
# License along with this library; see the file COPYING.LIB.
|
||||
# If not, write to the Free Software Foundation,
|
||||
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
before-all::
|
||||
rm -f ProjectCenter
|
||||
$(LN_S) . ProjectCenter
|
||||
|
||||
after-clean::
|
||||
rm -f ProjectCenter
|
|
@ -1,71 +0,0 @@
|
|||
# GNUmakefile.preamble
|
||||
#
|
||||
# Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
#
|
||||
# Author: Philippe C.D. Robert <probert@siggraph.org>
|
||||
#
|
||||
# This file is part of GNUstep
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library 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.
|
||||
#
|
||||
# If you are interested in a warranty or support for this source code,
|
||||
# contact Scott Christley at scottc@net-community.com
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; see the file COPYING.LIB.
|
||||
# If not, write to the Free Software Foundation,
|
||||
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#
|
||||
# Makefile.preamble
|
||||
#
|
||||
# Project specific makefile variables, and additional
|
||||
#
|
||||
# Do not put any Makefile rules in this file, instead they should
|
||||
# be put into Makefile.postamble.
|
||||
#
|
||||
|
||||
#
|
||||
# Flags dealing with compiling and linking
|
||||
#
|
||||
|
||||
# Additional flags to pass to the preprocessor
|
||||
ADDITIONAL_CPPFLAGS += -Wall -Werror
|
||||
|
||||
# Additional flags to pass to the Objective-C compiler
|
||||
ADDITIONAL_OBJCFLAGS += -Wall -Werror
|
||||
|
||||
# Additional flags to pass to the C compiler
|
||||
ADDITIONAL_CFLAGS += -Wall -Werror
|
||||
|
||||
# Additional include directories the compiler should search
|
||||
ADDITIONAL_INCLUDE_DIRS += -I../PCLib
|
||||
|
||||
# Additional LDFLAGS to pass to the linker
|
||||
#ADDITIONAL_LDFLAGS +=
|
||||
|
||||
# Additional library directories the linker should search
|
||||
ADDITIONAL_LIB_DIRS += -L../PCLib/$(GNUSTEP_OBJ_DIR)
|
||||
|
||||
ADDITIONAL_TOOL_LIBS +=
|
||||
|
||||
#
|
||||
# Flags dealing with installing and uninstalling
|
||||
#
|
||||
|
||||
# Additional directories to be created during installation
|
||||
ADDITIONAL_INSTALL_DIRS +=
|
||||
|
||||
#
|
||||
# Local configuration
|
||||
#
|
||||
|
||||
|
|
@ -1,381 +0,0 @@
|
|||
/*
|
||||
GNUstep ProjectCenter - http://www.gnustep.org
|
||||
|
||||
Copyright (C) 2000-2002 Free Software Foundation
|
||||
|
||||
Author: Philippe C.D. Robert <probert@siggraph.org>
|
||||
|
||||
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$
|
||||
*/
|
||||
|
||||
#include "PCFileManager.h"
|
||||
#include "PCDefines.h"
|
||||
#include "PCProject.h"
|
||||
#include "PCServer.h"
|
||||
#include "FileCreator.h"
|
||||
|
||||
#include "PCFileManager+UInterface.h"
|
||||
|
||||
@implementation PCFileManager
|
||||
|
||||
//==============================================================================
|
||||
// ==== Class methods
|
||||
//==============================================================================
|
||||
|
||||
static PCFileManager *_mgr = nil;
|
||||
|
||||
+ (PCFileManager *)fileManager
|
||||
{
|
||||
if (!_mgr) {
|
||||
_mgr = [[PCFileManager alloc] init];
|
||||
}
|
||||
return _mgr;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// ==== Init and free
|
||||
//==============================================================================
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
creators = [[NSMutableDictionary alloc] init];
|
||||
typeDescr = [[NSMutableDictionary alloc] init];
|
||||
|
||||
[self _initUI];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
RELEASE(creators);
|
||||
RELEASE(newFileWindow);
|
||||
RELEASE(typeDescr);
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
[fileTypePopup removeAllItems];
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// ==== Delegate
|
||||
// ===========================================================================
|
||||
|
||||
- (id)delegate
|
||||
{
|
||||
return delegate;
|
||||
}
|
||||
|
||||
- (void)setDelegate:(id)aDelegate
|
||||
{
|
||||
delegate = aDelegate;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// ==== File stuff
|
||||
// ===========================================================================
|
||||
|
||||
- (void)showAddFileWindow
|
||||
{
|
||||
NSOpenPanel *openPanel;
|
||||
int retval;
|
||||
|
||||
PCProject *project = nil;
|
||||
NSString *key = nil;
|
||||
NSString *title = nil;
|
||||
NSArray *types = nil;
|
||||
|
||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
if (delegate &&
|
||||
[delegate respondsToSelector:@selector(fileManagerWillAddFiles:)])
|
||||
{
|
||||
|
||||
if (!(project = [delegate fileManagerWillAddFiles:self]))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
key = [project selectedRootCategory];
|
||||
|
||||
title = [[[project rootCategories] allKeysForObject:key] objectAtIndex:0];
|
||||
title = [NSString stringWithFormat:@"Add to %@...",title];
|
||||
|
||||
types = [project fileExtensionsForCategory:[key uppercaseString]];
|
||||
|
||||
openPanel = [NSOpenPanel openPanel];
|
||||
[openPanel setAllowsMultipleSelection:YES];
|
||||
[openPanel setCanChooseFiles:YES];
|
||||
[openPanel setTitle:title];
|
||||
[openPanel setCanChooseDirectories:[key isEqualToString: @"Interfaces"]];
|
||||
|
||||
retval = [openPanel
|
||||
runModalForDirectory:[ud objectForKey:@"LastOpenDirectory"]
|
||||
file:nil
|
||||
types:types];
|
||||
|
||||
if (retval == NSOKButton)
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
NSString *file = nil;
|
||||
NSString *cPath = nil;
|
||||
|
||||
[ud setObject:[openPanel directory] forKey:@"LastOpenDirectory"];
|
||||
|
||||
// Check for "Images" "Documentation" "Non Project Files"
|
||||
if ([key isEqualToString:PCImages])
|
||||
{
|
||||
cPath = [[project projectPath]
|
||||
stringByAppendingPathComponent:@"Images"];
|
||||
}
|
||||
else if ([key isEqualToString:PCDocuFiles])
|
||||
{
|
||||
cPath = [[project projectPath]
|
||||
stringByAppendingPathComponent:@"Documentation"];
|
||||
}
|
||||
else if ([key isEqualToString:PCNonProject])
|
||||
{
|
||||
cPath = [[project projectPath]
|
||||
stringByAppendingPathComponent:@"NonProject"];
|
||||
}
|
||||
else if ([key isEqualToString:PCGModels])
|
||||
{
|
||||
NSString *language = [[project projectDict] objectForKey:@"LANGUAGE"];
|
||||
cPath = [[project projectPath] stringByAppendingPathComponent:
|
||||
[language stringByAppendingString:@".lproj"]];
|
||||
}
|
||||
else
|
||||
{
|
||||
cPath = [project projectPath];
|
||||
}
|
||||
|
||||
enumerator = [[openPanel filenames] objectEnumerator];
|
||||
while ((file = [enumerator nextObject]))
|
||||
{
|
||||
NSString *otherKey = nil;
|
||||
NSString *ext = nil;
|
||||
NSString *fn = nil;
|
||||
NSString *fileName = nil;
|
||||
NSString *pth = nil;
|
||||
BOOL ret = NO;
|
||||
|
||||
if ([delegate fileManager:self shouldAddFile:file forKey:key])
|
||||
{
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
|
||||
fileName = [file lastPathComponent];
|
||||
pth = [cPath stringByAppendingPathComponent:fileName];
|
||||
|
||||
if (![key isEqualToString:PCLibraries])
|
||||
{
|
||||
if (![fm fileExistsAtPath:pth])
|
||||
{
|
||||
[fm copyPath:file toPath:pth handler:nil];
|
||||
}
|
||||
}
|
||||
[project addFile:pth forKey:key];
|
||||
}
|
||||
|
||||
if ([key isEqualToString:PCClasses])
|
||||
{
|
||||
otherKey = PCHeaders;
|
||||
ext = [NSString stringWithString:@"h"];
|
||||
|
||||
fn = [file stringByDeletingPathExtension];
|
||||
fn = [fn stringByAppendingPathExtension:ext];
|
||||
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:fn])
|
||||
{
|
||||
ret = NSRunAlertPanel(@"Adding Header?",
|
||||
@"Should %@ be added to project %@ as well?",
|
||||
@"Yes",@"No",nil,fn,[project projectName]);
|
||||
}
|
||||
}
|
||||
else if ([key isEqualToString:PCHeaders])
|
||||
{
|
||||
otherKey = PCClasses;
|
||||
ext = [NSString stringWithString:@"m"];
|
||||
|
||||
fn = [file stringByDeletingPathExtension];
|
||||
fn = [fn stringByAppendingPathExtension:ext];
|
||||
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:fn])
|
||||
{
|
||||
ret = NSRunAlertPanel(@"Adding Class?",
|
||||
@"Should %@ be added to project %@ as well?",
|
||||
@"Yes",@"No",nil,fn,[project projectName]);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret)
|
||||
{
|
||||
if ([delegate fileManager:self shouldAddFile:fn forKey:otherKey])
|
||||
{
|
||||
NSString *pp = [project projectPath];
|
||||
|
||||
fileName = [fn lastPathComponent];
|
||||
pth = [pp stringByAppendingPathComponent:fileName];
|
||||
|
||||
/* Only copy the file if it isn't already there */
|
||||
if ([pth isEqual: fn] == NO)
|
||||
[[NSFileManager defaultManager] copyPath:fn toPath:pth handler:nil];
|
||||
|
||||
[project addFile:pth forKey:otherKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showNewFileWindow
|
||||
{
|
||||
[self popupChanged:fileTypePopup];
|
||||
|
||||
[newFileWindow center];
|
||||
[newFileWindow makeKeyAndOrderFront:self];
|
||||
}
|
||||
|
||||
- (void)buttonsPressed:(id)sender
|
||||
{
|
||||
switch ([[sender selectedCell] tag])
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
[self createFile];
|
||||
break;
|
||||
}
|
||||
[newFileWindow orderOut:self];
|
||||
[newFileName setStringValue:@""];
|
||||
}
|
||||
|
||||
- (void)popupChanged:(id)sender
|
||||
{
|
||||
NSString *k = [sender titleOfSelectedItem];
|
||||
|
||||
if( k )
|
||||
{
|
||||
#ifdef GNUSTEP_BASE_VERSION
|
||||
[descrView setText:[typeDescr objectForKey:k]];
|
||||
#else
|
||||
[descrView setString:[typeDescr objectForKey:k]];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
- (void)createFile
|
||||
{
|
||||
NSString *path = nil;
|
||||
NSString *fileName = [newFileName stringValue];
|
||||
NSString *fileType = [fileTypePopup titleOfSelectedItem];
|
||||
NSString *key = [[creators objectForKey:fileType] objectForKey:@"ProjectKey"];
|
||||
|
||||
if (delegate)
|
||||
{
|
||||
path = [delegate fileManager:self willCreateFile:fileName withKey:key];
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
NSLog(@"<%@ %x>: creating file at %@", [self class], self, path);
|
||||
#endif //DEBUG
|
||||
|
||||
// Create file
|
||||
if (path)
|
||||
{
|
||||
NSDictionary *newFiles;
|
||||
id<FileCreator> creator = [[creators objectForKey:fileType] objectForKey:@"Creator"];
|
||||
PCProject *p = [delegate activeProject];
|
||||
|
||||
if (!creator)
|
||||
{
|
||||
NSRunAlertPanel(@"Attention!",
|
||||
@"Could not create %@. The creator is missing!",
|
||||
@"OK",nil,nil,fileName);
|
||||
return;
|
||||
}
|
||||
|
||||
// Do it finally...
|
||||
newFiles = [creator createFileOfType:fileType path:path project:p];
|
||||
if (delegate
|
||||
&& [delegate respondsToSelector:@selector(fileManager:didCreateFile:withKey:)])
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
NSString *aFile;
|
||||
|
||||
enumerator = [[newFiles allKeys] objectEnumerator]; // Key: name of file
|
||||
while ((aFile = [enumerator nextObject]))
|
||||
{
|
||||
NSString *theType = [newFiles objectForKey:aFile];
|
||||
NSString *theKey = [[creators objectForKey:theType] objectForKey:@"ProjectKey"];
|
||||
|
||||
[delegate fileManager:self didCreateFile:aFile withKey:theKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)registerCreatorsWithObjectsAndKeys:(NSDictionary *)dict
|
||||
{
|
||||
NSEnumerator *enumerator = [dict keyEnumerator];
|
||||
id type;
|
||||
|
||||
#ifdef DEBUG
|
||||
NSLog(@"<%@ %x>: Registering creators...",[self class],self);
|
||||
#endif //DEBUG
|
||||
|
||||
while ((type = [enumerator nextObject]))
|
||||
{
|
||||
NSDictionary *cd = [dict objectForKey:type];
|
||||
id creator = [cd objectForKey:@"Creator"];
|
||||
|
||||
if (![creator conformsToProtocol:@protocol(FileCreator)])
|
||||
{
|
||||
[NSException raise:@"FileManagerGenericException"
|
||||
format:@"The target does not conform to the FileCreator protocol!"];
|
||||
return;
|
||||
}
|
||||
|
||||
if ([creators objectForKey:type])
|
||||
{
|
||||
[NSException raise:@"FileManagerGenericException"
|
||||
format:@"There is alreay a creator registered for this type!"];
|
||||
return;
|
||||
}
|
||||
|
||||
// Register the creator!
|
||||
[creators setObject:[dict objectForKey:type] forKey:type];
|
||||
[fileTypePopup addItemWithTitle:type];
|
||||
|
||||
if( [cd objectForKey:@"TypeDescription"] )
|
||||
{
|
||||
[typeDescr setObject:[cd objectForKey:@"TypeDescription"] forKey:type];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
|
@ -1,472 +0,0 @@
|
|||
/*
|
||||
* PCMakefileFactory.m created by probert on 2002-02-28 22:16:25 +0000
|
||||
*
|
||||
* Project ProjectCenter
|
||||
*
|
||||
* Created with ProjectCenter - http://www.gnustep.org
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "PCMakefileFactory.h"
|
||||
#include "PCDefines.h"
|
||||
|
||||
#define COMMENT_HEADERS @"\n\n#\n# Header files\n#\n\n"
|
||||
#define COMMENT_RESOURCES @"\n\n#\n# Resource files\n#\n\n"
|
||||
#define COMMENT_CLASSES @"\n\n#\n# Class files\n#\n\n"
|
||||
#define COMMENT_CFILES @"\n\n#\n# C files\n#\n\n"
|
||||
#define COMMENT_SUBPROJECTS @"\n\n#\n# Subprojects\n#\n\n"
|
||||
#define COMMENT_APP @"\n\n#\n# Main application\n#\n\n"
|
||||
#define COMMENT_LIBRARIES @"\n\n#\n# Additional libraries\n#\n\n"
|
||||
#define COMMENT_BUNDLE @"\n\n#\n# Bundle\n#\n\n"
|
||||
#define COMMENT_LIBRARY @"\n\n#\n# Library\n#\n\n"
|
||||
#define COMMENT_TOOL @"\n\n#\n# Tool\n#\n\n"
|
||||
|
||||
@interface PCMakefileFactory (Private)
|
||||
- (void)appendHeaders:(NSArray *)array forTarget: (NSString *)target;
|
||||
- (void)appendClasses:(NSArray *)array forTarget: (NSString *)target;
|
||||
- (void)appendOtherSources:(NSArray *)array forTarget: (NSString *)target;
|
||||
@end
|
||||
|
||||
@implementation PCMakefileFactory
|
||||
|
||||
static PCMakefileFactory *_factory = nil;
|
||||
|
||||
+ (PCMakefileFactory *)sharedFactory
|
||||
{
|
||||
static BOOL isInitialised = NO;
|
||||
|
||||
if( isInitialised == NO )
|
||||
{
|
||||
_factory = [[PCMakefileFactory alloc] init];
|
||||
|
||||
isInitialised = YES;
|
||||
}
|
||||
|
||||
return _factory;
|
||||
}
|
||||
|
||||
- (void)createMakefileForProject:(NSString *)prName
|
||||
{
|
||||
NSAssert( prName, @"No project name given!");
|
||||
|
||||
AUTORELEASE( mfile );
|
||||
mfile = [[NSMutableString alloc] init];
|
||||
|
||||
AUTORELEASE( pnme );
|
||||
pnme = [prName copy];
|
||||
|
||||
[mfile appendString:@"#\n"];
|
||||
[mfile appendString:@"# GNUmakefile - Generated by ProjectCenter\n"];
|
||||
[mfile appendString:@"# Written by Philippe C.D. Robert <probert@siggraph.org>\n"];
|
||||
[mfile appendString:@"#\n"];
|
||||
[mfile appendString:@"# NOTE: Do NOT change this file -- ProjectCenter maintains it!\n"];
|
||||
[mfile appendString:@"#\n"];
|
||||
[mfile appendString:@"# Put all of your customisations in GNUmakefile.preamble and\n"];
|
||||
[mfile appendString:@"# GNUmakefile.postamble\n"];
|
||||
[mfile appendString:@"#\n\n"];
|
||||
}
|
||||
|
||||
- (void)appendString:(NSString *)aString
|
||||
{
|
||||
NSAssert( mfile, @"No valid makefile available!");
|
||||
NSAssert( aString, @"No valid string!");
|
||||
|
||||
[mfile appendString:aString];
|
||||
}
|
||||
|
||||
- (void)appendHeaders:(NSArray *)array forTarget: (NSString *)target
|
||||
{
|
||||
[self appendString:COMMENT_HEADERS];
|
||||
[self appendString:[NSString stringWithFormat:@"%@_HEADER_FILES= ",
|
||||
target]];
|
||||
|
||||
if( array && [array count] )
|
||||
{
|
||||
NSString *tmp;
|
||||
NSEnumerator *enumerator = [array objectEnumerator];
|
||||
|
||||
while ( (tmp = [enumerator nextObject]) )
|
||||
{
|
||||
[self appendString:[NSString stringWithFormat:@"\\\n%@ ",tmp]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)appendHeaders:(NSArray *)array
|
||||
{
|
||||
[self appendHeaders: array forTarget: pnme];
|
||||
}
|
||||
|
||||
- (void)appendClasses:(NSArray *)array forTarget: (NSString *)target
|
||||
{
|
||||
[self appendString:COMMENT_CLASSES];
|
||||
[self appendString:[NSString stringWithFormat:@"%@_OBJC_FILES= ", target]];
|
||||
|
||||
if( array && [array count] )
|
||||
{
|
||||
NSString *tmp;
|
||||
NSEnumerator *enumerator = [array objectEnumerator];
|
||||
|
||||
while ( (tmp = [enumerator nextObject] ))
|
||||
{
|
||||
[self appendString:[NSString stringWithFormat:@"\\\n%@ ",tmp]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)appendClasses:(NSArray *)array
|
||||
{
|
||||
[self appendClasses: array forTarget: pnme];
|
||||
}
|
||||
|
||||
- (void)appendOtherSources:(NSArray *)array forTarget: (NSString *)target
|
||||
{
|
||||
NSMutableArray *marray = nil;
|
||||
NSEnumerator *oenum;
|
||||
NSString *file;
|
||||
|
||||
[self appendString:COMMENT_CFILES];
|
||||
[self appendString:[NSString stringWithFormat:@"%@_C_FILES= ", target]];
|
||||
if ( array == nil || [array count] == 0)
|
||||
return;
|
||||
|
||||
/* Other Sources can have both m files and c files (possibly others?). */
|
||||
oenum = [array objectEnumerator];
|
||||
while ((file = [oenum nextObject]))
|
||||
{
|
||||
if ([file hasSuffix: @".m"])
|
||||
{
|
||||
if (marray == nil)
|
||||
marray = [NSMutableArray arrayWithCapacity: 2];
|
||||
[marray addObject: file];
|
||||
}
|
||||
else /* if ([f hasSuffix: @".c"]) */
|
||||
{
|
||||
[self appendString:[NSString stringWithFormat:@"\\\n%@ ",file]];
|
||||
}
|
||||
}
|
||||
|
||||
[self appendString: @"\n"];
|
||||
[self appendString:[NSString stringWithFormat:@"%@_OBJC_FILES += ",pnme]];
|
||||
if ( marray )
|
||||
{
|
||||
NSString *file;
|
||||
NSEnumerator *enumerator = [marray objectEnumerator];
|
||||
|
||||
while ( (file = [enumerator nextObject]) )
|
||||
{
|
||||
[self appendString:[NSString stringWithFormat:@"\\\n%@ ", file]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)appendOtherSources:(NSArray *)array
|
||||
{
|
||||
[self appendOtherSources: array forTarget: pnme];
|
||||
}
|
||||
|
||||
- (void)appendInstallDir:(NSString*)dir
|
||||
{
|
||||
[self appendString:
|
||||
[NSString stringWithFormat:@"GNUSTEP_INSTALLATION_DIR=%@\n",dir]];
|
||||
}
|
||||
|
||||
- (void)appendResources
|
||||
{
|
||||
[self appendString:COMMENT_RESOURCES];
|
||||
[self appendString:[NSString stringWithFormat:@"%@_RESOURCE_FILES= ",pnme]];
|
||||
}
|
||||
|
||||
- (void)appendResourceItems:(NSArray *)array
|
||||
{
|
||||
NSString *tmp;
|
||||
NSEnumerator *enumerator = [array objectEnumerator];
|
||||
|
||||
while ((tmp = [enumerator nextObject])) {
|
||||
[self appendString:[NSString stringWithFormat:@"\\\n%@ ",tmp]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)appendSubprojects:(NSArray*)array
|
||||
{
|
||||
[self appendString:COMMENT_SUBPROJECTS];
|
||||
|
||||
if (array && [array count])
|
||||
{
|
||||
NSString *tmp;
|
||||
NSEnumerator *enumerator = [array objectEnumerator];
|
||||
|
||||
while ((tmp = [enumerator nextObject])) {
|
||||
[self appendString:[NSString stringWithFormat:@"\\\n%@ ",tmp]];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void)appendTailForApp
|
||||
{
|
||||
[self appendString:@"\n\n"];
|
||||
|
||||
[self appendString:@"-include GNUmakefile.preamble\n"];
|
||||
[self appendString:@"-include GNUmakefile.local\n"];
|
||||
[self appendString:@"include $(GNUSTEP_MAKEFILES)/aggregate.make\n"];
|
||||
[self appendString:@"include $(GNUSTEP_MAKEFILES)/application.make\n"];
|
||||
[self appendString:@"-include GNUmakefile.postamble\n"];
|
||||
}
|
||||
|
||||
- (void)appendTailForLibrary
|
||||
{
|
||||
NSString *libnme = [NSString stringWithFormat:@"lib%@",pnme];
|
||||
NSString *hinst;
|
||||
|
||||
[self appendString:@"\n\n"];
|
||||
|
||||
hinst = [NSString stringWithFormat:@"HEADERS_INSTALL = $(%@_HEADER_FILES)\n\n",libnme];
|
||||
[self appendString:hinst];
|
||||
|
||||
[self appendString:@"-include GNUmakefile.preamble\n"];
|
||||
[self appendString:@"-include GNUmakefile.local\n"];
|
||||
[self appendString:@"include $(GNUSTEP_MAKEFILES)/library.make\n"];
|
||||
[self appendString:@"-include GNUmakefile.postamble\n"];
|
||||
}
|
||||
|
||||
- (void)appendTailForTool
|
||||
{
|
||||
[self appendString:@"\n\n"];
|
||||
|
||||
[self appendString:@"-include GNUmakefile.preamble\n"];
|
||||
[self appendString:@"-include GNUmakefile.local\n"];
|
||||
[self appendString:@"include $(GNUSTEP_MAKEFILES)/aggregate.make\n"];
|
||||
[self appendString:@"include $(GNUSTEP_MAKEFILES)/tool.make\n"];
|
||||
[self appendString:@"-include GNUmakefile.postamble\n"];
|
||||
}
|
||||
|
||||
- (void)appendTailForBundle
|
||||
{
|
||||
[self appendString:@"\n\n"];
|
||||
|
||||
[self appendString:@"-include GNUmakefile.preamble\n"];
|
||||
[self appendString:@"-include GNUmakefile.local\n"];
|
||||
[self appendString:@"include $(GNUSTEP_MAKEFILES)/bundle.make\n"];
|
||||
[self appendString:@"-include GNUmakefile.postamble\n"];
|
||||
}
|
||||
|
||||
- (void)appendTailForGormApp
|
||||
{
|
||||
[self appendString:@""];
|
||||
}
|
||||
|
||||
- (NSData *)encodedMakefile
|
||||
{
|
||||
NSAssert( mfile, @"No valid makefile available!");
|
||||
|
||||
return [mfile dataUsingEncoding:[NSString defaultCStringEncoding]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation PCMakefileFactory (ApplicationProject)
|
||||
|
||||
- (void)appendApplication
|
||||
{
|
||||
[self appendString:COMMENT_APP];
|
||||
|
||||
[self appendString:[NSString stringWithFormat:@"PACKAGE_NAME=%@\n",pnme]];
|
||||
[self appendString:[NSString stringWithFormat:@"APP_NAME=%@\n",pnme]];
|
||||
|
||||
// TODO: proper support for localisation!!!
|
||||
//[self appendString:[NSString stringWithFormat:@"%@_LANGUAGES=English\n",pnme]];
|
||||
//[self appendString:[NSString stringWithFormat:@"%@_LOCALIZED_RESOURCE_FILES=Localizable.strings\n",pnme]];
|
||||
}
|
||||
|
||||
- (void)appendAppIcon:(NSString*)icn
|
||||
{
|
||||
[self appendString:
|
||||
[NSString stringWithFormat:@"%@_APPLICATION_ICON=%@\n",pnme, icn]];
|
||||
}
|
||||
|
||||
- (void)appendGuiLibraries:(NSArray*)array
|
||||
{
|
||||
[self appendString:COMMENT_LIBRARIES];
|
||||
[self appendString:@"ADDITIONAL_GUI_LIBS += "];
|
||||
|
||||
if( array && [array count] )
|
||||
{
|
||||
NSString *tmp;
|
||||
NSEnumerator *enumerator = [array objectEnumerator];
|
||||
|
||||
while ((tmp = [enumerator nextObject]))
|
||||
{
|
||||
if (![tmp isEqualToString:@"gnustep-base"] &&
|
||||
![tmp isEqualToString:@"gnustep-gui"])
|
||||
{
|
||||
[self appendString:[NSString stringWithFormat:@"-l%@ ",tmp]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation PCMakefileFactory (BundleProject)
|
||||
|
||||
- (void)appendBundle
|
||||
{
|
||||
[self appendString:COMMENT_BUNDLE];
|
||||
|
||||
[self appendString:[NSString stringWithFormat:@"PACKAGE_NAME=%@\n",pnme]];
|
||||
[self appendString:[NSString stringWithFormat:@"BUNDLE_NAME=%@\n",pnme]];
|
||||
[self appendString:[NSString stringWithFormat:@"BUNDLE_EXTENSION=.bundle\n"]];
|
||||
|
||||
}
|
||||
|
||||
- (void)appendPrincipalClass:(NSString *)cname
|
||||
{
|
||||
[self appendString:
|
||||
[NSString stringWithFormat:@"%@_PRINCIPAL_CLASS=%@\n",pnme,cname]];
|
||||
|
||||
}
|
||||
|
||||
- (void)appendBundleInstallDir:(NSString*)dir
|
||||
{
|
||||
[self appendString:
|
||||
[NSString stringWithFormat:@"BUNDLE_INSTALL_DIR=%@\n",dir]];
|
||||
}
|
||||
|
||||
- (void)appendLibraries:(NSArray*)array
|
||||
{
|
||||
[self appendString:COMMENT_LIBRARIES];
|
||||
|
||||
[self appendString:
|
||||
[NSString stringWithFormat:@"%@_LIBRARIES_DEPEND_UPON += ",pnme]];
|
||||
|
||||
if( array && [array count] )
|
||||
{
|
||||
NSString *tmp;
|
||||
NSEnumerator *enumerator = [array objectEnumerator];
|
||||
|
||||
while ((tmp = [enumerator nextObject]))
|
||||
{
|
||||
if (![tmp isEqualToString:@"gnustep-base"] &&
|
||||
![tmp isEqualToString:@"gnustep-gui"])
|
||||
{
|
||||
[self appendString:[NSString stringWithFormat:@"-l%@ ",tmp]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation PCMakefileFactory (LibraryProject)
|
||||
|
||||
- (void)appendLibrary
|
||||
{
|
||||
NSString *libnme;
|
||||
|
||||
[self appendString:COMMENT_LIBRARY];
|
||||
|
||||
[self appendString:[NSString stringWithFormat:@"PACKAGE_NAME=%@\n",pnme]];
|
||||
[self appendString:[NSString stringWithFormat:@"LIBRARY_VAR=%@\n",[pnme uppercaseString]]];
|
||||
|
||||
libnme = [NSString stringWithFormat:@"lib%@",pnme];
|
||||
[self appendString:[NSString stringWithFormat:@"LIBRARY_NAME=%@\n",libnme]];
|
||||
|
||||
[self appendString:[NSString stringWithFormat:@"%@_HEADER_FILES_DIR=.\n",libnme]];
|
||||
[self appendString:[NSString stringWithFormat:@"%@_HEADER_FILES_INSTALL_DIR=/%@\n",libnme,pnme]];
|
||||
|
||||
[self appendString:@"ADDITIONAL_INCLUDE_DIRS = -I..\n"];
|
||||
[self appendString:@"srcdir = .\n"];
|
||||
}
|
||||
|
||||
- (void)appendLibraryInstallDir:(NSString*)dir
|
||||
{
|
||||
[self appendString:[NSString stringWithFormat:@"%@_INSTALLATION_DIR=$(GNUSTEP_INSTALLATION_DIR)\n",[pnme uppercaseString]]];
|
||||
[self appendString:[NSString stringWithFormat:@"%@_INSTALL_PREFIX=$(GNUSTEP_INSTALLATION_DIR)\n",[pnme uppercaseString]]];
|
||||
}
|
||||
|
||||
- (void)appendLibraryLibraries:(NSArray*)array
|
||||
{
|
||||
NSString *libnme = [NSString stringWithFormat:@"lib%@",pnme];
|
||||
|
||||
[self appendString:COMMENT_LIBRARIES];
|
||||
|
||||
[self appendString:
|
||||
[NSString stringWithFormat:@"%@_LIBRARIES_DEPEND_UPON += ",libnme]];
|
||||
|
||||
if( array && [array count] )
|
||||
{
|
||||
NSString *tmp;
|
||||
NSEnumerator *enumerator = [array objectEnumerator];
|
||||
|
||||
while ((tmp = [enumerator nextObject]))
|
||||
{
|
||||
if (![tmp isEqualToString:@"gnustep-base"])
|
||||
{
|
||||
[self appendString:[NSString stringWithFormat:@"-l%@ ",tmp]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)appendLibraryHeaders:(NSArray*)array
|
||||
{
|
||||
NSString *libnme = [NSString stringWithFormat:@"lib%@",pnme];
|
||||
[self appendHeaders: array forTarget: libnme];
|
||||
}
|
||||
|
||||
- (void)appendLibraryClasses:(NSArray *)array
|
||||
{
|
||||
NSString *libnme = [NSString stringWithFormat:@"lib%@",pnme];
|
||||
[self appendClasses: array forTarget: libnme];
|
||||
}
|
||||
|
||||
- (void)appendLibraryOtherSources:(NSArray *)array
|
||||
{
|
||||
NSString *libnme = [NSString stringWithFormat:@"lib%@",pnme];
|
||||
[self appendOtherSources: array forTarget: libnme];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation PCMakefileFactory (ToolProject)
|
||||
|
||||
- (void)appendTool
|
||||
{
|
||||
[self appendString:COMMENT_TOOL];
|
||||
|
||||
[self appendString:[NSString stringWithFormat:@"PACKAGE_NAME=%@\n",pnme]];
|
||||
[self appendString:[NSString stringWithFormat:@"TOOL_NAME=%@\n",pnme]];
|
||||
|
||||
}
|
||||
|
||||
- (void)appendToolIcon:(NSString*)icn
|
||||
{
|
||||
[self appendString:
|
||||
[NSString stringWithFormat:@"%@_TOOL_ICON=%@\n",pnme, icn]];
|
||||
}
|
||||
|
||||
- (void)appendToolLibraries:(NSArray*)array
|
||||
{
|
||||
[self appendString:COMMENT_LIBRARIES];
|
||||
|
||||
[self appendString:[NSString stringWithFormat:@"%@_TOOL_LIBS += ",pnme]];
|
||||
|
||||
if( array && [array count] )
|
||||
{
|
||||
NSString *tmp;
|
||||
NSEnumerator *enumerator = [array objectEnumerator];
|
||||
|
||||
while ((tmp = [enumerator nextObject]) )
|
||||
{
|
||||
if (![tmp isEqualToString:@"gnustep-base"])
|
||||
{
|
||||
[self appendString:[NSString stringWithFormat:@"-l%@ ",tmp]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
# This file is included in various Makefile's to get version information.
|
||||
# Compatible with Bourne shell syntax, so it can included there too.
|
||||
|
||||
# The gcc version required to compile the library.
|
||||
GCC_VERSION=2.8.0
|
||||
|
||||
# The version number of this release.
|
||||
MAJOR_VERSION=0
|
||||
MINOR_VERSION=3
|
||||
SUBMINOR_VERSION=5
|
||||
PC_VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${SUBMINOR_VERSION}
|
||||
VERSION=${PC_VERSION}
|
Loading…
Reference in a new issue