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
& );
131 KernelModeDriver
= 5,
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;
191 std::string
GetTargetName () const;
192 std::string
GetDependencyPath () const;
193 std::string
GetBasePath () const;
194 std::string
GetPath () const;
195 std::string
GetPathWithPrefix ( const std::string
& prefix
) const;
196 void GetTargets ( string_list
& ) const;
197 std::string
GetInvocationTarget ( const int index
) const;
198 bool HasFileWithExtension ( const IfableData
&, const std::string
& extension
) const;
199 void InvokeModule () const;
202 std::string
GetDefaultModuleExtension () const;
203 std::string
GetDefaultModuleEntrypoint () const;
204 std::string
GetDefaultModuleBaseaddress () const;
205 void ProcessXMLSubElement ( const XMLElement
& e
,
206 const std::string
& path
,
214 const Project
& project
;
215 const Module
* module
;
216 const XMLElement
& node
;
217 std::string directory
;
218 std::string basePath
;
220 Include ( const Project
& project
,
221 const XMLElement
& includeNode
);
222 Include ( const Project
& project
,
223 const Module
* module
,
224 const XMLElement
& includeNode
);
235 const Project
& project
;
236 const Module
* module
;
237 const XMLElement
& node
;
241 Define ( const Project
& project
,
242 const XMLElement
& defineNode
);
243 Define ( const Project
& project
,
244 const Module
* module
,
245 const XMLElement
& defineNode
);
258 std::string switches
;
260 File ( const std::string
& _name
,
262 std::string _switches
);
271 const XMLElement
& node
;
272 const Module
& module
;
274 const Module
* imported_module
;
276 Library ( const XMLElement
& _node
,
277 const Module
& _module
,
278 const std::string
& _name
);
287 const XMLElement
& node
;
288 const Module
& module
;
289 const Module
* invokeModule
;
290 std::vector
<InvokeFile
*> input
;
291 std::vector
<InvokeFile
*> output
;
293 Invoke ( const XMLElement
& _node
,
294 const Module
& _module
);
297 void GetTargets ( string_list
& targets
) const;
298 std::string
GetParameters () const;
300 void ProcessXMLSubElement ( const XMLElement
& e
);
301 void ProcessXMLSubElementInput ( const XMLElement
& e
);
302 void ProcessXMLSubElementOutput ( const XMLElement
& e
);
309 const XMLElement
& node
;
311 std::string switches
;
313 InvokeFile ( const XMLElement
& _node
,
314 const std::string
& _name
);
323 const XMLElement
& node
;
324 const Module
& module
;
325 const Module
* dependencyModule
;
327 Dependency ( const XMLElement
& _node
,
328 const Module
& _module
);
337 const XMLElement
& node
;
338 const Module
& module
;
339 std::string basename
;
340 std::string definition
;
342 ImportLibrary ( const XMLElement
& _node
,
343 const Module
& module
);
352 const XMLElement
& node
;
353 const Project
& project
;
354 const Module
* module
;
355 std::string property
, value
;
358 If ( const XMLElement
& node_
,
359 const Project
& project_
,
360 const Module
* module_
);
370 const Project
& project
;
371 const Module
* module
;
372 const XMLElement
& node
;
375 CompilerFlag ( const Project
& project
,
376 const XMLElement
& compilerFlagNode
);
377 CompilerFlag ( const Project
& project
,
378 const Module
* module
,
379 const XMLElement
& compilerFlagNode
);
390 const Project
& project
;
391 const Module
* module
;
392 const XMLElement
& node
;
395 LinkerFlag ( const Project
& project
,
396 const XMLElement
& linkerFlagNode
);
397 LinkerFlag ( const Project
& project
,
398 const Module
* module
,
399 const XMLElement
& linkerFlagNode
);
410 const XMLElement
& node
;
411 const Project
& project
;
412 const Module
* module
;
413 std::string name
, value
;
415 Property ( const XMLElement
& node_
,
416 const Project
& project_
,
417 const Module
* module_
);
426 SourceFile ( AutomaticDependency
* automaticDependency
,
428 const std::string
& filename
,
430 bool isNonAutomaticDependency
);
431 SourceFile
* ParseFile ( const std::string
& normalizedFilename
);
433 std::string
Location () const;
434 std::vector
<SourceFile
*> files
;
435 AutomaticDependency
* automaticDependency
;
437 std::string filename
;
438 std::string filenamePart
;
439 std::string directoryPart
;
440 std::vector
<SourceFile
*> parents
; /* List of files, this file is included from */
441 bool isNonAutomaticDependency
;
442 std::string cachedDependencies
;
443 time_t lastWriteTime
;
444 time_t youngestLastWriteTime
; /* Youngest last write time of this file and all children */
445 SourceFile
* youngestFile
;
447 void GetDirectoryAndFilenameParts ();
450 void SkipWhitespace ();
451 bool ReadInclude ( std::string
& filename
,
453 bool IsIncludedFrom ( const std::string
& normalizedFilename
);
454 SourceFile
* GetParentSourceFile ();
455 bool CanProcessFile ( const std::string
& extension
);
456 bool IsParentOf ( const SourceFile
* parent
,
457 const SourceFile
* child
);
464 class AutomaticDependency
466 friend class SourceFileTest
;
468 const Project
& project
;
470 AutomaticDependency ( const Project
& project
);
471 ~AutomaticDependency ();
473 std::string
GetFilename ( const std::string
& filename
);
474 bool LocateIncludedFile ( const std::string
& directory
,
475 const std::string
& includedFilename
,
476 std::string
& resolvedFilename
);
477 bool LocateIncludedFile ( SourceFile
* sourceFile
,
479 const std::string
& includedFilename
,
481 std::string
& resolvedFilename
);
482 SourceFile
* RetrieveFromCacheOrParse ( Module
& module
,
483 const std::string
& filename
,
484 SourceFile
* parentSourceFile
);
485 SourceFile
* RetrieveFromCache ( const std::string
& filename
);
486 void CheckAutomaticDependencies ( bool verbose
);
487 void CheckAutomaticDependenciesForFile ( SourceFile
* sourceFile
);
489 void ProcessModule ( Module
& module
);
490 void ProcessFile ( Module
& module
,
492 std::map
<std::string
, SourceFile
*> sourcefile_map
;
499 const Project
& project
;
500 const Module
* module
;
501 const XMLElement
& node
;
503 std::string nameoncd
;
505 Bootstrap ( const Project
& project
,
506 const Module
* module
,
507 const XMLElement
& bootstrapNode
);
511 bool IsSupportedModuleType ( ModuleType type
);
519 const Project
& project
;
520 const XMLElement
& node
;
523 std::string nameoncd
;
526 CDFile ( const Project
& project
,
527 const XMLElement
& bootstrapNode
,
528 const std::string
& path
);
531 std::string
GetPath () const;
538 const Project
& project
;
539 const XMLElement
& node
;
545 InstallFile ( const Project
& project
,
546 const XMLElement
& bootstrapNode
,
547 const std::string
& path
);
550 std::string
GetPath () const;
557 const XMLElement
& node
;
558 const Module
& module
;
562 const XMLElement
& node
,
563 const Module
& module
,
564 const std::string
& header
);
569 class StubbedComponent
572 const Module
* module
;
573 const XMLElement
& node
;
575 std::vector
<StubbedSymbol
*> symbols
;
577 StubbedComponent ( const Module
* module_
,
578 const XMLElement
& stubbedComponentNode
);
579 ~StubbedComponent ();
581 void ProcessXMLSubElement ( const XMLElement
& e
);
588 const XMLElement
& node
;
592 StubbedSymbol ( const XMLElement
& stubbedSymbolNode
);
598 FixSeparator ( const std::string
& s
);
602 const std::string
& filename
,
603 const std::string
& newExtension
);
607 const std::string
& location
,
608 const std::string
& path
,
609 const std::string
& att_value
);
612 GetExtension ( const std::string
& filename
);
615 GetDirectory ( const std::string
& filename
);
618 NormalizeFilename ( const std::string
& filename
);
620 #endif /* __RBUILD_H */