diff --git a/Framework/PCProjectManager.m b/Framework/PCProjectManager.m index 87c1d6f..153656b 100644 --- a/Framework/PCProjectManager.m +++ b/Framework/PCProjectManager.m @@ -391,7 +391,8 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange"; PCFileManager *pcfm = [PCFileManager defaultManager]; NSArray *_srcExtensionArray = [NSArray arrayWithObjects: @"m",nil]; NSArray *_hdrExtensionArray = [NSArray arrayWithObjects: @"h",nil]; - NSArray *_otherSrcsExtensionArray = [NSArray arrayWithObjects: @"c",nil]; + NSArray *_otherSrcsExtensionArray = [NSArray arrayWithObjects: @"c", @"original",nil]; + NSArray *_interfaceFileExtensionArray = [NSArray arrayWithObjects: @"gorm", @"gsmarkup", nil]; NSMutableArray *_srcFiles = [[NSMutableArray alloc] init]; NSMutableArray *_hdrFiles = [[NSMutableArray alloc] init]; NSMutableArray *_otherSrcFiles = [[NSMutableArray alloc] init]; @@ -400,6 +401,7 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange"; [pcfm findFilesAt: path withExtensions: _srcExtensionArray into: _srcFiles]; [pcfm findFilesAt: path withExtensions: _hdrExtensionArray into: _hdrFiles]; [pcfm findFilesAt: path withExtensions: _otherSrcsExtensionArray into: _otherSrcFiles]; + [pcfm findFilesAt: path withExtensions: _interfaceFileExtensionArray into: _gormFiles]; if (DLSA_DEBUG) { // print the array of files @@ -411,8 +413,11 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange"; for (idx = 0; idx < [_hdrFiles count]; idx++) { printf("%s\n", [[_hdrFiles objectAtIndex: idx] cString]); } - for (idx = 0; idx < [[projectDict objectForKey: PCOtherSources] count]; idx++) { - printf("%s\n", [[[projectDict objectForKey: PCOtherSources] objectAtIndex: idx] cString]); + for (idx = 0; idx < [_otherSrcFiles count]; idx++) { + printf("%s\n", [[_otherSrcFiles objectAtIndex: idx] cString]); + } + for (idx = 0; idx < [_gormFiles count]; idx++) { + printf("%s\n", [[_gormFiles objectAtIndex: idx] cString]); } } @@ -422,21 +427,6 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange"; otherSrcs = [otherSrcs arrayByAddingObjectsFromArray: _otherSrcFiles]; [projectDict setObject: otherSrcs forKey: PCOtherSources]; [projectDict setObject: _gormFiles forKey: PCInterfaces]; - - if (DLSA_DEBUG) { - // print the array of files - printf("---------------------------------\n"); - int idx; - for (idx = 0; idx < [_srcFiles count]; idx++) { - printf("%s\n", [[_srcFiles objectAtIndex: idx] cString]); - } - for (idx = 0; idx < [_hdrFiles count]; idx++) { - printf("%s\n", [[_hdrFiles objectAtIndex: idx] cString]); - } - for (idx = 0; idx < [otherSrcs count]; idx++) { - printf("%s\n", [[otherSrcs objectAtIndex: idx] cString]); - } - } } - (BOOL) processMakefile: (NSMutableDictionary*)projectDict scanningFrom: (NSString*) path { @@ -473,9 +463,11 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange"; NSFileManager *fm = [NSFileManager defaultManager]; NSString *fromFullPath = [NSString pathWithComponents: oldFileNamePath]; NSString *toFullPath = [NSString pathWithComponents: newFileNamePath]; - BOOL _moveResult = YES; + BOOL _moveResult = NO; NSError *error; - _moveResult = [fm moveItemAtPath: fromFullPath toPath: toFullPath error: &error]; + if ([fm fileExistsAtPath: fromFullPath isDirectory: NO]) { + _moveResult = [fm moveItemAtPath: fromFullPath toPath: toFullPath error: &error]; + } return _moveResult; } diff --git a/Modules/Projects/Aggregate/PCAggregateProject.m b/Modules/Projects/Aggregate/PCAggregateProject.m index 4fd701e..f8adc4e 100644 --- a/Modules/Projects/Aggregate/PCAggregateProject.m +++ b/Modules/Projects/Aggregate/PCAggregateProject.m @@ -133,7 +133,52 @@ // dlsa - addFromSources - (PCProject *)createProjectFromSourcesAt: (NSString *)path withOption: (NSString *)projOption { + + PCFileManager *pcfm = [PCFileManager defaultManager]; + NSString *_file; + NSBundle *projectBundle; + BOOL _moveResult = YES; + NSAssert(path,@"No valid project path provided!"); + + projectBundle = [NSBundle bundleForClass:[self class]]; + + [pcfm createDirectoriesIfNeededAtPath:path]; + + _file = [projectBundle pathForResource:@"PC" ofType:@"project"]; + [projectDict initWithContentsOfFile:_file]; + + // Customise the project + [self setProjectPath:path]; + [self setProjectName:[path lastPathComponent]]; + if ([[projectName pathExtension] isEqualToString:@"subproj"]) + { + projectName = [projectName stringByDeletingPathExtension]; + } + [projectDict setObject:projectName forKey:PCProjectName]; + [projectDict setObject:[[NSCalendarDate date] description] + forKey:PCCreationDate]; + [projectDict setObject:NSFullUserName() forKey:PCProjectCreator]; + [projectDict setObject:NSFullUserName() forKey:PCProjectMaintainer]; + [projectDict setObject:[NSUserDefaults userLanguages] forKey:PCUserLanguages]; + + // move an existing GNUMakefile and create the one from the template and add other makefiles + _moveResult = [projectManager processMakefile: projectDict scanningFrom:path]; + if (!_moveResult) { + NSRunAlertPanel(@"File Conflict", + @"The directory already contains a GNUmakefile file that cannot be moved. The Project center makefiles will not be generated", + @"Dismiss", nil, nil); + } + + // GNUmakefile.postamble + [[PCMakefileFactory sharedFactory] createPostambleForProject:self]; + + // Save the project to disc + if (_moveResult) { + [self writeMakefile]; + } + [self save]; + return self; } diff --git a/Modules/Projects/Application/PCAppProject.m b/Modules/Projects/Application/PCAppProject.m index 4ec9844..6e9fd03 100644 --- a/Modules/Projects/Application/PCAppProject.m +++ b/Modules/Projects/Application/PCAppProject.m @@ -284,7 +284,6 @@ NSString *_2file = nil; NSBundle *projBundle = [NSBundle bundleForClass:[self class]]; NSMutableArray *_array = nil; - NSMutableArray *_subdirs = [[NSMutableArray alloc] init]; NSString *helpFile = nil; NSString *_executableFileName; BOOL _moveResult = YES; @@ -318,15 +317,13 @@ // search for all .m and .h files and add them to the project [projectManager setSrcFilesOn: projectDict scanningFrom: path]; - [pcfm findDirectoriesAt: path into: _subdirs]; - [projectDict setObject: _subdirs forKey: PCSubprojects]; // move an existing GNUMakefile and create the one from the template and add other makefiles _moveResult = [projectManager processMakefile: projectDict scanningFrom:path]; if (!_moveResult) { NSRunAlertPanel(@"File Conflict", - @"The directory already contains a GNUmakefile file that cannot be moved. The Project center makefiles will not be generated", - @"Dismiss", @"Dismiss", nil); + @"The directory already contains a GNUmakefile file that cannot be moved.\nThe Project center makefiles will not be generated", + @"Dismiss",nil, nil); } // Info-gnustep.plist diff --git a/Modules/Projects/Bundle/PCBundleProject.m b/Modules/Projects/Bundle/PCBundleProject.m index 9ce7c3f..bd8aa18 100644 --- a/Modules/Projects/Bundle/PCBundleProject.m +++ b/Modules/Projects/Bundle/PCBundleProject.m @@ -28,6 +28,8 @@ #import #import #import +// dlsa - create from sources +#import #import "PCBundleProject.h" @@ -161,6 +163,71 @@ // dlsa - addFromSources - (PCProject *)createProjectFromSourcesAt: (NSString *)path withOption: (NSString *)projOption { + NSBundle *projectBundle = nil; + NSString *_file = nil; + NSString *_2file = nil; + PCFileCreator *pcfc = [PCFileCreator sharedCreator]; + BOOL _moveResult = YES; + + NSAssert(path,@"No valid project path provided!"); + + projectBundle = [NSBundle bundleForClass:[self class]]; + + _file = [projectBundle pathForResource:@"PC" ofType:@"project"]; + [projectDict initWithContentsOfFile:_file]; + + // Customise the project + [self setProjectPath:path]; + [self setProjectName:[path lastPathComponent]]; + if ([[projectName pathExtension] isEqualToString:@"subproj"]) + { + projectName = [projectName stringByDeletingPathExtension]; + } + [projectDict setObject:projectName forKey:PCProjectName]; + [projectDict setObject:projectName forKey:PCPrincipalClass]; + [projectDict setObject:[[NSCalendarDate date] description] + forKey:PCCreationDate]; + [projectDict setObject:NSFullUserName() forKey:PCProjectCreator]; + [projectDict setObject:NSFullUserName() forKey:PCProjectMaintainer]; + [projectDict setObject:[NSUserDefaults userLanguages] forKey:PCUserLanguages]; + + // Copy the project files to the provided path + + // $PROJECTNAME$.m + _file = [NSString stringWithFormat:@"%@", projectName]; + _2file = [NSString stringWithFormat:@"%@.m", projectName]; + _moveResult = [projectManager moveFileNamed: _2file atPath: path toFileName: [_2file stringByAppendingString: @".original"]]; + _moveResult = [projectManager moveFileNamed: [NSString stringWithFormat:@"%@.h", projectName] + atPath: path + toFileName: [[NSString stringWithFormat:@"%@.h", projectName] stringByAppendingString: @".original"]]; + + [pcfc createFileOfType:ObjCClass + path:[path stringByAppendingPathComponent:_file] + project:self]; + + // $PROJECTNAME$.h already created by creating $PROJECTNAME$.m + _file = [NSString stringWithFormat:@"%@.h", projectName]; + + // move an existing GNUMakefile and create the one from the template and add other makefiles + _moveResult = [projectManager processMakefile: projectDict scanningFrom:path]; + if (!_moveResult) { + NSRunAlertPanel(@"File Conflict", + @"The directory already contains a GNUmakefile file that cannot be moved. The Project center makefiles will not be generated", + @"Dismiss", nil, nil); + } + + // search for all .m and .h files and add them to the project + [projectManager setSrcFilesOn: projectDict scanningFrom: path]; + + // GNUmakefile.postamble + [[PCMakefileFactory sharedFactory] createPostambleForProject:self]; + + // Save the project to disc + if (_moveResult) { + [self writeMakefile]; + } + [self save]; + return self; } diff --git a/Modules/Projects/Framework/PCFrameworkProject.m b/Modules/Projects/Framework/PCFrameworkProject.m index e4e2c18..b1a52f3 100644 --- a/Modules/Projects/Framework/PCFrameworkProject.m +++ b/Modules/Projects/Framework/PCFrameworkProject.m @@ -145,6 +145,7 @@ // _resourcePath = [path stringByAppendingPathComponent:@"Resources"]; // Save the project to disc + [self writeMakefile]; [self save]; @@ -153,6 +154,73 @@ // dlsa - addFromSources - (PCProject *)createProjectFromSourcesAt: (NSString *)path withOption: (NSString *)projOption { +// PCFileManager *pcfm = [PCFileManager defaultManager]; + PCFileCreator *pcfc = [PCFileCreator sharedCreator]; + NSBundle *projectBundle = nil; + NSString *_file = nil; + NSString *_2file = nil; +// NSString *_resourcePath; + BOOL _moveResult = YES; + + NSAssert(path,@"No valid project path provided!"); + + projectBundle = [NSBundle bundleForClass:[self class]]; + + _file = [projectBundle pathForResource:@"PC" ofType:@"project"]; + [projectDict initWithContentsOfFile:_file]; + + // Customise the project + [self setProjectPath:path]; + [self setProjectName:[path lastPathComponent]]; + if ([[projectName pathExtension] isEqualToString:@"subproj"]) + { + projectName = [projectName stringByDeletingPathExtension]; + } + [projectDict setObject:projectName forKey:PCProjectName]; + [projectDict setObject:[NSUserDefaults userLanguages] forKey:PCUserLanguages]; + + // move an existing GNUMakefile and create the one from the template and add other makefiles + _moveResult = [projectManager processMakefile: projectDict scanningFrom:path]; + if (!_moveResult) { + NSRunAlertPanel(@"File Conflict", + @"The directory already contains a GNUmakefile file that cannot be moved. The Project center makefiles will not be generated", + @"Dismiss", @"Dismiss", nil); + } + + // Copy the project files to the provided path + + // $PROJECTNAME$.m + _file = [NSString stringWithFormat:@"%@", projectName]; + _2file = [NSString stringWithFormat:@"%@.m", projectName]; + _moveResult = [projectManager moveFileNamed: _2file atPath: path toFileName: [_2file stringByAppendingString: @".original"]]; + _moveResult = [projectManager moveFileNamed: [NSString stringWithFormat:@"%@.h", projectName] + atPath: path + toFileName: [[NSString stringWithFormat:@"%@.h", projectName] stringByAppendingString: @".original"]]; + + [pcfc createFileOfType:ObjCClass + path:[path stringByAppendingPathComponent:_file] + project:self]; + + // $PROJECTNAME$.h already created by creating $PROJECTNAME$.m + _file = [NSString stringWithFormat:@"%@.h", projectName]; + [projectDict setObject:[NSArray arrayWithObjects:_file,nil] + forKey:PCPublicHeaders]; + + // search for all .m and .h files and add them to the project + [projectManager setSrcFilesOn: projectDict scanningFrom: path]; + + // GNUmakefile.postamble + [[PCMakefileFactory sharedFactory] createPostambleForProject:self]; + + // Resources +// _resourcePath = [path stringByAppendingPathComponent:@"Resources"]; + + // Save the project to disc + if (_moveResult) { + [self writeMakefile]; + } + [self save]; + return self; } diff --git a/Modules/Projects/Library/PCLibProject.m b/Modules/Projects/Library/PCLibProject.m index 3df9129..d22bed4 100644 --- a/Modules/Projects/Library/PCLibProject.m +++ b/Modules/Projects/Library/PCLibProject.m @@ -89,7 +89,6 @@ NSString *_2file = nil; NSBundle *projBundle = [NSBundle bundleForClass:[self class]]; NSString *_resourcePath = nil; - NSMutableArray *_subdirs = [[NSMutableArray alloc] init]; BOOL _moveResult = YES; NSAssert(path,@"No valid project path provided!"); @@ -116,17 +115,12 @@ [projectDict setObject:NSFullUserName() forKey:PCProjectMaintainer]; [projectDict setObject:[NSUserDefaults userLanguages] forKey:PCUserLanguages]; - // search for all .m and .h files and add them to the project - [projectManager setSrcFilesOn: projectDict scanningFrom: path]; - [pcfm findDirectoriesAt: path into: _subdirs]; - [projectDict setObject: _subdirs forKey: PCSubprojects]; - // move an existing GNUMakefile and create the one from the template and add other makefiles _moveResult = [projectManager processMakefile: projectDict scanningFrom:path]; if (!_moveResult) { NSRunAlertPanel(@"File Conflict", @"The directory already contains a GNUmakefile file that cannot be moved. The Project center makefiles will not be generated", - @"Dismiss", @"Dismiss", nil); + @"Dismiss", nil, nil); } // Copy the project files to the provided path @@ -135,31 +129,22 @@ _file = [NSString stringWithFormat:@"%@", projectName]; _2file = [NSString stringWithFormat:@"%@.m", projectName]; _moveResult = [projectManager moveFileNamed: _2file atPath: path toFileName: [_2file stringByAppendingString: @".original"]]; - if (!_moveResult) { - NSRunAlertPanel(@"File Conflict", - [NSString stringWithFormat: @"The directory already contains a %@ file that cannot be moved. The Project center file will not be generated", _2file], - @"Dismiss", @"Dismiss", nil); - } else { - [pcfc createFileOfType:ObjCClass - path:[path stringByAppendingPathComponent:_file] - project:self]; - [projectDict setObject:[NSArray arrayWithObjects:_2file,nil] - forKey:PCClasses]; - } + _moveResult = [projectManager moveFileNamed: [NSString stringWithFormat:@"%@.h", projectName] + atPath: path + toFileName: [[NSString stringWithFormat:@"%@.h", projectName] stringByAppendingString: @".original"]]; + + [pcfc createFileOfType:ObjCClass + path:[path stringByAppendingPathComponent:_file] + project:self]; // $PROJECTNAME$.h already created by creating $PROJECTNAME$.m _file = [NSString stringWithFormat:@"%@.h", projectName]; - _moveResult = [projectManager moveFileNamed: _file atPath: path toFileName: [_file stringByAppendingString: @".original"]]; - if (!_moveResult) { - NSRunAlertPanel(@"File Conflict", - [NSString stringWithFormat: @"The directory already contains a %@ file that cannot be moved. The Project center file will not be generated", _2file], - @"Dismiss", @"Dismiss", nil); - } else { - [projectDict setObject:[NSArray arrayWithObjects:_file,nil] - forKey:PCHeaders]; - [projectDict setObject:[NSArray arrayWithObjects:_file,nil] - forKey:PCPublicHeaders]; - } + [projectDict setObject:[NSArray arrayWithObjects:_file,nil] + forKey:PCPublicHeaders]; + + // search for all .m and .h files and add them to the project + [projectManager setSrcFilesOn: projectDict scanningFrom: path]; + // GNUmakefile.postamble [[PCMakefileFactory sharedFactory] createPostambleForProject:self]; diff --git a/Modules/Projects/ResourceSet/PCResourceSetProject.m b/Modules/Projects/ResourceSet/PCResourceSetProject.m index d0b4aaa..e4520b9 100644 --- a/Modules/Projects/ResourceSet/PCResourceSetProject.m +++ b/Modules/Projects/ResourceSet/PCResourceSetProject.m @@ -118,6 +118,46 @@ // dlsa - addFromSources - (PCProject *)createProjectFromSourcesAt: (NSString *)path withOption: (NSString *)projOption { + NSBundle *projectBundle = nil; + NSString *_file = nil; + BOOL _moveResult = YES; + + NSAssert(path,@"No valid project path provided!"); + + projectBundle = [NSBundle bundleForClass:[self class]]; + + _file = [projectBundle pathForResource:@"PC" ofType:@"project"]; + [projectDict initWithContentsOfFile:_file]; + + // Customise the project + [self setProjectPath:path]; + [self setProjectName:[path lastPathComponent]]; + if ([[projectName pathExtension] isEqualToString:@"subproj"]) + { + projectName = [projectName stringByDeletingPathExtension]; + } + [projectDict setObject:projectName forKey:PCProjectName]; + [projectDict setObject:[[NSCalendarDate date] description] + forKey:PCCreationDate]; + [projectDict setObject:NSFullUserName() forKey:PCProjectCreator]; + [projectDict setObject:NSFullUserName() forKey:PCProjectMaintainer]; + [projectDict setObject:[NSUserDefaults userLanguages] forKey:PCUserLanguages]; + + // move an existing GNUMakefile and create the one from the template and add other makefiles + _moveResult = [projectManager processMakefile: projectDict scanningFrom:path]; + if (!_moveResult) { + NSRunAlertPanel(@"File Conflict", + @"The directory already contains a GNUmakefile file that cannot be moved. The Project center makefiles will not be generated", + @"Dismiss", nil, nil); + } + + // GNUmakefile.postamble + [[PCMakefileFactory sharedFactory] createPostambleForProject:self]; + + // Save the project to disc + [self writeMakefile]; + [self save]; + return self; } diff --git a/Modules/Projects/Tool/PCToolProject.m b/Modules/Projects/Tool/PCToolProject.m index 71da285..2a93324 100644 --- a/Modules/Projects/Tool/PCToolProject.m +++ b/Modules/Projects/Tool/PCToolProject.m @@ -209,13 +209,11 @@ // dlsa - addFromSources - (PCProject *)createProjectFromSourcesAt: (NSString *)path withOption: (NSString *)projOption { - PCFileManager *pcfm = [PCFileManager defaultManager]; NSBundle *projectBundle; NSString *_file; NSString *_2file; NSMutableArray *_array = nil; NSString *_executableFileName; - NSMutableArray *_subdirs = [[NSMutableArray alloc] init]; BOOL _moveResult = YES; NSAssert(path,@"No valid project path provided!"); @@ -246,15 +244,13 @@ // search for all .m and .h files and add them to the project [projectManager setSrcFilesOn: projectDict scanningFrom: path]; - [pcfm findDirectoriesAt: path into: _subdirs]; - [projectDict setObject: _subdirs forKey: PCSubprojects]; // move an existing GNUMakefile and create the one from the template and add other makefiles _moveResult = [projectManager processMakefile: projectDict scanningFrom:path]; if (!_moveResult) { NSRunAlertPanel(@"File Conflict", @"The directory already contains a GNUmakefile file that cannot be moved. The Project center makefiles will not be generated", - @"Dismiss", @"Dismiss", nil); + @"Dismiss", nil, nil); } // GNUmakefile.postamble