-#ifndef __RBUILD_H\r
-#define __RBUILD_H\r
-\r
-#include "pch.h"\r
-\r
-#ifdef WIN32\r
-#include <direct.h>\r
-#include <io.h>\r
-#endif/*WIN32*/\r
-#include <sys/stat.h>\r
-#include <time.h>\r
-#ifdef _MSC_VER\r
-#include <sys/utime.h>\r
-#else/*_MSC_VER*/\r
-#include <utime.h>\r
-#ifdef WIN32\r
-#include <process.h>\r
-#endif/*WIN32*/\r
-#endif/*_MSC_VER*/\r
-\r
-#include "ssprintf.h"\r
-#include "exception.h"\r
-#include "XML.h"\r
-\r
-typedef std::vector<std::string> string_list;\r
-\r
-#ifdef WIN32\r
-#define EXEPREFIX ""\r
-#define EXEPOSTFIX ".exe"\r
-#define CSEP '\\'\r
-#define CBAD_SEP '/'\r
-#define SSEP "\\"\r
-#define SBAD_SEP "/"\r
-#else\r
-#define EXEPREFIX "./"\r
-#define EXEPOSTFIX ""\r
-#define CSEP '/'\r
-#define CBAD_SEP '\\'\r
-#define SSEP "/"\r
-#define SBAD_SEP "\\"\r
-#endif\r
-\r
-class Project;\r
-class IfableData;\r
-class Module;\r
-class Include;\r
-class Define;\r
-class File;\r
-class Library;\r
-class Invoke;\r
-class InvokeFile;\r
-class Dependency;\r
-class ImportLibrary;\r
-class If;\r
-class CompilerFlag;\r
-class LinkerFlag;\r
-class Property;\r
-class AutomaticDependency;\r
-class Bootstrap;\r
-class CDFile;\r
-class InstallFile;\r
-class PchFile;\r
-class StubbedComponent;\r
-class StubbedSymbol;\r
-\r
-class SourceFileTest;\r
-\r
-class IfableData\r
-{\r
-public:\r
- std::vector<File*> files;\r
- std::vector<Include*> includes;\r
- std::vector<Define*> defines;\r
- std::vector<Library*> libraries;\r
- std::vector<Property*> properties;\r
- std::vector<If*> ifs;\r
-\r
- ~IfableData();\r
- void ProcessXML();\r
-};\r
-\r
-class Project\r
-{\r
- std::string xmlfile;\r
- XMLElement *node, *head;\r
-public:\r
- std::string name;\r
- std::string makefile;\r
- XMLIncludes xmlbuildfiles;\r
- std::vector<Module*> modules;\r
- std::vector<LinkerFlag*> linkerFlags;\r
- std::vector<CDFile*> cdfiles;\r
- std::vector<InstallFile*> installfiles;\r
- IfableData non_if_data;\r
-\r
- Project ( const std::string& filename );\r
- ~Project ();\r
- void WriteConfigurationFile ();\r
- void ExecuteInvocations ();\r
- void ProcessXML ( const std::string& path );\r
- Module* LocateModule ( const std::string& name );\r
- const Module* LocateModule ( const std::string& name ) const;\r
- std::string GetProjectFilename () const;\r
-private:\r
- const Property* LookupProperty ( const std::string& name ) const;\r
- void SetConfigurationOption ( char* s,\r
- std::string name,\r
- std::string* alternativeName );\r
- void SetConfigurationOption ( char* s,\r
- std::string name );\r
- void WriteIfChanged ( char* outbuf,\r
- std::string filename );\r
- void ReadXml ();\r
- void ProcessXMLSubElement ( const XMLElement& e,\r
- const std::string& path,\r
- If* pIf = NULL );\r
-\r
- // disable copy semantics\r
- Project ( const Project& );\r
- Project& operator = ( const Project& );\r
-};\r
-\r
-\r
-enum ModuleType\r
-{\r
- BuildTool,\r
- StaticLibrary,\r
- ObjectLibrary,\r
- Kernel,\r
- KernelModeDLL,\r
- KernelModeDriver,\r
- NativeDLL,\r
- NativeCUI,\r
- Win32DLL,\r
- Win32CUI,\r
- Win32GUI,\r
- BootLoader,\r
- BootSector,\r
- Iso,\r
- LiveIso,\r
- Test,\r
- RpcServer,\r
- RpcClient\r
-};\r
-\r
-enum HostType\r
-{\r
- HostFalse,\r
- HostDefault,\r
- HostTrue\r
-};\r
-\r
-class Module\r
-{\r
-public:\r
- const Project& project;\r
- const XMLElement& node;\r
- std::string xmlbuildFile;\r
- std::string name;\r
- std::string extension;\r
- std::string entrypoint;\r
- std::string baseaddress;\r
- std::string path;\r
- ModuleType type;\r
- ImportLibrary* importLibrary;\r
- bool mangledSymbols;\r
- Bootstrap* bootstrap;\r
- IfableData non_if_data;\r
- std::vector<Invoke*> invocations;\r
- std::vector<Dependency*> dependencies;\r
- std::vector<CompilerFlag*> compilerFlags;\r
- std::vector<LinkerFlag*> linkerFlags;\r
- std::vector<StubbedComponent*> stubbedComponents;\r
- PchFile* pch;\r
- bool cplusplus;\r
- std::string prefix;\r
- HostType host;\r
- std::string installBase;\r
- std::string installName;\r
- bool useWRC;\r
- bool enableWarnings;\r
-\r
- Module ( const Project& project,\r
- const XMLElement& moduleNode,\r
- const std::string& modulePath );\r
- ~Module ();\r
- ModuleType GetModuleType ( const std::string& location,\r
- const XMLAttribute& attribute );\r
- bool HasImportLibrary () const;\r
- std::string GetTargetName () const;\r
- std::string GetDependencyPath () const;\r
- std::string GetBasePath () const;\r
- std::string GetPath () const;\r
- std::string GetPathWithPrefix ( const std::string& prefix ) const;\r
- void GetTargets ( string_list& ) const;\r
- std::string GetInvocationTarget ( const int index ) const;\r
- bool HasFileWithExtension ( const IfableData&, const std::string& extension ) const;\r
- void InvokeModule () const;\r
- void ProcessXML ();\r
-private:\r
- std::string GetDefaultModuleExtension () const;\r
- std::string GetDefaultModuleEntrypoint () const;\r
- std::string GetDefaultModuleBaseaddress () const;\r
- void ProcessXMLSubElement ( const XMLElement& e,\r
- const std::string& path,\r
- If* pIf = NULL );\r
-};\r
-\r
-\r
-class Include\r
-{\r
-public:\r
- const Project& project;\r
- const Module* module;\r
- const XMLElement& node;\r
- std::string directory;\r
- std::string basePath;\r
-\r
- Include ( const Project& project,\r
- const XMLElement& includeNode );\r
- Include ( const Project& project,\r
- const Module* module,\r
- const XMLElement& includeNode );\r
- ~Include ();\r
- void ProcessXML();\r
-private:\r
- void Initialize();\r
-};\r
-\r
-\r
-class Define\r
-{\r
-public:\r
- const Project& project;\r
- const Module* module;\r
- const XMLElement& node;\r
- std::string name;\r
- std::string value;\r
-\r
- Define ( const Project& project,\r
- const XMLElement& defineNode );\r
- Define ( const Project& project,\r
- const Module* module,\r
- const XMLElement& defineNode );\r
- ~Define();\r
- void ProcessXML();\r
-private:\r
- void Initialize();\r
-};\r
-\r
-\r
-class File\r
-{\r
-public:\r
- std::string name;\r
- bool first;\r
-\r
- File ( const std::string& _name, bool _first );\r
-\r
- void ProcessXML();\r
-};\r
-\r
-\r
-class Library\r
-{\r
-public:\r
- const XMLElement& node;\r
- const Module& module;\r
- std::string name;\r
- const Module* imported_module;\r
-\r
- Library ( const XMLElement& _node,\r
- const Module& _module,\r
- const std::string& _name );\r
-\r
- void ProcessXML();\r
-};\r
-\r
-\r
-class Invoke\r
-{\r
-public:\r
- const XMLElement& node;\r
- const Module& module;\r
- const Module* invokeModule;\r
- std::vector<InvokeFile*> input;\r
- std::vector<InvokeFile*> output;\r
-\r
- Invoke ( const XMLElement& _node,\r
- const Module& _module );\r
-\r
- void ProcessXML();\r
- void GetTargets ( string_list& targets ) const;\r
- std::string GetParameters () const;\r
-private:\r
- void ProcessXMLSubElement ( const XMLElement& e );\r
- void ProcessXMLSubElementInput ( const XMLElement& e );\r
- void ProcessXMLSubElementOutput ( const XMLElement& e );\r
-};\r
-\r
-\r
-class InvokeFile\r
-{\r
-public:\r
- const XMLElement& node;\r
- std::string name;\r
- std::string switches;\r
-\r
- InvokeFile ( const XMLElement& _node,\r
- const std::string& _name );\r
-\r
- void ProcessXML ();\r
-};\r
-\r
-\r
-class Dependency\r
-{\r
-public:\r
- const XMLElement& node;\r
- const Module& module;\r
- const Module* dependencyModule;\r
-\r
- Dependency ( const XMLElement& _node,\r
- const Module& _module );\r
-\r
- void ProcessXML();\r
-};\r
-\r
-\r
-class ImportLibrary\r
-{\r
-public:\r
- const XMLElement& node;\r
- const Module& module;\r
- std::string basename;\r
- std::string definition;\r
-\r
- ImportLibrary ( const XMLElement& _node,\r
- const Module& module );\r
-\r
- void ProcessXML ();\r
-};\r
-\r
-\r
-class If\r
-{\r
-public:\r
- const XMLElement& node;\r
- const Project& project;\r
- const Module* module;\r
- std::string property, value;\r
- IfableData data;\r
-\r
- If ( const XMLElement& node_,\r
- const Project& project_,\r
- const Module* module_ );\r
- ~If();\r
-\r
- void ProcessXML();\r
-};\r
-\r
-\r
-class CompilerFlag\r
-{\r
-public:\r
- const Project& project;\r
- const Module* module;\r
- const XMLElement& node;\r
- std::string flag;\r
-\r
- CompilerFlag ( const Project& project,\r
- const XMLElement& compilerFlagNode );\r
- CompilerFlag ( const Project& project,\r
- const Module* module,\r
- const XMLElement& compilerFlagNode );\r
- ~CompilerFlag ();\r
- void ProcessXML();\r
-private:\r
- void Initialize();\r
-};\r
-\r
-\r
-class LinkerFlag\r
-{\r
-public:\r
- const Project& project;\r
- const Module* module;\r
- const XMLElement& node;\r
- std::string flag;\r
-\r
- LinkerFlag ( const Project& project,\r
- const XMLElement& linkerFlagNode );\r
- LinkerFlag ( const Project& project,\r
- const Module* module,\r
- const XMLElement& linkerFlagNode );\r
- ~LinkerFlag ();\r
- void ProcessXML();\r
-private:\r
- void Initialize();\r
-};\r
-\r
-\r
-class Property\r
-{\r
-public:\r
- const XMLElement& node;\r
- const Project& project;\r
- const Module* module;\r
- std::string name, value;\r
-\r
- Property ( const XMLElement& node_,\r
- const Project& project_,\r
- const Module* module_ );\r
-\r
- void ProcessXML();\r
-};\r
-\r
-\r
-class SourceFile\r
-{\r
-public:\r
- SourceFile ( AutomaticDependency* automaticDependency,\r
- Module& module,\r
- const std::string& filename,\r
- SourceFile* parent,\r
- bool isNonAutomaticDependency );\r
- SourceFile* ParseFile ( const std::string& normalizedFilename );\r
- void Parse ();\r
- std::string Location () const;\r
- std::vector<SourceFile*> files;\r
- AutomaticDependency* automaticDependency;\r
- Module& module;\r
- std::string filename;\r
- std::string filenamePart;\r
- std::string directoryPart;\r
- std::vector<SourceFile*> parents; /* List of files, this file is included from */\r
- bool isNonAutomaticDependency;\r
- std::string cachedDependencies;\r
- time_t lastWriteTime;\r
- time_t youngestLastWriteTime; /* Youngest last write time of this file and all children */\r
- SourceFile* youngestFile;\r
-private:\r
- void GetDirectoryAndFilenameParts ();\r
- void Close ();\r
- void Open ();\r
- void SkipWhitespace ();\r
- bool ReadInclude ( std::string& filename,\r
- bool& includeNext );\r
- bool IsIncludedFrom ( const std::string& normalizedFilename );\r
- SourceFile* GetParentSourceFile ();\r
- bool CanProcessFile ( const std::string& extension );\r
- bool IsParentOf ( const SourceFile* parent,\r
- const SourceFile* child );\r
- std::string buf;\r
- const char *p;\r
- const char *end;\r
-};\r
-\r
-\r
-class AutomaticDependency\r
-{\r
- friend class SourceFileTest;\r
-public:\r
- const Project& project;\r
-\r
- AutomaticDependency ( const Project& project );\r
- ~AutomaticDependency ();\r
- void Process ();\r
- std::string GetFilename ( const std::string& filename );\r
- bool LocateIncludedFile ( const std::string& directory,\r
- const std::string& includedFilename,\r
- std::string& resolvedFilename );\r
- bool LocateIncludedFile ( SourceFile* sourceFile,\r
- Module& module,\r
- const std::string& includedFilename,\r
- bool includeNext,\r
- std::string& resolvedFilename );\r
- SourceFile* RetrieveFromCacheOrParse ( Module& module,\r
- const std::string& filename,\r
- SourceFile* parentSourceFile );\r
- SourceFile* RetrieveFromCache ( const std::string& filename );\r
- void CheckAutomaticDependencies ( bool verbose );\r
- void CheckAutomaticDependenciesForFile ( SourceFile* sourceFile );\r
-private:\r
- void ProcessModule ( Module& module );\r
- void ProcessFile ( Module& module,\r
- const File& file );\r
- std::map<std::string, SourceFile*> sourcefile_map;\r
-};\r
-\r
-\r
-class Bootstrap\r
-{\r
-public:\r
- const Project& project;\r
- const Module* module;\r
- const XMLElement& node;\r
- std::string base;\r
- std::string nameoncd;\r
-\r
- Bootstrap ( const Project& project,\r
- const Module* module,\r
- const XMLElement& bootstrapNode );\r
- ~Bootstrap ();\r
- void ProcessXML();\r
-private:\r
- bool IsSupportedModuleType ( ModuleType type );\r
- void Initialize();\r
-};\r
-\r
-\r
-class CDFile\r
-{\r
-public:\r
- const Project& project;\r
- const XMLElement& node;\r
- std::string name;\r
- std::string base;\r
- std::string nameoncd;\r
- std::string path;\r
-\r
- CDFile ( const Project& project,\r
- const XMLElement& bootstrapNode,\r
- const std::string& path );\r
- ~CDFile ();\r
- void ProcessXML();\r
- std::string GetPath () const;\r
-};\r
-\r
-\r
-class InstallFile\r
-{\r
-public:\r
- const Project& project;\r
- const XMLElement& node;\r
- std::string name;\r
- std::string base;\r
- std::string newname;\r
- std::string path;\r
-\r
- InstallFile ( const Project& project,\r
- const XMLElement& bootstrapNode,\r
- const std::string& path );\r
- ~InstallFile ();\r
- void ProcessXML ();\r
- std::string GetPath () const;\r
-};\r
-\r
-\r
-class PchFile\r
-{\r
-public:\r
- const XMLElement& node;\r
- const Module& module;\r
- std::string header;\r
-\r
- PchFile (\r
- const XMLElement& node,\r
- const Module& module,\r
- const std::string& header );\r
- void ProcessXML();\r
-};\r
-\r
-\r
-class StubbedComponent\r
-{\r
-public:\r
- const Module* module;\r
- const XMLElement& node;\r
- std::string name;\r
- std::vector<StubbedSymbol*> symbols;\r
-\r
- StubbedComponent ( const Module* module_,\r
- const XMLElement& stubbedComponentNode );\r
- ~StubbedComponent ();\r
- void ProcessXML ();\r
- void ProcessXMLSubElement ( const XMLElement& e );\r
-};\r
-\r
-\r
-class StubbedSymbol\r
-{\r
-public:\r
- const XMLElement& node;\r
- std::string symbol;\r
- std::string newname;\r
-\r
- StubbedSymbol ( const XMLElement& stubbedSymbolNode );\r
- ~StubbedSymbol ();\r
- void ProcessXML();\r
-};\r
-\r
-extern std::string\r
-FixSeparator ( const std::string& s );\r
-\r
-extern std::string\r
-ReplaceExtension (\r
- const std::string& filename,\r
- const std::string& newExtension );\r
-\r
-extern std::string\r
-GetSubPath (\r
- const std::string& location,\r
- const std::string& path,\r
- const std::string& att_value );\r
-\r
-extern std::string\r
-GetExtension ( const std::string& filename );\r
-\r
-extern std::string\r
-GetDirectory ( const std::string& filename );\r
-\r
-extern std::string\r
-NormalizeFilename ( const std::string& filename );\r
-\r
-#endif /* __RBUILD_H */\r
+/*
+ * Copyright (C) 2005 Casper S. Hornstrup
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#ifndef __RBUILD_H
+#define __RBUILD_H
+
+#include "pch.h"
+
+#ifdef WIN32
+#include <direct.h>
+#include <io.h>
+#endif/*WIN32*/
+#include <sys/stat.h>
+#include <time.h>
+#ifdef _MSC_VER
+#include <sys/utime.h>
+#else/*_MSC_VER*/
+#include <utime.h>
+#ifdef WIN32
+#include <process.h>
+#endif/*WIN32*/
+#endif/*_MSC_VER*/
+
+#include <infhost.h>
+
+#include "ssprintf.h"
+#include "exception.h"
+#include "xml.h"
+
+class Backend; // forward declaration
+
+typedef std::vector<std::string> string_list;
+
+extern std::string ExePrefix;
+extern std::string ExePostfix;
+extern std::string sSep;
+extern std::string sBadSep;
+extern char cSep;
+extern char cBadSep;
+
+#ifdef WIN32
+#define DEF_EXEPREFIX ""
+#define DEF_EXEPOSTFIX ".exe"
+#define DEF_CSEP '\\'
+#define DEF_CBAD_SEP '/'
+#define DEF_SSEP "\\"
+#define DEF_SBAD_SEP "/"
+#else
+#define DEF_EXEPREFIX "./"
+#define DEF_EXEPOSTFIX ""
+#define DEF_CSEP '/'
+#define DEF_CBAD_SEP '\\'
+#define DEF_SSEP "/"
+#define DEF_SBAD_SEP "\\"
+#endif
+
+#define MS_VS_DEF_VERSION "7.10"
+
+class Directory;
+class Project;
+class IfableData;
+class Module;
+class Include;
+class Define;
+class File;
+class Library;
+class Invoke;
+class InvokeFile;
+class Dependency;
+class ImportLibrary;
+class If;
+class CompilerFlag;
+class LinkerFlag;
+class LinkerScript;
+class Property;
+class TestSupportCode;
+class WineResource;
+class AutomaticDependency;
+class Bootstrap;
+class CDFile;
+class InstallFile;
+class PchFile;
+class StubbedComponent;
+class StubbedSymbol;
+class CompilationUnit;
+class FileLocation;
+class AutoRegister;
+
+class SourceFileTest;
+
+
+typedef std::map<std::string,Directory*> directory_map;
+
+class Directory
+{
+public:
+ std::string name;
+ directory_map subdirs;
+ Directory ( const std::string& name );
+ void Add ( const char* subdir );
+ void GenerateTree ( const std::string& parent,
+ bool verbose );
+ std::string EscapeSpaces ( std::string path );
+ void CreateRule ( FILE* f,
+ const std::string& parent );
+private:
+ bool mkdir_p ( const char* path );
+ std::string ReplaceVariable ( std::string name,
+ std::string value,
+ std::string path );
+ std::string GetEnvironmentVariable ( const std::string& name );
+ void ResolveVariablesInPath ( char* buf,
+ std::string path );
+ bool CreateDirectory ( std::string path );
+};
+
+
+class Configuration
+{
+public:
+ Configuration ();
+ ~Configuration ();
+ bool Verbose;
+ bool CleanAsYouGo;
+ bool AutomaticDependencies;
+ bool CheckDependenciesForModuleOnly;
+ bool CompilationUnitsEnabled;
+ std::string CheckDependenciesForModuleOnlyModule;
+ std::string VSProjectVersion;
+ std::string VSConfigurationType;
+ bool MakeHandlesInstallDirectories;
+ bool GenerateProxyMakefilesInSourceTree;
+ bool InstallFiles;
+};
+
+class Environment
+{
+public:
+ static std::string GetVariable ( const std::string& name );
+ static std::string GetIntermediatePath ();
+ static std::string GetOutputPath ();
+ static std::string GetInstallPath ();
+ static std::string GetEnvironmentVariablePathOrDefault ( const std::string& name,
+ const std::string& defaultValue );
+};
+
+
+class FileSupportCode
+{
+public:
+ static void WriteIfChanged ( char* outbuf,
+ std::string filename );
+};
+
+
+class ParseContext
+{
+public:
+ If* ifData;
+ CompilationUnit* compilationUnit;
+ ParseContext ();
+};
+
+
+class IfableData
+{
+public:
+ std::vector<CompilationUnit*> compilationUnits;
+ std::vector<File*> files;
+ std::vector<Include*> includes;
+ std::vector<Define*> defines;
+ std::vector<Library*> libraries;
+ std::vector<Property*> properties;
+ std::vector<Module*> modules;
+ std::vector<CompilerFlag*> compilerFlags;
+ std::vector<If*> ifs;
+
+ ~IfableData();
+ void ProcessXML();
+ void ExtractModules( std::vector<Module*> &modules );
+};
+
+class Project
+{
+ std::string xmlfile;
+ XMLElement *node, *head;
+ Backend* _backend;
+public:
+ const Configuration& configuration;
+ std::string name;
+ std::string makefile;
+ XMLIncludes xmlbuildfiles;
+ std::vector<LinkerFlag*> linkerFlags;
+ std::vector<CDFile*> cdfiles;
+ std::vector<InstallFile*> installfiles;
+ std::vector<Module*> modules;
+ IfableData non_if_data;
+
+ Project ( const Configuration& configuration,
+ const std::string& filename );
+ ~Project ();
+ void SetBackend ( Backend* backend ) { _backend = backend; }
+ Backend& GetBackend() { return *_backend; }
+ void WriteConfigurationFile ();
+ void ExecuteInvocations ();
+
+ void ProcessXML ( const std::string& path );
+ Module* LocateModule ( const std::string& name );
+ const Module* LocateModule ( const std::string& name ) const;
+ std::string GetProjectFilename () const;
+ std::string ResolveProperties ( const std::string& s ) const;
+private:
+ std::string ResolveNextProperty ( std::string& s ) const;
+ const Property* LookupProperty ( const std::string& name ) const;
+ void SetConfigurationOption ( char* s,
+ std::string name,
+ std::string* alternativeName );
+ void SetConfigurationOption ( char* s,
+ std::string name );
+ void ReadXml ();
+ void ProcessXMLSubElement ( const XMLElement& e,
+ const std::string& path,
+ ParseContext& parseContext );
+
+ // disable copy semantics
+ Project ( const Project& );
+ Project& operator = ( const Project& );
+};
+
+
+enum ModuleType
+{
+ BuildTool = 0,
+ StaticLibrary = 1,
+ ObjectLibrary = 2,
+ Kernel = 3,
+ KernelModeDLL = 4,
+ KernelModeDriver = 5,
+ NativeDLL = 6,
+ NativeCUI = 7,
+ Win32DLL = 8,
+ Win32CUI = 9,
+ Win32GUI = 10,
+ BootLoader = 11,
+ BootSector = 12,
+ Iso = 13,
+ LiveIso = 14,
+ Test = 15,
+ RpcServer = 16,
+ RpcClient = 17,
+ Alias = 18,
+ BootProgram = 19
+};
+
+enum HostType
+{
+ HostFalse,
+ HostDefault,
+ HostTrue
+};
+
+class Module
+{
+public:
+ const Project& project;
+ const XMLElement& node;
+ std::string xmlbuildFile;
+ std::string name;
+ std::string guid;
+ std::string extension;
+ std::string entrypoint;
+ std::string baseaddress;
+ std::string payload;
+ std::string path;
+ ModuleType type;
+ ImportLibrary* importLibrary;
+ bool mangledSymbols;
+ bool isUnicode;
+ Bootstrap* bootstrap;
+ AutoRegister* autoRegister;
+ IfableData non_if_data;
+ std::vector<Invoke*> invocations;
+ std::vector<Dependency*> dependencies;
+ std::vector<CompilerFlag*> compilerFlags;
+ std::vector<LinkerFlag*> linkerFlags;
+ std::vector<StubbedComponent*> stubbedComponents;
+ LinkerScript* linkerScript;
+ PchFile* pch;
+ bool cplusplus;
+ std::string prefix;
+ HostType host;
+ std::string installBase;
+ std::string installName;
+ std::string aliasedModuleName;
+ bool useWRC;
+ bool allowWarnings;
+ bool enabled;
+
+ Module ( const Project& project,
+ const XMLElement& moduleNode,
+ const std::string& modulePath );
+ ~Module ();
+ ModuleType GetModuleType ( const std::string& location,
+ const XMLAttribute& attribute );
+ bool HasImportLibrary () const;
+ bool IsDLL () const;
+ bool GenerateInOutputTree () const;
+ std::string GetTargetName () const; // "foo.exe"
+ std::string GetDependencyPath () const; // "path/foo.exe" or "path/libfoo.a"
+ std::string GetBasePath () const; // "path"
+ std::string GetPath () const; // "path/foo.exe"
+ std::string GetPathWithPrefix ( const std::string& prefix ) const; // "path/prefixfoo.exe"
+ std::string GetPathToBaseDir() const; // "../" offset to rootdirectory
+ void GetTargets ( string_list& ) const;
+ std::string GetInvocationTarget ( const int index ) const;
+ bool HasFileWithExtension ( const IfableData&, const std::string& extension ) const;
+ void InvokeModule () const;
+ void ProcessXML ();
+ void GetSourceFilenames ( string_list& list,
+ bool includeGeneratedFiles ) const;
+private:
+ std::string GetDefaultModuleExtension () const;
+ std::string GetDefaultModuleEntrypoint () const;
+ std::string GetDefaultModuleBaseaddress () const;
+ void ProcessXMLSubElement ( const XMLElement& e,
+ const std::string& path,
+ ParseContext& parseContext );
+};
+
+
+class Include
+{
+public:
+ const Project& project;
+ const Module* module;
+ const XMLElement* node;
+ const Module* baseModule;
+ std::string directory;
+ std::string basePath;
+
+ Include ( const Project& project,
+ const XMLElement* includeNode );
+ Include ( const Project& project,
+ const Module* module,
+ const XMLElement* includeNode );
+ Include ( const Project& project,
+ std::string directory,
+ std::string basePath );
+ ~Include ();
+ void ProcessXML();
+private:
+};
+
+
+class Define
+{
+public:
+ const Project& project;
+ const Module* module;
+ const XMLElement& node;
+ std::string name;
+ std::string value;
+
+ Define ( const Project& project,
+ const XMLElement& defineNode );
+ Define ( const Project& project,
+ const Module* module,
+ const XMLElement& defineNode );
+ ~Define();
+ void ProcessXML();
+private:
+ void Initialize();
+};
+
+
+class File
+{
+public:
+ std::string name;
+ bool first;
+ std::string switches;
+ bool isPreCompiledHeader;
+
+ File ( const std::string& _name,
+ bool _first,
+ std::string _switches,
+ bool _isPreCompiledHeader );
+
+ void ProcessXML();
+};
+
+
+class Library
+{
+public:
+ const XMLElement& node;
+ const Module& module;
+ std::string name;
+ const Module* importedModule;
+
+ Library ( const XMLElement& _node,
+ const Module& _module,
+ const std::string& _name );
+
+ void ProcessXML();
+};
+
+
+class Invoke
+{
+public:
+ const XMLElement& node;
+ const Module& module;
+ const Module* invokeModule;
+ std::vector<InvokeFile*> input;
+ std::vector<InvokeFile*> output;
+
+ Invoke ( const XMLElement& _node,
+ const Module& _module );
+
+ void ProcessXML();
+ void GetTargets ( string_list& targets ) const;
+ std::string GetParameters () const;
+private:
+ void ProcessXMLSubElement ( const XMLElement& e );
+ void ProcessXMLSubElementInput ( const XMLElement& e );
+ void ProcessXMLSubElementOutput ( const XMLElement& e );
+};
+
+
+class InvokeFile
+{
+public:
+ const XMLElement& node;
+ std::string name;
+ std::string switches;
+
+ InvokeFile ( const XMLElement& _node,
+ const std::string& _name );
+
+ void ProcessXML ();
+};
+
+
+class Dependency
+{
+public:
+ const XMLElement& node;
+ const Module& module;
+ const Module* dependencyModule;
+
+ Dependency ( const XMLElement& _node,
+ const Module& _module );
+
+ void ProcessXML();
+};
+
+
+class ImportLibrary
+{
+public:
+ const XMLElement& node;
+ const Module& module;
+ std::string basename;
+ std::string definition;
+
+ ImportLibrary ( const XMLElement& _node,
+ const Module& module );
+
+ void ProcessXML ();
+};
+
+
+class If
+{
+public:
+ const XMLElement& node;
+ const Project& project;
+ const Module* module;
+ const bool negated;
+ std::string property, value;
+ IfableData data;
+
+ If ( const XMLElement& node_,
+ const Project& project_,
+ const Module* module_,
+ const bool negated_ = false );
+ ~If();
+
+ void ProcessXML();
+};
+
+
+class CompilerFlag
+{
+public:
+ const Project& project;
+ const Module* module;
+ const XMLElement& node;
+ std::string flag;
+
+ CompilerFlag ( const Project& project,
+ const XMLElement& compilerFlagNode );
+ CompilerFlag ( const Project& project,
+ const Module* module,
+ const XMLElement& compilerFlagNode );
+ ~CompilerFlag ();
+ void ProcessXML();
+private:
+ void Initialize();
+};
+
+
+class LinkerFlag
+{
+public:
+ const Project& project;
+ const Module* module;
+ const XMLElement& node;
+ std::string flag;
+
+ LinkerFlag ( const Project& project,
+ const XMLElement& linkerFlagNode );
+ LinkerFlag ( const Project& project,
+ const Module* module,
+ const XMLElement& linkerFlagNode );
+ ~LinkerFlag ();
+ void ProcessXML();
+private:
+ void Initialize();
+};
+
+
+class LinkerScript
+{
+public:
+ const Project& project;
+ const Module* module;
+ const XMLElement& node;
+ const Module* baseModule;
+ std::string directory;
+ std::string basePath;
+
+ LinkerScript ( const Project& project,
+ const Module* module,
+ const XMLElement& node );
+ ~LinkerScript ();
+ void ProcessXML();
+};
+
+
+class Property
+{
+public:
+ const XMLElement& node;
+ const Project& project;
+ const Module* module;
+ std::string name, value;
+
+ Property ( const XMLElement& node_,
+ const Project& project_,
+ const Module* module_ );
+
+ void ProcessXML();
+};
+
+
+class TestSupportCode
+{
+public:
+ const Project& project;
+
+ TestSupportCode ( const Project& project );
+ ~TestSupportCode ();
+ void GenerateTestSupportCode ( bool verbose );
+private:
+ bool IsTestModule ( const Module& module );
+ void GenerateTestSupportCodeForModule ( Module& module,
+ bool verbose );
+ std::string GetHooksFilename ( Module& module );
+ char* WriteStubbedSymbolToHooksFile ( char* buffer,
+ const StubbedComponent& component,
+ const StubbedSymbol& symbol );
+ char* WriteStubbedComponentToHooksFile ( char* buffer,
+ const StubbedComponent& component );
+ void WriteHooksFile ( Module& module );
+ std::string GetStubsFilename ( Module& module );
+ char* WriteStubbedSymbolToStubsFile ( char* buffer,
+ const StubbedComponent& component,
+ const StubbedSymbol& symbol,
+ int stubIndex );
+ char* WriteStubbedComponentToStubsFile ( char* buffer,
+ const StubbedComponent& component,
+ int* stubIndex );
+ void WriteStubsFile ( Module& module );
+ std::string GetStartupFilename ( Module& module );
+ bool IsUnknownCharacter ( char ch );
+ std::string GetTestDispatcherName ( std::string filename );
+ bool IsTestFile ( std::string& filename ) const;
+ void GetSourceFilenames ( string_list& list,
+ Module& module ) const;
+ char* WriteTestDispatcherPrototypesToStartupFile ( char* buffer,
+ Module& module );
+ char* WriteRegisterTestsFunctionToStartupFile ( char* buffer,
+ Module& module );
+ void WriteStartupFile ( Module& module );
+};
+
+
+class WineResource
+{
+public:
+ const Project& project;
+ std::string bin2res;
+
+ WineResource ( const Project& project,
+ std::string bin2res );
+ ~WineResource ();
+ void UnpackResources ( bool verbose );
+private:
+ bool IsSpecFile ( const File& file );
+ bool IsWineModule ( const Module& module );
+ bool IsResourceFile ( const File& file );
+ std::string GetResourceFilename ( const Module& module );
+ void UnpackResourcesInModule ( Module& module,
+ bool verbose );
+};
+
+
+class SourceFile
+{
+public:
+ SourceFile ( AutomaticDependency* automaticDependency,
+ const Module& module,
+ const std::string& filename,
+ SourceFile* parent,
+ bool isNonAutomaticDependency );
+ SourceFile* ParseFile ( const std::string& normalizedFilename );
+ void Parse ();
+ std::string Location () const;
+ std::vector<SourceFile*> files;
+ AutomaticDependency* automaticDependency;
+ const Module& module;
+ std::string filename;
+ std::string filenamePart;
+ std::string directoryPart;
+ std::vector<SourceFile*> parents; /* List of files, this file is included from */
+ bool isNonAutomaticDependency;
+ std::string cachedDependencies;
+ time_t lastWriteTime;
+ time_t youngestLastWriteTime; /* Youngest last write time of this file and all children */
+ SourceFile* youngestFile;
+private:
+ void GetDirectoryAndFilenameParts ();
+ void Close ();
+ void Open ();
+ void SkipWhitespace ();
+ bool ReadInclude ( std::string& filename,
+ bool& searchCurrentDirectory,
+ bool& includeNext );
+ bool IsIncludedFrom ( const std::string& normalizedFilename );
+ SourceFile* GetParentSourceFile ();
+ bool CanProcessFile ( const std::string& extension );
+ bool IsParentOf ( const SourceFile* parent,
+ const SourceFile* child );
+ std::string buf;
+ const char *p;
+ const char *end;
+};
+
+
+class AutomaticDependency
+{
+ friend class SourceFileTest;
+public:
+ const Project& project;
+
+ AutomaticDependency ( const Project& project );
+ ~AutomaticDependency ();
+ std::string GetFilename ( const std::string& filename );
+ bool LocateIncludedFile ( const std::string& directory,
+ const std::string& includedFilename,
+ std::string& resolvedFilename );
+ bool LocateIncludedFile ( SourceFile* sourceFile,
+ const Module& module,
+ const std::string& includedFilename,
+ bool searchCurrentDirectory,
+ bool includeNext,
+ std::string& resolvedFilename );
+ SourceFile* RetrieveFromCacheOrParse ( const Module& module,
+ const std::string& filename,
+ SourceFile* parentSourceFile );
+ SourceFile* RetrieveFromCache ( const std::string& filename );
+ void CheckAutomaticDependencies ( bool verbose );
+ void CheckAutomaticDependenciesForModule ( Module& module,
+ bool verbose );
+private:
+ void GetModulesToCheck ( Module& module, std::vector<const Module*>& modules );
+ void CheckAutomaticDependencies ( const Module& module,
+ bool verbose );
+ void CheckAutomaticDependenciesForFile ( SourceFile* sourceFile );
+ void GetIncludeDirectories ( std::vector<Include*>& includes,
+ const Module& module,
+ Include& currentDirectory,
+ bool searchCurrentDirectory );
+ void GetModuleFiles ( const Module& module,
+ std::vector<File*>& files ) const;
+ void ParseFiles ();
+ void ParseFiles ( const Module& module );
+ void ParseFile ( const Module& module,
+ const File& file );
+ std::map<std::string, SourceFile*> sourcefile_map;
+};
+
+
+class Bootstrap
+{
+public:
+ const Project& project;
+ const Module* module;
+ const XMLElement& node;
+ std::string base;
+ std::string nameoncd;
+
+ Bootstrap ( const Project& project,
+ const Module* module,
+ const XMLElement& bootstrapNode );
+ ~Bootstrap ();
+ void ProcessXML();
+private:
+ bool IsSupportedModuleType ( ModuleType type );
+ void Initialize();
+};
+
+
+class CDFile
+{
+public:
+ const Project& project;
+ const XMLElement& node;
+ std::string name;
+ std::string base;
+ std::string nameoncd;
+ std::string path;
+
+ CDFile ( const Project& project,
+ const XMLElement& bootstrapNode,
+ const std::string& path );
+ ~CDFile ();
+ void ProcessXML();
+ std::string GetPath () const;
+};
+
+
+class InstallFile
+{
+public:
+ const Project& project;
+ const XMLElement& node;
+ std::string name;
+ std::string base;
+ std::string newname;
+ std::string path;
+
+ InstallFile ( const Project& project,
+ const XMLElement& bootstrapNode,
+ const std::string& path );
+ ~InstallFile ();
+ void ProcessXML ();
+ std::string GetPath () const;
+};
+
+
+class PchFile
+{
+public:
+ const XMLElement& node;
+ const Module& module;
+ File file;
+
+ PchFile (
+ const XMLElement& node,
+ const Module& module,
+ const File file );
+ void ProcessXML();
+};
+
+
+class StubbedComponent
+{
+public:
+ const Module* module;
+ const XMLElement& node;
+ std::string name;
+ std::vector<StubbedSymbol*> symbols;
+
+ StubbedComponent ( const Module* module_,
+ const XMLElement& stubbedComponentNode );
+ ~StubbedComponent ();
+ void ProcessXML ();
+ void ProcessXMLSubElement ( const XMLElement& e );
+};
+
+
+class StubbedSymbol
+{
+public:
+ const XMLElement& node;
+ std::string symbol;
+ std::string newname;
+ std::string strippedName;
+
+ StubbedSymbol ( const XMLElement& stubbedSymbolNode );
+ ~StubbedSymbol ();
+ void ProcessXML();
+private:
+ std::string StripSymbol ( std::string symbol );
+};
+
+
+class CompilationUnit
+{
+public:
+ const Project* project;
+ const Module* module;
+ const XMLElement* node;
+ std::string name;
+ std::vector<File*> files;
+
+ CompilationUnit ( File* file );
+ CompilationUnit ( const Project* project,
+ const Module* module,
+ const XMLElement* node );
+ ~CompilationUnit ();
+ void ProcessXML();
+ bool IsGeneratedFile () const;
+ bool HasFileWithExtension ( const std::string& extension ) const;
+ bool IsFirstFile () const;
+ FileLocation* GetFilename ( Directory* intermediateDirectory ) const;
+ std::string GetSwitches () const;
+};
+
+
+class CompilationUnitSupportCode
+{
+public:
+ const Project& project;
+
+ CompilationUnitSupportCode ( const Project& project );
+ ~CompilationUnitSupportCode ();
+ void Generate ( bool verbose );
+private:
+ void GenerateForModule ( Module& module,
+ bool verbose );
+ std::string GetCompilationUnitFilename ( Module& module,
+ CompilationUnit& compilationUnit );
+ void WriteCompilationUnitFile ( Module& module,
+ CompilationUnit& compilationUnit );
+};
+
+
+class FileLocation
+{
+public:
+ Directory* directory;
+ std::string filename;
+ FileLocation ( Directory* directory,
+ std::string filename );
+};
+
+
+enum AutoRegisterType
+{
+ DllRegisterServer,
+ DllInstall,
+ Both
+};
+
+class AutoRegister
+{
+public:
+ const Project& project;
+ const Module* module;
+ const XMLElement& node;
+ std::string infSection;
+ AutoRegisterType type;
+ AutoRegister ( const Project& project_,
+ const Module* module_,
+ const XMLElement& node_ );
+ ~AutoRegister ();
+ void ProcessXML();
+private:
+ bool IsSupportedModuleType ( ModuleType type );
+ AutoRegisterType GetAutoRegisterType( std::string type );
+ void Initialize ();
+};
+
+
+class SysSetupGenerator
+{
+public:
+ const Project& project;
+ SysSetupGenerator ( const Project& project );
+ ~SysSetupGenerator ();
+ void Generate ();
+private:
+ std::string GetDirectoryId ( const Module& module );
+ std::string GetFlags ( const Module& module );
+ void Generate ( HINF inf,
+ const Module& module );
+};
+
+
+extern void
+InitializeEnvironment ();
+
+extern std::string
+Right ( const std::string& s, size_t n );
+
+extern std::string
+Replace ( const std::string& s, const std::string& find, const std::string& with );
+
+extern std::string
+ChangeSeparator ( const std::string& s,
+ const char fromSeparator,
+ const char toSeparator );
+
+extern std::string
+FixSeparator ( const std::string& s );
+
+extern std::string
+FixSeparatorForSystemCommand ( const std::string& s );
+
+extern std::string
+DosSeparator ( const std::string& s );
+
+extern std::string
+ReplaceExtension (
+ const std::string& filename,
+ const std::string& newExtension );
+
+extern std::string
+GetSubPath (
+ const std::string& location,
+ const std::string& path,
+ const std::string& att_value );
+
+extern std::string
+GetExtension ( const std::string& filename );
+
+extern std::string
+GetDirectory ( const std::string& filename );
+
+extern std::string
+GetFilename ( const std::string& filename );
+
+extern std::string
+NormalizeFilename ( const std::string& filename );
+
+extern std::string
+ToLower ( std::string filename );
+
+#endif /* __RBUILD_H */