1 /*
2    GNUstep ProjectCenter - http://www.gnustep.org/experience/ProjectCenter.html
3 
4    Copyright (C) 2000-2004 Free Software Foundation
5 
6    Authors: Philippe C.D. Robert
7             Serg Stoyan
8 
9    This file is part of GNUstep.
10 
11    This application is free software; you can redistribute it and/or
12    modify it under the terms of the GNU General Public
13    License as published by the Free Software Foundation; either
14    version 2 of the License, or (at your option) any later version.
15 
16    This application is distributed in the hope that it will be useful,
17    but WITHOUT ANY WARRANTY; without even the implied warranty of
18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19    Library General Public License for more details.
20 
21    You should have received a copy of the GNU General Public
22    License along with this library; if not, write to the Free
23    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
24 */
25 
26 #ifndef _PCProjectBuilder_h_
27 #define _PCProjectBuilder_h_
28 
29 #import <AppKit/AppKit.h>
30 
31 @class PCProject;
32 @class PCButton;
33 @class PCProjectBuilderOptions;
34 
35 typedef enum _ErrorLevel {
36     ELFile,
37     ELFunction,
38     ELIncluded,
39     ELIncludedError,
40     ELError,
41     ELNone
42 } ErrorLevel;
43 
44 @interface PCProjectBuilder : NSObject
45 {
46   PCProject       *project;
47   PCProjectBuilderOptions *buildOptions;
48 
49   // Preferences
50   NSString        *successSound;
51   NSString        *failureSound;
52   NSString        *buildTool;
53   NSString        *rootBuildDir;
54   BOOL            promptOnClean;
55 
56   // Options panel
57   BOOL            verboseBuilding;
58 
59   NSString        *buildStatus;
60   NSMutableString *buildStatusTarget;
61   NSMutableString *buildTarget;
62   NSMutableArray  *buildArgs;
63   SEL             postProcess;
64   NSTask          *makeTask;
65 
66   NSPipe          *stdOutPipe;
67   NSPipe          *stdErrorPipe;
68   NSFileHandle    *stdOutHandle;
69   NSFileHandle    *stdErrorHandle;
70 
71   BOOL            _isBuilding;
72   BOOL            _isCleaning;
73   BOOL            _isLogging;
74   BOOL            _isErrorLogging;
75 
76   // Component view
77   BOOL            _isCVLoaded;
78   NSBox           *componentView;
79   PCButton        *buildButton;
80   PCButton        *cleanButton;
81   PCButton        *optionsButton;
82   NSTextField     *errorsCountField;
83   NSSplitView     *split;
84   NSTextField     *statusField;
85   NSTextField     *targetField;
86 
87   // Error logging
88   NSTableView     *errorOutput;
89   NSTableColumn   *errorImageColumn;
90   NSTableColumn   *errorColumn;
91   NSMutableArray  *errorArray;
92   NSMutableString *errorString;
93 
94   ErrorLevel      currentEL;
95   ErrorLevel      lastEL;
96   ErrorLevel      nextEL;
97   NSString        *lastIndentString;
98   int             errorsCount;
99   int             warningsCount;
100 
101   // Output logging
102   NSTextView      *logOutput;
103   NSMutableString *currentBuildFile;
104   NSMutableString *currentBuildPath;
105 }
106 
107 - (id)initWithProject:(PCProject *)aProject;
108 - (void)dealloc;
109 
110 - (NSView *)componentView;
111 - (void)loadPreferences:(NSNotification *)aNotification;
112 - (void)updateTargetField;
113 
114 // --- Accessory
115 - (BOOL)isBuilding;
116 - (BOOL)isCleaning;
117 - (void)performStartBuild;
118 - (void)performStartClean;
119 - (void)performStopBuild;
120 - (NSArray *)buildArguments;
121 
122 // --- Actions
123 - (void)startBuild:(id)sender;
124 - (void)startClean:(id)sender;
125 - (BOOL)stopMake:(id)sender;
126 - (void)showOptionsPanel:(id)sender;
127 - (void)cleanupAfterMake:(NSString *)statusString;
128 
129 - (BOOL)prebuildCheck;
130 - (void)build:(id)sender;
131 //- (void)buildDidTerminate;
132 
133 @end
134 
135 @interface PCProjectBuilder (Logging)
136 
137 - (void)updateErrorsCountField;
138 
139 - (void)logStdOut:(NSNotification *)aNotif;
140 - (void)logErrOut:(NSNotification *)aNotif;
141 - (void)logData:(NSData *)data error:(BOOL)isError;
142 
143 @end
144 
145 @interface PCProjectBuilder (BuildLogging)
146 
147 // --- Parsing utilities
148 - (BOOL)line:(NSString *)lineString startsWithString:(NSString *)substring;
149 - (NSArray *)componentsOfLine:(NSString *)lineString;
150 - (void)parseMakeLine:(NSString *)lineString;
151 - (NSString *)parseCompilerLine:(NSString *)lineString;
152 
153 - (void)logBuildString:(NSString *)string newLine:(BOOL)newLine;
154 - (NSString *)parseBuildLine:(NSString *)string;
155 
156 @end
157 
158 @interface PCProjectBuilder (ErrorLogging)
159 
160 - (void)logErrorString:(NSString *)string;
161 
162 - (NSString *)lineTail:(NSString*)line afterString:(NSString*)string;
163 - (NSArray *)parseErrorLine:(NSString *)string;
164 
165 @end
166 
167 #endif
168