Improve support for dependency on multiple source files.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@11995 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2002-01-05 08:34:57 +00:00
parent 441ffcd257
commit 589424ab9d
4 changed files with 116 additions and 52 deletions

View file

@ -1,6 +1,10 @@
2002-01-05 Richard Frith-Macdonald <rfm@gnu.org>
* Tools/autogsdoc.m: Simplify by removing SourceDirectory default.
Change mechanism for handling multiple source files for one header
(need capability to write dependency rules for make).
* Tools/AGSPasrser.[hm]: Add mechanism to return list of source
files on which a document depends.
* Source/GNUmakefile (Base_AGSDOC_FLAGS): Remove the SourceDirectory
option ... now assumed to be the current directory for simplicity.

View file

@ -55,12 +55,13 @@
unsigned length;
unsigned pos;
BOOL commentsRead;
BOOL haveSource;
NSString *declared; // Where classes were declared.
NSMutableArray *ifStack; // track preprocessor conditionals.
NSString *comment; // Documentation accumulator.
NSMutableDictionary *info; // All information parsed.
NSMutableArray *source; // Names of source files.
NSCharacterSet *identifier; // Legit char in identifier
NSCharacterSet *identStart; // Legit initial char of identifier
NSCharacterSet *spaces; // All blank characters
@ -94,5 +95,6 @@
- (unsigned) skipStatementLine;
- (unsigned) skipUnit;
- (unsigned) skipWhiteSpace;
- (NSArray*) source;
@end
#endif

View file

