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
;
281 bool isPreCompiledHeader
;
283 File ( const std::string
& _name
,
285 std::string _switches
,
286 bool _isPreCompiledHeader
);
289 bool IsGeneratedFile () const;
296 const XMLElement
& node
;
297 const Module
& module
;
299 const Module
* imported_module
;
301 Library ( const XMLElement
& _node
,
302 const Module
& _module
,
303 const std::string
& _name
);
312 const XMLElement
& node
;
313 const Module
& module
;
314 const Module
* invokeModule
;
315 std::vector
<InvokeFile
*> input
;
316 std::vector
<InvokeFile
*> output
;
318 Invoke ( const XMLElement
& _node
,
319 const Module
& _module
);
322 void GetTargets ( string_list
& targets
) const;
323 std::string
GetParameters () const;
325 void ProcessXMLSubElement ( const XMLElement
& e
);
326 void ProcessXMLSubElementInput ( const XMLElement
& e
);
327 void ProcessXMLSubElementOutput ( const XMLElement
& e
);
334 const XMLElement
& node
;
336 std::string switches
;
338 InvokeFile ( const XMLElement
& _node
,
339 const std::string
& _name
);
348 const XMLElement
& node
;
349 const Module
& module
;
350 const Module
* dependencyModule
;
352 Dependency ( const XMLElement
& _node
,
353 const Module
& _module
);
362 const XMLElement
& node
;
363 const Module
& module
;
364 std::string basename
;
365 std::string definition
;
367 ImportLibrary ( const XMLElement
& _node
,
368 const Module
& module
);
377 const XMLElement
& node
;
378 const Project
& project
;
379 const Module
* module
;
380 std::string property
, value
;
383 If ( const XMLElement
& node_
,
384 const Project
& project_
,
385 const Module
* module_
);
395 const Project
& project
;
396 const Module
* module
;
397 const XMLElement
& node
;
400 CompilerFlag ( const Project
& project
,
401 const XMLElement
& compilerFlagNode
);
402 CompilerFlag ( const Project
& project
,
403 const Module
* module
,
404 const XMLElement
& compilerFlagNode
);
415 const Project
& project
;
416 const Module
* module
;
417 const XMLElement
& node
;
420 LinkerFlag ( const Project
& project
,
421 const XMLElement
& linkerFlagNode
);
422 LinkerFlag ( const Project
& project
,
423 const Module
* module
,
424 const XMLElement
& linkerFlagNode
);
435 const XMLElement
& node
;
436 const Project
& project
;
437 const Module
* module
;
438 std::string name
, value
;
440 Property ( const XMLElement
& node_
,
441 const Project
& project_
,
442 const Module
* module_
);
448 class TestSupportCode
451 const Project
& project
;
453 TestSupportCode ( const Project
& project
);
455 void GenerateTestSupportCode ( bool verbose
);
457 bool IsTestModule ( const Module
& module
);
458 void GenerateTestSupportCodeForModule ( Module
& module
,
460 std::string
GetHooksFilename ( Module
& module
);
461 char* WriteStubbedSymbolToHooksFile ( char* buffer
,
462 const StubbedComponent
& component
,
463 const StubbedSymbol
& symbol
);
464 char* WriteStubbedComponentToHooksFile ( char* buffer
,
465 const StubbedComponent
& component
);
466 void WriteHooksFile ( Module
& module
);
467 std::string
GetStubsFilename ( Module
& module
);
468 char* WriteStubbedSymbolToStubsFile ( char* buffer
,
469 const StubbedComponent
& component
,
470 const StubbedSymbol
& symbol
,
472 char* WriteStubbedComponentToStubsFile ( char* buffer
,
473 const StubbedComponent
& component
,
475 void WriteStubsFile ( Module
& module
);
476 std::string
GetStartupFilename ( Module
& module
);
477 std::string
GetTestDispatcherName ( std::string filename
);
478 bool IsTestFile ( std::string
& filename
) const;
479 void GetSourceFilenames ( string_list
& list
,
480 Module
& module
) const;
481 char* WriteTestDispatcherPrototypesToStartupFile ( char* buffer
,
483 char* WriteRegisterTestsFunctionToStartupFile ( char* buffer
,
485 void WriteStartupFile ( Module
& module
);
492 const Project
& project
;
495 WineResource ( const Project
& project
,
496 std::string bin2res
);
498 void UnpackResources ( bool verbose
);
500 bool IsSpecFile ( const File
& file
);
501 bool IsWineModule ( const Module
& module
);
502 bool IsResourceFile ( const File
& file
);
503 std::string
GetResourceFilename ( const Module
& module
);
504 void UnpackResourcesInModule ( Module
& module
,
512 SourceFile ( AutomaticDependency
* automaticDependency
,
514 const std::string
& filename
,
516 bool isNonAutomaticDependency
);
517 SourceFile
* ParseFile ( const std::string
& normalizedFilename
);
519 std::string
Location () const;
520 std::vector
<SourceFile
*> files
;
521 AutomaticDependency
* automaticDependency
;
523 std::string filename
;
524 std::string filenamePart
;
525 std::string directoryPart
;
526 std::vector
<SourceFile
*> parents
; /* List of files, this file is included from */
527 bool isNonAutomaticDependency
;
528 std::string cachedDependencies
;
529 time_t lastWriteTime
;
530 time_t youngestLastWriteTime
; /* Youngest last write time of this file and all children */
531 SourceFile
* youngestFile
;
533 void GetDirectoryAndFilenameParts ();
536 void SkipWhitespace ();
537 bool ReadInclude ( std::string
& filename
,
539 bool IsIncludedFrom ( const std::string
& normalizedFilename
);
540 SourceFile
* GetParentSourceFile ();
541 bool CanProcessFile ( const std::string
& extension
);
542 bool IsParentOf ( const SourceFile
* parent
,
543 const SourceFile
* child
);
550 class AutomaticDependency
552 friend class SourceFileTest
;
554 const Project
& project
;
556 AutomaticDependency ( const Project
& project
);
557 ~AutomaticDependency ();
559 std::string
GetFilename ( const std::string
& filename
);
560 bool LocateIncludedFile ( const std::string
& directory
,
561 const std::string
& includedFilename
,
562 std::string
& resolvedFilename
);
563 bool LocateIncludedFile ( SourceFile
* sourceFile
,
565 const std::string
& includedFilename
,
567 std::string
& resolvedFilename
);
568 SourceFile
* RetrieveFromCacheOrParse ( Module
& module
,
569 const std::string
& filename
,
570 SourceFile
* parentSourceFile
);
571 SourceFile
* RetrieveFromCache ( const std::string
& filename
);
572 void CheckAutomaticDependencies ( bool verbose
);
573 void CheckAutomaticDependenciesForFile ( SourceFile
* sourceFile
);
575 void GetModuleFiles ( Module
& module
,
576 std::vector
<File
*>& files
) const;
577 void ProcessModule ( Module
& module
);
578 void ProcessFile ( Module
& module
,
580 std::map
<std::string
, SourceFile
*> sourcefile_map
;
587 const Project
& project
;
588 const Module
* module
;
589 const XMLElement
& node
;
591 std::string nameoncd
;
593 Bootstrap ( const Project
& project
,
594 const Module
* module
,
595 const XMLElement
& bootstrapNode
);
599 bool IsSupportedModuleType ( ModuleType type
);
607 const Project
& project
;
608 const XMLElement
& node
;
611 std::string nameoncd
;
614 CDFile ( const Project
& project
,
615 const XMLElement
& bootstrapNode
,
616 const std::string
& path
);
619 std::string
GetPath () const;
626 const Project
& project
;
627 const XMLElement
& node
;
633 InstallFile ( const Project
& project
,
634 const XMLElement
& bootstrapNode
,
635 const std::string
& path
);
638 std::string
GetPath () const;
645 const XMLElement
& node
;
646 const Module
& module
;
650 const XMLElement
& node
,
651 const Module
& module
,
657 class StubbedComponent
660 const Module
* module
;
661 const XMLElement
& node
;
663 std::vector
<StubbedSymbol
*> symbols
;
665 StubbedComponent ( const Module
* module_
,
666 const XMLElement
& stubbedComponentNode
);
667 ~StubbedComponent ();
669 void ProcessXMLSubElement ( const XMLElement
& e
);
676 const XMLElement
& node
;
679 std::string strippedName
;
681 StubbedSymbol ( const XMLElement
& stubbedSymbolNode
);
685 std::string
StripSymbol ( std::string symbol
);
689 FixSeparator ( const std::string
& s
);
693 const std::string
& filename
,
694 const std::string
& newExtension
);
698 const std::string
& location
,
699 const std::string
& path
,
700 const std::string
& att_value
);
703 GetExtension ( const std::string
& filename
);
706 GetDirectory ( const std::string
& filename
);
709 GetFilename ( const std::string
& filename
);
712 NormalizeFilename ( const std::string
& filename
);
714 #endif /* __RBUILD_H */