Final tweak for cleaning ... clean up template files.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14766 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2002-10-13 17:34:45 +00:00
parent d1cbad4d32
commit 2bd2ab5457
2 changed files with 80 additions and 23 deletions

View file

@ -14,7 +14,9 @@
type specifications of the form (id<protocol1,protocol2,...>) type specifications of the form (id<protocol1,protocol2,...>)
* Tools/autogsdoc.m: Add -Files option to read names of files * Tools/autogsdoc.m: Add -Files option to read names of files
to process as a property list rather than using command line args. to process as a property list rather than using command line args.
Add -Clean flag to remove generated output files. Add -Clean flag to remove generated output files and purge
generated data from templates. Add -CleanTemplates to completely
temove template files.
* Tools/AGSParser.m: Warn about private methods and ivars. * Tools/AGSParser.m: Warn about private methods and ivars.
2002-10-12 Richard Frith-Macdonald <rfm@gnu.org> 2002-10-12 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -678,27 +678,25 @@ main(int argc, char **argv, char **env)
NSEnumerator *enumerator; NSEnumerator *enumerator;
NSArray *outputNames; NSArray *outputNames;
NSMutableSet *allPaths; NSMutableSet *allPaths;
NSMutableSet *templates = nil;
NSSet *preserve = nil; NSSet *preserve = nil;
NSString *path; NSString *path;
NSArray *keys = [NSArray arrayWithObjects:
@"Constants",
@"Functions",
@"Macros",
@"Typedefs",
@"Variables",
nil];
/* /*
* Unless we are supposed to clean templates, we preserve any * Build a set of all template files.
* template gsdoc files.
*/ */
if ([defs boolForKey: @"CleanTemplates"] == NO) templates = AUTORELEASE([NSMutableSet new]);
{
NSArray *keys = [NSArray arrayWithObjects:
@"ConstantsTemplate",
@"FunctionsTemplate",
@"MacrosTemplate",
@"TypesTemplate",
@"VariablesTemplate",
nil];
NSMutableSet *s = [NSMutableSet new];
enumerator = [keys objectEnumerator]; enumerator = [keys objectEnumerator];
while ((path = [enumerator nextObject]) != nil) while ((path = [enumerator nextObject]) != nil)
{ {
path = [path stringByAppendingString: @"Template"];
path = [defs stringForKey: path]; path = [defs stringForKey: path];
if (path != nil) if (path != nil)
{ {
@ -708,10 +706,64 @@ main(int argc, char **argv, char **env)
path = [documentationDirectory path = [documentationDirectory
stringByAppendingPathComponent: path]; stringByAppendingPathComponent: path];
} }
[s addObject: path]; [templates addObject: path];
}
}
/*
* Unless we are supposed to clean templates, we preserve any
* template gsdoc files, but remove any generated content.
*/
if ([defs boolForKey: @"CleanTemplates"] == NO)
{
preserve = templates;
enumerator = [templates objectEnumerator];
while ((path = [enumerator nextObject]) != nil)
{
if ([mgr isReadableFileAtPath: path] == YES)
{
NSMutableString *ms;
NSEnumerator *e = [keys objectEnumerator];
NSString *k;
unsigned length;
ms = [[NSMutableString alloc] initWithContentsOfFile: path];
if (ms == nil)
{
NSLog(@"Cleaning ... failed to read '%@'", path);
continue;
}
length = [ms length];
while ((k = [e nextObject]) != nil)
{
NSString *ss;
NSString *es;
NSRange sr;
NSRange er;
ss = [NSString stringWithFormat: @"<!--Start%@-->", k];
sr = [ms rangeOfString: ss];
es = [NSString stringWithFormat: @"<!--End%@-->", k];
er = [ms rangeOfString: es];
if (sr.length > 0 && er.length > 0
&& er.location > sr.location)
{
NSRange r;
r.location = sr.location;
r.length = NSMaxRange(er) - r.location;
[ms replaceCharactersInRange: r withString: @""];
}
}
if ([ms length] != length)
{
if ([ms writeToFile: path atomically: YES] == NO)
{
NSLog(@"Cleaning ... failed to write '%@'", path);
}
}
} }
} }
preserve = AUTORELEASE(s);
} }
/* /*
@ -720,7 +772,7 @@ main(int argc, char **argv, char **env)
*/ */
output = [[projectRefs refs] objectForKey: @"output"]; output = [[projectRefs refs] objectForKey: @"output"];
enumerator = [output objectEnumerator]; enumerator = [output objectEnumerator];
allPaths = [NSMutableSet new]; allPaths = [[NSMutableSet alloc] initWithSet: templates];
while ((outputNames = [enumerator nextObject]) != nil) while ((outputNames = [enumerator nextObject]) != nil)
{ {
[allPaths addObjectsFromArray: outputNames]; [allPaths addObjectsFromArray: outputNames];
@ -756,10 +808,13 @@ main(int argc, char **argv, char **env)
/* /*
* Remove the project index file. * Remove the project index file.
*/ */
if ([mgr fileExistsAtPath: refsFile] == YES)
{
if ([mgr removeFileAtPath: refsFile handler: nil] == NO) if ([mgr removeFileAtPath: refsFile handler: nil] == NO)
{ {
NSLog(@"Cleaning ... failed to remove %@", refsFile); NSLog(@"Cleaning ... failed to remove %@", refsFile);
} }
}
/* /*
* Remove any HTML documents resulting from gsdoc files which * Remove any HTML documents resulting from gsdoc files which