From c47403f9b0737fcc0a6e61f9f2f23f6bdf67e8b0 Mon Sep 17 00:00:00 2001 From: Sergii Stoian Date: Fri, 12 Jan 2007 18:02:41 +0000 Subject: [PATCH] Project Builder make errors parsing: finished formatting, testing git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@24343 72102866-910b-0410-8b05-ffd578937521 --- .../English.lproj/Builder.gorm/data.classes | 3 +- .../English.lproj/Builder.gorm/objects.gorm | Bin 23543 -> 23681 bytes .../BuilderPanel.gorm/objects.gorm | Bin 1854 -> 1879 bytes Framework/PCProjectBuilder.m | 179 +++++++++++------- Framework/PCProjectBuilderPanel.m | 21 +- Headers/ProjectCenter/PCProjectBuilder.h | 9 +- 6 files changed, 122 insertions(+), 90 deletions(-) diff --git a/Framework/English.lproj/Builder.gorm/data.classes b/Framework/English.lproj/Builder.gorm/data.classes index 39d18ed..d94f5cf 100644 --- a/Framework/English.lproj/Builder.gorm/data.classes +++ b/Framework/English.lproj/Builder.gorm/data.classes @@ -34,7 +34,8 @@ split, optionsButton, buildStatusField, - targetField + targetField, + errorsCountField ); Super = NSObject; }; diff --git a/Framework/English.lproj/Builder.gorm/objects.gorm b/Framework/English.lproj/Builder.gorm/objects.gorm index 17e33c8bd7908c112a3b12b1472af6fbf26fbbaf..a7cc33c69aee9aa21084afe8ed4c6e9997463e8a 100644 GIT binary patch delta 1458 zcmbVLOKcle6n$^f*d&wC(56nRrvBn8wxV#InpT8G6`PW{5=|Q?aXuj7CRSx(*# zO38W^j^tSxkQu8a&7MQ_6sRW`skPuRl5Gy2Dbb(+2tk`tHeKWQN$^xlld3^4D z_n!MXet%!*^EbF+tKHWL`ZMO&JYVyU#~HK8!Cx7ZgV*Mm#Ue9$^w+=K5;Hz~=xiH0 zrS|>*6U!woVws{qtyU*s?GEw6B`Gf99Ddckx9F}q&l}iniHVcjQYhqQhZq*zR{XqY zD_-tt!dpHs&V*W}9~j!)7U?I3H$z_TC^}5j)tu3Bd+{4N-&7*R71#1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!6UMH^tW7z+D5Cwscj(ktfw!+tijR+r-@QJwSRepTJ^@ z9ycdju32E3>E`>u837goh^dRx5Rt0=|@uQ+!pWMZS)0AUx-F~{RetM79qXgywH zarkcVNaxji`dgLIiIFt|HsKnp%tx=G^UyYe^I$W{mctf&j7(DO z%0(JF3AN%|RvC0*-@+)^#;!pcIuo_C7^|VzpbjQk60e~}sB`u&NSW&|MP2xv!q6p7 z@>$sKQPQon(~Vvx&_TDl(GCL54D2M($Urv%ih*4OTnzMJu}vQ1pgWM;BVax&A{A-) zOmPvXbW>$@dFrP6`q~<_+Y?PY=w`GB+iY?nW}`;biz%BzxR;G6)Q2Z*ir9T@Plf7e(?rXa^d?Yl}j#smNFOibq8h zIM4wyA{QPcQ6q_lac7YtZ-hu_VPt3O*y~qR l+N;aaYi!y!G>-2TDMMfP%wvq;k-eTFyGIc-{fTSIe**p<;qw3h diff --git a/Framework/English.lproj/BuilderPanel.gorm/objects.gorm b/Framework/English.lproj/BuilderPanel.gorm/objects.gorm index 171e72eb455f1d704490c0e0a37979e3ce5b19fe..2f508f87f4dad5487c18f9ba0b88e818126d1337 100644 GIT binary patch delta 179 zcmdnTcb#v7I+L-%MooD}CS!-mUW^+jmoX|%mSHksoH#jP5 z#JCxN08EH+J3jz2ox3&*G4Ek^HPG6~p$3#=R|OKRq97KNU$B39UTV<>B?E1UBo|zg xizzujuOv0E#3{eRKxd=q2CWSW2D+1fu}O34fqC)<`jh3@B{&Q=3W1De003+sC^rBA delta 192 zcmcc4w~udvI+Ib_MooD}Ch3OBUW^+hLKqmt#JCxN08EH+JHH1qokJ!IGubkROb%oc z1Ckj??7d935^flp9)L8tZ5CqQ!_2lpc7u|E*5tQrvcB3IMS(m81D%Z=YCtPERDlGm qD2T6Bk#pbJ(bZ=eTJ!wOf!%2be;mzraszflOJnE?Rt3?{_@ diff --git a/Framework/PCProjectBuilder.m b/Framework/PCProjectBuilder.m index d9540ee..2509b41 100644 --- a/Framework/PCProjectBuilder.m +++ b/Framework/PCProjectBuilder.m @@ -67,6 +67,8 @@ [optionsButton setToolTip:@"Options"]; // [optionsButton setImage:IMAGE(@"Options")]; + + [errorsCountField setStringValue:@""]; /* * Error output @@ -81,7 +83,7 @@ [errorColumn setEditable:NO]; errorOutputTable = [[NSTableView alloc] - initWithFrame:NSMakeRect(6,6,209,111)]; + initWithFrame:NSMakeRect(0,0,209,111)]; [errorOutputTable setAllowsMultipleSelection:NO]; [errorOutputTable setAllowsColumnReordering:NO]; [errorOutputTable setAllowsColumnResizing:NO]; @@ -470,6 +472,42 @@ [optionsPanel orderFront:nil]; } +- (void)updateErrorsCountField +{ + NSString *string; + NSString *errorsString = [NSString stringWithString:@""];; + NSString *warningsString = [NSString stringWithString:@""]; + + if (errorsCount > 0) + { + if (errorsCount > 1) + { + errorsString = [NSString stringWithFormat:@"%i errors", + errorsCount]; + } + else + { + errorsString = [NSString stringWithString:@"1 error"]; + } + } + + if (warningsCount > 0) + { + if (warningsCount > 1) + { + warningsString = [NSString stringWithFormat:@"%i warnings", + warningsCount]; + } + else + { + warningsString = [NSString stringWithString:@"1 warning"]; + } + } + + string = [NSString stringWithFormat:@"%@ %@", errorsString, warningsString]; + [errorsCountField setStringValue:string]; +} + // --- Actions - (void)build:(id)sender { @@ -505,6 +543,7 @@ selector:@selector(logStdOut:) name:NSFileHandleDataAvailableNotification object:readHandle]; + _isLogging = YES; errorPipe = [NSPipe pipe]; errorReadHandle = [errorPipe fileHandleForReading]; @@ -514,12 +553,15 @@ selector:@selector(logErrOut:) name:NSFileHandleDataAvailableNotification object:errorReadHandle]; + _isErrorLogging = YES; + [errorsCountField setStringValue:[NSString stringWithString:@""]]; + errorsCount = 0; + warningsCount = 0; [buildStatusField setStringValue:statusString]; // Run make task [logOutput setString:@""]; -// [errorOutput setString:@""]; [errorArray removeAllObjects]; [errorOutputTable reloadData]; @@ -532,7 +574,6 @@ [makeTask setArguments:buildArgs]; [makeTask setCurrentDirectoryPath:[currentProject projectPath]]; [makeTask setLaunchPath:makePath]; - [makeTask setStandardOutput:logPipe]; [makeTask setStandardError:errorPipe]; @@ -565,8 +606,6 @@ NSLog(@"task did terminate"); -// [NOTIFICATION_CENTER removeObserver:self]; - [NOTIFICATION_CENTER removeObserver:self name:NSTaskDidTerminateNotification object:nil]; @@ -581,24 +620,47 @@ status = 1; } NS_ENDHANDLER - + + // Finish task + RELEASE(makeTask); + makeTask = nil; + + // Wait for logging end + while (_isLogging || _isErrorLogging) + { + [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode + beforeDate:[NSDate distantFuture]]; + }; + + [self updateErrorsCountField]; + if (status == 0) { [self logString: - [NSString stringWithFormat:@"=== %@ succeeded!", buildTarget] + [NSString stringWithFormat:@"=== %@ succeeded! ===", buildTarget] error:NO - newLine:NO]; + newLine:YES]; [buildStatusField setStringValue:[NSString stringWithFormat: - @"%@ - %@ succeeded...", [currentProject projectName], buildTarget]]; + @"%@ - %@ succeeded", [currentProject projectName], buildTarget]]; } else { [self logString: - [NSString stringWithFormat:@"=== %@ terminated!", buildTarget] + [NSString stringWithFormat:@"=== %@ terminated! ===", buildTarget] error:NO - newLine:NO]; - [buildStatusField setStringValue:[NSString stringWithFormat: - @"%@ - %@ terminated...", [currentProject projectName], buildTarget]]; + newLine:YES]; + if (errorsCount > 0) + { + [buildStatusField setStringValue:[NSString stringWithFormat: + @"%@ - %@ unsuccessful (%i errors)", + [currentProject projectName], buildTarget, errorsCount]]; + } + else + { + [buildStatusField setStringValue:[NSString stringWithFormat: + @"%@ - %@ unsuccessful", + [currentProject projectName], buildTarget]]; + } } // Rstore buttons state @@ -621,11 +683,6 @@ [cleanButton setEnabled:YES]; } - [buildArgs removeAllObjects]; - [buildTarget setString:@"Default"]; - - RELEASE(makeTask); - makeTask = nil; // Run post process if configured /* if (status && postProcess) @@ -634,6 +691,9 @@ postProcess = NULL; }*/ + [buildArgs removeAllObjects]; + [buildTarget setString:@"Default"]; + _isBuilding = NO; _isCleaning = NO; } @@ -667,6 +727,7 @@ } else { + _isLogging = NO; [NOTIFICATION_CENTER removeObserver:self name:NSFileHandleDataAvailableNotification object:readHandle]; @@ -679,8 +740,7 @@ // NSLog(@"logErrOut"); -// if ((data = [errorReadHandle availableData]) && [data length] > 1) - if ((data = [errorReadHandle availableData])) + if ((data = [errorReadHandle availableData]) && [data length] > 0) { [self logData:data error:YES]; } @@ -691,37 +751,17 @@ } else { + _isErrorLogging = NO; [NOTIFICATION_CENTER removeObserver:self name:NSFileHandleDataAvailableNotification object:errorReadHandle]; } } -- (void)copyPackageTo:(NSString *)path -{ - NSString *source = nil; - NSString *dest = nil; - NSString *rpm = nil; - NSString *srcrpm = nil; - - // Copy the rpm files to the source directory - if (source) - { - [[NSFileManager defaultManager] copyPath:srcrpm toPath:dest handler:nil]; - [[NSFileManager defaultManager] copyPath:rpm toPath:dest handler:nil]; - } -} - @end @implementation PCProjectBuilder (BuildLogging) -- (void)logString:(NSString *)string - error:(BOOL)yn -{ - [self logString:string error:yn newLine:NO]; -} - - (void)logString:(NSString *)str error:(BOOL)yn newLine:(BOOL)newLine @@ -777,6 +817,9 @@ NSRange lineRange; NSArray *items; + // Send it to standard out anyway to see all make process errors + [self logString:string error:NO newLine:NO]; + // Process new data lineRange.location = 0; [errorString appendString:string]; @@ -790,7 +833,7 @@ if (newLineRange.location < [errorString length]) { - NSLog(@"<------%@------>", errorString); +// NSLog(@"<------%@------>", errorString); lineRange.length = newLineRange.location+1; string = [errorString substringWithRange:lineRange]; @@ -841,29 +884,35 @@ NSString *message = [NSString stringWithString:@""]; NSMutableArray *items = [NSMutableArray arrayWithCapacity:1]; NSMutableDictionary *errorItem; - NSString *indentString = @"\t"; + NSString *indentString = @" "; NSString *lastFile = @""; NSString *lastIncludedFile = @""; + NSAttributedString *attributedString; + NSMutableDictionary *attributes = [NSMutableDictionary new]; + NSFont *font = [NSFont boldSystemFontOfSize:12.0]; + + [attributes setObject:font forKey:NSFontAttributeName]; + [attributes setObject:[NSNumber numberWithInt:NSSingleUnderlineStyle] + forKey:NSUnderlineStyleAttributeName]; + lastEL = currentEL; - if (lastEL == ELFile) NSLog(@"+++ELFile"); +/* if (lastEL == ELFile) NSLog(@"+++ELFile"); if (lastEL == ELFunction) NSLog(@"+++ELFunction"); if (lastEL == ELIncluded) NSLog(@"+++ELIncluded"); if (lastEL == ELError) NSLog(@"+++ELError"); - if (lastEL == ELNone) NSLog(@"+++ELNone"); + if (lastEL == ELNone) NSLog(@"+++ELNone");*/ if ([errorArray count] > 0) { lastFile = [[errorArray lastObject] objectForKey:@"File"]; -// if (!lastFile) lastFile = @""; lastIncludedFile = [[errorArray lastObject] objectForKey:@"IncludedFile"]; -// if (!lastIncludedFile) lastIncludedFile = @""; } if ([string rangeOfString:@"In file included from "].location != NSNotFound) { - NSLog(@"In file included from "); +// NSLog(@"In file included from "); currentEL = ELIncluded; file = [self lineTail:[components objectAtIndex:0] afterString:@"In file included from "]; @@ -895,7 +944,7 @@ file = [components objectAtIndex:0]; if (lastEL == ELIncluded || [file isEqualToString:lastIncludedFile]) {// first message after "In file included from" - NSLog(@"Inlcuded File: %@", file); +// NSLog(@"Inlcuded File: %@", file); includedFile = file; file = lastFile; currentEL = ELIncludedError; @@ -909,10 +958,12 @@ if ((typeIndex = [components indexOfObject:@" warning"]) != NSNotFound) { type = [components objectAtIndex:typeIndex]; + warningsCount++; } else if ((typeIndex = [components indexOfObject:@" error"]) != NSNotFound) { type = [components objectAtIndex:typeIndex]; + errorsCount++; } // position if (typeIndex == 2) // :line: @@ -939,7 +990,7 @@ { if (lastEL == ELFunction) { - indentString = @"\t\t"; + indentString = @" "; } else if (lastEL == ELError) { @@ -952,7 +1003,7 @@ } else if (currentEL == ELIncludedError) { - indentString = @"\t\t"; + indentString = @" "; } message = [NSString stringWithFormat:@"%@%@", indentString, message]; @@ -963,21 +1014,16 @@ || ![includedFile isEqualToString:@""]) && ![includedFile isEqualToString:lastIncludedFile]) { -// NSString *includedMessage; + NSString *incMessage = [NSString stringWithFormat:@" %@", includedFile]; - NSLog(@"lastEL == ELIncluded"); - -/* includedMessage = [NSString stringWithFormat:@"\t%@(%@)", - includedFile, file];*/ - - NSLog(@"Included: %@ != %@", includedFile, lastIncludedFile); +// NSLog(@"Included: %@ != %@", includedFile, lastIncludedFile); errorItem = [NSMutableDictionary dictionaryWithCapacity:1]; [errorItem setObject:@"" forKey:@"ErrorImage"]; [errorItem setObject:[file copy] forKey:@"File"]; [errorItem setObject:[includedFile copy] forKey:@"IncludedFile"]; [errorItem setObject:@"" forKey:@"Position"]; [errorItem setObject:@"" forKey:@"Type"]; - [errorItem setObject:[includedFile copy] forKey:@"Error"]; + [errorItem setObject:[incMessage copy] forKey:@"Error"]; [items addObject:errorItem]; } @@ -987,15 +1033,19 @@ && currentEL != ELIncluded && currentEL != ELIncludedError) { - NSLog(@"lastEL == ELNone (%@)", includedFile); - NSLog(@"File: %@ != %@", file, lastFile); +// NSLog(@"lastEL == ELNone (%@)", includedFile); +// NSLog(@"File: %@ != %@", file, lastFile); errorItem = [NSMutableDictionary dictionaryWithCapacity:1]; [errorItem setObject:@"" forKey:@"ErrorImage"]; [errorItem setObject:[file copy] forKey:@"File"]; [errorItem setObject:[includedFile copy] forKey:@"IncludedFile"]; [errorItem setObject:@"" forKey:@"Position"]; [errorItem setObject:@"" forKey:@"Type"]; - [errorItem setObject:[file copy] forKey:@"Error"]; + + attributedString = [[NSAttributedString alloc] initWithString:file + attributes:attributes]; + [errorItem setObject:[attributedString copy] forKey:@"Error"]; + [attributedString release]; [items addObject:errorItem]; } @@ -1008,7 +1058,7 @@ [errorItem setObject:[type copy] forKey:@"Type"]; [errorItem setObject:[message copy] forKey:@"Error"]; - NSLog(@"Parsed message: %@ (%@)", message, includedFile); +// NSLog(@"Parsed message: %@ (%@)", message, includedFile); [items addObject:errorItem]; @@ -1033,9 +1083,6 @@ if (errorArray != nil && aTableView == errorOutputTable) { - id dataCell = [aTableColumn dataCellForRow:rowIndex]; - - [dataCell setBackgroundColor:[NSColor whiteColor]]; errorItem = [errorArray objectAtIndex:rowIndex]; return [errorItem objectForKey:[aTableColumn identifier]]; diff --git a/Framework/PCProjectBuilderPanel.m b/Framework/PCProjectBuilderPanel.m index cf8dad8..135f1f9 100644 --- a/Framework/PCProjectBuilderPanel.m +++ b/Framework/PCProjectBuilderPanel.m @@ -33,36 +33,17 @@ - (void)awakeFromNib { - PCProject *activeProject = [projectManager rootActiveProject]; -// PCProjectBuilder *projectBuilder = [activeProject projectBuilder]; + PCProject *activeProject = [projectManager rootActiveProject]; -/* self = [super initWithContentRect: NSMakeRect (0, 300, 480, 322) - styleMask: (NSTitledWindowMask - | NSClosableWindowMask - | NSResizableWindowMask) - backing: NSBackingStoreRetained - defer: YES]; - [self setMinSize: NSMakeSize(440, 222)]; - [self setReleasedWhenClosed: NO]; - [self setHidesOnDeactivate: NO];*/ [panel setFrameAutosaveName:@"ProjectBuilder"]; [panel setTitle:[NSString stringWithFormat: @"%@ - Project Build", [activeProject projectName]]]; // Panel's content view -/* contentBox = [[NSBox alloc] init]; - [contentBox setContentViewMargins:NSMakeSize(8.0, 0.0)]; - [contentBox setTitlePosition:NSNoTitle]; - [contentBox setBorderType:NSNoBorder];*/ [panel setContentView:contentBox]; // Empty content view of contentBox RETAIN(emptyBox); -/* emptyBox = [[NSBox alloc] init]; - [emptyBox setContentViewMargins:NSMakeSize(0.0, 0.0)]; - [emptyBox setTitlePosition:NSNoTitle]; - [emptyBox setBorderType:NSLineBorder]; - [contentBox setContentView:emptyBox];*/ // Track project switching [[NSNotificationCenter defaultCenter] diff --git a/Headers/ProjectCenter/PCProjectBuilder.h b/Headers/ProjectCenter/PCProjectBuilder.h index a95c319..a0a942f 100644 --- a/Headers/ProjectCenter/PCProjectBuilder.h +++ b/Headers/ProjectCenter/PCProjectBuilder.h @@ -47,6 +47,7 @@ typedef enum _ErrorLevel { PCButton *cleanButton; PCButton *installButton; PCButton *optionsButton; + NSTextField *errorsCountField; NSSplitView *split; id buildStatusField; id targetField; @@ -85,8 +86,13 @@ typedef enum _ErrorLevel { NSFileHandle *readHandle; NSFileHandle *errorReadHandle; + int errorsCount; + int warningsCount; + BOOL _isBuilding; BOOL _isCleaning; + BOOL _isLogging; + BOOL _isErrorLogging; } - (id)initWithProject:(PCProject *)aProject; @@ -113,8 +119,6 @@ typedef enum _ErrorLevel { - (void)logStdOut:(NSNotification *)aNotif; - (void)logErrOut:(NSNotification *)aNotif; -- (void)copyPackageTo:(NSString *)path; - @end @interface PCProjectBuilder (UserInterface) @@ -125,7 +129,6 @@ typedef enum _ErrorLevel { @interface PCProjectBuilder (BuildLogging) -- (void)logString:(NSString *)string error:(BOOL)yn; - (void)logString:(NSString *)string error:(BOOL)yn newLine:(BOOL)newLine; - (void)logData:(NSData *)data error:(BOOL)yn;