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
);
258 File ( const std::string
& _name
, bool _first
);
267 const XMLElement
& node
;
268 const Module
& module
;
270 const Module
* imported_module
;
272 Library ( const XMLElement
& _node
,
273 const Module
& _module
,
274 const std::string
& _name
);
283 const XMLElement
& node
;
284 const Module
& module
;
285 const Module
* invokeModule
;
286 std::vector
<InvokeFile
*> input
;
287 std::vector
<InvokeFile
*> output
;
289 Invoke ( const XMLElement
& _node
,
290 const Module
& _module
);
293 void GetTargets ( string_list
& targets
) const;
294 std::string
GetParameters () const;
296 void ProcessXMLSubElement ( const XMLElement
& e
);
297 void ProcessXMLSubElementInput ( const XMLElement
& e
);
298 void ProcessXMLSubElementOutput ( const XMLElement
& e
);
305 const XMLElement
& node
;
307 std::string switches
;
309 InvokeFile ( const XMLElement
& _node
,
310 const std::string
& _name
);
319 const XMLElement
& node
;
320 const Module
& module
;
321 const Module
* dependencyModule
;
323 Dependency ( const XMLElement
& _node
,
324 const Module
& _module
);
333 const XMLElement
& node
;
334 const Module
& module
;
335 std::string basename
;
336 std::string definition
;
338 ImportLibrary ( const XMLElement
& _node
,
339 const Module
& module
);
348 const XMLElement
& node
;
349 const Project
& project
;
350 const Module
* module
;
351 std::string property
, value
;
354 If ( const XMLElement
& node_
,
355 const Project
& project_
,
356 const Module
* module_
);
366 const Project
& project
;
367 const Module
* module
;
368 const XMLElement
& node
;
371 CompilerFlag ( const Project
& project
,
372 const XMLElement
& compilerFlagNode
);
373 CompilerFlag ( const Project
& project
,
374 const Module
* module
,
375 const XMLElement
& compilerFlagNode
);
386 const Project
& project
;
387 const Module
* module
;
388 const XMLElement
& node
;
391 LinkerFlag ( const Project
& project
,
392 const XMLElement
& linkerFlagNode
);
393 LinkerFlag ( const Project
& project
,
394 const Module
* module
,
395 const XMLElement
& linkerFlagNode
);
406 const XMLElement
& node
;
407 const Project
& project
;
408 const Module
* module
;
409 std::string name
, value
;
411 Property ( const XMLElement
& node_
,
412 const Project
& project_
,
413 const Module
* module_
);
422 SourceFile ( AutomaticDependency
* automaticDependency
,
424 const std::string
& filename
,
426 bool isNonAutomaticDependency
);
427 SourceFile
* ParseFile ( const std::string
& normalizedFilename
);
429 std::string
Location () const;
430 std::vector
<SourceFile
*> files
;
431 AutomaticDependency
* automaticDependency
;
433 std::string filename
;
434 std::string filenamePart
;
435 std::string directoryPart
;
436 std::vector
<SourceFile
*> parents
; /* List of files, this file is included from */
437 bool isNonAutomaticDependency
;
438 std::string cachedDependencies
;
439 time_t lastWriteTime
;
440 time_t youngestLastWriteTime
; /* Youngest last write time of this file and all children */
441 SourceFile
* youngestFile
;
443 void GetDirectoryAndFilenameParts ();
446 void SkipWhitespace ();
447 bool ReadInclude ( std::string
& filename
,
449 bool IsIncludedFrom ( const std::string
& normalizedFilename
);
450 SourceFile
* GetParentSourceFile ();
451 bool CanProcessFile ( const std::string
& extension
);
452 bool IsParentOf ( const SourceFile
* parent
,
453 const SourceFile
* child
);
460 class AutomaticDependency
462 friend class SourceFileTest
;
464 const Project
& project
;
466 AutomaticDependency ( const Project
& project
);
467 ~AutomaticDependency ();
469 std::string
GetFilename ( const std::string
& filename
);
470 bool LocateIncludedFile ( const std::string
& directory
,
471 const std::string
& includedFilename
,
472 std::string
& resolvedFilename
);
473 bool LocateIncludedFile ( SourceFile
* sourceFile
,
475 const std::string
& includedFilename
,
477 std::string
& resolvedFilename
);
478 SourceFile
* RetrieveFromCacheOrParse ( Module
& module
,
479 const std::string
& filename
,
480 SourceFile
* parentSourceFile
);
481 SourceFile
* RetrieveFromCache ( const std::string
& filename
);
482 void CheckAutomaticDependencies ( bool verbose
);
483 void CheckAutomaticDependenciesForFile ( SourceFile
* sourceFile
);
485 void ProcessModule ( Module
& module
);
486 void ProcessFile ( Module
& module
,
488 std::map
<std::string
, SourceFile
*> sourcefile_map
;
495 const Project
& project
;
496 const Module
* module
;
497 const XMLElement
& node
;
499 std::string nameoncd
;
501 Bootstrap ( const Project
& project
,
502 const Module
* module
,
503 const XMLElement
& bootstrapNode
);
507 bool IsSupportedModuleType ( ModuleType type
);
515 const Project
& project
;
516 const XMLElement
& node
;
519 std::string nameoncd
;
522 CDFile ( const Project
& project
,
523 const XMLElement
& bootstrapNode
,
524 const std::string
& path
);
527 std::string
GetPath () const;
534 const Project
& project
;
535 const XMLElement
& node
;
541 InstallFile ( const Project
& project
,
542 const XMLElement
& bootstrapNode
,
543 const std::string
& path
);
546 std::string
GetPath () const;
553 const XMLElement
& node
;
554 const Module
& module
;
558 const XMLElement
& node
,
559 const Module
& module
,
560 const std::string
& header
);
565 class StubbedComponent
568 const Module
* module
;
569 const XMLElement
& node
;
571 std::vector
<StubbedSymbol
*> symbols
;
573 StubbedComponent ( const Module
* module_
,
574 const XMLElement
& stubbedComponentNode
);
575 ~StubbedComponent ();
577 void ProcessXMLSubElement ( const XMLElement
& e
);
584 const XMLElement
& node
;
588 StubbedSymbol ( const XMLElement
& stubbedSymbolNode
);
594 FixSeparator ( const std::string
& s
);
598 const std::string
& filename
,
599 const std::string
& newExtension
);
603 const std::string
& location
,
604 const std::string
& path
,
605 const std::string
& att_value
);
608 GetExtension ( const std::string
& filename
);
611 GetDirectory ( const std::string
& filename
);
614 NormalizeFilename ( const std::string
& filename
);
616 #endif /* __RBUILD_H */