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
;
84 static std::string
GetVariable ( const std::string
& name
);
85 static std::string
GetIntermediatePath ();
86 static std::string
GetOutputPath ();
87 static std::string
GetInstallPath ();
88 static std::string
GetEnvironmentVariablePathOrDefault ( const std::string
& name
,
89 const std::string
& defaultValue
);
95 static void WriteIfChanged ( char* outbuf
,
96 std::string filename
);
102 std::vector
<File
*> files
;
103 std::vector
<Include
*> includes
;
104 std::vector
<Define
*> defines
;
105 std::vector
<Library
*> libraries
;
106 std::vector
<Property
*> properties
;
107 std::vector
<CompilerFlag
*> compilerFlags
;
108 std::vector
<If
*> ifs
;
117 XMLElement
*node
, *head
;
120 std::string makefile
;
121 XMLIncludes xmlbuildfiles
;
122 std::vector
<Module
*> modules
;
123 std::vector
<LinkerFlag
*> linkerFlags
;
124 std::vector
<CDFile
*> cdfiles
;
125 std::vector
<InstallFile
*> installfiles
;
126 IfableData non_if_data
;
128 Project ( const std::string
& filename
);
130 void WriteConfigurationFile ();
131 void ExecuteInvocations ();
132 void ProcessXML ( const std::string
& path
);
133 Module
* LocateModule ( const std::string
& name
);
134 const Module
* LocateModule ( const std::string
& name
) const;
135 std::string
GetProjectFilename () const;
137 const Property
* LookupProperty ( const std::string
& name
) const;
138 void SetConfigurationOption ( char* s
,
140 std::string
* alternativeName
);
141 void SetConfigurationOption ( char* s
,
144 void ProcessXMLSubElement ( const XMLElement
& e
,
145 const std::string
& path
,
148 // disable copy semantics
149 Project ( const Project
& );
150 Project
& operator = ( const Project
& );
161 KernelModeDriver
= 5,
186 const Project
& project
;
187 const XMLElement
& node
;
188 std::string xmlbuildFile
;
190 std::string extension
;
191 std::string entrypoint
;
192 std::string baseaddress
;
195 ImportLibrary
* importLibrary
;
197 Bootstrap
* bootstrap
;
198 IfableData non_if_data
;
199 std::vector
<Invoke
*> invocations
;
200 std::vector
<Dependency
*> dependencies
;
201 std::vector
<CompilerFlag
*> compilerFlags
;
202 std::vector
<LinkerFlag
*> linkerFlags
;
203 std::vector
<StubbedComponent
*> stubbedComponents
;
208 std::string installBase
;
209 std::string installName
;
213 Module ( const Project
& project
,
214 const XMLElement
& moduleNode
,
215 const std::string
& modulePath
);
217 ModuleType
GetModuleType ( const std::string
& location
,
218 const XMLAttribute
& attribute
);
219 bool HasImportLibrary () const;
221 std::string
GetTargetName () const;
222 std::string
GetDependencyPath () const;
223 std::string
GetBasePath () const;
224 std::string
GetPath () const;
225 std::string
GetPathWithPrefix ( const std::string
& prefix
) const;
226 void GetTargets ( string_list
& ) const;
227 std::string
GetInvocationTarget ( const int index
) const;
228 bool HasFileWithExtension ( const IfableData
&, const std::string
& extension
) const;
229 void InvokeModule () const;
231 void GetSourceFilenames ( string_list
& list
,
232 bool includeGeneratedFiles
) const;
234 std::string
GetDefaultModuleExtension () const;
235 std::string
GetDefaultModuleEntrypoint () const;
236 std::string
GetDefaultModuleBaseaddress () const;
237 void ProcessXMLSubElement ( const XMLElement
& e
,
238 const std::string
& path
,
246 const Project
& project
;
247 const Module
* module
;
248 const XMLElement
& node
;
249 std::string directory
;
250 std::string basePath
;
252 Include ( const Project
& project
,
253 const XMLElement
& includeNode
);
254 Include ( const Project
& project
,
255 const Module
* module
,
256 const XMLElement
& includeNode
);
267 const Project
& project
;
268 const Module
* module
;
269 const XMLElement
& node
;
273 Define ( const Project
& project
,
274 const XMLElement
& defineNode
);
275 Define ( const Project
& project
,
276 const Module
* module
,
277 const XMLElement
& defineNode
);
290 std::string switches
;
291 bool isPreCompiledHeader
;
293 File ( const std::string
& _name
,
295 std::string _switches
,
296 bool _isPreCompiledHeader
);
299 bool IsGeneratedFile () const;
306 const XMLElement
& node
;
307 const Module
& module
;
309 const Module
* imported_module
;
311 Library ( const XMLElement
& _node
,
312 const Module
& _module
,
313 const std::string
& _name
);
322 const XMLElement
& node
;
323 const Module
& module
;
324 const Module
* invokeModule
;
325 std::vector
<InvokeFile
*> input
;
326 std::vector
<InvokeFile
*> output
;
328 Invoke ( const XMLElement
& _node
,
329 const Module
& _module
);
332 void GetTargets ( string_list
& targets
) const;
333 std::string
GetParameters () const;
335 void ProcessXMLSubElement ( const XMLElement
& e
);
336 void ProcessXMLSubElementInput ( const XMLElement
& e
);
337 void ProcessXMLSubElementOutput ( const XMLElement
& e
);
344 const XMLElement
& node
;
346 std::string switches
;
348 InvokeFile ( const XMLElement
& _node
,
349 const std::string
& _name
);
358 const XMLElement
& node
;
359 const Module
& module
;
360 const Module
* dependencyModule
;
362 Dependency ( const XMLElement
& _node
,
363 const Module
& _module
);
372 const XMLElement
& node
;
373 const Module
& module
;
374 std::string basename
;
375 std::string definition
;
377 ImportLibrary ( const XMLElement
& _node
,
378 const Module
& module
);
387 const XMLElement
& node
;
388 const Project
& project
;
389 const Module
* module
;
390 std::string property
, value
;
393 If ( const XMLElement
& node_
,
394 const Project
& project_
,
395 const Module
* module_
);
405 const Project
& project
;
406 const Module
* module
;
407 const XMLElement
& node
;
410 CompilerFlag ( const Project
& project
,
411 const XMLElement
& compilerFlagNode
);
412 CompilerFlag ( const Project
& project
,
413 const Module
* module
,
414 const XMLElement
& compilerFlagNode
);
425 const Project
& project
;
426 const Module
* module
;
427 const XMLElement
& node
;
430 LinkerFlag ( const Project
& project
,
431 const XMLElement
& linkerFlagNode
);
432 LinkerFlag ( const Project
& project
,
433 const Module
* module
,
434 const XMLElement
& linkerFlagNode
);
445 const XMLElement
& node
;
446 const Project
& project
;
447 const Module
* module
;
448 std::string name
, value
;
450 Property ( const XMLElement
& node_
,
451 const Project
& project_
,
452 const Module
* module_
);
458 class TestSupportCode
461 const Project
& project
;
463 TestSupportCode ( const Project
& project
);
465 void GenerateTestSupportCode ( bool verbose
);
467 bool IsTestModule ( const Module
& module
);
468 void GenerateTestSupportCodeForModule ( Module
& module
,
470 std::string
GetHooksFilename ( Module
& module
);
471 char* WriteStubbedSymbolToHooksFile ( char* buffer
,
472 const StubbedComponent
& component
,
473 const StubbedSymbol
& symbol
);
474 char* WriteStubbedComponentToHooksFile ( char* buffer
,
475 const StubbedComponent
& component
);
476 void WriteHooksFile ( Module
& module
);
477 std::string
GetStubsFilename ( Module
& module
);
478 char* WriteStubbedSymbolToStubsFile ( char* buffer
,
479 const StubbedComponent
& component
,
480 const StubbedSymbol
& symbol
,
482 char* WriteStubbedComponentToStubsFile ( char* buffer
,
483 const StubbedComponent
& component
,
485 void WriteStubsFile ( Module
& module
);
486 std::string
GetStartupFilename ( Module
& module
);
487 std::string
GetTestDispatcherName ( std::string filename
);
488 bool IsTestFile ( std::string
& filename
) const;
489 void GetSourceFilenames ( string_list
& list
,
490 Module
& module
) const;
491 char* WriteTestDispatcherPrototypesToStartupFile ( char* buffer
,
493 char* WriteRegisterTestsFunctionToStartupFile ( char* buffer
,
495 void WriteStartupFile ( Module
& module
);
502 const Project
& project
;
505 WineResource ( const Project
& project
,
506 std::string bin2res
);
508 void UnpackResources ( bool verbose
);
510 bool IsSpecFile ( const File
& file
);
511 bool IsWineModule ( const Module
& module
);
512 bool IsResourceFile ( const File
& file
);
513 std::string
GetResourceFilename ( const Module
& module
);
514 void UnpackResourcesInModule ( Module
& module
,
522 SourceFile ( AutomaticDependency
* automaticDependency
,
524 const std::string
& filename
,
526 bool isNonAutomaticDependency
);
527 SourceFile
* ParseFile ( const std::string
& normalizedFilename
);
529 std::string
Location () const;
530 std::vector
<SourceFile
*> files
;
531 AutomaticDependency
* automaticDependency
;
533 std::string filename
;
534 std::string filenamePart
;
535 std::string directoryPart
;
536 std::vector
<SourceFile
*> parents
; /* List of files, this file is included from */
537 bool isNonAutomaticDependency
;
538 std::string cachedDependencies
;
539 time_t lastWriteTime
;
540 time_t youngestLastWriteTime
; /* Youngest last write time of this file and all children */
541 SourceFile
* youngestFile
;
543 void GetDirectoryAndFilenameParts ();
546 void SkipWhitespace ();
547 bool ReadInclude ( std::string
& filename
,
549 bool IsIncludedFrom ( const std::string
& normalizedFilename
);
550 SourceFile
* GetParentSourceFile ();
551 bool CanProcessFile ( const std::string
& extension
);
552 bool IsParentOf ( const SourceFile
* parent
,
553 const SourceFile
* child
);
560 class AutomaticDependency
562 friend class SourceFileTest
;
564 const Project
& project
;
566 AutomaticDependency ( const Project
& project
);
567 ~AutomaticDependency ();
569 std::string
GetFilename ( const std::string
& filename
);
570 bool LocateIncludedFile ( const std::string
& directory
,
571 const std::string
& includedFilename
,
572 std::string
& resolvedFilename
);
573 bool LocateIncludedFile ( SourceFile
* sourceFile
,
575 const std::string
& includedFilename
,
577 std::string
& resolvedFilename
);
578 SourceFile
* RetrieveFromCacheOrParse ( Module
& module
,
579 const std::string
& filename
,
580 SourceFile
* parentSourceFile
);
581 SourceFile
* RetrieveFromCache ( const std::string
& filename
);
582 void CheckAutomaticDependencies ( bool verbose
);
583 void CheckAutomaticDependenciesForFile ( SourceFile
* sourceFile
);
585 void GetModuleFiles ( Module
& module
,
586 std::vector
<File
*>& files
) const;
587 void ProcessModule ( Module
& module
);
588 void ProcessFile ( Module
& module
,
590 std::map
<std::string
, SourceFile
*> sourcefile_map
;
597 const Project
& project
;
598 const Module
* module
;
599 const XMLElement
& node
;
601 std::string nameoncd
;
603 Bootstrap ( const Project
& project
,
604 const Module
* module
,
605 const XMLElement
& bootstrapNode
);
609 bool IsSupportedModuleType ( ModuleType type
);
617 const Project
& project
;
618 const XMLElement
& node
;
621 std::string nameoncd
;
624 CDFile ( const Project
& project
,
625 const XMLElement
& bootstrapNode
,
626 const std::string
& path
);
629 std::string
GetPath () const;
636 const Project
& project
;
637 const XMLElement
& node
;
643 InstallFile ( const Project
& project
,
644 const XMLElement
& bootstrapNode
,
645 const std::string
& path
);
648 std::string
GetPath () const;
655 const XMLElement
& node
;
656 const Module
& module
;
660 const XMLElement
& node
,
661 const Module
& module
,
667 class StubbedComponent
670 const Module
* module
;
671 const XMLElement
& node
;
673 std::vector
<StubbedSymbol
*> symbols
;
675 StubbedComponent ( const Module
* module_
,
676 const XMLElement
& stubbedComponentNode
);
677 ~StubbedComponent ();
679 void ProcessXMLSubElement ( const XMLElement
& e
);
686 const XMLElement
& node
;
689 std::string strippedName
;
691 StubbedSymbol ( const XMLElement
& stubbedSymbolNode
);
695 std::string
StripSymbol ( std::string symbol
);
699 FixSeparator ( const std::string
& s
);
703 const std::string
& filename
,
704 const std::string
& newExtension
);
708 const std::string
& location
,
709 const std::string
& path
,
710 const std::string
& att_value
);
713 GetExtension ( const std::string
& filename
);
716 GetDirectory ( const std::string
& filename
);
719 GetFilename ( const std::string
& filename
);
722 NormalizeFilename ( const std::string
& filename
);
724 #endif /* __RBUILD_H */