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
;
78 bool AutomaticDependencies
;
79 bool MakeHandlesInstallDirectories
;
80 bool GenerateProxyMakefilesInSourceTree
;
86 static std::string
GetVariable ( const std::string
& name
);
87 static std::string
GetIntermediatePath ();
88 static std::string
GetOutputPath ();
89 static std::string
GetInstallPath ();
90 static std::string
GetEnvironmentVariablePathOrDefault ( const std::string
& name
,
91 const std::string
& defaultValue
);
97 static void WriteIfChanged ( char* outbuf
,
98 std::string filename
);
104 std::vector
<File
*> files
;
105 std::vector
<Include
*> includes
;
106 std::vector
<Define
*> defines
;
107 std::vector
<Library
*> libraries
;
108 std::vector
<Property
*> properties
;
109 std::vector
<CompilerFlag
*> compilerFlags
;
110 std::vector
<If
*> ifs
;
119 XMLElement
*node
, *head
;
122 std::string makefile
;
123 XMLIncludes xmlbuildfiles
;
124 std::vector
<Module
*> modules
;
125 std::vector
<LinkerFlag
*> linkerFlags
;
126 std::vector
<CDFile
*> cdfiles
;
127 std::vector
<InstallFile
*> installfiles
;
128 IfableData non_if_data
;
130 Project ( const std::string
& filename
);
132 void WriteConfigurationFile ();
133 void ExecuteInvocations ();
134 void ProcessXML ( const std::string
& path
);
135 Module
* LocateModule ( const std::string
& name
);
136 const Module
* LocateModule ( const std::string
& name
) const;
137 std::string
GetProjectFilename () const;
138 std::string
ResolveProperties ( const std::string
& s
) const;
140 std::string
ResolveNextProperty ( std::string
& s
) const;
141 const Property
* LookupProperty ( const std::string
& name
) const;
142 void SetConfigurationOption ( char* s
,
144 std::string
* alternativeName
);
145 void SetConfigurationOption ( char* s
,
148 void ProcessXMLSubElement ( const XMLElement
& e
,
149 const std::string
& path
,
152 // disable copy semantics
153 Project ( const Project
& );
154 Project
& operator = ( const Project
& );
165 KernelModeDriver
= 5,
190 const Project
& project
;
191 const XMLElement
& node
;
192 std::string xmlbuildFile
;
194 std::string extension
;
195 std::string entrypoint
;
196 std::string baseaddress
;
199 ImportLibrary
* importLibrary
;
201 Bootstrap
* bootstrap
;
202 IfableData non_if_data
;
203 std::vector
<Invoke
*> invocations
;
204 std::vector
<Dependency
*> dependencies
;
205 std::vector
<CompilerFlag
*> compilerFlags
;
206 std::vector
<LinkerFlag
*> linkerFlags
;
207 std::vector
<StubbedComponent
*> stubbedComponents
;
212 std::string installBase
;
213 std::string installName
;
218 Module ( const Project
& project
,
219 const XMLElement
& moduleNode
,
220 const std::string
& modulePath
);
222 ModuleType
GetModuleType ( const std::string
& location
,
223 const XMLAttribute
& attribute
);
224 bool HasImportLibrary () const;
226 bool GenerateInOutputTree () const;
227 std::string
GetTargetName () const;
228 std::string
GetDependencyPath () const;
229 std::string
GetBasePath () const;
230 std::string
GetPath () const;
231 std::string
GetPathWithPrefix ( const std::string
& prefix
) const;
232 void GetTargets ( string_list
& ) const;
233 std::string
GetInvocationTarget ( const int index
) const;
234 bool HasFileWithExtension ( const IfableData
&, const std::string
& extension
) const;
235 void InvokeModule () const;
237 void GetSourceFilenames ( string_list
& list
,
238 bool includeGeneratedFiles
) const;
240 std::string
GetDefaultModuleExtension () const;
241 std::string
GetDefaultModuleEntrypoint () const;
242 std::string
GetDefaultModuleBaseaddress () const;
243 void ProcessXMLSubElement ( const XMLElement
& e
,
244 const std::string
& path
,
252 const Project
& project
;
253 const Module
* module
;
254 const XMLElement
& node
;
255 std::string directory
;
256 std::string basePath
;
258 Include ( const Project
& project
,
259 const XMLElement
& includeNode
);
260 Include ( const Project
& project
,
261 const Module
* module
,
262 const XMLElement
& includeNode
);
273 const Project
& project
;
274 const Module
* module
;
275 const XMLElement
& node
;
279 Define ( const Project
& project
,
280 const XMLElement
& defineNode
);
281 Define ( const Project
& project
,
282 const Module
* module
,
283 const XMLElement
& defineNode
);
296 std::string switches
;
297 bool isPreCompiledHeader
;
299 File ( const std::string
& _name
,
301 std::string _switches
,
302 bool _isPreCompiledHeader
);
305 bool IsGeneratedFile () const;
312 const XMLElement
& node
;
313 const Module
& module
;
315 const Module
* imported_module
;
317 Library ( const XMLElement
& _node
,
318 const Module
& _module
,
319 const std::string
& _name
);
328 const XMLElement
& node
;
329 const Module
& module
;
330 const Module
* invokeModule
;
331 std::vector
<InvokeFile
*> input
;
332 std::vector
<InvokeFile
*> output
;
334 Invoke ( const XMLElement
& _node
,
335 const Module
& _module
);
338 void GetTargets ( string_list
& targets
) const;
339 std::string
GetParameters () const;
341 void ProcessXMLSubElement ( const XMLElement
& e
);
342 void ProcessXMLSubElementInput ( const XMLElement
& e
);
343 void ProcessXMLSubElementOutput ( const XMLElement
& e
);
350 const XMLElement
& node
;
352 std::string switches
;
354 InvokeFile ( const XMLElement
& _node
,
355 const std::string
& _name
);
364 const XMLElement
& node
;
365 const Module
& module
;
366 const Module
* dependencyModule
;
368 Dependency ( const XMLElement
& _node
,
369 const Module
& _module
);
378 const XMLElement
& node
;
379 const Module
& module
;
380 std::string basename
;
381 std::string definition
;
383 ImportLibrary ( const XMLElement
& _node
,
384 const Module
& module
);
393 const XMLElement
& node
;
394 const Project
& project
;
395 const Module
* module
;
396 std::string property
, value
;
399 If ( const XMLElement
& node_
,
400 const Project
& project_
,
401 const Module
* module_
);
411 const Project
& project
;
412 const Module
* module
;
413 const XMLElement
& node
;
416 CompilerFlag ( const Project
& project
,
417 const XMLElement
& compilerFlagNode
);
418 CompilerFlag ( const Project
& project
,
419 const Module
* module
,
420 const XMLElement
& compilerFlagNode
);
431 const Project
& project
;
432 const Module
* module
;
433 const XMLElement
& node
;
436 LinkerFlag ( const Project
& project
,
437 const XMLElement
& linkerFlagNode
);
438 LinkerFlag ( const Project
& project
,
439 const Module
* module
,
440 const XMLElement
& linkerFlagNode
);
451 const XMLElement
& node
;
452 const Project
& project
;
453 const Module
* module
;
454 std::string name
, value
;
456 Property ( const XMLElement
& node_
,
457 const Project
& project_
,
458 const Module
* module_
);
464 class TestSupportCode
467 const Project
& project
;
469 TestSupportCode ( const Project
& project
);
471 void GenerateTestSupportCode ( bool verbose
);
473 bool IsTestModule ( const Module
& module
);
474 void GenerateTestSupportCodeForModule ( Module
& module
,
476 std::string
GetHooksFilename ( Module
& module
);
477 char* WriteStubbedSymbolToHooksFile ( char* buffer
,
478 const StubbedComponent
& component
,
479 const StubbedSymbol
& symbol
);
480 char* WriteStubbedComponentToHooksFile ( char* buffer
,
481 const StubbedComponent
& component
);
482 void WriteHooksFile ( Module
& module
);
483 std::string
GetStubsFilename ( Module
& module
);
484 char* WriteStubbedSymbolToStubsFile ( char* buffer
,
485 const StubbedComponent
& component
,
486 const StubbedSymbol
& symbol
,
488 char* WriteStubbedComponentToStubsFile ( char* buffer
,
489 const StubbedComponent
& component
,
491 void WriteStubsFile ( Module
& module
);
492 std::string
GetStartupFilename ( Module
& module
);
493 std::string
GetTestDispatcherName ( std::string filename
);
494 bool IsTestFile ( std::string
& filename
) const;
495 void GetSourceFilenames ( string_list
& list
,
496 Module
& module
) const;
497 char* WriteTestDispatcherPrototypesToStartupFile ( char* buffer
,
499 char* WriteRegisterTestsFunctionToStartupFile ( char* buffer
,
501 void WriteStartupFile ( Module
& module
);
508 const Project
& project
;
511 WineResource ( const Project
& project
,
512 std::string bin2res
);
514 void UnpackResources ( bool verbose
);
516 bool IsSpecFile ( const File
& file
);
517 bool IsWineModule ( const Module
& module
);
518 bool IsResourceFile ( const File
& file
);
519 std::string
GetResourceFilename ( const Module
& module
);
520 void UnpackResourcesInModule ( Module
& module
,
528 SourceFile ( AutomaticDependency
* automaticDependency
,
530 const std::string
& filename
,
532 bool isNonAutomaticDependency
);
533 SourceFile
* ParseFile ( const std::string
& normalizedFilename
);
535 std::string
Location () const;
536 std::vector
<SourceFile
*> files
;
537 AutomaticDependency
* automaticDependency
;
539 std::string filename
;
540 std::string filenamePart
;
541 std::string directoryPart
;
542 std::vector
<SourceFile
*> parents
; /* List of files, this file is included from */
543 bool isNonAutomaticDependency
;
544 std::string cachedDependencies
;
545 time_t lastWriteTime
;
546 time_t youngestLastWriteTime
; /* Youngest last write time of this file and all children */
547 SourceFile
* youngestFile
;
549 void GetDirectoryAndFilenameParts ();
552 void SkipWhitespace ();
553 bool ReadInclude ( std::string
& filename
,
555 bool IsIncludedFrom ( const std::string
& normalizedFilename
);
556 SourceFile
* GetParentSourceFile ();
557 bool CanProcessFile ( const std::string
& extension
);
558 bool IsParentOf ( const SourceFile
* parent
,
559 const SourceFile
* child
);
566 class AutomaticDependency
568 friend class SourceFileTest
;
570 const Project
& project
;
572 AutomaticDependency ( const Project
& project
);
573 ~AutomaticDependency ();
575 std::string
GetFilename ( const std::string
& filename
);
576 bool LocateIncludedFile ( const std::string
& directory
,
577 const std::string
& includedFilename
,
578 std::string
& resolvedFilename
);
579 bool LocateIncludedFile ( SourceFile
* sourceFile
,
581 const std::string
& includedFilename
,
583 std::string
& resolvedFilename
);
584 SourceFile
* RetrieveFromCacheOrParse ( Module
& module
,
585 const std::string
& filename
,
586 SourceFile
* parentSourceFile
);
587 SourceFile
* RetrieveFromCache ( const std::string
& filename
);
588 void CheckAutomaticDependencies ( bool verbose
);
589 void CheckAutomaticDependenciesForFile ( SourceFile
* sourceFile
);
591 void GetModuleFiles ( Module
& module
,
592 std::vector
<File
*>& files
) const;
593 void ProcessModule ( Module
& module
);
594 void ProcessFile ( Module
& module
,
596 std::map
<std::string
, SourceFile
*> sourcefile_map
;
603 const Project
& project
;
604 const Module
* module
;
605 const XMLElement
& node
;
607 std::string nameoncd
;
609 Bootstrap ( const Project
& project
,
610 const Module
* module
,
611 const XMLElement
& bootstrapNode
);
615 bool IsSupportedModuleType ( ModuleType type
);
623 const Project
& project
;
624 const XMLElement
& node
;
627 std::string nameoncd
;
630 CDFile ( const Project
& project
,
631 const XMLElement
& bootstrapNode
,
632 const std::string
& path
);
635 std::string
GetPath () const;
642 const Project
& project
;
643 const XMLElement
& node
;
649 InstallFile ( const Project
& project
,
650 const XMLElement
& bootstrapNode
,
651 const std::string
& path
);
654 std::string
GetPath () const;
661 const XMLElement
& node
;
662 const Module
& module
;
666 const XMLElement
& node
,
667 const Module
& module
,
673 class StubbedComponent
676 const Module
* module
;
677 const XMLElement
& node
;
679 std::vector
<StubbedSymbol
*> symbols
;
681 StubbedComponent ( const Module
* module_
,
682 const XMLElement
& stubbedComponentNode
);
683 ~StubbedComponent ();
685 void ProcessXMLSubElement ( const XMLElement
& e
);
692 const XMLElement
& node
;
695 std::string strippedName
;
697 StubbedSymbol ( const XMLElement
& stubbedSymbolNode
);
701 std::string
StripSymbol ( std::string symbol
);
705 FixSeparator ( const std::string
& s
);
709 const std::string
& filename
,
710 const std::string
& newExtension
);
714 const std::string
& location
,
715 const std::string
& path
,
716 const std::string
& att_value
);
719 GetExtension ( const std::string
& filename
);
722 GetDirectory ( const std::string
& filename
);
725 GetFilename ( const std::string
& filename
);
728 NormalizeFilename ( const std::string
& filename
);
730 #endif /* __RBUILD_H */