13 #include <sys/utime.h>
22 #include "exception.h"
27 #define EXEPOSTFIX ".exe"
33 #define EXEPREFIX "./"
56 class AutomaticDependency
;
60 class StubbedComponent
;
68 std::vector
<File
*> files
;
69 std::vector
<Include
*> includes
;
70 std::vector
<Define
*> defines
;
71 std::vector
<Library
*> libraries
;
72 std::vector
<Property
*> properties
;
82 XMLElement
*node
, *head
;
86 XMLIncludes xmlbuildfiles
;
87 std::vector
<Module
*> modules
;
88 std::vector
<LinkerFlag
*> linkerFlags
;
89 std::vector
<CDFile
*> cdfiles
;
90 IfableData non_if_data
;
92 Project ( const std::string
& filename
);
94 void WriteConfigurationFile ();
95 void ExecuteInvocations ();
96 void ProcessXML ( const std::string
& path
);
97 Module
* LocateModule ( const std::string
& name
);
98 const Module
* LocateModule ( const std::string
& name
) const;
99 std::string
GetProjectFilename () const;
101 const Property
* LookupProperty ( const std::string
& name
) const;
102 void SetConfigurationOption ( char* s
,
104 std::string
* alternativeName
);
105 void SetConfigurationOption ( char* s
,
107 void WriteIfChanged ( char* outbuf
,
108 std::string filename
);
110 void ProcessXMLSubElement ( const XMLElement
& e
,
111 const std::string
& path
,
114 // disable copy semantics
115 Project ( const Project
& );
116 Project
& operator = ( const Project
& );
149 const Project
& project
;
150 const XMLElement
& node
;
152 std::string extension
;
153 std::string entrypoint
;
154 std::string baseaddress
;
157 ImportLibrary
* importLibrary
;
159 Bootstrap
* bootstrap
;
160 IfableData non_if_data
;
161 std::vector
<Invoke
*> invocations
;
162 std::vector
<Dependency
*> dependencies
;
163 std::vector
<CompilerFlag
*> compilerFlags
;
164 std::vector
<LinkerFlag
*> linkerFlags
;
165 std::vector
<StubbedComponent
*> stubbedComponents
;
171 Module ( const Project
& project
,
172 const XMLElement
& moduleNode
,
173 const std::string
& modulePath
);
175 ModuleType
GetModuleType ( const std::string
& location
,
176 const XMLAttribute
& attribute
);
177 bool HasImportLibrary () const;
178 std::string
GetTargetName () const;
179 std::string
GetDependencyPath () const;
180 std::string
GetBasePath () const;
181 std::string
GetPath () const;
182 std::string
GetPathWithPrefix ( const std::string
& prefix
) const;
183 std::string
GetTargets () const;
184 std::string
GetInvocationTarget ( const int index
) const;
185 bool HasFileWithExtension ( const IfableData
&, const std::string
& extension
) const;
186 void InvokeModule () const;
189 std::string
GetDefaultModuleExtension () const;
190 std::string
GetDefaultModuleEntrypoint () const;
191 std::string
GetDefaultModuleBaseaddress () const;
192 void ProcessXMLSubElement ( const XMLElement
& e
,
193 const std::string
& path
,
201 const Project
& project
;
202 const Module
* module
;
203 const XMLElement
& node
;
204 std::string directory
;
205 std::string basePath
;
207 Include ( const Project
& project
,
208 const XMLElement
& includeNode
);
209 Include ( const Project
& project
,
210 const Module
* module
,
211 const XMLElement
& includeNode
);
222 const Project
& project
;
223 const Module
* module
;
224 const XMLElement
& node
;
228 Define ( const Project
& project
,
229 const XMLElement
& defineNode
);
230 Define ( const Project
& project
,
231 const Module
* module
,
232 const XMLElement
& defineNode
);
246 File ( const std::string
& _name
, bool _first
);
255 const XMLElement
& node
;
256 const Module
& module
;
258 const Module
* imported_module
;
260 Library ( const XMLElement
& _node
,
261 const Module
& _module
,
262 const std::string
& _name
);
271 const XMLElement
& node
;
272 const Module
& module
;
273 const Module
* invokeModule
;
274 std::vector
<InvokeFile
*> input
;
275 std::vector
<InvokeFile
*> output
;
277 Invoke ( const XMLElement
& _node
,
278 const Module
& _module
);
281 std::string
GetTargets () const;
282 std::string
GetParameters () const;
284 void ProcessXMLSubElement ( const XMLElement
& e
);
285 void ProcessXMLSubElementInput ( const XMLElement
& e
);
286 void ProcessXMLSubElementOutput ( const XMLElement
& e
);
293 const XMLElement
& node
;
295 std::string switches
;
297 InvokeFile ( const XMLElement
& _node
,
298 const std::string
& _name
);
307 const XMLElement
& node
;
308 const Module
& module
;
309 const Module
* dependencyModule
;
311 Dependency ( const XMLElement
& _node
,
312 const Module
& _module
);
321 const XMLElement
& node
;
322 const Module
& module
;
323 std::string basename
;
324 std::string definition
;
326 ImportLibrary ( const XMLElement
& _node
,
327 const Module
& module
);
336 const XMLElement
& node
;
337 const Project
& project
;
338 const Module
* module
;
339 std::string property
, value
;
342 If ( const XMLElement
& node_
,
343 const Project
& project_
,
344 const Module
* module_
);
354 const Project
& project
;
355 const Module
* module
;
356 const XMLElement
& node
;
359 CompilerFlag ( const Project
& project
,
360 const XMLElement
& compilerFlagNode
);
361 CompilerFlag ( const Project
& project
,
362 const Module
* module
,
363 const XMLElement
& compilerFlagNode
);
374 const Project
& project
;
375 const Module
* module
;
376 const XMLElement
& node
;
379 LinkerFlag ( const Project
& project
,
380 const XMLElement
& linkerFlagNode
);
381 LinkerFlag ( const Project
& project
,
382 const Module
* module
,
383 const XMLElement
& linkerFlagNode
);
394 const XMLElement
& node
;
395 const Project
& project
;
396 const Module
* module
;
397 std::string name
, value
;
399 Property ( const XMLElement
& node_
,
400 const Project
& project_
,
401 const Module
* module_
);
410 SourceFile ( AutomaticDependency
* automaticDependency
,
412 const std::string
& filename
,
414 bool isNonAutomaticDependency
);
415 SourceFile
* ParseFile ( const std::string
& normalizedFilename
);
417 std::string
Location () const;
418 std::vector
<SourceFile
*> files
;
419 AutomaticDependency
* automaticDependency
;
421 std::string filename
;
422 std::string filenamePart
;
423 std::string directoryPart
;
424 std::vector
<SourceFile
*> parents
; /* List of files, this file is included from */
425 bool isNonAutomaticDependency
;
426 std::string cachedDependencies
;
427 time_t lastWriteTime
;
428 time_t youngestLastWriteTime
; /* Youngest last write time of this file and all children */
429 SourceFile
* youngestFile
;
431 void GetDirectoryAndFilenameParts ();
434 void SkipWhitespace ();
435 bool ReadInclude ( std::string
& filename
,
437 bool IsIncludedFrom ( const std::string
& normalizedFilename
);
438 SourceFile
* GetParentSourceFile ();
439 bool CanProcessFile ( const std::string
& extension
);
440 bool IsParentOf ( const SourceFile
* parent
,
441 const SourceFile
* child
);
448 class AutomaticDependency
450 friend class SourceFileTest
;
452 const Project
& project
;
454 AutomaticDependency ( const Project
& project
);
455 ~AutomaticDependency ();
457 std::string
GetFilename ( const std::string
& filename
);
458 bool LocateIncludedFile ( const std::string
& directory
,
459 const std::string
& includedFilename
,
460 std::string
& resolvedFilename
);
461 bool LocateIncludedFile ( SourceFile
* sourceFile
,
463 const std::string
& includedFilename
,
465 std::string
& resolvedFilename
);
466 SourceFile
* RetrieveFromCacheOrParse ( Module
& module
,
467 const std::string
& filename
,
468 SourceFile
* parentSourceFile
);
469 SourceFile
* RetrieveFromCache ( const std::string
& filename
);
470 void CheckAutomaticDependencies ();
471 void CheckAutomaticDependenciesForFile ( SourceFile
* sourceFile
);
473 void ProcessModule ( Module
& module
);
474 void ProcessFile ( Module
& module
,
476 std::map
<std::string
, SourceFile
*> sourcefile_map
;
483 const Project
& project
;
484 const Module
* module
;
485 const XMLElement
& node
;
487 std::string nameoncd
;
489 Bootstrap ( const Project
& project
,
490 const Module
* module
,
491 const XMLElement
& bootstrapNode
);
495 bool IsSupportedModuleType ( ModuleType type
);
503 const Project
& project
;
504 const XMLElement
& node
;
507 std::string nameoncd
;
510 CDFile ( const Project
& project
,
511 const XMLElement
& bootstrapNode
,
512 const std::string
& path
);
515 std::string
GetPath () const;
522 const XMLElement
& node
;
523 const Module
& module
;
527 const XMLElement
& node
,
528 const Module
& module
,
529 const std::string
& header
);
534 class StubbedComponent
537 const Module
* module
;
538 const XMLElement
& node
;
540 std::vector
<StubbedSymbol
*> symbols
;
542 StubbedComponent ( const Module
* module_
,
543 const XMLElement
& stubbedComponentNode
);
544 ~StubbedComponent ();
546 void ProcessXMLSubElement ( const XMLElement
& e
);
553 const XMLElement
& node
;
557 StubbedSymbol ( const XMLElement
& stubbedSymbolNode
);
563 FixSeparator ( const std::string
& s
);
567 const std::string
& location
,
568 const std::string
& path
,
569 const std::string
& att_value
);
572 GetExtension ( const std::string
& filename
);
575 GetDirectory ( const std::string
& filename
);
578 NormalizeFilename ( const std::string
& filename
);
580 #endif /* __RBUILD_H */