13 #include <sys/utime.h>
22 #include "exception.h"
25 typedef std::vector
<std::string
> string_list
;
29 #define EXEPOSTFIX ".exe"
35 #define EXEPREFIX "./"
59 class AutomaticDependency
;
64 class StubbedComponent
;
72 std::vector
<File
*> files
;
73 std::vector
<Include
*> includes
;
74 std::vector
<Define
*> defines
;
75 std::vector
<Library
*> libraries
;
76 std::vector
<Property
*> properties
;
77 std::vector
<CompilerFlag
*> compilerFlags
;
87 XMLElement
*node
, *head
;
91 XMLIncludes xmlbuildfiles
;
92 std::vector
<Module
*> modules
;
93 std::vector
<LinkerFlag
*> linkerFlags
;
94 std::vector
<CDFile
*> cdfiles
;
95 std::vector
<InstallFile
*> installfiles
;
96 IfableData non_if_data
;
98 Project ( const std::string
& filename
);
100 void WriteConfigurationFile ();
101 void ExecuteInvocations ();
102 void ProcessXML ( const std::string
& path
);
103 Module
* LocateModule ( const std::string
& name
);
104 const Module
* LocateModule ( const std::string
& name
) const;
105 std::string
GetProjectFilename () const;
107 const Property
* LookupProperty ( const std::string
& name
) const;
108 void SetConfigurationOption ( char* s
,
110 std::string
* alternativeName
);
111 void SetConfigurationOption ( char* s
,
113 void WriteIfChanged ( char* outbuf
,
114 std::string filename
);
116 void ProcessXMLSubElement ( const XMLElement
& e
,
117 const std::string
& path
,
120 // disable copy semantics
121 Project ( const Project
& );
122 Project
& operator = ( const Project
& );
133 KernelModeDriver
= 5,
158 const Project
& project
;
159 const XMLElement
& node
;
160 std::string xmlbuildFile
;
162 std::string extension
;
163 std::string entrypoint
;
164 std::string baseaddress
;
167 ImportLibrary
* importLibrary
;
169 Bootstrap
* bootstrap
;
170 IfableData non_if_data
;
171 std::vector
<Invoke
*> invocations
;
172 std::vector
<Dependency
*> dependencies
;
173 std::vector
<CompilerFlag
*> compilerFlags
;
174 std::vector
<LinkerFlag
*> linkerFlags
;
175 std::vector
<StubbedComponent
*> stubbedComponents
;
180 std::string installBase
;
181 std::string installName
;
185 Module ( const Project
& project
,
186 const XMLElement
& moduleNode
,
187 const std::string
& modulePath
);
189 ModuleType
GetModuleType ( const std::string
& location
,
190 const XMLAttribute
& attribute
);
191 bool HasImportLibrary () const;
193 std::string
GetTargetName () const;
194 std::string
GetDependencyPath () const;
195 std::string
GetBasePath () const;
196 std::string
GetPath () const;
197 std::string
GetPathWithPrefix ( const std::string
& prefix
) const;
198 void GetTargets ( string_list
& ) const;
199 std::string
GetInvocationTarget ( const int index
) const;
200 bool HasFileWithExtension ( const IfableData
&, const std::string
& extension
) const;
201 void InvokeModule () const;
204 std::string
GetDefaultModuleExtension () const;
205 std::string
GetDefaultModuleEntrypoint () const;
206 std::string
GetDefaultModuleBaseaddress () const;
207 void ProcessXMLSubElement ( const XMLElement
& e
,
208 const std::string
& path
,
216 const Project
& project
;
217 const Module
* module
;
218 const XMLElement
& node
;
219 std::string directory
;
220 std::string basePath
;
222 Include ( const Project
& project
,
223 const XMLElement
& includeNode
);
224 Include ( const Project
& project
,
225 const Module
* module
,
226 const XMLElement
& includeNode
);
237 const Project
& project
;
238 const Module
* module
;
239 const XMLElement
& node
;
243 Define ( const Project
& project
,
244 const XMLElement
& defineNode
);
245 Define ( const Project
& project
,
246 const Module
* module
,
247 const XMLElement
& defineNode
);
260 std::string switches
;
262 File ( const std::string
& _name
,
264 std::string _switches
);
273 const XMLElement
& node
;
274 const Module
& module
;
276 const Module
* imported_module
;
278 Library ( const XMLElement
& _node
,
279 const Module
& _module
,
280 const std::string
& _name
);
289 const XMLElement
& node
;
290 const Module
& module
;
291 const Module
* invokeModule
;
292 std::vector
<InvokeFile
*> input
;
293 std::vector
<InvokeFile
*> output
;
295 Invoke ( const XMLElement
& _node
,
296 const Module
& _module
);
299 void GetTargets ( string_list
& targets
) const;
300 std::string
GetParameters () const;
302 void ProcessXMLSubElement ( const XMLElement
& e
);
303 void ProcessXMLSubElementInput ( const XMLElement
& e
);
304 void ProcessXMLSubElementOutput ( const XMLElement
& e
);
311 const XMLElement
& node
;
313 std::string switches
;
315 InvokeFile ( const XMLElement
& _node
,
316 const std::string
& _name
);
325 const XMLElement
& node
;
326 const Module
& module
;
327 const Module
* dependencyModule
;
329 Dependency ( const XMLElement
& _node
,
330 const Module
& _module
);
339 const XMLElement
& node
;
340 const Module
& module
;
341 std::string basename
;
342 std::string definition
;
344 ImportLibrary ( const XMLElement
& _node
,
345 const Module
& module
);
354 const XMLElement
& node
;
355 const Project
& project
;
356 const Module
* module
;
357 std::string property
, value
;
360 If ( const XMLElement
& node_
,
361 const Project
& project_
,
362 const Module
* module_
);
372 const Project
& project
;
373 const Module
* module
;
374 const XMLElement
& node
;
377 CompilerFlag ( const Project
& project
,
378 const XMLElement
& compilerFlagNode
);
379 CompilerFlag ( const Project
& project
,
380 const Module
* module
,
381 const XMLElement
& compilerFlagNode
);
392 const Project
& project
;
393 const Module
* module
;
394 const XMLElement
& node
;
397 LinkerFlag ( const Project
& project
,
398 const XMLElement
& linkerFlagNode
);
399 LinkerFlag ( const Project
& project
,
400 const Module
* module
,
401 const XMLElement
& linkerFlagNode
);
412 const XMLElement
& node
;
413 const Project
& project
;
414 const Module
* module
;
415 std::string name
, value
;
417 Property ( const XMLElement
& node_
,
418 const Project
& project_
,
419 const Module
* module_
);
428 const Project
& project
;
431 WineResource ( const Project
& project
,
432 std::string bin2res
);
434 void UnpackResources ( bool verbose
);
436 bool IsSpecFile ( const File
& file
);
437 bool IsWineModule ( const Module
& module
);
438 bool IsResourceFile ( const File
& file
);
439 std::string
GetResourceFilename ( const Module
& module
);
440 void UnpackResourcesInModule ( Module
& module
,
448 SourceFile ( AutomaticDependency
* automaticDependency
,
450 const std::string
& filename
,
452 bool isNonAutomaticDependency
);
453 SourceFile
* ParseFile ( const std::string
& normalizedFilename
);
455 std::string
Location () const;
456 std::vector
<SourceFile
*> files
;
457 AutomaticDependency
* automaticDependency
;
459 std::string filename
;
460 std::string filenamePart
;
461 std::string directoryPart
;
462 std::vector
<SourceFile
*> parents
; /* List of files, this file is included from */
463 bool isNonAutomaticDependency
;
464 std::string cachedDependencies
;
465 time_t lastWriteTime
;
466 time_t youngestLastWriteTime
; /* Youngest last write time of this file and all children */
467 SourceFile
* youngestFile
;
469 void GetDirectoryAndFilenameParts ();
472 void SkipWhitespace ();
473 bool ReadInclude ( std::string
& filename
,
475 bool IsIncludedFrom ( const std::string
& normalizedFilename
);
476 SourceFile
* GetParentSourceFile ();
477 bool CanProcessFile ( const std::string
& extension
);
478 bool IsParentOf ( const SourceFile
* parent
,
479 const SourceFile
* child
);
486 class AutomaticDependency
488 friend class SourceFileTest
;
490 const Project
& project
;
492 AutomaticDependency ( const Project
& project
);
493 ~AutomaticDependency ();
495 std::string
GetFilename ( const std::string
& filename
);
496 bool LocateIncludedFile ( const std::string
& directory
,
497 const std::string
& includedFilename
,
498 std::string
& resolvedFilename
);
499 bool LocateIncludedFile ( SourceFile
* sourceFile
,
501 const std::string
& includedFilename
,
503 std::string
& resolvedFilename
);
504 SourceFile
* RetrieveFromCacheOrParse ( Module
& module
,
505 const std::string
& filename
,
506 SourceFile
* parentSourceFile
);
507 SourceFile
* RetrieveFromCache ( const std::string
& filename
);
508 void CheckAutomaticDependencies ( bool verbose
);
509 void CheckAutomaticDependenciesForFile ( SourceFile
* sourceFile
);
511 void ProcessModule ( Module
& module
);
512 void ProcessFile ( Module
& module
,
514 std::map
<std::string
, SourceFile
*> sourcefile_map
;
521 const Project
& project
;
522 const Module
* module
;
523 const XMLElement
& node
;
525 std::string nameoncd
;
527 Bootstrap ( const Project
& project
,
528 const Module
* module
,
529 const XMLElement
& bootstrapNode
);
533 bool IsSupportedModuleType ( ModuleType type
);
541 const Project
& project
;
542 const XMLElement
& node
;
545 std::string nameoncd
;
548 CDFile ( const Project
& project
,
549 const XMLElement
& bootstrapNode
,
550 const std::string
& path
);
553 std::string
GetPath () const;
560 const Project
& project
;
561 const XMLElement
& node
;
567 InstallFile ( const Project
& project
,
568 const XMLElement
& bootstrapNode
,
569 const std::string
& path
);
572 std::string
GetPath () const;
579 const XMLElement
& node
;
580 const Module
& module
;
584 const XMLElement
& node
,
585 const Module
& module
,
586 const std::string
& header
);
591 class StubbedComponent
594 const Module
* module
;
595 const XMLElement
& node
;
597 std::vector
<StubbedSymbol
*> symbols
;
599 StubbedComponent ( const Module
* module_
,
600 const XMLElement
& stubbedComponentNode
);
601 ~StubbedComponent ();
603 void ProcessXMLSubElement ( const XMLElement
& e
);
610 const XMLElement
& node
;
614 StubbedSymbol ( const XMLElement
& stubbedSymbolNode
);
620 FixSeparator ( const std::string
& s
);
624 const std::string
& filename
,
625 const std::string
& newExtension
);
629 const std::string
& location
,
630 const std::string
& path
,
631 const std::string
& att_value
);
634 GetExtension ( const std::string
& filename
);
637 GetDirectory ( const std::string
& filename
);
640 NormalizeFilename ( const std::string
& filename
);
642 #endif /* __RBUILD_H */