13 #include <sys/utime.h>
22 #include "exception.h"
25 typedef std::vector
<std::string
> string_list
;
29 #define EXEPOSTFIX ".exe"
35 #define EXEPREFIX "./"
58 class AutomaticDependency
;
63 class StubbedComponent
;
71 std::vector
<File
*> files
;
72 std::vector
<Include
*> includes
;
73 std::vector
<Define
*> defines
;
74 std::vector
<Library
*> libraries
;
75 std::vector
<Property
*> properties
;
85 XMLElement
*node
, *head
;
89 XMLIncludes xmlbuildfiles
;
90 std::vector
<Module
*> modules
;
91 std::vector
<LinkerFlag
*> linkerFlags
;
92 std::vector
<CDFile
*> cdfiles
;
93 std::vector
<InstallFile
*> installfiles
;
94 IfableData non_if_data
;
96 Project ( const std::string
& filename
);
98 void WriteConfigurationFile ();
99 void ExecuteInvocations ();
100 void ProcessXML ( const std::string
& path
);
101 Module
* LocateModule ( const std::string
& name
);
102 const Module
* LocateModule ( const std::string
& name
) const;
103 std::string
GetProjectFilename () const;
105 const Property
* LookupProperty ( const std::string
& name
) const;
106 void SetConfigurationOption ( char* s
,
108 std::string
* alternativeName
);
109 void SetConfigurationOption ( char* s
,
111 void WriteIfChanged ( char* outbuf
,
112 std::string filename
);
114 void ProcessXMLSubElement ( const XMLElement
& e
,
115 const std::string
& path
,
118 // disable copy semantics
119 Project ( const Project
& );
120 Project
& operator = ( const Project
& );
156 const Project
& project
;
157 const XMLElement
& node
;
158 std::string xmlbuildFile
;
160 std::string extension
;
161 std::string entrypoint
;
162 std::string baseaddress
;
165 ImportLibrary
* importLibrary
;
167 Bootstrap
* bootstrap
;
168 IfableData non_if_data
;
169 std::vector
<Invoke
*> invocations
;
170 std::vector
<Dependency
*> dependencies
;
171 std::vector
<CompilerFlag
*> compilerFlags
;
172 std::vector
<LinkerFlag
*> linkerFlags
;
173 std::vector
<StubbedComponent
*> stubbedComponents
;
178 std::string installBase
;
179 std::string installName
;
183 Module ( const Project
& project
,
184 const XMLElement
& moduleNode
,
185 const std::string
& modulePath
);
187 ModuleType
GetModuleType ( const std::string
& location
,
188 const XMLAttribute
& attribute
);
189 bool HasImportLibrary () const;
190 std::string
GetTargetName () const;
191 std::string
GetDependencyPath () const;
192 std::string
GetBasePath () const;
193 std::string
GetPath () const;
194 std::string
GetPathWithPrefix ( const std::string
& prefix
) const;
195 void GetTargets ( string_list
& ) const;
196 std::string
GetInvocationTarget ( const int index
) const;
197 bool HasFileWithExtension ( const IfableData
&, const std::string
& extension
) const;
198 void InvokeModule () const;
201 std::string
GetDefaultModuleExtension () const;
202 std::string
GetDefaultModuleEntrypoint () const;
203 std::string
GetDefaultModuleBaseaddress () const;
204 void ProcessXMLSubElement ( const XMLElement
& e
,
205 const std::string
& path
,
213 const Project
& project
;
214 const Module
* module
;
215 const XMLElement
& node
;
216 std::string directory
;
217 std::string basePath
;
219 Include ( const Project
& project
,
220 const XMLElement
& includeNode
);
221 Include ( const Project
& project
,
222 const Module
* module
,
223 const XMLElement
& includeNode
);
234 const Project
& project
;
235 const Module
* module
;
236 const XMLElement
& node
;
240 Define ( const Project
& project
,
241 const XMLElement
& defineNode
);
242 Define ( const Project
& project
,
243 const Module
* module
,
244 const XMLElement
& defineNode
);
257 std::string switches
;
259 File ( const std::string
& _name
,
261 std::string _switches
);
270 const XMLElement
& node
;
271 const Module
& module
;
273 const Module
* imported_module
;
275 Library ( const XMLElement
& _node
,
276 const Module
& _module
,
277 const std::string
& _name
);
286 const XMLElement
& node
;
287 const Module
& module
;
288 const Module
* invokeModule
;
289 std::vector
<InvokeFile
*> input
;
290 std::vector
<InvokeFile
*> output
;
292 Invoke ( const XMLElement
& _node
,
293 const Module
& _module
);
296 void GetTargets ( string_list
& targets
) const;
297 std::string
GetParameters () const;
299 void ProcessXMLSubElement ( const XMLElement
& e
);
300 void ProcessXMLSubElementInput ( const XMLElement
& e
);
301 void ProcessXMLSubElementOutput ( const XMLElement
& e
);
308 const XMLElement
& node
;
310 std::string switches
;
312 InvokeFile ( const XMLElement
& _node
,
313 const std::string
& _name
);
322 const XMLElement
& node
;
323 const Module
& module
;
324 const Module
* dependencyModule
;
326 Dependency ( const XMLElement
& _node
,
327 const Module
& _module
);
336 const XMLElement
& node
;
337 const Module
& module
;
338 std::string basename
;
339 std::string definition
;
341 ImportLibrary ( const XMLElement
& _node
,
342 const Module
& module
);
351 const XMLElement
& node
;
352 const Project
& project
;
353 const Module
* module
;
354 std::string property
, value
;
357 If ( const XMLElement
& node_
,
358 const Project
& project_
,
359 const Module
* module_
);
369 const Project
& project
;
370 const Module
* module
;
371 const XMLElement
& node
;
374 CompilerFlag ( const Project
& project
,
375 const XMLElement
& compilerFlagNode
);
376 CompilerFlag ( const Project
& project
,
377 const Module
* module
,
378 const XMLElement
& compilerFlagNode
);
389 const Project
& project
;
390 const Module
* module
;
391 const XMLElement
& node
;
394 LinkerFlag ( const Project
& project
,
395 const XMLElement
& linkerFlagNode
);
396 LinkerFlag ( const Project
& project
,
397 const Module
* module
,
398 const XMLElement
& linkerFlagNode
);
409 const XMLElement
& node
;
410 const Project
& project
;
411 const Module
* module
;
412 std::string name
, value
;
414 Property ( const XMLElement
& node_
,
415 const Project
& project_
,
416 const Module
* module_
);
425 SourceFile ( AutomaticDependency
* automaticDependency
,
427 const std::string
& filename
,
429 bool isNonAutomaticDependency
);
430 SourceFile
* ParseFile ( const std::string
& normalizedFilename
);
432 std::string
Location () const;
433 std::vector
<SourceFile
*> files
;
434 AutomaticDependency
* automaticDependency
;
436 std::string filename
;
437 std::string filenamePart
;
438 std::string directoryPart
;
439 std::vector
<SourceFile
*> parents
; /* List of files, this file is included from */
440 bool isNonAutomaticDependency
;
441 std::string cachedDependencies
;
442 time_t lastWriteTime
;
443 time_t youngestLastWriteTime
; /* Youngest last write time of this file and all children */
444 SourceFile
* youngestFile
;
446 void GetDirectoryAndFilenameParts ();
449 void SkipWhitespace ();
450 bool ReadInclude ( std::string
& filename
,
452 bool IsIncludedFrom ( const std::string
& normalizedFilename
);
453 SourceFile
* GetParentSourceFile ();
454 bool CanProcessFile ( const std::string
& extension
);
455 bool IsParentOf ( const SourceFile
* parent
,
456 const SourceFile
* child
);
463 class AutomaticDependency
465 friend class SourceFileTest
;
467 const Project
& project
;
469 AutomaticDependency ( const Project
& project
);
470 ~AutomaticDependency ();
472 std::string
GetFilename ( const std::string
& filename
);
473 bool LocateIncludedFile ( const std::string
& directory
,
474 const std::string
& includedFilename
,
475 std::string
& resolvedFilename
);
476 bool LocateIncludedFile ( SourceFile
* sourceFile
,
478 const std::string
& includedFilename
,
480 std::string
& resolvedFilename
);
481 SourceFile
* RetrieveFromCacheOrParse ( Module
& module
,
482 const std::string
& filename
,
483 SourceFile
* parentSourceFile
);
484 SourceFile
* RetrieveFromCache ( const std::string
& filename
);
485 void CheckAutomaticDependencies ( bool verbose
);
486 void CheckAutomaticDependenciesForFile ( SourceFile
* sourceFile
);
488 void ProcessModule ( Module
& module
);
489 void ProcessFile ( Module
& module
,
491 std::map
<std::string
, SourceFile
*> sourcefile_map
;
498 const Project
& project
;
499 const Module
* module
;
500 const XMLElement
& node
;
502 std::string nameoncd
;
504 Bootstrap ( const Project
& project
,
505 const Module
* module
,
506 const XMLElement
& bootstrapNode
);
510 bool IsSupportedModuleType ( ModuleType type
);
518 const Project
& project
;
519 const XMLElement
& node
;
522 std::string nameoncd
;
525 CDFile ( const Project
& project
,
526 const XMLElement
& bootstrapNode
,
527 const std::string
& path
);
530 std::string
GetPath () const;
537 const Project
& project
;
538 const XMLElement
& node
;
544 InstallFile ( const Project
& project
,
545 const XMLElement
& bootstrapNode
,
546 const std::string
& path
);
549 std::string
GetPath () const;
556 const XMLElement
& node
;
557 const Module
& module
;
561 const XMLElement
& node
,
562 const Module
& module
,
563 const std::string
& header
);
568 class StubbedComponent
571 const Module
* module
;
572 const XMLElement
& node
;
574 std::vector
<StubbedSymbol
*> symbols
;
576 StubbedComponent ( const Module
* module_
,
577 const XMLElement
& stubbedComponentNode
);
578 ~StubbedComponent ();
580 void ProcessXMLSubElement ( const XMLElement
& e
);
587 const XMLElement
& node
;
591 StubbedSymbol ( const XMLElement
& stubbedSymbolNode
);
597 FixSeparator ( const std::string
& s
);
601 const std::string
& filename
,
602 const std::string
& newExtension
);
606 const std::string
& location
,
607 const std::string
& path
,
608 const std::string
& att_value
);
611 GetExtension ( const std::string
& filename
);
614 GetDirectory ( const std::string
& filename
);
617 NormalizeFilename ( const std::string
& filename
);
619 #endif /* __RBUILD_H */