@ -34,6 +34,7 @@
DESTROY(identStart);
DESTROY(spaces);
DESTROY(spacenl);
DESTROY(source);
[super dealloc];
}
@ -57,6 +58,7 @@
identStart = RETAIN([NSCharacterSet characterSetWithCharactersInString:
@"_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"]);
info = [[NSMutableDictionary alloc] initWithCapacity: 6];
source = [NSMutableArray new];
return self;
}
@ -130,6 +132,18 @@
{
ASSIGN(declared, [fileName lastPathComponent]);
}
/**
* If this is parsing a header file (isSource == NO) then we reset the
* list of known source files associated with the header before proceeding.
*/
[source removeAllObjects];
if (isSource == NO)
{
[source removeAllObjects];
[source addObject:
[[[fileName lastPathComponent] stringByDeletingPathExtension]
stringByAppendingPathExtension: @"m"]];
}
unitName = nil;
itemName = nil;
DESTROY(comment);
@ -1183,7 +1197,9 @@ fail:
- (void) reset
{
[source removeAllObjects];
[info removeAllObjects];
haveSource = NO;
DESTROY(declared);
DESTROY(comment);
fileName = nil;
@ -1734,6 +1750,52 @@ fail:
}
}
/*
* Lines of the form 'AutogsdocSource: ...' are used as the
* names of source files to provide documentation information.
* whitespace around a filename is stripped.
*/
r = NSMakeRange(0, commentLength);
while (r.length > 0)
{
/*
* Look for 'AtogsdocSource:' lines.
*/
r = [comment rangeOfString: @"AutogsdocSource:"
options: NSCaseInsensitiveSearch
range: r];
if (r.length > 0)
{
unsigned i = NSMaxRange(r);
NSString *line;
r = NSMakeRange(i, commentLength - i);
r = [comment rangeOfString: @"\n"
options: NSLiteralSearch
range: r];
if (r.length == 0)
{
r.location = commentLength;
}
r = NSMakeRange(i, NSMaxRange(r) - i);
line = [comment substringWithRange: r];
line = [line stringByTrimmingSpaces];
if ([line length] > 0
&& [source containsObject: line] == NO)
{
if (haveSource == NO)
{
[source removeAllObjects]; // remove default.
}
[source addObject: line];
haveSource = YES;
}
i = NSMaxRange(r);
r = NSMakeRange(i, commentLength - i);
}
}
/**
* There are various sections we can extract from the
* document - at most one of each.
@ -2204,5 +2266,9 @@ fail:
return pos;
}
- (NSArray*) source
{
return AUTORELEASE([source copy]);
}
@end

View file

@ -52,6 +52,14 @@
placed into appropriate locations in the output document -
</p>
<list>
<item><strong>AutogsdocSource</strong>
In any line where <code>AutogsdocSource</code>: is found, the remainder
of the line is taken as a source file name to be used instead of
making the assumption that each .h file processed uses a .m file
of the same name. You may supply multiple <code>AutogsdocSource</code>:
lines where a header file declares items which are defined in
multiple source files.
</item>
<item><strong>&lt;abstract&gt;</strong>
An abstract of the content of the document ... placed in the head
of the gsdoc output.
@ -62,8 +70,9 @@
head of the gsdoc output.<br />
As an aid to readability of the source, some special additional
processing is performed related to the document author -<br />
Any line of the form 'Author: name &lt;email-address&gt;', or
'By: name &lt;email-address&gt;', or 'Author: name' or 'By: name'
Any line of the form '<code>Author</code>: name &lt;email-address&gt;',
or '<code>By</code>: name &lt;email-address&gt;',
or '<code>Author</code>: name' or '<code>By</code>: name'
will be recognised and converted to an <em>author</em> element,
possibly containing an <em>email</em> element.
</item>
@ -346,7 +355,6 @@ main(int argc, char **argv, char **env)
NSMutableArray *sFiles = nil; // Source
NSMutableArray *gFiles = nil; // GSDOC
NSMutableArray *hFiles = nil; // HTML
NSMutableArray *tmpArray;
CREATE_AUTORELEASE_POOL(outer);
CREATE_AUTORELEASE_POOL(pool);
@ -415,7 +423,6 @@ main(int argc, char **argv, char **env)
sFiles = [NSMutableArray array];
gFiles = [NSMutableArray array];
hFiles = [NSMutableArray array];
tmpArray = nil;
count = [files count];
for (i = 1; i < count; i++)
{
@ -427,27 +434,11 @@ main(int argc, char **argv, char **env)
}
else if ([arg hasSuffix: @".h"] == YES)
{
if (tmpArray != nil)
{
[sFiles addObject: tmpArray];
}
tmpArray = [NSMutableArray array];
[tmpArray addObject: arg];
[sFiles addObject: arg];
}
else if ([arg hasSuffix: @".m"] == YES)
{
if (tmpArray == nil)
{
// NSLog(@"Source file %@ with no preceeding header", arg);
tmpArray = [NSMutableArray array];
[tmpArray addObject: arg];
[sFiles addObject: tmpArray];
tmpArray = nil;
}
else
{
[tmpArray addObject: arg];
}
[sFiles addObject: arg];
}
else if ([arg hasSuffix: @".gsdoc"] == YES)
{
@ -463,10 +454,6 @@ main(int argc, char **argv, char **env)
NSLog(@"Unknown argument '%@' ... ignored", arg);
}
}
if (tmpArray != nil)
{
[sFiles addObject: tmpArray];
}
if ([sFiles count] == 0 && [gFiles count] == 0 && [hFiles count] == 0)
{
@ -496,10 +483,10 @@ main(int argc, char **argv, char **env)
for (i = 0; i < count; i++)
{
NSMutableArray *a = [sFiles objectAtIndex: i];
NSString *arg = [a objectAtIndex: 0];
NSString *hfile = [sFiles objectAtIndex: i];
NSString *gsdocfile;
NSString *file;
NSArray *a;
NSString *generated;
NSDictionary *attrs;
NSDate *sDate = nil;
@ -512,35 +499,25 @@ main(int argc, char **argv, char **env)
pool = [NSAutoreleasePool new];
}
/*
* If no source files are specified, make a source file name
* corresponding to the header file.
*/
file = [arg stringByDeletingPathExtension];
if ([a count] == 1)
{
[a addObject: [file stringByAppendingPathExtension: @"m"]];
}
/*
* Note the name of the header file without path or extension.
* This will be used to generate the outut file.
*/
file = [hfile stringByDeletingPathExtension];
file = [file lastPathComponent];
/*
* Ensure that all file names are set up using the source and
* header directories specified unless they are absolute.
* Ensure that header file name is set up using the
* header directory specified unless is is absolute.
*/
if ([arg isAbsolutePath] == NO)
if ([hfile isAbsolutePath] == NO)
{
if ([[arg pathExtension] isEqual: @"h"] == YES)
if ([[hfile pathExtension] isEqual: @"h"] == YES)
{
if ([headerDirectory length] > 0)
{
arg = [headerDirectory stringByAppendingPathComponent:
[arg lastPathComponent]];
[a replaceObjectAtIndex: 0 withObject: arg];
hfile = [headerDirectory stringByAppendingPathComponent:
[hfile lastPathComponent]];
}
}
}
@ -551,14 +528,29 @@ main(int argc, char **argv, char **env)
if (ignoreDependencies == NO)
{
NSDate *d;
attrs = [mgr fileAttributesAtPath: hfile
traverseLink: YES];
d = [attrs objectForKey: NSFileModificationDate];
if (sDate == nil || [d earlierDate: sDate] == sDate)
{
sDate = d;
AUTORELEASE(RETAIN(sDate));
}
/*
* When were the files last modified?
* FIXME work out dependencies for .m files.
* for the moment, hack in an assumption that the .h simply
* depends on the corresponding .m
*/
a = [NSArray arrayWithObject:
[[[hfile lastPathComponent] stringByDeletingPathExtension]
stringByAppendingPathExtension: @"m"]];
for (i = 0; i < [a count]; i++)
{
NSDate *d;
NSString *sfile = [a objectAtIndex: i];
attrs = [mgr fileAttributesAtPath: [a objectAtIndex: i]
attrs = [mgr fileAttributesAtPath: sfile
traverseLink: YES];
d = [attrs objectForKey: NSFileModificationDate];
if (sDate == nil || [d earlierDate: sDate] == sDate)
@ -567,6 +559,7 @@ main(int argc, char **argv, char **env)
AUTORELEASE(RETAIN(sDate));
}
}
attrs = [mgr fileAttributesAtPath: gsdocfile traverseLink: YES];
gDate = [attrs objectForKey: NSFileModificationDate];
AUTORELEASE(RETAIN(gDate));
@ -574,8 +567,6 @@ main(int argc, char **argv, char **env)
if (gDate == nil || [sDate earlierDate: gDate] == gDate)
{
NSString *hfile = [a objectAtIndex: 0];
if (showDependencies == YES)
{
NSLog(@"%@: source %@, gsdoc %@ ==> regenerate",
@ -601,7 +592,8 @@ main(int argc, char **argv, char **env)
}
[parser parseFile: hfile isSource: NO];
for (i = 1; i < [a count]; i++)
a = [parser source];
for (i = 0; i < [a count]; i++)
{
NSString *sfile = [a objectAtIndex: i];