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 TestSupportCode
;
60 class AutomaticDependency
;
65 class StubbedComponent
;
74 static std::string
GetVariable ( const std::string
& name
);
75 static std::string
GetIntermediatePath ();
76 static std::string
GetOutputPath ();
77 static std::string
GetInstallPath ();
78 static std::string
GetEnvironmentVariablePathOrDefault ( const std::string
& name
,
79 const std::string
& defaultValue
);
85 static void WriteIfChanged ( char* outbuf
,
86 std::string filename
);
92 std::vector
<File
*> files
;
93 std::vector
<Include
*> includes
;
94 std::vector
<Define
*> defines
;
95 std::vector
<Library
*> libraries
;
96 std::vector
<Property
*> properties
;
97 std::vector
<CompilerFlag
*> compilerFlags
;
107 XMLElement
*node
, *head
;
110 std::string makefile
;
111 XMLIncludes xmlbuildfiles
;
112 std::vector
<Module
*> modules
;
113 std::vector
<LinkerFlag
*> linkerFlags
;
114 std::vector
<CDFile
*> cdfiles
;
115 std::vector
<InstallFile
*> installfiles
;
116 IfableData non_if_data
;
118 Project ( const std::string
& filename
);
120 void WriteConfigurationFile ();
121 void ExecuteInvocations ();
122 void ProcessXML ( const std::string
& path
);
123 Module
* LocateModule ( const std::string
& name
);
124 const Module
* LocateModule ( const std::string
& name
) const;
125 std::string
GetProjectFilename () const;
127 const Property
* LookupProperty ( const std::string
& name
) const;
128 void SetConfigurationOption ( char* s
,
130 std::string
* alternativeName
);
131 void SetConfigurationOption ( char* s
,
134 void ProcessXMLSubElement ( const XMLElement
& e
,
135 const std::string
& path
,
138 // disable copy semantics
139 Project ( const Project
& );
140 Project
& operator = ( const Project
& );
151 KernelModeDriver
= 5,
176 const Project
& project
;
177 const XMLElement
& node
;
178 std::string xmlbuildFile
;
180 std::string extension
;
181 std::string entrypoint
;
182 std::string baseaddress
;
185 ImportLibrary
* importLibrary
;
187 Bootstrap
* bootstrap
;
188 IfableData non_if_data
;
189 std::vector
<Invoke
*> invocations
;
190 std::vector
<Dependency
*> dependencies
;
191 std::vector
<CompilerFlag
*> compilerFlags
;
192 std::vector
<LinkerFlag
*> linkerFlags
;
193 std::vector
<StubbedComponent
*> stubbedComponents
;
198 std::string installBase
;
199 std::string installName
;
203 Module ( const Project
& project
,
204 const XMLElement
& moduleNode
,
205 const std::string
& modulePath
);
207 ModuleType
GetModuleType ( const std::string
& location
,
208 const XMLAttribute
& attribute
);
209 bool HasImportLibrary () const;
211 std::string
GetTargetName () const;
212 std::string
GetDependencyPath () const;
213 std::string
GetBasePath () const;
214 std::string
GetPath () const;
215 std::string
GetPathWithPrefix ( const std::string
& prefix
) const;
216 void GetTargets ( string_list
& ) const;
217 std::string
GetInvocationTarget ( const int index
) const;
218 bool HasFileWithExtension ( const IfableData
&, const std::string
& extension
) const;
219 void InvokeModule () const;
221 void GetSourceFilenames ( string_list
& list
,
222 bool includeGeneratedFiles
) const;
224 std::string
GetDefaultModuleExtension () const;
225 std::string
GetDefaultModuleEntrypoint () const;
226 std::string
GetDefaultModuleBaseaddress () const;
227 void ProcessXMLSubElement ( const XMLElement
& e
,
228 const std::string
& path
,
236 const Project
& project
;
237 const Module
* module
;
238 const XMLElement
& node
;
239 std::string directory
;
240 std::string basePath
;
242 Include ( const Project
& project
,
243 const XMLElement
& includeNode
);
244 Include ( const Project
& project
,
245 const Module
* module
,
246 const XMLElement
& includeNode
);
257 const Project
& project
;
258 const Module
* module
;
259 const XMLElement
& node
;
263 Define ( const Project
& project
,
264 const XMLElement
& defineNode
);
265 Define ( const Project
& project
,
266 const Module
* module
,
267 const XMLElement
& defineNode
);
280 std::string switches
;
282 File ( const std::string
& _name
,
284 std::string _switches
);
287 bool IsGeneratedFile () const;
294 const XMLElement
& node
;
295 const Module
& module
;
297 const Module
* imported_module
;
299 Library ( const XMLElement
& _node
,
300 const Module
& _module
,
301 const std::string
& _name
);
310 const XMLElement
& node
;
311 const Module
& module
;
312 const Module
* invokeModule
;
313 std::vector
<InvokeFile
*> input
;
314 std::vector
<InvokeFile
*> output
;
316 Invoke ( const XMLElement
& _node
,
317 const Module
& _module
);
320 void GetTargets ( string_list
& targets
) const;
321 std::string
GetParameters () const;
323 void ProcessXMLSubElement ( const XMLElement
& e
);
324 void ProcessXMLSubElementInput ( const XMLElement
& e
);
325 void ProcessXMLSubElementOutput ( const XMLElement
& e
);
332 const XMLElement
& node
;
334 std::string switches
;
336 InvokeFile ( const XMLElement
& _node
,
337 const std::string
& _name
);
346 const XMLElement
& node
;
347 const Module
& module
;
348 const Module
* dependencyModule
;
350 Dependency ( const XMLElement
& _node
,
351 const Module
& _module
);
360 const XMLElement
& node
;
361 const Module
& module
;
362 std::string basename
;
363 std::string definition
;
365 ImportLibrary ( const XMLElement
& _node
,
366 const Module
& module
);
375 const XMLElement
& node
;
376 const Project
& project
;
377 const Module
* module
;
378 std::string property
, value
;
381 If ( const XMLElement
& node_
,
382 const Project
& project_
,
383 const Module
* module_
);
393 const Project
& project
;
394 const Module
* module
;
395 const XMLElement
& node
;
398 CompilerFlag ( const Project
& project
,
399 const XMLElement
& compilerFlagNode
);
400 CompilerFlag ( const Project
& project
,
401 const Module
* module
,
402 const XMLElement
& compilerFlagNode
);
413 const Project
& project
;
414 const Module
* module
;
415 const XMLElement
& node
;
418 LinkerFlag ( const Project
& project
,
419 const XMLElement
& linkerFlagNode
);
420 LinkerFlag ( const Project
& project
,
421 const Module
* module
,
422 const XMLElement
& linkerFlagNode
);
433 const XMLElement
& node
;
434 const Project
& project
;
435 const Module
* module
;
436 std::string name
, value
;
438 Property ( const XMLElement
& node_
,
439 const Project
& project_
,
440 const Module
* module_
);
446 class TestSupportCode
449 const Project
& project
;
451 TestSupportCode ( const Project
& project
);
453 void GenerateTestSupportCode ( bool verbose
);
455 bool IsTestModule ( const Module
& module
);
456 void GenerateTestSupportCodeForModule ( Module
& module
,
458 std::string
GetHooksFilename ( Module
& module
);
459 char* WriteStubbedSymbolToHooksFile ( char* buffer
,
460 const StubbedComponent
& component
,
461 const StubbedSymbol
& symbol
);
462 char* WriteStubbedComponentToHooksFile ( char* buffer
,
463 const StubbedComponent
& component
);
464 void WriteHooksFile ( Module
& module
);
465 std::string
GetStubsFilename ( Module
& module
);
466 char* WriteStubbedSymbolToStubsFile ( char* buffer
,
467 const StubbedComponent
& component
,
468 const StubbedSymbol
& symbol
,
470 char* WriteStubbedComponentToStubsFile ( char* buffer
,
471 const StubbedComponent
& component
,
473 void WriteStubsFile ( Module
& module
);
474 std::string
GetStartupFilename ( Module
& module
);
475 std::string
GetTestDispatcherName ( std::string filename
);
476 bool IsTestFile ( std::string
& filename
) const;
477 void GetSourceFilenames ( string_list
& list
,
478 Module
& module
) const;
479 char* WriteTestDispatcherPrototypesToStartupFile ( char* buffer
,
481 char* WriteRegisterTestsFunctionToStartupFile ( char* buffer
,
483 void WriteStartupFile ( Module
& module
);
490 const Project
& project
;
493 WineResource ( const Project
& project
,
494 std::string bin2res
);
496 void UnpackResources ( bool verbose
);
498 bool IsSpecFile ( const File
& file
);
499 bool IsWineModule ( const Module
& module
);
500 bool IsResourceFile ( const File
& file
);
501 std::string
GetResourceFilename ( const Module
& module
);
502 void UnpackResourcesInModule ( Module
& module
,
510 SourceFile ( AutomaticDependency
* automaticDependency
,
512 const std::string
& filename
,
514 bool isNonAutomaticDependency
);
515 SourceFile
* ParseFile ( const std::string
& normalizedFilename
);
517 std::string
Location () const;
518 std::vector
<SourceFile
*> files
;
519 AutomaticDependency
* automaticDependency
;
521 std::string filename
;
522 std::string filenamePart
;
523 std::string directoryPart
;
524 std::vector
<SourceFile
*> parents
; /* List of files, this file is included from */
525 bool isNonAutomaticDependency
;
526 std::string cachedDependencies
;
527 time_t lastWriteTime
;
528 time_t youngestLastWriteTime
; /* Youngest last write time of this file and all children */
529 SourceFile
* youngestFile
;
531 void GetDirectoryAndFilenameParts ();
534 void SkipWhitespace ();
535 bool ReadInclude ( std::string
& filename
,
537 bool IsIncludedFrom ( const std::string
& normalizedFilename
);
538 SourceFile
* GetParentSourceFile ();
539 bool CanProcessFile ( const std::string
& extension
);
540 bool IsParentOf ( const SourceFile
* parent
,
541 const SourceFile
* child
);
548 class AutomaticDependency
550 friend class SourceFileTest
;
552 const Project
& project
;
554 AutomaticDependency ( const Project
& project
);
555 ~AutomaticDependency ();
557 std::string
GetFilename ( const std::string
& filename
);
558 bool LocateIncludedFile ( const std::string
& directory
,
559 const std::string
& includedFilename
,
560 std::string
& resolvedFilename
);
561 bool LocateIncludedFile ( SourceFile
* sourceFile
,
563 const std::string
& includedFilename
,
565 std::string
& resolvedFilename
);
566 SourceFile
* RetrieveFromCacheOrParse ( Module
& module
,
567 const std::string
& filename
,
568 SourceFile
* parentSourceFile
);
569 SourceFile
* RetrieveFromCache ( const std::string
& filename
);
570 void CheckAutomaticDependencies ( bool verbose
);
571 void CheckAutomaticDependenciesForFile ( SourceFile
* sourceFile
);
573 void ProcessModule ( Module
& module
);
574 void ProcessFile ( Module
& module
,
576 std::map
<std::string
, SourceFile
*> sourcefile_map
;
583 const Project
& project
;
584 const Module
* module
;
585 const XMLElement
& node
;
587 std::string nameoncd
;
589 Bootstrap ( const Project
& project
,
590 const Module
* module
,
591 const XMLElement
& bootstrapNode
);
595 bool IsSupportedModuleType ( ModuleType type
);
603 const Project
& project
;
604 const XMLElement
& node
;
607 std::string nameoncd
;
610 CDFile ( const Project
& project
,
611 const XMLElement
& bootstrapNode
,
612 const std::string
& path
);
615 std::string
GetPath () const;
622 const Project
& project
;
623 const XMLElement
& node
;
629 InstallFile ( const Project
& project
,
630 const XMLElement
& bootstrapNode
,
631 const std::string
& path
);
634 std::string
GetPath () const;
641 const XMLElement
& node
;
642 const Module
& module
;
646 const XMLElement
& node
,
647 const Module
& module
,
648 const std::string
& header
);
653 class StubbedComponent
656 const Module
* module
;
657 const XMLElement
& node
;
659 std::vector
<StubbedSymbol
*> symbols
;
661 StubbedComponent ( const Module
* module_
,
662 const XMLElement
& stubbedComponentNode
);
663 ~StubbedComponent ();
665 void ProcessXMLSubElement ( const XMLElement
& e
);
672 const XMLElement
& node
;
675 std::string strippedName
;
677 StubbedSymbol ( const XMLElement
& stubbedSymbolNode
);
681 std::string
StripSymbol ( std::string symbol
);
685 FixSeparator ( const std::string
& s
);
689 const std::string
& filename
,
690 const std::string
& newExtension
);
694 const std::string
& location
,
695 const std::string
& path
,
696 const std::string
& att_value
);
699 GetExtension ( const std::string
& filename
);
702 GetDirectory ( const std::string
& filename
);
705 GetFilename ( const std::string
& filename
);
708 NormalizeFilename ( const std::string
& filename
);
710 #endif /* __RBUILD_H */