diff --git a/reactos/tools/rbuild/automaticdependency.cpp b/reactos/tools/rbuild/automaticdependency.cpp index 17685196916..800f1c7ff39 100644 --- a/reactos/tools/rbuild/automaticdependency.cpp +++ b/reactos/tools/rbuild/automaticdependency.cpp @@ -320,7 +320,10 @@ AutomaticDependency::GetModuleFiles ( const Module& module, /* FIXME: Collect files in IFs here */ if ( module.pch != NULL ) - files.push_back ( &module.pch->file ); + { + File *file = new File ( module.pch->file.relative_path + sSep + module.pch->file.name , false, "", true ); + files.push_back ( file ); + } } void diff --git a/reactos/tools/rbuild/autoregister.cpp b/reactos/tools/rbuild/autoregister.cpp new file mode 100644 index 00000000000..4e56cf15c16 --- /dev/null +++ b/reactos/tools/rbuild/autoregister.cpp @@ -0,0 +1,88 @@ +/* + * 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. + */ +#include "pch.h" + +#include "rbuild.h" + +using std::string; + +AutoRegister::AutoRegister ( const Project& project_, + const Module* module_, + const XMLElement& node_ ) + : XmlNode(project_, node_), + module(module_) +{ + Initialize(); +} + +bool +AutoRegister::IsSupportedModuleType ( ModuleType type ) +{ + if ( type == Win32DLL || + type == Win32OCX ) + { + return true; + } + else + { + return false; + } +} + +AutoRegisterType +AutoRegister::GetAutoRegisterType( const string& type ) +{ + if ( type == "DllRegisterServer" ) + return DllRegisterServer; + if ( type == "DllInstall" ) + return DllInstall; + if ( type == "Both" ) + return Both; + throw XMLInvalidBuildFileException ( + node.location, + " type attribute must be DllRegisterServer, DllInstall or Both." ); +} + +void +AutoRegister::Initialize () +{ + if ( !IsSupportedModuleType ( module->type ) ) + { + throw XMLInvalidBuildFileException ( + node.location, + " is not applicable for this module type." ); + } + + const XMLAttribute* att = node.GetAttribute ( "infsection", true ); + if ( !att ) + { + throw XMLInvalidBuildFileException ( + node.location, + " must have a 'infsection' attribute." ); + } + infSection = att->value; + + att = node.GetAttribute ( "type", true ); + if ( !att ) + { + throw XMLInvalidBuildFileException ( + node.location, + " must have a 'type' attribute." ); + } + type = GetAutoRegisterType ( att->value ); +} diff --git a/reactos/tools/rbuild/backend/mingw/mingw.cpp b/reactos/tools/rbuild/backend/mingw/mingw.cpp index 64fe6d33207..eff8f3eeba7 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.cpp +++ b/reactos/tools/rbuild/backend/mingw/mingw.cpp @@ -34,6 +34,104 @@ using std::map; typedef set set_string; +string +strDirectory ( const FileLocation *file ) +{ + MingwModuleHandler::PassThruCacheDirectory ( file ); + + string directory; + switch ( file->directory ) + { + case SourceDirectory: + directory = ""; + break; + case IntermediateDirectory: + directory = "$(INTERMEDIATE)"; + break; + case OutputDirectory: + directory = "$(OUTPUT)"; + break; + case InstallDirectory: + directory = "$(INSTALL)"; + break; + case TemporaryDirectory: + directory = "$(TEMPORARY)"; + break; + default: + throw InvalidOperationException ( __FILE__, + __LINE__, + "Invalid directory." ); + } + + if ( file->relative_path.length () > 0 ) + { + if ( directory.length () > 0 ) + directory += sSep; + directory += file->relative_path; + } + return directory; +} + +string +strFile ( const FileLocation *file ) +{ + string directory; + switch ( file->directory ) + { + case SourceDirectory: + directory = ""; + break; + case IntermediateDirectory: + directory = "$(INTERMEDIATE)"; + break; + case OutputDirectory: + directory = "$(OUTPUT)"; + break; + case InstallDirectory: + directory = "$(INSTALL)"; + break; + case TemporaryDirectory: + directory = "$(TEMPORARY)"; + break; + default: + throw InvalidOperationException ( __FILE__, + __LINE__, + "Invalid directory." ); + } + + if ( file->relative_path.length () > 0 ) + { + if ( directory.length () > 0 ) + directory += sSep; + directory += file->relative_path; + } + + if ( directory.length () > 0 ) + directory += sSep; + + return directory + file->name; +} + + +string +v2s ( const vector& files, int wrap_at ) +{ + if ( !files.size() ) + return ""; + string s; + int wrap_count = 0; + for ( size_t i = 0; i < files.size(); i++ ) + { + const FileLocation& file = files[i]; + if ( wrap_at > 0 && wrap_count++ == wrap_at ) + s += " \\\n\t\t"; + else if ( s.size() ) + s += " "; + s += strFile ( &file ); + } + return s; +} + string v2s ( const string_list& v, int wrap_at ) @@ -1049,22 +1147,18 @@ MingwBackend::DetectPCHSupport () void MingwBackend::GetNonModuleInstallTargetFiles ( - vector& out ) const + vector& out ) const { for ( size_t i = 0; i < ProjectNode.installfiles.size (); i++ ) { const InstallFile& installfile = *ProjectNode.installfiles[i]; - string targetFilenameNoFixup = installfile.base + sSep + installfile.newname; - string targetFilename = MingwModuleHandler::PassThruCacheDirectory ( - NormalizeFilename ( targetFilenameNoFixup ), - installDirectory ); - out.push_back ( targetFilename ); + out.push_back ( *installfile.target ); } } void MingwBackend::GetModuleInstallTargetFiles ( - vector& out ) const + vector& out ) const { for ( size_t i = 0; i < ProjectNode.modules.size (); i++ ) { @@ -1073,54 +1167,36 @@ MingwBackend::GetModuleInstallTargetFiles ( continue; if ( module.installName.length () > 0 ) { - string targetFilenameNoFixup; - if ( module.installBase.length () > 0 ) - targetFilenameNoFixup = module.installBase + sSep + module.installName; - else - targetFilenameNoFixup = module.installName; - string targetFilename = MingwModuleHandler::PassThruCacheDirectory ( - NormalizeFilename ( targetFilenameNoFixup ), - installDirectory ); - out.push_back ( targetFilename ); + out.push_back ( FileLocation ( InstallDirectory, + module.installBase, + module.installName ) ); } } } void MingwBackend::GetInstallTargetFiles ( - vector& out ) const + vector& out ) const { GetNonModuleInstallTargetFiles ( out ); GetModuleInstallTargetFiles ( out ); } void -MingwBackend::OutputInstallTarget ( const string& sourceFilename, - const string& targetFilename, - const string& targetDirectory ) +MingwBackend::OutputInstallTarget ( const FileLocation& source, + const FileLocation& target ) { - string fullTargetFilename; - if ( targetDirectory.length () > 0) - fullTargetFilename = targetDirectory + sSep + targetFilename; - else - fullTargetFilename = targetFilename; - string normalizedTargetFilename = MingwModuleHandler::PassThruCacheDirectory ( - NormalizeFilename ( fullTargetFilename ), - installDirectory ); - string normalizedTargetDirectory = MingwModuleHandler::PassThruCacheDirectory ( - NormalizeFilename ( targetDirectory ), - installDirectory ); fprintf ( fMakefile, "%s: %s | %s\n", - normalizedTargetFilename.c_str (), - sourceFilename.c_str (), - normalizedTargetDirectory.c_str () ); + strFile( &target ).c_str (), + strFile( &source ).c_str (), + strDirectory( &target ).c_str () ); fprintf ( fMakefile, "\t$(ECHO_CP)\n" ); fprintf ( fMakefile, "\t${cp} %s %s 1>$(NUL)\n", - sourceFilename.c_str (), - normalizedTargetFilename.c_str () ); + strFile( &source ).c_str (), + strFile( &target ).c_str () ); } void @@ -1129,9 +1205,7 @@ MingwBackend::OutputNonModuleInstallTargets () for ( size_t i = 0; i < ProjectNode.installfiles.size (); i++ ) { const InstallFile& installfile = *ProjectNode.installfiles[i]; - OutputInstallTarget ( installfile.GetPath (), - installfile.newname, - installfile.base ); + OutputInstallTarget ( *installfile.source, *installfile.target ); } } @@ -1159,12 +1233,10 @@ MingwBackend::OutputModuleInstallTargets () if ( module.installName.length () > 0 ) { const Module& aliasedModule = GetAliasedModuleOrModule ( module ); - string sourceFilename = MingwModuleHandler::PassThruCacheDirectory ( - NormalizeFilename ( aliasedModule.GetPath () ), - outputDirectory ); - OutputInstallTarget ( sourceFilename, - module.installName, - module.installBase ); + + FileLocation source ( OutputDirectory, aliasedModule.GetBasePath (), aliasedModule.GetTargetName () ); + FileLocation target ( InstallDirectory, module.installBase, module.installName ); + OutputInstallTarget ( source, target ); } } } @@ -1182,24 +1254,23 @@ MingwBackend::GetRegistrySourceFiles () string MingwBackend::GetRegistryTargetFiles () { - string system32ConfigDirectory = NormalizeFilename ( - MingwModuleHandler::PassThruCacheDirectory ( - "system32" + sSep + "config" + sSep, - installDirectory ) ); - return system32ConfigDirectory + sSep + "default " + - system32ConfigDirectory + sSep + "sam " + - system32ConfigDirectory + sSep + "security " + - system32ConfigDirectory + sSep + "software " + - system32ConfigDirectory + sSep + "system"; + string system32ConfigDirectory = "system32" + sSep + "config"; + FileLocation system32 ( InstallDirectory, system32ConfigDirectory, "" ); + + vector registry_files; + registry_files.push_back ( FileLocation ( InstallDirectory, system32ConfigDirectory, "default" ) ); + registry_files.push_back ( FileLocation ( InstallDirectory, system32ConfigDirectory, "sam" ) ); + registry_files.push_back ( FileLocation ( InstallDirectory, system32ConfigDirectory, "security" ) ); + registry_files.push_back ( FileLocation ( InstallDirectory, system32ConfigDirectory, "software" ) ); + registry_files.push_back ( FileLocation ( InstallDirectory, system32ConfigDirectory, "system" ) ); + + return v2s( registry_files, 6 ); } void MingwBackend::OutputRegistryInstallTarget () { - string system32ConfigDirectory = NormalizeFilename ( - MingwModuleHandler::PassThruCacheDirectory ( - "system32" + sSep + "config" + sSep, - installDirectory ) ); + FileLocation system32 ( InstallDirectory, "system32" + sSep + "config", "" ); string registrySourceFiles = GetRegistrySourceFiles (); string registryTargetFiles = GetRegistryTargetFiles (); @@ -1210,12 +1281,12 @@ MingwBackend::OutputRegistryInstallTarget () "%s: %s %s $(MKHIVE_TARGET)\n", registryTargetFiles.c_str (), registrySourceFiles.c_str (), - system32ConfigDirectory.c_str () ); + strDirectory ( &system32 ).c_str () ); fprintf ( fMakefile, "\t$(ECHO_MKHIVE)\n" ); fprintf ( fMakefile, "\t$(MKHIVE_TARGET) boot%cbootdata %s boot%cbootdata%chiveinst.inf\n", - cSep, system32ConfigDirectory.c_str (), + cSep, strDirectory ( &system32 ).c_str (), cSep, cSep ); fprintf ( fMakefile, "\n" ); @@ -1224,7 +1295,7 @@ MingwBackend::OutputRegistryInstallTarget () void MingwBackend::GenerateInstallTarget () { - vector vInstallTargetFiles; + vector vInstallTargetFiles; GetInstallTargetFiles ( vInstallTargetFiles ); string installTargetFiles = v2s ( vInstallTargetFiles, 5 ); string registryTargetFiles = GetRegistryTargetFiles (); @@ -1232,7 +1303,7 @@ MingwBackend::GenerateInstallTarget () fprintf ( fMakefile, "install: %s %s\n", installTargetFiles.c_str (), - registryTargetFiles.c_str () ); + registryTargetFiles.c_str () ); OutputNonModuleInstallTargets (); OutputModuleInstallTargets (); OutputRegistryInstallTarget (); diff --git a/reactos/tools/rbuild/backend/mingw/mingw.h b/reactos/tools/rbuild/backend/mingw/mingw.h index 2c150b60408..865d3745d14 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.h +++ b/reactos/tools/rbuild/backend/mingw/mingw.h @@ -29,6 +29,8 @@ class Directory; class MingwModuleHandler; +extern std::string +v2s ( const std::vector& files, int wrap_at ); extern std::string v2s ( const string_list& v, int wrap_at ); @@ -62,7 +64,7 @@ private: void GenerateGlobalCFlagsAndProperties ( const char* op, IfableData& data ) const; void GenerateProjectGccOptionsMacro ( const char* assignmentOperation, - IfableData& data ) const; + IfableData& data ) const; void GenerateProjectGccOptions ( const char* assignmentOperation, IfableData& data ) const; std::string GenerateProjectLFLAGS () const; @@ -106,12 +108,10 @@ private: std::string GetInstallDirectories ( const std::string& installDirectory ); void GetNonModuleInstallFiles ( std::vector& out ) const; void GetInstallFiles ( std::vector& out ) const; - void GetNonModuleInstallTargetFiles ( std::vector& out ) const; - void GetModuleInstallTargetFiles ( std::vector& out ) const; - void GetInstallTargetFiles ( std::vector& out ) const; - void OutputInstallTarget ( const std::string& sourceFilename, - const std::string& targetFilename, - const std::string& targetDirectory ); + void GetNonModuleInstallTargetFiles ( std::vector& out ) const; + void GetModuleInstallTargetFiles ( std::vector& out ) const; + void GetInstallTargetFiles ( std::vector& out ) const; + void OutputInstallTarget ( const FileLocation& source, const FileLocation& target ); void OutputNonModuleInstallTargets (); void OutputModuleInstallTargets (); std::string GetRegistrySourceFiles (); diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp index 646989a4770..8432135e722 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp @@ -25,14 +25,18 @@ using std::string; using std::vector; -#define CLEAN_FILE(f) clean_files.push_back ( f ); +#define CLEAN_FILE(f) clean_files.push_back ( (f)->name.length () > 0 ? strFile ( f ) : strDirectory ( f ) ); -static string ros_temp = "$(TEMPORARY_)"; MingwBackend* MingwModuleHandler::backend = NULL; FILE* MingwModuleHandler::fMakefile = NULL; +extern string +strDirectory ( const FileLocation *file ); +extern string +strFile ( const FileLocation *file ); + string PrefixFilename ( const string& filename, @@ -96,69 +100,45 @@ MingwModuleHandler::EnablePreCompiledHeaderSupport () use_pch = true; } -/* static*/ string -MingwModuleHandler::RemoveVariables ( string path) +/*static*/ const FileLocation* +MingwModuleHandler::PassThruCacheDirectory (const FileLocation* file ) { - size_t i = path.find ( '$' ); - if ( i != string::npos ) + switch ( file->directory ) { - size_t j = path.find ( ')', i ); - if ( j != string::npos ) - { - if ( j + 2 < path.length () && path[j + 1] == cSep ) - return path.substr ( j + 2); - else - return path.substr ( j + 1); - } + case IntermediateDirectory: + backend->AddDirectoryTarget ( file->relative_path, backend->intermediateDirectory ); + break; + case OutputDirectory: + backend->AddDirectoryTarget ( file->relative_path, backend->outputDirectory ); + break; + case InstallDirectory: + backend->AddDirectoryTarget ( file->relative_path, backend->installDirectory ); + break; + default: + throw InvalidOperationException ( __FILE__, + __LINE__, + "Invalid directory %d.", + file->directory ); } - return path; + + return file; } -/*static*/ string -MingwModuleHandler::PassThruCacheDirectory ( - const string &file, - Directory* directoryTree ) -{ - string directory ( GetDirectory ( RemoveVariables ( file ) ) ); - if ( directoryTree == NULL ) - return file; - string generatedFilesDirectory = backend->AddDirectoryTarget ( directory, - directoryTree ); - if ( directory.find ( generatedFilesDirectory ) != string::npos ) - /* This path already includes the generated files directory variable */ - return file; - else - { - if ( file == "" ) - return generatedFilesDirectory; - return generatedFilesDirectory + sSep + file; - } -} - -/*static*/ string -MingwModuleHandler::PassThruCacheDirectory (const FileLocation* fileLocation ) -{ - return PassThruCacheDirectory ( fileLocation->filename, - fileLocation->directory ); -} - -/*static*/ Directory* +/*static*/ DirectoryLocation MingwModuleHandler::GetTargetDirectoryTree ( const Module& module ) { if ( module.type == StaticLibrary ) - return backend->intermediateDirectory; - return backend->outputDirectory; + return IntermediateDirectory; + return OutputDirectory; } -/*static*/ string +/*static*/ const FileLocation* MingwModuleHandler::GetTargetFilename ( const Module& module, string_list* pclean_files ) { - string target = PassThruCacheDirectory ( - NormalizeFilename ( module.GetPath () ), - GetTargetDirectoryTree ( module ) ); + FileLocation *target = new FileLocation ( GetTargetDirectoryTree ( module ), module.GetBasePath (), module.GetTargetName () ); if ( pclean_files ) { string_list& clean_files = *pclean_files; @@ -167,14 +147,12 @@ MingwModuleHandler::GetTargetFilename ( return target; } -/*static*/ string +/*static*/ const FileLocation* MingwModuleHandler::GetImportLibraryFilename ( const Module& module, string_list* pclean_files ) { - string target = PassThruCacheDirectory ( - NormalizeFilename ( module.GetDependencyPath () ), - backend->intermediateDirectory ); + FileLocation *target = new FileLocation ( IntermediateDirectory, module.GetBasePath (), module.GetDependencyTargetName () ); if ( pclean_files ) { string_list& clean_files = *pclean_files; @@ -294,65 +272,60 @@ MingwModuleHandler::GetBasename ( const string& filename ) const return ""; } -FileLocation* +const FileLocation* MingwModuleHandler::GetActualSourceFilename ( - const FileLocation* fileLocation ) const + const FileLocation* file ) const { - string filename = fileLocation->filename; + string filename = file->name; + string extension = GetExtension ( filename ); if ( extension == ".spec" || extension == ".SPEC" ) { string basename = GetBasename ( filename ); - PassThruCacheDirectory ( NormalizeFilename ( basename + ".stubs.c" ), - backend->intermediateDirectory ); - return new FileLocation ( backend->intermediateDirectory, NormalizeFilename ( basename + ".stubs.c" ) ); + return new FileLocation ( + IntermediateDirectory, + file->relative_path, + basename + ".stubs.c" ); } else if ( extension == ".idl" || extension == ".IDL" ) { string basename = GetBasename ( filename ); - string newname; if ( module.type == RpcServer ) { - newname = basename + "_s.c"; - PassThruCacheDirectory ( NormalizeFilename ( newname ), - backend->intermediateDirectory ); - return new FileLocation ( backend->intermediateDirectory, NormalizeFilename ( newname ) ); + return new FileLocation ( + IntermediateDirectory, + file->relative_path, + basename + "_s.c" ); } else if ( module.type == RpcClient ) { - newname = basename + "_c.c"; - PassThruCacheDirectory ( NormalizeFilename ( newname ), - backend->intermediateDirectory ); - return new FileLocation ( backend->intermediateDirectory, NormalizeFilename ( newname ) ); - } - else if ( module.type == IdlHeader ) - { - newname = basename + ".h"; - PassThruCacheDirectory ( NormalizeFilename ( newname ), - backend->intermediateDirectory ); - return new FileLocation ( fileLocation->directory, filename ); + return new FileLocation ( + IntermediateDirectory, + file->relative_path, + basename + "_c.c" ); } else { - return new FileLocation ( fileLocation->directory, filename ); + return new FileLocation ( *file ); } } else - return new FileLocation ( fileLocation->directory, filename ); + return new FileLocation ( *file ); } string MingwModuleHandler::GetExtraDependencies ( - const string& filename ) const + const FileLocation *file ) const { - string extension = GetExtension ( filename ); + string extension = GetExtension ( file->name ); if ( extension == ".idl" || extension == ".IDL" ) { - string basename = GetBasename ( filename ); if ( (module.type == RpcServer) || (module.type == RpcClient) ) - return GetRpcServerHeaderFilename ( basename ) + " " + GetRpcClientHeaderFilename ( basename ); + return strFile ( GetRpcServerHeaderFilename ( file ) ) + + " " + + strFile ( GetRpcClientHeaderFilename ( file ) ); else if ( module.type == IdlHeader ) - return GetIdlHeaderFilename ( basename ); + return strFile ( GetIdlHeaderFilename ( file ) ); else return ""; } @@ -375,15 +348,14 @@ MingwModuleHandler::GetCompilationUnitDependencies ( return v2s ( sourceFiles, 10 ); } -string +const FileLocation* MingwModuleHandler::GetModuleArchiveFilename () const { if ( module.type == StaticLibrary ) - return GetTargetFilename ( module, NULL ); - return PassThruCacheDirectory ( ReplaceExtension ( - NormalizeFilename ( module.GetPath () ), - ".temp.a" ), - backend->intermediateDirectory ); + return new FileLocation ( *GetTargetFilename ( module, NULL ) ); + return new FileLocation ( IntermediateDirectory, + module.GetBasePath (), + ReplaceExtension ( module.name, ".temp.a" ) ); } bool @@ -408,6 +380,18 @@ MingwModuleHandler::ReferenceObjects ( return false; } +void +MingwModuleHandler::OutputCopyCommand ( const FileLocation& source, + const FileLocation& destination ) +{ + fprintf ( fMakefile, + "\t$(ECHO_CP)\n" ); + fprintf ( fMakefile, + "\t${cp} %s %s 1>$(NUL)\n", + strFile ( &source ).c_str (), + strFile ( &destination ).c_str () ); +} + string MingwModuleHandler::GetImportLibraryDependency ( const Module& importedModule ) @@ -416,13 +400,13 @@ MingwModuleHandler::GetImportLibraryDependency ( if ( ReferenceObjects ( importedModule ) ) dep = GetTargetMacro ( importedModule ); else - dep = GetImportLibraryFilename ( importedModule, NULL ); + dep = strFile ( GetImportLibraryFilename ( importedModule, NULL ) ); return dep; } void MingwModuleHandler::GetTargets ( const Module& dependencyModule, - string_list& targets ) + string_list& targets ) { if ( dependencyModule.invocations.size () > 0 ) { @@ -452,11 +436,17 @@ MingwModuleHandler::GetModuleDependencies ( GetTargets ( dependencyModule, dependencies ); } - GetDefinitionDependencies ( dependencies ); + vector v; + GetDefinitionDependencies ( v ); + for ( size_t i = 0; i < v.size (); i++ ) + { + const FileLocation& file = v[i]; + dependencies.push_back ( strFile ( &file ) ); + } } void -MingwModuleHandler::GetSourceFilenames ( string_list& list, +MingwModuleHandler::GetSourceFilenames ( vector& list, bool includeGeneratedFiles ) const { size_t i; @@ -466,10 +456,9 @@ MingwModuleHandler::GetSourceFilenames ( string_list& list, { if ( includeGeneratedFiles || !compilationUnits[i]->IsGeneratedFile () ) { - FileLocation* sourceFileLocation = GetActualSourceFilename ( - compilationUnits[i]->GetFilename ( backend->intermediateDirectory ) ); - list.push_back ( PassThruCacheDirectory ( sourceFileLocation->filename, - sourceFileLocation->directory ) ); + const FileLocation* sourceFileLocation = GetActualSourceFilename ( + compilationUnits[i]->GetFilename () ); + list.push_back ( *sourceFileLocation ); } } // intentionally make a copy so that we can append more work in @@ -489,10 +478,9 @@ MingwModuleHandler::GetSourceFilenames ( string_list& list, CompilationUnit& compilationUnit = *compilationUnits[j]; if ( includeGeneratedFiles || !compilationUnit.IsGeneratedFile () ) { - FileLocation* sourceFileLocation = GetActualSourceFilename ( - compilationUnit.GetFilename ( backend->intermediateDirectory ) ); - list.push_back ( PassThruCacheDirectory ( sourceFileLocation->filename, - sourceFileLocation->directory ) ); + const FileLocation* sourceFileLocation = GetActualSourceFilename ( + compilationUnit.GetFilename () ); + list.push_back ( *sourceFileLocation ); } } } @@ -500,18 +488,18 @@ MingwModuleHandler::GetSourceFilenames ( string_list& list, void MingwModuleHandler::GetSourceFilenamesWithoutGeneratedFiles ( - string_list& list ) const + vector& list ) const { GetSourceFilenames ( list, false ); } -string +const FileLocation* MingwModuleHandler::GetObjectFilename ( - const FileLocation* sourceFileLocation, + const FileLocation* sourceFile, string_list* pclean_files ) const { - string sourceFilename = sourceFileLocation->filename; - Directory* directoryTree; + string sourceFilename = sourceFile->name; + DirectoryLocation destination_directory; string newExtension; string extension = GetExtension ( sourceFilename ); if ( extension == ".rc" || extension == ".RC" ) @@ -531,15 +519,14 @@ MingwModuleHandler::GetObjectFilename ( newExtension = ".o"; if ( module.type == BootSector ) - directoryTree = backend->outputDirectory; + destination_directory = OutputDirectory; else - directoryTree = backend->intermediateDirectory; + destination_directory = IntermediateDirectory; - string obj_file = PassThruCacheDirectory ( - NormalizeFilename ( ReplaceExtension ( - RemoveVariables ( sourceFilename ), - newExtension ) ), - directoryTree ); + const FileLocation *obj_file = new FileLocation( + destination_directory, + sourceFile->relative_path, + ReplaceExtension ( sourceFile->name, newExtension ) ); if ( pclean_files ) { @@ -583,7 +570,7 @@ MingwModuleHandler::GenerateCleanTarget () const v2s ( referencedModuleNames, 10 ).c_str () ); for ( size_t i = 0; i < clean_files.size(); i++ ) { - if ( 9==((i+1)%10) ) + if ( ( i + 1 ) % 10 == 9 ) fprintf ( fMakefile, " 2>$(NUL)\n\t-@${rm}" ); fprintf ( fMakefile, " %s", clean_files[i].c_str() ); } @@ -597,12 +584,12 @@ MingwModuleHandler::GenerateInstallTarget () const if ( module.installName.length () == 0 ) return; fprintf ( fMakefile, ".PHONY: %s_install\n", module.name.c_str() ); - string normalizedTargetFilename = MingwModuleHandler::PassThruCacheDirectory ( - NormalizeFilename ( module.installBase + sSep + module.installName ), - backend->installDirectory ); + string normalizedTargetFilename = + NormalizeFilename ( module.installBase + sSep + module.installName ); fprintf ( fMakefile, - "%s_install: %s\n", + "%s_install: $(INSTALL)%c%s\n", module.name.c_str (), + cSep, normalizedTargetFilename.c_str() ); } @@ -634,7 +621,7 @@ MingwModuleHandler::GetObjectFilenames () { if ( objectFilenames.size () > 0 ) objectFilenames += " "; - objectFilenames += GetObjectFilename ( compilationUnits[i]->GetFilename ( backend->intermediateDirectory ), NULL ); + objectFilenames += strFile ( GetObjectFilename ( compilationUnits[i]->GetFilename (), NULL ) ); } return objectFilenames; } @@ -793,7 +780,7 @@ MingwModuleHandler::GenerateMacro ( { fprintf ( fMakefile, " -I%s", - GetDirectory ( GetPrecompiledHeaderFilename () ).c_str () ); + strDirectory ( GetPrecompiledHeaderFilename () ).c_str () ); } string compilerParameters = GenerateCompilerParametersFromVector ( data.compilerFlags ); @@ -813,8 +800,10 @@ MingwModuleHandler::GenerateMacro ( ( include.baseModule->type == RpcServer || include.baseModule->type == RpcClient || include.baseModule->type == IdlHeader) ) - includeDirectory = PassThruCacheDirectory ( NormalizeFilename ( include.directory ), - backend->intermediateDirectory ); + { + path_prefix = "$(INTERMEDIATE)" + sSep; + includeDirectory = NormalizeFilename ( include.directory ); + } else includeDirectory = include.directory; @@ -822,8 +811,11 @@ MingwModuleHandler::GenerateMacro ( path_prefix = "$(INTERMEDIATE)" + sSep; else if (include.root == "output" ) path_prefix = "$(OUTPUT)" + sSep; - else - path_prefix = ""; + else if ( include.root != "" ) + throw InvalidOperationException ( __FILE__, + __LINE__, + "Unsupported root prefix '%s'", + include.root.c_str () ); fprintf ( fMakefile, @@ -952,7 +944,7 @@ MingwModuleHandler::GenerateObjectMacros ( fprintf ( fMakefile, "%s := %s $(%s)\n", objectsMacro.c_str(), - GetObjectFilename ( compilationUnit.GetFilename ( backend->intermediateDirectory ), NULL ).c_str (), + strFile ( GetObjectFilename ( compilationUnit.GetFilename (), NULL ) ).c_str (), objectsMacro.c_str() ); } } @@ -970,7 +962,7 @@ MingwModuleHandler::GenerateObjectMacros ( fMakefile, "%s%s", ( i%10 == 9 ? " \\\n\t" : " " ), - GetObjectFilename ( compilationUnit.GetFilename ( backend->intermediateDirectory ), NULL ).c_str () ); + strFile ( GetObjectFilename ( compilationUnit.GetFilename (), NULL ) ).c_str () ); } } fprintf ( fMakefile, "\n" ); @@ -1011,46 +1003,46 @@ MingwModuleHandler::GenerateObjectMacros ( fMakefile, "%s += %s\n", objectsMacro.c_str(), - GetObjectFilename ( sourceCompilationUnits[i]->GetFilename ( backend->intermediateDirectory ), NULL ).c_str () ); + strFile ( GetObjectFilename ( sourceCompilationUnits[i]->GetFilename (), NULL ) ).c_str () ); } CleanupCompilationUnitVector ( sourceCompilationUnits ); } -string +const FileLocation* MingwModuleHandler::GetPrecompiledHeaderFilename () const { const string& basePchFilename = module.pch->file.name + ".gch"; - return PassThruCacheDirectory ( NormalizeFilename ( basePchFilename ), - backend->intermediateDirectory ); + return new FileLocation ( IntermediateDirectory, + module.pch->file.relative_path, + basePchFilename ); } void MingwModuleHandler::GenerateGccCommand ( - const FileLocation* sourceFileLocation, + const FileLocation* sourceFile, const string& extraDependencies, const string& cc, const string& cflagsMacro ) { - string sourceFilename = PassThruCacheDirectory ( sourceFileLocation ); - string dependencies = sourceFilename; + string dependencies = strFile ( sourceFile ); if ( extraDependencies != "" ) dependencies += " " + extraDependencies; if ( module.pch && use_pch ) - dependencies += " " + GetPrecompiledHeaderFilename (); + dependencies += " " + strFile ( GetPrecompiledHeaderFilename () ); /* WIDL generated headers may be used */ - vector rpcDependencies; + vector rpcDependencies; GetRpcHeaderDependencies ( rpcDependencies ); dependencies += " " + v2s ( rpcDependencies, 5 ); dependencies += " " + NormalizeFilename ( module.xmlbuildFile ); - string objectFilename = GetObjectFilename ( - sourceFileLocation, &clean_files ); + const FileLocation *objectFilename = GetObjectFilename ( + sourceFile, &clean_files ); fprintf ( fMakefile, "%s: %s | %s\n", - objectFilename.c_str (), + strFile ( objectFilename ).c_str (), dependencies.c_str (), - GetDirectory ( objectFilename ).c_str () ); + strDirectory ( objectFilename ).c_str () ); fprintf ( fMakefile, "\t$(ECHO_CC)\n" ); fprintf ( fMakefile, "\t%s -c $< -o $@ %s\n", @@ -1060,20 +1052,20 @@ MingwModuleHandler::GenerateGccCommand ( void MingwModuleHandler::GenerateGccAssemblerCommand ( - const FileLocation* sourceFileLocation, + const FileLocation* sourceFile, const string& cc, const string& cflagsMacro ) { - string sourceFilename = PassThruCacheDirectory ( sourceFileLocation ); - string dependencies = sourceFilename; + string dependencies = strFile ( sourceFile ); dependencies += " " + NormalizeFilename ( module.xmlbuildFile ); - string objectFilename = GetObjectFilename ( - sourceFileLocation, &clean_files ); + + const FileLocation *objectFilename = GetObjectFilename ( + sourceFile, &clean_files ); fprintf ( fMakefile, "%s: %s | %s\n", - objectFilename.c_str (), + strFile ( objectFilename ).c_str (), dependencies.c_str (), - GetDirectory ( objectFilename ).c_str () ); + strDirectory ( objectFilename ).c_str () ); fprintf ( fMakefile, "\t$(ECHO_GAS)\n" ); fprintf ( fMakefile, "\t%s -x assembler-with-cpp -c $< -o $@ -D__ASM__ %s\n", @@ -1083,19 +1075,19 @@ MingwModuleHandler::GenerateGccAssemblerCommand ( void MingwModuleHandler::GenerateNasmCommand ( - const FileLocation* sourceFileLocation, + const FileLocation* sourceFile, const string& nasmflagsMacro ) { - string sourceFilename = PassThruCacheDirectory ( sourceFileLocation ); - string dependencies = sourceFilename; + string dependencies = strFile ( sourceFile ); dependencies += " " + NormalizeFilename ( module.xmlbuildFile ); - string objectFilename = GetObjectFilename ( - sourceFileLocation, &clean_files ); + + const FileLocation *objectFilename = GetObjectFilename ( + sourceFile, &clean_files ); fprintf ( fMakefile, "%s: %s | %s\n", - objectFilename.c_str (), + strFile ( objectFilename ).c_str (), dependencies.c_str (), - GetDirectory ( objectFilename ).c_str () ); + strDirectory ( objectFilename ).c_str () ); fprintf ( fMakefile, "\t$(ECHO_NASM)\n" ); fprintf ( fMakefile, "\t%s -f win32 $< -o $@ %s\n", @@ -1105,99 +1097,104 @@ MingwModuleHandler::GenerateNasmCommand ( void MingwModuleHandler::GenerateWindresCommand ( - const FileLocation* sourceFileLocation, + const FileLocation* sourceFile, const string& windresflagsMacro ) { - string sourceFilename = PassThruCacheDirectory ( sourceFileLocation ); - string dependencies = sourceFilename; + string dependencies = strFile ( sourceFile ); dependencies += " " + NormalizeFilename ( module.xmlbuildFile ); - string objectFilename = GetObjectFilename ( sourceFileLocation, &clean_files ); - string sourceFilenamePart = ReplaceExtension ( GetFilename ( sourceFilename ), "" ); - string rciFilename = ros_temp + module.name + "." + sourceFilenamePart + ".rci.tmp"; - string resFilename = ros_temp + module.name + "." + sourceFilenamePart + ".res.tmp"; + + const FileLocation *objectFilename = GetObjectFilename ( sourceFile, &clean_files ); + if ( module.useWRC ) { + string sourceFilenamePart = module.name + "." + ReplaceExtension ( sourceFile->name, "" ); + FileLocation rciFilename ( TemporaryDirectory, + "", + sourceFilenamePart + ".rci.tmp" ); + FileLocation resFilename ( TemporaryDirectory, + "", + sourceFilenamePart + ".res.tmp" ); + fprintf ( fMakefile, "%s: %s $(WRC_TARGET) | %s\n", - objectFilename.c_str (), + strFile ( objectFilename ).c_str (), dependencies.c_str (), - GetDirectory ( objectFilename ).c_str () ); + strDirectory ( objectFilename ).c_str () ); fprintf ( fMakefile, "\t$(ECHO_WRC)\n" ); fprintf ( fMakefile, "\t${gcc} -xc -E -DRC_INVOKED ${%s} %s > %s\n", windresflagsMacro.c_str (), - sourceFilename.c_str (), - rciFilename.c_str () ); + strFile ( sourceFile ).c_str (), + strFile ( &rciFilename ).c_str () ); fprintf ( fMakefile, "\t$(Q)$(WRC_TARGET) ${%s} %s %s\n", windresflagsMacro.c_str (), - rciFilename.c_str (), - resFilename.c_str () ); + strFile ( &rciFilename ).c_str (), + strFile ( &resFilename ).c_str () ); fprintf ( fMakefile, "\t-@${rm} %s 2>$(NUL)\n", - rciFilename.c_str () ); + strFile ( &rciFilename ).c_str () ); fprintf ( fMakefile, "\t${windres} %s -o $@\n", - resFilename.c_str () ); + strFile ( &resFilename ).c_str () ); fprintf ( fMakefile, "\t-@${rm} %s 2>$(NUL)\n", - resFilename.c_str () ); + strFile ( &resFilename ).c_str () ); } else { fprintf ( fMakefile, "%s: %s $(WRC_TARGET) | %s\n", - objectFilename.c_str (), + strFile ( objectFilename ).c_str (), dependencies.c_str (), - GetDirectory ( objectFilename ).c_str () ); + strDirectory ( objectFilename ).c_str () ); fprintf ( fMakefile, "\t$(ECHO_WRC)\n" ); fprintf ( fMakefile, "\t${windres} $(%s) %s -o $@\n", windresflagsMacro.c_str (), - sourceFilename.c_str () ); + strFile ( sourceFile ).c_str () ); } } void MingwModuleHandler::GenerateWinebuildCommands ( - const FileLocation* sourceFileLocation ) + const FileLocation* sourceFile ) { - string sourceFilename = PassThruCacheDirectory ( sourceFileLocation ); - string dependencies = sourceFilename; + string dependencies = strFile ( sourceFile ); dependencies += " " + NormalizeFilename ( module.xmlbuildFile ); - string basename = GetBasename ( sourceFilename ); - string def_file = PassThruCacheDirectory ( - basename + ".spec.def", - backend->intermediateDirectory ); - CLEAN_FILE(def_file); + string basename = GetBasename ( sourceFile->name ); + FileLocation def_file ( IntermediateDirectory, + sourceFile->relative_path, + basename + ".spec.def" ); + CLEAN_FILE ( &def_file ); - string stub_file = PassThruCacheDirectory ( - basename + ".stubs.c", - backend->intermediateDirectory ); - CLEAN_FILE(stub_file) + FileLocation stub_file ( IntermediateDirectory, + sourceFile->relative_path, + basename + ".stubs.c" ); + CLEAN_FILE ( &stub_file ); fprintf ( fMakefile, "%s: %s $(WINEBUILD_TARGET) | %s\n", - def_file.c_str (), + strFile ( &def_file ).c_str (), dependencies.c_str (), - GetDirectory ( def_file ).c_str () ); + strDirectory ( &def_file ).c_str () ); fprintf ( fMakefile, "\t$(ECHO_WINEBLD)\n" ); fprintf ( fMakefile, "\t%s -o %s --def -E %s\n", "$(Q)$(WINEBUILD_TARGET)", - def_file.c_str (), - sourceFilename.c_str () ); + strFile ( &def_file ).c_str (), + strFile ( sourceFile ).c_str () ); fprintf ( fMakefile, "%s: %s $(WINEBUILD_TARGET)\n", - stub_file.c_str (), - sourceFilename.c_str () ); + strFile ( &stub_file ).c_str (), + strFile ( sourceFile ).c_str () ); fprintf ( fMakefile, "\t$(ECHO_WINEBLD)\n" ); fprintf ( fMakefile, "\t%s -o %s --pedll %s\n", "$(Q)$(WINEBUILD_TARGET)", - stub_file.c_str (), - sourceFilename.c_str () ); + strFile ( &stub_file ).c_str (), + strFile ( sourceFile ).c_str () ); } string @@ -1218,11 +1215,11 @@ MingwModuleHandler::GetPropertyValue ( const Module& module, const std::string& return string ( "" ); } -string -MingwModuleHandler::GetRpcServerHeaderFilename ( string basename ) const +const FileLocation* +MingwModuleHandler::GetRpcServerHeaderFilename ( const FileLocation *base ) const { - return PassThruCacheDirectory ( basename + "_s.h", - backend->intermediateDirectory ); + string newname = GetBasename ( base->name ) + "_s.h"; + return new FileLocation ( IntermediateDirectory, base->relative_path, newname ); } void @@ -1230,50 +1227,49 @@ MingwModuleHandler::GenerateWidlCommandsServer ( const CompilationUnit& compilationUnit, const string& widlflagsMacro ) { - FileLocation* sourceFileLocation = compilationUnit.GetFilename ( backend->intermediateDirectory ); - string filename = sourceFileLocation->filename; - string dependencies = filename; + const FileLocation* sourceFile = compilationUnit.GetFilename (); + string dependencies = strFile ( sourceFile ); dependencies += " " + NormalizeFilename ( module.xmlbuildFile ); - string basename = GetBasename ( filename ); + string basename = GetBasename ( sourceFile->name ); - string generatedHeaderFilename = GetRpcServerHeaderFilename ( basename ); + const FileLocation *generatedHeaderFilename = GetRpcServerHeaderFilename ( sourceFile ); CLEAN_FILE(generatedHeaderFilename); - string generatedServerFilename = PassThruCacheDirectory ( - basename + "_s.c", - backend->intermediateDirectory ); - CLEAN_FILE(generatedServerFilename); + FileLocation generatedServerFilename ( IntermediateDirectory, + sourceFile->relative_path, + basename + "_s.c" ); + CLEAN_FILE(&generatedServerFilename); fprintf ( fMakefile, "%s %s: %s $(WIDL_TARGET) | %s\n", - generatedServerFilename.c_str (), - generatedHeaderFilename.c_str (), + strFile ( &generatedServerFilename ).c_str (), + strFile ( generatedHeaderFilename ).c_str (), dependencies.c_str (), - GetDirectory ( generatedServerFilename ).c_str () ); + strDirectory ( &generatedServerFilename ).c_str () ); fprintf ( fMakefile, "\t$(ECHO_WIDL)\n" ); fprintf ( fMakefile, "\t%s %s %s -h -H %s -s -S %s %s\n", "$(Q)$(WIDL_TARGET)", GetWidlFlags ( compilationUnit ).c_str (), widlflagsMacro.c_str (), - generatedHeaderFilename.c_str (), - generatedServerFilename.c_str (), - filename.c_str () ); + strFile ( generatedHeaderFilename ).c_str (), + strFile ( &generatedServerFilename ).c_str (), + strFile ( sourceFile ).c_str () ); } -string -MingwModuleHandler::GetRpcClientHeaderFilename ( string basename ) const +const FileLocation* +MingwModuleHandler::GetRpcClientHeaderFilename ( const FileLocation *base ) const { - return PassThruCacheDirectory ( basename + "_c.h", - backend->intermediateDirectory ); + string newname = GetBasename ( base->name ) + "_c.h"; + return new FileLocation ( IntermediateDirectory, base->relative_path, newname ); } -string -MingwModuleHandler::GetIdlHeaderFilename ( string basename ) const +const FileLocation* +MingwModuleHandler::GetIdlHeaderFilename ( const FileLocation *base ) const { - return PassThruCacheDirectory ( basename + ".h", - backend->intermediateDirectory ); + string newname = GetBasename ( base->name ) + ".h"; + return new FileLocation ( IntermediateDirectory, base->relative_path, newname ); } void @@ -1281,30 +1277,29 @@ MingwModuleHandler::GenerateWidlCommandsEmbeddedTypeLib ( const CompilationUnit& compilationUnit, const string& widlflagsMacro ) { - FileLocation* sourceFileLocation = compilationUnit.GetFilename ( backend->intermediateDirectory ); - string filename = sourceFileLocation->filename; - string dependencies = filename; + const FileLocation* sourceFile = compilationUnit.GetFilename (); + string dependencies = strFile ( sourceFile ); dependencies += " " + NormalizeFilename ( module.xmlbuildFile ); - string basename = GetBasename ( filename ); + string basename = GetBasename ( sourceFile->name ); - string EmbeddedTypeLibFilename = PassThruCacheDirectory ( - basename + ".tlb", - backend->intermediateDirectory ); + FileLocation EmbeddedTypeLibFilename ( IntermediateDirectory, + sourceFile->relative_path, + basename + ".tlb" ); fprintf ( fMakefile, "%s: %s $(WIDL_TARGET) | %s\n", GetTargetMacro ( module ).c_str (), dependencies.c_str (), - GetDirectory ( EmbeddedTypeLibFilename ).c_str () ); + strDirectory ( &EmbeddedTypeLibFilename ).c_str () ); fprintf ( fMakefile, "\t$(ECHO_WIDL)\n" ); fprintf ( fMakefile, "\t%s %s %s -t -T %s %s\n", "$(Q)$(WIDL_TARGET)", GetWidlFlags ( compilationUnit ).c_str (), widlflagsMacro.c_str (), - EmbeddedTypeLibFilename.c_str(), - filename.c_str () ); + strFile ( &EmbeddedTypeLibFilename ).c_str(), + strFile ( sourceFile ).c_str () ); } void @@ -1312,36 +1307,35 @@ MingwModuleHandler::GenerateWidlCommandsClient ( const CompilationUnit& compilationUnit, const string& widlflagsMacro ) { - FileLocation* sourceFileLocation = compilationUnit.GetFilename ( backend->intermediateDirectory ); - string filename = sourceFileLocation->filename; - string dependencies = filename; + const FileLocation* sourceFile = compilationUnit.GetFilename (); + string dependencies = strFile ( sourceFile ); dependencies += " " + NormalizeFilename ( module.xmlbuildFile ); - string basename = GetBasename ( filename ); + string basename = GetBasename ( sourceFile->name ); - string generatedHeaderFilename = GetRpcClientHeaderFilename ( basename ); + const FileLocation *generatedHeaderFilename = GetRpcClientHeaderFilename ( sourceFile ); CLEAN_FILE(generatedHeaderFilename); - string generatedClientFilename = PassThruCacheDirectory ( - basename + "_c.c", - backend->intermediateDirectory ); - CLEAN_FILE(generatedClientFilename); + FileLocation generatedClientFilename ( IntermediateDirectory, + sourceFile->relative_path, + basename + "_c.c" ); + CLEAN_FILE(&generatedClientFilename); fprintf ( fMakefile, "%s %s: %s $(WIDL_TARGET) | %s\n", - generatedClientFilename.c_str (), - generatedHeaderFilename.c_str (), + strFile ( &generatedClientFilename ).c_str (), + strFile ( generatedHeaderFilename ).c_str (), dependencies.c_str (), - GetDirectory ( generatedClientFilename ).c_str () ); + strDirectory ( &generatedClientFilename ).c_str () ); fprintf ( fMakefile, "\t$(ECHO_WIDL)\n" ); fprintf ( fMakefile, "\t%s %s %s -h -H %s -c -C %s %s\n", "$(Q)$(WIDL_TARGET)", GetWidlFlags ( compilationUnit ).c_str (), widlflagsMacro.c_str (), - generatedHeaderFilename.c_str (), - generatedClientFilename.c_str (), - filename.c_str () ); + strFile ( generatedHeaderFilename ).c_str (), + strFile ( &generatedClientFilename ).c_str (), + strFile ( sourceFile ).c_str () ); } void @@ -1349,29 +1343,28 @@ MingwModuleHandler::GenerateWidlCommandsIdlHeader ( const CompilationUnit& compilationUnit, const string& widlflagsMacro ) { - FileLocation* sourceFileLocation = compilationUnit.GetFilename ( backend->intermediateDirectory ); - string filename = sourceFileLocation->filename; - string dependencies = filename; + const FileLocation* sourceFile = compilationUnit.GetFilename (); + string dependencies = strFile ( sourceFile ); dependencies += " " + NormalizeFilename ( module.xmlbuildFile ); - string basename = GetBasename ( filename ); + string basename = GetBasename ( sourceFile->name ); - string generatedHeaderFilename = GetIdlHeaderFilename ( basename ); - CLEAN_FILE(generatedHeaderFilename); + const FileLocation *generatedHeader = GetIdlHeaderFilename ( sourceFile ); + CLEAN_FILE(generatedHeader); fprintf ( fMakefile, "%s: %s $(WIDL_TARGET) | %s\n", - generatedHeaderFilename.c_str (), + strFile( generatedHeader ).c_str (), dependencies.c_str (), - GetDirectory ( generatedHeaderFilename ).c_str () ); + strDirectory ( generatedHeader ).c_str () ); fprintf ( fMakefile, "\t$(ECHO_WIDL)\n" ); fprintf ( fMakefile, "\t%s %s %s -h -H %s %s\n", "$(Q)$(WIDL_TARGET)", GetWidlFlags ( compilationUnit ).c_str (), widlflagsMacro.c_str (), - generatedHeaderFilename.c_str (), - filename.c_str () ); + strFile( generatedHeader ).c_str (), + strFile ( sourceFile ).c_str () ); } void @@ -1403,12 +1396,12 @@ MingwModuleHandler::GenerateCommands ( const string& windresflagsMacro, const string& widlflagsMacro ) { - FileLocation* sourceFileLocation = compilationUnit.GetFilename ( backend->intermediateDirectory ); - string filename = sourceFileLocation->filename; + const FileLocation* sourceFile = compilationUnit.GetFilename (); + string filename = strFile ( sourceFile ); string extension = GetExtension ( filename ); if ( extension == ".c" || extension == ".C" ) { - GenerateGccCommand ( sourceFileLocation, + GenerateGccCommand ( sourceFile, GetCompilationUnitDependencies ( compilationUnit ), cc, cflagsMacro ); @@ -1418,7 +1411,7 @@ MingwModuleHandler::GenerateCommands ( extension == ".cpp" || extension == ".CPP" || extension == ".cxx" || extension == ".CXX" ) { - GenerateGccCommand ( sourceFileLocation, + GenerateGccCommand ( sourceFile, GetCompilationUnitDependencies ( compilationUnit ), cppc, cflagsMacro ); @@ -1426,27 +1419,27 @@ MingwModuleHandler::GenerateCommands ( } else if ( extension == ".s" || extension == ".S" ) { - GenerateGccAssemblerCommand ( sourceFileLocation, + GenerateGccAssemblerCommand ( sourceFile, cc, cflagsMacro ); return; } else if ( extension == ".asm" || extension == ".ASM" ) { - GenerateNasmCommand ( sourceFileLocation, + GenerateNasmCommand ( sourceFile, nasmflagsMacro ); return; } else if ( extension == ".rc" || extension == ".RC" ) { - GenerateWindresCommand ( sourceFileLocation, + GenerateWindresCommand ( sourceFile, windresflagsMacro ); return; } else if ( extension == ".spec" || extension == ".SPEC" ) { - GenerateWinebuildCommands ( sourceFileLocation ); - GenerateGccCommand ( GetActualSourceFilename ( sourceFileLocation ), + GenerateWinebuildCommands ( sourceFile ); + GenerateGccCommand ( GetActualSourceFilename ( sourceFile ), "", cc, cflagsMacro ); @@ -1458,10 +1451,10 @@ MingwModuleHandler::GenerateCommands ( widlflagsMacro ); if ( (module.type == RpcServer) || (module.type == RpcClient) ) { - GenerateGccCommand ( GetActualSourceFilename ( sourceFileLocation ), - GetExtraDependencies ( filename ), - cc, - cflagsMacro ); + GenerateGccCommand ( GetActualSourceFilename ( sourceFile ), + GetExtraDependencies ( sourceFile ), + cc, + cflagsMacro ); } return; } @@ -1474,22 +1467,22 @@ MingwModuleHandler::GenerateCommands ( } void -MingwModuleHandler::GenerateBuildMapCode ( const char *mapTarget ) +MingwModuleHandler::GenerateBuildMapCode ( const FileLocation *mapTarget ) { fprintf ( fMakefile, "ifeq ($(ROS_BUILDMAP),full)\n" ); - string mapFilename = PassThruCacheDirectory ( - GetBasename ( module.GetPath () ) + ".map", - backend->outputDirectory ); - CLEAN_FILE ( mapFilename ); + FileLocation mapFilename ( OutputDirectory, + module.GetBasePath (), + GetBasename ( module.GetTargetName () ) + ".map" ); + CLEAN_FILE ( &mapFilename ); fprintf ( fMakefile, "\t$(ECHO_OBJDUMP)\n" ); fprintf ( fMakefile, "\t$(Q)${objdump} -d -S %s > %s\n", - mapTarget ? mapTarget : "$@", - mapFilename.c_str () ); + mapTarget ? strFile ( mapTarget ).c_str () : "$@", + strFile ( &mapFilename ).c_str () ); fprintf ( fMakefile, "else\n" ); @@ -1500,8 +1493,8 @@ MingwModuleHandler::GenerateBuildMapCode ( const char *mapTarget ) "\t$(ECHO_NM)\n" ); fprintf ( fMakefile, "\t$(Q)${nm} --numeric-sort %s > %s\n", - mapTarget ? mapTarget : "$@", - mapFilename.c_str () ); + mapTarget ? strFile ( mapTarget ).c_str () : "$@", + strFile ( &mapFilename ).c_str () ); fprintf ( fMakefile, "endif\n" ); @@ -1516,28 +1509,23 @@ MingwModuleHandler::GenerateBuildNonSymbolStrippedCode () fprintf ( fMakefile, "ifeq ($(ROS_BUILDNOSTRIP),yes)\n" ); - string filename = module.GetPath (); - string outputFilename = PassThruCacheDirectory ( - filename, - backend->outputDirectory ); - string nostripFilename = PassThruCacheDirectory ( - GetBasename ( filename ) + ".nostrip" + GetExtension ( filename ), - backend->outputDirectory ); - CLEAN_FILE ( nostripFilename ); + string filename = module.GetTargetName (); + FileLocation outputFilename ( OutputDirectory, + module.GetBasePath (), + filename ); + FileLocation nostripFilename ( OutputDirectory, + module.GetBasePath (), + GetBasename ( filename ) + ".nostrip" + GetExtension ( filename ) ); + CLEAN_FILE ( &nostripFilename ); - fprintf ( fMakefile, - "\t$(ECHO_CP)\n" ); - fprintf ( fMakefile, - "\t${cp} %s %s 1>$(NUL)\n", - outputFilename.c_str (), - nostripFilename.c_str () ); + OutputCopyCommand ( outputFilename, nostripFilename ); fprintf ( fMakefile, "endif\n" ); } void -MergeStringVector ( const vector& input, +MergeStringVector ( const vector& input, vector& output ) { int wrap_at = 25; @@ -1545,8 +1533,6 @@ MergeStringVector ( const vector& input, int wrap_count = -1; for ( size_t i = 0; i < input.size (); i++ ) { - if ( input[i].size () == 0 ) - continue; if ( wrap_count++ == wrap_at ) { output.push_back ( s ); @@ -1555,7 +1541,7 @@ MergeStringVector ( const vector& input, } else if ( s.size () > 0) s += " "; - s += input[i]; + s += strFile ( &input[i] ); } if ( s.length () > 0 ) output.push_back ( s ); @@ -1563,12 +1549,12 @@ MergeStringVector ( const vector& input, void MingwModuleHandler::GetObjectsVector ( const IfableData& data, - vector& objectFiles ) const + vector& objectFiles ) const { for ( size_t i = 0; i < data.compilationUnits.size (); i++ ) { CompilationUnit& compilationUnit = *data.compilationUnits[i]; - objectFiles.push_back ( GetObjectFilename ( compilationUnit.GetFilename ( backend->intermediateDirectory ), NULL ) ); + objectFiles.push_back ( *GetObjectFilename ( compilationUnit.GetFilename (), NULL ) ); } } @@ -1577,7 +1563,7 @@ MingwModuleHandler::GenerateCleanObjectsAsYouGoCode () const { if ( backend->configuration.CleanAsYouGo ) { - vector objectFiles; + vector objectFiles; GetObjectsVector ( module.non_if_data, objectFiles ); vector lines; @@ -1624,8 +1610,8 @@ MingwModuleHandler::GenerateLinkerCommand ( const string& pefixupParameters ) { string target ( GetTargetMacro ( module ) ); - string target_folder ( GetDirectory ( GetTargetFilename ( module, NULL ) ) ); - string definitionFilename = GetDefinitionFilename (); + string target_folder ( strDirectory ( GetTargetFilename ( module, NULL ) ) ); + const FileLocation *definitionFilename = GetDefinitionFilename (); string linkerScriptArgument; if ( module.linkerScript != NULL ) @@ -1636,7 +1622,7 @@ MingwModuleHandler::GenerateLinkerCommand ( fprintf ( fMakefile, "%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n", target.c_str (), - definitionFilename.c_str (), + strFile ( definitionFilename ).c_str (), dependencies.c_str (), target_folder.c_str () ); fprintf ( fMakefile, "\t$(ECHO_LD)\n" ); @@ -1656,14 +1642,16 @@ MingwModuleHandler::GenerateLinkerCommand ( } else if ( module.HasImportLibrary () ) { - string temp_exp = ros_temp + module.name + ".temp.exp"; - CLEAN_FILE ( temp_exp ); + FileLocation temp_exp ( TemporaryDirectory, + "", + module.name + ".temp.exp" ); + CLEAN_FILE ( &temp_exp ); fprintf ( fMakefile, "\t${dlltool} --dllname %s --def %s --output-exp %s %s %s\n", targetName.c_str (), - definitionFilename.c_str (), - temp_exp.c_str (), + strFile ( definitionFilename ).c_str (), + strFile ( &temp_exp ).c_str (), module.mangledSymbols ? "" : "--kill-at", module.underscoreSymbols ? "--add-underscore" : "" ); @@ -1672,7 +1660,7 @@ MingwModuleHandler::GenerateLinkerCommand ( linker.c_str (), linkerParameters.c_str (), linkerScriptArgument.c_str (), - temp_exp.c_str (), + strFile ( &temp_exp ).c_str (), target.c_str (), objectsMacro.c_str (), libsMacro.c_str (), @@ -1685,7 +1673,7 @@ MingwModuleHandler::GenerateLinkerCommand ( fprintf ( fMakefile, "\t-@${rm} %s 2>$(NUL)\n", - temp_exp.c_str () ); + strFile ( &temp_exp ).c_str () ); } else { @@ -1722,7 +1710,7 @@ MingwModuleHandler::GeneratePhonyTarget() const targetMacro.c_str ()); fprintf ( fMakefile, "%s: | %s\n", targetMacro.c_str (), - GetDirectory ( GetTargetFilename ( module, NULL ) ).c_str () ); + strDirectory ( GetTargetFilename ( module, NULL ) ).c_str () ); } void @@ -1789,25 +1777,25 @@ MingwModuleHandler::GenerateObjectFileTargets ( { if ( module.pch && use_pch ) { - const string& baseHeaderFilename = module.pch->file.name; - const string& pchFilename = GetPrecompiledHeaderFilename (); + const FileLocation& baseHeaderFile = module.pch->file; + const FileLocation *pchFilename = GetPrecompiledHeaderFilename (); CLEAN_FILE(pchFilename); - string dependencies = baseHeaderFilename; + string dependencies = strFile ( &baseHeaderFile ); /* WIDL generated headers may be used */ - vector rpcDependencies; + vector rpcDependencies; GetRpcHeaderDependencies ( rpcDependencies ); dependencies += " " + v2s ( rpcDependencies, 5 ); fprintf ( fMakefile, "%s: %s\n", - pchFilename.c_str(), + strFile ( pchFilename ).c_str(), dependencies.c_str() ); fprintf ( fMakefile, "\t$(ECHO_PCH)\n" ); fprintf ( fMakefile, "\t%s -o %s %s -g %s\n\n", module.cplusplus ? cppc.c_str() : cc.c_str(), - pchFilename.c_str(), + strFile ( pchFilename ).c_str(), cflagsMacro.c_str(), - baseHeaderFilename.c_str() ); + strFile ( &baseHeaderFile ).c_str() ); } GenerateObjectFileTargets ( module.non_if_data, @@ -1820,27 +1808,26 @@ MingwModuleHandler::GenerateObjectFileTargets ( fprintf ( fMakefile, "\n" ); } -string +const FileLocation* MingwModuleHandler::GenerateArchiveTarget ( const string& ar, const string& objs_macro ) const { - string archiveFilename ( GetModuleArchiveFilename () ); + const FileLocation *archiveFilename = GetModuleArchiveFilename (); fprintf ( fMakefile, "%s: %s | %s\n", - archiveFilename.c_str (), + strFile ( archiveFilename ).c_str (), objs_macro.c_str (), - GetDirectory(archiveFilename).c_str() ); + strDirectory ( archiveFilename ).c_str() ); if ( module.type == StaticLibrary && module.importLibrary ) { - string archiveFilename ( GetModuleArchiveFilename () ); - string definitionFilename ( GetDefinitionFilename () ); + const FileLocation *definitionFilename ( GetDefinitionFilename () ); fprintf ( fMakefile, "\t${dlltool} --dllname %s --def %s --output-lib $@ %s %s\n", module.importLibrary->dllname.c_str (), - definitionFilename.c_str (), + strFile ( definitionFilename ).c_str (), module.mangledSymbols ? "" : "--kill-at", module.underscoreSymbols ? "--add-underscore" : "" ); } @@ -1898,7 +1885,7 @@ MingwModuleHandler::GetModuleTargets ( const Module& module ) if ( ReferenceObjects ( module ) ) return GetObjectsMacro ( module ); else - return GetTargetFilename ( module, NULL ); + return strFile ( GetTargetFilename ( module, NULL ) ).c_str (); } void @@ -1926,7 +1913,7 @@ MingwModuleHandler::GenerateTargetMacro () void MingwModuleHandler::GetRpcHeaderDependencies ( - vector& dependencies ) const + vector& dependencies ) const { for ( size_t i = 0; i < module.non_if_data.libraries.size (); i++ ) { @@ -1938,17 +1925,17 @@ MingwModuleHandler::GetRpcHeaderDependencies ( for ( size_t j = 0; j < library.importedModule->non_if_data.compilationUnits.size (); j++ ) { CompilationUnit& compilationUnit = *library.importedModule->non_if_data.compilationUnits[j]; - FileLocation* sourceFileLocation = compilationUnit.GetFilename ( backend->intermediateDirectory ); - string extension = GetExtension ( sourceFileLocation->filename ); + const FileLocation* sourceFile = compilationUnit.GetFilename (); + string extension = GetExtension ( sourceFile->name ); if ( extension == ".idl" || extension == ".IDL" ) { - string basename = GetBasename ( sourceFileLocation->filename ); + string basename = GetBasename ( sourceFile->name ); if ( library.importedModule->type == RpcServer ) - dependencies.push_back ( GetRpcServerHeaderFilename ( basename ) ); + dependencies.push_back ( *GetRpcServerHeaderFilename ( sourceFile ) ); if ( library.importedModule->type == RpcClient ) - dependencies.push_back ( GetRpcClientHeaderFilename ( basename ) ); + dependencies.push_back ( *GetRpcClientHeaderFilename ( sourceFile ) ); if ( library.importedModule->type == IdlHeader ) - dependencies.push_back ( GetIdlHeaderFilename ( basename ) ); + dependencies.push_back ( *GetIdlHeaderFilename ( sourceFile ) ); } } } @@ -1971,17 +1958,17 @@ MingwModuleHandler::GenerateOtherMacros () module.non_if_data, &module.linkerFlags ); - vector s; + vector s; if ( module.importLibrary ) { const vector& compilationUnits = module.non_if_data.compilationUnits; for ( size_t i = 0; i < compilationUnits.size (); i++ ) { CompilationUnit& compilationUnit = *compilationUnits[i]; - FileLocation* sourceFileLocation = compilationUnit.GetFilename ( backend->intermediateDirectory ); - string extension = GetExtension ( sourceFileLocation->filename ); + const FileLocation* sourceFile = compilationUnit.GetFilename (); + string extension = GetExtension ( sourceFile->name ); if ( extension == ".spec" || extension == ".SPEC" ) - GetSpecObjectDependencies ( s, sourceFileLocation->filename ); + GetSpecObjectDependencies ( s, sourceFile ); } } if ( s.size () > 0 ) @@ -1993,7 +1980,7 @@ MingwModuleHandler::GenerateOtherMacros () for ( size_t i = 0; i < s.size(); i++ ) fprintf ( fMakefile, " %s", - s[i].c_str () ); + strFile ( &s[i] ).c_str () ); fprintf ( fMakefile, "\n" ); } @@ -2088,14 +2075,15 @@ MingwModuleHandler::GenerateRules () if ( module.name != "zlib" ) /* Avoid make warning */ { - string proxyMakefile = PassThruCacheDirectory ( - NormalizeFilename ( module.GetBasePath () + sSep + "makefile" ), - backend->outputDirectory ); - CLEAN_FILE ( proxyMakefile ); + FileLocation proxyMakefile ( OutputDirectory, + module.GetBasePath (), + "makefile" ); + CLEAN_FILE ( &proxyMakefile ); } string targetMacro = GetTargetMacro ( module ); - CLEAN_FILE ( targetMacro ); + //CLEAN_FILE ( &targetMacro ); + CLEAN_FILE ( new FileLocation ( SourceDirectory, "", targetMacro ) ); // generate phony target for module name fprintf ( fMakefile, ".PHONY: %s\n", @@ -2115,9 +2103,8 @@ MingwModuleHandler::GenerateRules () if ( !ReferenceObjects ( module ) ) { - string ar_target ( GenerateArchiveTarget ( ar, objectsMacro ) ); - if ( targetMacro != ar_target ) - CLEAN_FILE ( ar_target ); + const FileLocation* ar_target = GenerateArchiveTarget ( ar, objectsMacro ); + CLEAN_FILE ( ar_target ); } GenerateObjectFileTargets ( cc, @@ -2221,7 +2208,7 @@ void MingwModuleHandler::GeneratePreconditionDependencies () { string preconditionDependenciesName = GetPreconditionDependenciesName (); - string_list sourceFilenames; + vector sourceFilenames; GetSourceFilenamesWithoutGeneratedFiles ( sourceFilenames ); string_list dependencies; GetDefaultDependencies ( dependencies ); @@ -2245,7 +2232,7 @@ MingwModuleHandler::GeneratePreconditionDependencies () { fprintf ( fMakefile, "%s: ${%s}\n", - sourceFilenames[i].c_str(), + strFile ( &sourceFilenames[i] ).c_str (), preconditionDependenciesName.c_str ()); } fprintf ( fMakefile, "\n" ); @@ -2261,20 +2248,33 @@ MingwModuleHandler::IsWineModule () const return ( index != string::npos ); } -string +const FileLocation* MingwModuleHandler::GetDefinitionFilename () const { if ( module.importLibrary != NULL ) { - string defFilename = module.GetBasePath () + sSep + module.importLibrary->definition; + DirectoryLocation directory; if ( IsWineModule () ) - return PassThruCacheDirectory ( NormalizeFilename ( defFilename ), - backend->intermediateDirectory ); + directory = IntermediateDirectory; else - return defFilename; + directory = SourceDirectory; + + size_t pos = module.importLibrary->definition.find_last_of ( "/\\" ); + if ( pos == string::npos ) + { + return new FileLocation ( directory, + module.GetBasePath (), + module.importLibrary->definition ); + } + + string dir = module.importLibrary->definition.substr ( 0, pos ); + string name = module.importLibrary->definition.substr ( pos + 1); + return new FileLocation ( directory, + NormalizeFilename ( module.GetBasePath () + sSep + dir ), + name ); } else - return "tools" + sSep + "rbuild" + sSep + "empty.def"; + return new FileLocation ( SourceDirectory, "tools" + sSep + "rbuild", "empty.def" ); } void @@ -2282,34 +2282,33 @@ MingwModuleHandler::GenerateImportLibraryTargetIfNeeded () { if ( module.importLibrary != NULL ) { - string library_target ( - GetImportLibraryFilename ( module, &clean_files ) ); - string defFilename = GetDefinitionFilename (); + const FileLocation *library_target = GetImportLibraryFilename ( module, &clean_files ); + const FileLocation *defFilename = GetDefinitionFilename (); - string_list deps; + vector deps; GetDefinitionDependencies ( deps ); fprintf ( fMakefile, "# IMPORT LIBRARY RULE:\n" ); fprintf ( fMakefile, "%s: %s", - library_target.c_str (), - defFilename.c_str () ); + strFile ( library_target ).c_str (), + strFile ( defFilename ).c_str () ); size_t i, iend = deps.size(); for ( i = 0; i < iend; i++ ) fprintf ( fMakefile, " %s", - deps[i].c_str () ); + strFile ( &deps[i] ).c_str () ); fprintf ( fMakefile, " | %s\n", - GetDirectory ( GetImportLibraryFilename ( module, NULL ) ).c_str () ); + strDirectory ( GetImportLibraryFilename ( module, NULL ) ).c_str () ); fprintf ( fMakefile, "\t$(ECHO_DLLTOOL)\n" ); fprintf ( fMakefile, "\t${dlltool} --dllname %s --def %s --output-lib %s %s %s\n\n", module.GetTargetName ().c_str (), - defFilename.c_str (), - library_target.c_str (), + strFile ( defFilename ).c_str (), + strFile ( library_target ).c_str (), module.mangledSymbols ? "" : "--kill-at", module.underscoreSymbols ? "--add-underscore" : "" ); } @@ -2317,50 +2316,52 @@ MingwModuleHandler::GenerateImportLibraryTargetIfNeeded () void MingwModuleHandler::GetSpecObjectDependencies ( - string_list& dependencies, - const string& filename ) const + vector& dependencies, + const FileLocation *file ) const { - string basename = GetBasename ( filename ); - string defDependency = PassThruCacheDirectory ( - NormalizeFilename ( basename + ".spec.def" ), - backend->intermediateDirectory ); + string basename = GetBasename ( file->name ); + + FileLocation defDependency ( IntermediateDirectory, + file->relative_path, + basename + ".spec.def" ); dependencies.push_back ( defDependency ); - string stubsDependency = PassThruCacheDirectory ( - NormalizeFilename ( basename + ".stubs.c" ), - backend->intermediateDirectory ); + + FileLocation stubsDependency ( IntermediateDirectory, + file->relative_path, + basename + ".stubs.c" ); dependencies.push_back ( stubsDependency ); } void MingwModuleHandler::GetWidlObjectDependencies ( - string_list& dependencies, - const string& filename ) const + vector& dependencies, + const FileLocation *file ) const { - string basename = GetBasename ( filename ); - string serverSourceDependency = PassThruCacheDirectory ( - NormalizeFilename ( basename + "_s.c" ), - backend->intermediateDirectory ); + string basename = GetBasename ( file->name ); + + FileLocation serverSourceDependency ( IntermediateDirectory, + file->relative_path, + basename + "_s.c" ); dependencies.push_back ( serverSourceDependency ); - dependencies.push_back ( GetRpcServerHeaderFilename ( basename ) ); + dependencies.push_back ( *GetRpcServerHeaderFilename ( file ) ); } void MingwModuleHandler::GetDefinitionDependencies ( - string_list& dependencies ) const + vector& dependencies ) const { - string dkNkmLibNoFixup = "dk/nkm/lib"; const vector& compilationUnits = module.non_if_data.compilationUnits; for ( size_t i = 0; i < compilationUnits.size (); i++ ) { CompilationUnit& compilationUnit = *compilationUnits[i]; - FileLocation* sourceFileLocation = compilationUnit.GetFilename ( backend->intermediateDirectory ); - string extension = GetExtension ( sourceFileLocation->filename ); + const FileLocation* sourceFile = compilationUnit.GetFilename (); + string extension = GetExtension ( sourceFile->name ); if ( extension == ".spec" || extension == ".SPEC" ) - GetSpecObjectDependencies ( dependencies, sourceFileLocation->filename ); + GetSpecObjectDependencies ( dependencies, sourceFile ); if ( extension == ".idl" || extension == ".IDL" ) { if ( ( module.type == RpcServer ) || ( module.type == RpcClient ) ) - GetWidlObjectDependencies ( dependencies, sourceFileLocation->filename ); + GetWidlObjectDependencies ( dependencies, sourceFile ); } } } @@ -2424,7 +2425,7 @@ MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget () targetMacro.c_str (), objectsMacro.c_str (), linkDepsMacro.c_str (), - GetDirectory(GetTargetFilename(module,NULL)).c_str () ); + strDirectory(GetTargetFilename(module,NULL)).c_str () ); fprintf ( fMakefile, "\t$(ECHO_LD)\n" ); fprintf ( fMakefile, "\t%s %s -o $@ %s %s\n\n", @@ -3049,8 +3050,10 @@ MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget () string targetName ( module.GetTargetName () ); string targetMacro ( GetTargetMacro (module) ); string workingDirectory = GetWorkingDirectory (); - string junk_tmp = ros_temp + module.name + ".junk.tmp"; - CLEAN_FILE ( junk_tmp ); + FileLocation junk_tmp ( TemporaryDirectory, + "", + module.name + ".junk.tmp" ); + CLEAN_FILE ( &junk_tmp ); string objectsMacro = GetObjectsMacro ( module ); string linkDepsMacro = GetLinkingDependenciesMacro (); string libsMacro = GetLibsMacro (); @@ -3061,23 +3064,23 @@ MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget () targetMacro.c_str (), objectsMacro.c_str (), linkDepsMacro.c_str (), - GetDirectory(GetTargetFilename(module,NULL)).c_str () ); + strDirectory(GetTargetFilename(module,NULL)).c_str () ); fprintf ( fMakefile, "\t$(ECHO_LD)\n" ); fprintf ( fMakefile, "\t${ld} %s -N -Ttext=0x8000 -o %s %s %s\n", GetLinkerMacro ().c_str (), - junk_tmp.c_str (), + strFile ( &junk_tmp ).c_str (), objectsMacro.c_str (), linkDepsMacro.c_str () ); fprintf ( fMakefile, "\t${objcopy} -O binary %s $@\n", - junk_tmp.c_str () ); - GenerateBuildMapCode ( junk_tmp.c_str() ); + strFile ( &junk_tmp ).c_str () ); + GenerateBuildMapCode ( &junk_tmp ); fprintf ( fMakefile, "\t-@${rm} %s 2>$(NUL)\n", - junk_tmp.c_str () ); + strFile ( &junk_tmp ).c_str () ); } @@ -3128,12 +3131,18 @@ MingwBootProgramModuleHandler::GenerateBootProgramModuleTarget () string targetName ( module.GetTargetName () ); string targetMacro ( GetTargetMacro (module) ); string workingDirectory = GetWorkingDirectory (); - string junk_tmp = ros_temp + module.name + ".junk.tmp"; - string junk_elf = ros_temp + module.name + ".junk.elf"; - string junk_cpy = ros_temp + module.name + ".junk.cpy"; - CLEAN_FILE ( junk_tmp ); - CLEAN_FILE ( junk_elf ); - CLEAN_FILE ( junk_cpy ); + FileLocation junk_tmp ( TemporaryDirectory, + "", + module.name + ".junk.tmp" ); + FileLocation junk_elf ( TemporaryDirectory, + "", + module.name + ".junk.elf" ); + FileLocation junk_cpy ( TemporaryDirectory, + "", + module.name + ".junk.elf" ); + CLEAN_FILE ( &junk_tmp ); + CLEAN_FILE ( &junk_elf ); + CLEAN_FILE ( &junk_cpy ); string objectsMacro = GetObjectsMacro ( module ); string linkDepsMacro = GetLinkingDependenciesMacro (); string libsMacro = GetLibsMacro (); @@ -3145,35 +3154,35 @@ MingwBootProgramModuleHandler::GenerateBootProgramModuleTarget () targetMacro.c_str (), objectsMacro.c_str (), linkDepsMacro.c_str (), - payload->name.c_str (), - GetDirectory(GetTargetFilename(module,NULL)).c_str () ); + payload->name.c_str (), + strDirectory(GetTargetFilename(module,NULL)).c_str () ); fprintf ( fMakefile, "\t$(ECHO_BOOTPROG)\n" ); fprintf ( fMakefile, "\t$(%s_PREPARE) $(OUTPUT)$(SEP)%s %s\n", module.buildtype.c_str (), NormalizeFilename( payload->GetPath() ).c_str (), - junk_cpy.c_str () ); + strFile ( &junk_cpy ).c_str () ); fprintf ( fMakefile, "\t${objcopy} $(%s_FLATFORMAT) %s %s\n", module.buildtype.c_str (), - junk_cpy.c_str (), - junk_tmp.c_str () ); + strFile ( &junk_cpy ).c_str (), + strFile ( &junk_tmp ).c_str () ); fprintf ( fMakefile, "\t${ld} $(%s_LINKFORMAT) %s %s -g -o %s\n", module.buildtype.c_str (), linkDepsMacro.c_str (), - junk_tmp.c_str (), - junk_elf.c_str () ); + strFile ( &junk_tmp ).c_str (), + strFile ( &junk_elf ).c_str () ); fprintf ( fMakefile, "\t${objcopy} $(%s_COPYFORMAT) %s $(INTERMEDIATE)$(SEP)%s\n", module.buildtype.c_str (), - junk_elf.c_str (), + strFile ( &junk_elf ).c_str (), module.GetPath().c_str () ); fprintf ( fMakefile, "\t-@${rm} %s %s %s 2>$(NUL)\n", - junk_tmp.c_str (), junk_elf.c_str (), junk_cpy.c_str () ); + strFile ( &junk_tmp ).c_str (), strFile ( &junk_elf ).c_str (), strFile ( &junk_cpy ).c_str () ); } @@ -3201,19 +3210,13 @@ MingwIsoModuleHandler::OutputBootstrapfileCopyCommands ( continue; if ( m.bootstrap != NULL ) { - string sourceFilename = PassThruCacheDirectory ( - NormalizeFilename ( m.GetPath () ), - backend->outputDirectory ); - string targetFilenameNoFixup ( bootcdDirectory + sSep + m.bootstrap->base + sSep + m.bootstrap->nameoncd ); - string targetFilename = MingwModuleHandler::PassThruCacheDirectory ( - NormalizeFilename ( targetFilenameNoFixup ), - backend->outputDirectory ); - fprintf ( fMakefile, - "\t$(ECHO_CP)\n" ); - fprintf ( fMakefile, - "\t${cp} %s %s 1>$(NUL)\n", - sourceFilename.c_str (), - targetFilename.c_str () ); + FileLocation sourceFile ( OutputDirectory, + m.GetBasePath (), + m.GetTargetName () ); + FileLocation targetFile ( OutputDirectory, + bootcdDirectory + sSep + m.bootstrap->base, + m.bootstrap->nameoncd ); + OutputCopyCommand ( sourceFile, targetFile ); } } } @@ -3225,23 +3228,19 @@ MingwIsoModuleHandler::OutputCdfileCopyCommands ( for ( size_t i = 0; i < module.project.cdfiles.size (); i++ ) { const CDFile& cdfile = *module.project.cdfiles[i]; - string targetFilenameNoFixup = bootcdDirectory + sSep + cdfile.base + sSep + cdfile.nameoncd; - string targetFilename = MingwModuleHandler::PassThruCacheDirectory ( - NormalizeFilename ( targetFilenameNoFixup ), - backend->outputDirectory ); - fprintf ( fMakefile, - "\t$(ECHO_CP)\n" ); - fprintf ( fMakefile, - "\t${cp} %s %s 1>$(NUL)\n", - cdfile.GetPath ().c_str (), - targetFilename.c_str () ); + FileLocation targetFile ( OutputDirectory, + cdfile.target->relative_path.length () > 0 + ? bootcdDirectory + sSep + cdfile.target->relative_path + : bootcdDirectory, + cdfile.target->name ); + OutputCopyCommand ( *cdfile.source, targetFile ); } } -string -MingwIsoModuleHandler::GetBootstrapCdDirectories ( const string& bootcdDirectory ) +void +MingwIsoModuleHandler::GetBootstrapCdDirectories ( vector& out, + const string& bootcdDirectory ) { - string directories; for ( size_t i = 0; i < module.project.modules.size (); i++ ) { const Module& m = *module.project.modules[i]; @@ -3249,45 +3248,41 @@ MingwIsoModuleHandler::GetBootstrapCdDirectories ( const string& bootcdDirectory continue; if ( m.bootstrap != NULL ) { - string targetDirectory ( bootcdDirectory + sSep + m.bootstrap->base ); - if ( directories.size () > 0 ) - directories += " "; - directories += PassThruCacheDirectory ( - NormalizeFilename ( targetDirectory ), - backend->outputDirectory ); + FileLocation targetDirectory ( OutputDirectory, + bootcdDirectory + sSep + m.bootstrap->base, + "" ); + out.push_back ( targetDirectory ); } } - return directories; } -string -MingwIsoModuleHandler::GetNonModuleCdDirectories ( const string& bootcdDirectory ) +void +MingwIsoModuleHandler::GetNonModuleCdDirectories ( vector& out, + const string& bootcdDirectory ) { - string directories; for ( size_t i = 0; i < module.project.cdfiles.size (); i++ ) { const CDFile& cdfile = *module.project.cdfiles[i]; - string targetDirectory ( bootcdDirectory + sSep + cdfile.base ); - if ( directories.size () > 0 ) - directories += " "; - directories += PassThruCacheDirectory ( - NormalizeFilename ( targetDirectory ), - backend->outputDirectory ); + FileLocation targetDirectory ( OutputDirectory, + cdfile.target->relative_path.length () > 0 + ? bootcdDirectory + sSep + cdfile.target->relative_path + : bootcdDirectory, + "" ); + out.push_back( targetDirectory ); } - return directories; } -string -MingwIsoModuleHandler::GetCdDirectories ( const string& bootcdDirectory ) +void +MingwIsoModuleHandler::GetCdDirectories ( vector& out, + const string& bootcdDirectory ) { - string directories = GetBootstrapCdDirectories ( bootcdDirectory ); - directories += " " + GetNonModuleCdDirectories ( bootcdDirectory ); - return directories; + GetBootstrapCdDirectories ( out, bootcdDirectory ); + GetNonModuleCdDirectories ( out, bootcdDirectory ); } void MingwIsoModuleHandler::GetBootstrapCdFiles ( - vector& out ) const + vector& out ) const { for ( size_t i = 0; i < module.project.modules.size (); i++ ) { @@ -3296,28 +3291,28 @@ MingwIsoModuleHandler::GetBootstrapCdFiles ( continue; if ( m.bootstrap != NULL ) { - string filename = PassThruCacheDirectory ( - NormalizeFilename ( m.GetPath () ), - backend->outputDirectory ); - out.push_back ( filename ); + FileLocation file ( OutputDirectory, + m.GetBasePath (), + m.GetTargetName () ); + out.push_back ( file ); } } } void MingwIsoModuleHandler::GetNonModuleCdFiles ( - vector& out ) const + vector& out ) const { for ( size_t i = 0; i < module.project.cdfiles.size (); i++ ) { const CDFile& cdfile = *module.project.cdfiles[i]; - out.push_back ( cdfile.GetPath () ); + out.push_back ( *cdfile.source ); } } void MingwIsoModuleHandler::GetCdFiles ( - vector& out ) const + vector& out ) const { GetBootstrapCdFiles ( out ); GetNonModuleCdFiles ( out ); @@ -3327,86 +3322,92 @@ void MingwIsoModuleHandler::GenerateIsoModuleTarget () { string bootcdDirectory = "cd"; - string srcunattend = NormalizeFilename("boot/bootdata/bootcdregtest/unattend.inf"); - string tarunattend = NormalizeFilename("$(OUTPUT)/cd/reactos/unattend.inf"); + FileLocation bootcd ( OutputDirectory, + bootcdDirectory, + "" ); + FileLocation bootcdReactos ( OutputDirectory, + bootcdDirectory + sSep + Environment::GetCdOutputPath (), + "" ); + vector vSourceFiles, vCdFiles; + vector vCdDirectories; - vector vCdFiles; - string bootcd = PassThruCacheDirectory ( - NormalizeFilename ( bootcdDirectory + sSep ), - backend->outputDirectory ); + // unattend.inf + FileLocation srcunattend ( SourceDirectory, + "boot" + sSep + "bootdata" + sSep + "bootcdregtest", + "unattend.inf" ); + FileLocation tarunattend ( bootcdReactos.directory, + bootcdReactos.relative_path, + "unattend.inf" ); + if (module.type == IsoRegTest) + vSourceFiles.push_back ( srcunattend ); + + // bootsector + FileLocation isoboot ( OutputDirectory, + "boot" + sSep + "freeldr" + sSep + "bootsect", + module.type == IsoRegTest + ? "isobtrt.o" + : "isoboot.o" ); + vSourceFiles.push_back ( isoboot ); + + // prepare reactos.dff and reactos.inf + FileLocation reactosDff ( SourceDirectory, + "boot" + sSep + "bootdata" + sSep + "packages", + "reactos.dff" ); + FileLocation reactosInf ( TemporaryDirectory, + "", + "reactos.inf" ); + vSourceFiles.push_back ( reactosDff ); - string bootloader; string IsoName; if (module.type == IsoRegTest) - { - vCdFiles.push_back (srcunattend.c_str ()); - bootloader = "isobtrt.o"; IsoName = "ReactOS-RegTest.iso"; - } else - { - bootloader = "isoboot.o"; IsoName = "ReactOS.iso"; - } - string isoboot = PassThruCacheDirectory ( - NormalizeFilename ( "boot" + sSep + "freeldr" + sSep + "bootsect" + sSep + bootloader.c_str() ), - backend->outputDirectory ); - string bootcdReactosNoFixup = bootcdDirectory + sSep + Environment::GetCdOutputPath (); - string bootcdReactos = PassThruCacheDirectory ( - NormalizeFilename ( bootcdReactosNoFixup + sSep ), - backend->outputDirectory ); - CLEAN_FILE ( bootcdReactos ); - string reactosInf = PassThruCacheDirectory ( - NormalizeFilename ( bootcdReactosNoFixup + sSep + "reactos.inf" ), - backend->outputDirectory ); - string reactosDff = NormalizeFilename ( "boot" + sSep + "bootdata" + sSep + "packages" + sSep + "reactos.dff" ); - string cdDirectories = GetCdDirectories ( bootcdDirectory ); + string sourceFiles = v2s ( vSourceFiles, 5 ); + + // fill cdrom + GetCdDirectories ( vCdDirectories, bootcdDirectory ); GetCdFiles ( vCdFiles ); + string cdDirectories = v2s ( vCdDirectories, 5 ); string cdFiles = v2s ( vCdFiles, 5 ); fprintf ( fMakefile, ".PHONY: %s\n\n", module.name.c_str ()); fprintf ( fMakefile, - "%s: all %s %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET)\n", + "%s: all %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET) | %s\n", module.name.c_str (), - isoboot.c_str (), - bootcdReactos.c_str (), - cdDirectories.c_str (), - cdFiles.c_str () ); + strFile ( &isoboot ).c_str (), + sourceFiles.c_str (), + cdFiles.c_str (), + cdDirectories.c_str () ); fprintf ( fMakefile, "\t$(ECHO_CABMAN)\n" ); fprintf ( fMakefile, "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n", - reactosDff.c_str (), - bootcdReactos.c_str () ); + strFile ( &reactosDff ).c_str (), + strDirectory ( &bootcdReactos ).c_str () ); fprintf ( fMakefile, "\t$(Q)$(CABMAN_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n", - reactosDff.c_str (), - reactosInf.c_str (), - bootcdReactos.c_str ()); + strFile ( &reactosDff ).c_str (), + strFile ( &reactosInf ).c_str (), + strDirectory ( &bootcdReactos ).c_str ()); fprintf ( fMakefile, "\t-@${rm} %s 2>$(NUL)\n", - reactosInf.c_str () ); + strFile ( &reactosInf ).c_str () ); OutputBootstrapfileCopyCommands ( bootcdDirectory ); OutputCdfileCopyCommands ( bootcdDirectory ); + if (module.type == IsoRegTest) - { - fprintf ( fMakefile, - "\t$(ECHO_CP)\n" ); - fprintf ( fMakefile, - "\t${cp} %s %s 1>$(NUL)\n", - srcunattend.c_str (), - tarunattend.c_str () ); - } + OutputCopyCommand ( srcunattend, tarunattend ); fprintf ( fMakefile, "\t$(ECHO_CDMAKE)\n" ); fprintf ( fMakefile, "\t$(Q)$(CDMAKE_TARGET) -v -j -m -b %s %s REACTOS %s\n", - isoboot.c_str (), - bootcd.c_str (), - IsoName.c_str() ); + strFile ( &isoboot ).c_str (), + strDirectory ( &bootcd ).c_str (), + IsoName.c_str() ); fprintf ( fMakefile, "\n" ); } @@ -3428,25 +3429,10 @@ MingwLiveIsoModuleHandler::Process () void MingwLiveIsoModuleHandler::CreateDirectory ( const string& directory ) { - string normalizedDirectory = MingwModuleHandler::PassThruCacheDirectory ( - NormalizeFilename ( directory ) + sSep, - backend->outputDirectory ); -} - -void -MingwLiveIsoModuleHandler::OutputCopyCommand ( const string& sourceFilename, - const string& targetFilename, - const string& targetDirectory ) -{ - string normalizedTargetFilename = MingwModuleHandler::PassThruCacheDirectory ( - NormalizeFilename ( targetDirectory + sSep + targetFilename ), - backend->outputDirectory ); - fprintf ( fMakefile, - "\t$(ECHO_CP)\n" ); - fprintf ( fMakefile, - "\t${cp} %s %s 1>$(NUL)\n", - sourceFilename.c_str (), - normalizedTargetFilename.c_str () ); + FileLocation dir ( OutputDirectory, + directory, + "" ); + MingwModuleHandler::PassThruCacheDirectory ( &dir ); } void @@ -3461,12 +3447,16 @@ MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string& livecdDirectory, if ( m.installName.length () > 0 ) { const Module& aliasedModule = backend->GetAliasedModuleOrModule ( m ); - string sourceFilename = MingwModuleHandler::PassThruCacheDirectory ( - NormalizeFilename ( aliasedModule.GetPath () ), - backend->outputDirectory ); - OutputCopyCommand ( sourceFilename, - m.installName, - livecdDirectory + sSep + reactosDirectory + sSep + m.installBase ); + FileLocation source ( OutputDirectory, + aliasedModule.GetBasePath (), + aliasedModule.GetTargetName () ); + FileLocation destination ( OutputDirectory, + m.installBase.length () > 0 + ? livecdDirectory + sSep + reactosDirectory + sSep + m.installBase + : livecdDirectory + sSep + reactosDirectory, + m.installName ); + OutputCopyCommand ( source, + destination); } } } @@ -3478,9 +3468,12 @@ MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string& livecdDirectory for ( size_t i = 0; i < module.project.installfiles.size (); i++ ) { const InstallFile& installfile = *module.project.installfiles[i]; - OutputCopyCommand ( installfile.GetPath (), - installfile.newname, - livecdDirectory + sSep + reactosDirectory + sSep + installfile.base ); + FileLocation target ( OutputDirectory, + installfile.target->relative_path.length () > 0 + ? livecdDirectory + sSep + reactosDirectory + sSep + installfile.target->relative_path + : livecdDirectory + sSep + reactosDirectory, + installfile.target->name ); + OutputCopyCommand ( *installfile.source, target ); } } @@ -3494,36 +3487,40 @@ MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string& livecdDirec CreateDirectory ( livecdDirectory + sSep + "Profiles" + sSep + "Default User" + sSep + "Desktop" ); CreateDirectory ( livecdDirectory + sSep + "Profiles" + sSep + "Default User" + sSep + "My Documents" ); - string livecdIni = "boot" + sSep + "bootdata" + sSep + "livecd.ini"; + FileLocation livecdIni ( SourceDirectory, + "boot" + sSep + "bootdata", + "livecd.ini" ); + FileLocation destination ( OutputDirectory, + livecdDirectory, + "freeldr.ini" ); OutputCopyCommand ( livecdIni, - "freeldr.ini", - livecdDirectory ); + destination ); } void MingwLiveIsoModuleHandler::OutputLoaderCommands ( string& livecdDirectory ) { - string freeldr = PassThruCacheDirectory ( - NormalizeFilename ( "boot" + sSep + "freeldr" + sSep + "freeldr" + sSep + "freeldr.sys" ), - backend->outputDirectory ); - CreateDirectory ( livecdDirectory + sSep + "loader" ); + FileLocation freeldr ( OutputDirectory, + "boot" + sSep + "freeldr" + sSep + "freeldr", + "freeldr.sys" ); + FileLocation destination ( OutputDirectory, + livecdDirectory + sSep + "loader", + "setupldr.sys" ); OutputCopyCommand ( freeldr, - "setupldr.sys", - livecdDirectory + sSep + "loader" ); + destination ); } void MingwLiveIsoModuleHandler::OutputRegistryCommands ( string& livecdDirectory ) { - string reactosSystem32ConfigDirectory = NormalizeFilename ( - MingwModuleHandler::PassThruCacheDirectory ( - livecdDirectory + sSep + "reactos" + sSep + "system32" + sSep + "config" + sSep, - backend->outputDirectory ) ); + FileLocation reactosSystem32ConfigDirectory ( OutputDirectory, + livecdDirectory + sSep + "reactos" + sSep + "system32" + sSep + "config", + "" ); fprintf ( fMakefile, "\t$(ECHO_MKHIVE)\n" ); fprintf ( fMakefile, "\t$(MKHIVE_TARGET) boot%cbootdata %s boot%cbootdata%clivecd.inf boot%cbootdata%chiveinst.inf\n", - cSep, reactosSystem32ConfigDirectory.c_str (), + cSep, strDirectory ( &reactosSystem32ConfigDirectory ).c_str (), cSep, cSep, cSep, cSep ); } @@ -3531,9 +3528,7 @@ void MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget () { string livecdDirectory = module.name; - string livecd = PassThruCacheDirectory ( - NormalizeFilename ( livecdDirectory + sSep ), - backend->outputDirectory ); + FileLocation livecd ( OutputDirectory, livecdDirectory, "" ); string bootloader; string IsoName; @@ -3549,24 +3544,22 @@ MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget () IsoName = "ReactOS-LiveCD.iso"; } - string isoboot = PassThruCacheDirectory ( - NormalizeFilename ( "boot" + sSep + "freeldr" + sSep + "bootsect" + sSep + bootloader.c_str() ), - backend->outputDirectory ); + FileLocation isoboot ( OutputDirectory, "boot" + sSep + "freeldr" + sSep + "bootsect", bootloader ); string reactosDirectory = "reactos"; string livecdReactosNoFixup = livecdDirectory + sSep + reactosDirectory; - string livecdReactos = NormalizeFilename ( PassThruCacheDirectory ( - NormalizeFilename ( livecdReactosNoFixup + sSep ), - backend->outputDirectory ) ); - CLEAN_FILE ( livecdReactos ); + FileLocation livecdReactos ( OutputDirectory, + livecdReactosNoFixup, + "" ); + CLEAN_FILE ( &livecdReactos ); fprintf ( fMakefile, ".PHONY: %s\n\n", module.name.c_str ()); fprintf ( fMakefile, "%s: all %s %s $(MKHIVE_TARGET) $(CDMAKE_TARGET)\n", module.name.c_str (), - isoboot.c_str (), - livecdReactos.c_str () ); + strFile ( &isoboot) .c_str (), + strDirectory ( &livecdReactos ).c_str () ); OutputModuleCopyCommands ( livecdDirectory, reactosDirectory ); OutputNonModuleCopyCommands ( livecdDirectory, @@ -3577,9 +3570,9 @@ MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget () fprintf ( fMakefile, "\t$(ECHO_CDMAKE)\n" ); fprintf ( fMakefile, "\t$(Q)$(CDMAKE_TARGET) -v -m -j -b %s %s REACTOS %s\n", - isoboot.c_str (), - livecd.c_str (), - IsoName.c_str() ); + strFile( &isoboot ).c_str (), + strDirectory ( &livecd ).c_str (), + IsoName.c_str() ); fprintf ( fMakefile, "\n" ); } @@ -3723,7 +3716,7 @@ MingwElfExecutableModuleHandler::Process () targetMacro.c_str (), objectsMacro.c_str (), linkDepsMacro.c_str (), - GetDirectory(GetTargetFilename(module,NULL)).c_str () ); + strDirectory(GetTargetFilename(module,NULL)).c_str () ); fprintf ( fMakefile, "\t$(ECHO_BOOTPROG)\n" ); diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.h b/reactos/tools/rbuild/backend/mingw/modulehandler.h index d1309d32589..417971dd753 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.h +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.h @@ -41,21 +41,16 @@ public: static void SetMakefile ( FILE* f ); void EnablePreCompiledHeaderSupport (); - static std::string PassThruCacheDirectory ( - const std::string &f, - Directory* directoryTree ); + static const FileLocation* PassThruCacheDirectory (const FileLocation* fileLocation ); - static std::string PassThruCacheDirectory (const FileLocation* fileLocation ); - - static Directory* GetTargetDirectoryTree ( + static DirectoryLocation GetTargetDirectoryTree ( const Module& module ); - static std::string GetTargetFilename ( + static const FileLocation* GetTargetFilename ( const Module& module, string_list* pclean_files ); - static std::string - GetImportLibraryFilename ( + static const FileLocation* GetImportLibraryFilename ( const Module& module, string_list* pclean_files ); @@ -64,7 +59,7 @@ public: std::string GetModuleTargets ( const Module& module ); void GetObjectsVector ( const IfableData& data, - std::vector& objectFiles ) const; + std::vector& objectFiles ) const; void GenerateObjectMacro(); void GenerateTargetMacro(); void GenerateOtherMacros(); @@ -83,25 +78,28 @@ public: void GenerateDependsTarget () const; static bool ReferenceObjects ( const Module& module ); virtual void AddImplicitLibraries ( Module& module ) { return; } + + void OutputCopyCommand ( const FileLocation& source, + const FileLocation& destination ); protected: virtual void GetModuleSpecificCompilationUnits ( std::vector& compilationUnits ); std::string GetWorkingDirectory () const; std::string GetBasename ( const std::string& filename ) const; - FileLocation* GetActualSourceFilename ( const FileLocation* fileLocation ) const; - std::string GetExtraDependencies ( const std::string& filename ) const; + const FileLocation* GetActualSourceFilename ( const FileLocation* file ) const; + std::string GetExtraDependencies ( const FileLocation *file ) const; std::string GetCompilationUnitDependencies ( const CompilationUnit& compilationUnit ) const; - std::string GetModuleArchiveFilename () const; + const FileLocation* GetModuleArchiveFilename () const; bool IsGeneratedFile ( const File& file ) const; std::string GetImportLibraryDependency ( const Module& importedModule ); void GetTargets ( const Module& dependencyModule, string_list& targets ); void GetModuleDependencies ( string_list& dependencies ); std::string GetAllDependencies () const; - void GetSourceFilenames ( string_list& list, + void GetSourceFilenames ( std::vector& list, bool includeGeneratedFiles ) const; - void GetSourceFilenamesWithoutGeneratedFiles ( string_list& list ) const; - std::string GetObjectFilename ( const FileLocation* sourceFileLocation, - string_list* pclean_files ) const; + void GetSourceFilenamesWithoutGeneratedFiles ( std::vector& list ) const; + const FileLocation* GetObjectFilename ( const FileLocation* sourceFile, + string_list* pclean_files ) const; std::string GetObjectFilenames (); @@ -121,10 +119,10 @@ protected: const std::string& libsMacro, const std::string& pefixupParameters ); void GeneratePhonyTarget() const; - void GenerateBuildMapCode ( const char *mapTarget = NULL ); + void GenerateBuildMapCode ( const FileLocation *mapTarget = NULL ); void GenerateRules (); void GenerateImportLibraryTargetIfNeeded (); - void GetDefinitionDependencies ( string_list& dependencies ) const; + void GetDefinitionDependencies ( std::vector& dependencies ) const; std::string GetLinkingDependencies () const; static MingwBackend* backend; @@ -150,19 +148,19 @@ private: std::string GenerateGccIncludeParameters () const; std::string GenerateGccParameters () const; std::string GenerateNasmParameters () const; - std::string GetPrecompiledHeaderFilename () const; - void GenerateGccCommand ( const FileLocation* sourceFileLocation, + const FileLocation* GetPrecompiledHeaderFilename () const; + void GenerateGccCommand ( const FileLocation* sourceFile, const std::string& extraDependencies, const std::string& cc, const std::string& cflagsMacro ); - void GenerateGccAssemblerCommand ( const FileLocation* sourceFileLocation, + void GenerateGccAssemblerCommand ( const FileLocation* sourceFile, const std::string& cc, const std::string& cflagsMacro ); - void GenerateNasmCommand ( const FileLocation* sourceFileLocation, + void GenerateNasmCommand ( const FileLocation* sourceFile, const std::string& nasmflagsMacro ); - void GenerateWindresCommand ( const FileLocation* sourceFileLocation, + void GenerateWindresCommand ( const FileLocation* sourceFile, const std::string& windresflagsMacro ); - void GenerateWinebuildCommands ( const FileLocation* sourceFileLocation ); + void GenerateWinebuildCommands ( const FileLocation* sourceFile ); std::string GetWidlFlags ( const CompilationUnit& compilationUnit ); void GenerateWidlCommandsServer ( const CompilationUnit& compilationUnit, @@ -198,24 +196,23 @@ private: const std::string& nasmflagsMacro, const std::string& windresflagsMacro, const std::string& widlflagsMacro ); - std::string GenerateArchiveTarget ( const std::string& ar, - const std::string& objs_macro ) const; - void GetSpecObjectDependencies ( string_list& dependencies, - const std::string& filename ) const; - void GetWidlObjectDependencies ( string_list& dependencies, - const std::string& filename ) const; + const FileLocation* GenerateArchiveTarget ( const std::string& ar, + const std::string& objs_macro ) const; + void GetSpecObjectDependencies ( std::vector& dependencies, + const FileLocation *file ) const; + void GetWidlObjectDependencies ( std::vector& dependencies, + const FileLocation *file ) const; void GetDefaultDependencies ( string_list& dependencies ) const; void GetInvocationDependencies ( const Module& module, string_list& dependencies ); bool IsWineModule () const; - std::string GetDefinitionFilename () const; - static std::string RemoveVariables ( std::string path); + const FileLocation* GetDefinitionFilename () const; void GenerateBuildNonSymbolStrippedCode (); void CleanupCompilationUnitVector ( std::vector& compilationUnits ); - void GetRpcHeaderDependencies ( std::vector& dependencies ) const; + void GetRpcHeaderDependencies ( std::vector& dependencies ) const; static std::string GetPropertyValue ( const Module& module, const std::string& name ); - std::string GetRpcServerHeaderFilename ( std::string basename ) const; - std::string GetRpcClientHeaderFilename ( std::string basename ) const; - std::string GetIdlHeaderFilename ( std::string basename ) const; + const FileLocation* GetRpcServerHeaderFilename ( const FileLocation *base ) const; + const FileLocation* GetRpcClientHeaderFilename ( const FileLocation *base ) const; + const FileLocation* GetIdlHeaderFilename ( const FileLocation *base ) const; std::string GetModuleCleanTarget ( const Module& module ) const; void GetReferencedObjectLibraryModuleCleanTargets ( std::vector& moduleNames ) const; public: @@ -427,12 +424,12 @@ public: virtual void Process (); private: void GenerateIsoModuleTarget (); - std::string GetBootstrapCdDirectories ( const std::string& bootcdDirectory ); - std::string GetNonModuleCdDirectories ( const std::string& bootcdDirectory ); - std::string GetCdDirectories ( const std::string& bootcdDirectory ); - void GetBootstrapCdFiles ( std::vector& out ) const; - void GetNonModuleCdFiles ( std::vector& out ) const; - void GetCdFiles ( std::vector& out ) const; + void GetBootstrapCdDirectories ( std::vector& out, const std::string& bootcdDirectory ); + void GetNonModuleCdDirectories ( std::vector& out, const std::string& bootcdDirectory ); + void GetCdDirectories ( std::vector& out, const std::string& bootcdDirectory ); + void GetBootstrapCdFiles ( std::vector& out ) const; + void GetNonModuleCdFiles ( std::vector& out ) const; + void GetCdFiles ( std::vector& out ) const; void OutputBootstrapfileCopyCommands ( const std::string& bootcdDirectory ); void OutputCdfileCopyCommands ( const std::string& bootcdDirectory ); }; @@ -447,9 +444,6 @@ public: private: void GenerateLiveIsoModuleTarget (); void CreateDirectory ( const std::string& directory ); - void OutputCopyCommand ( const std::string& sourceFilename, - const std::string& targetFilename, - const std::string& targetDirectory ); void OutputModuleCopyCommands ( std::string& livecdDirectory, std::string& livecdReactos ); void OutputNonModuleCopyCommands ( std::string& livecdDirectory, diff --git a/reactos/tools/rbuild/backend/mingw/proxymakefile.cpp b/reactos/tools/rbuild/backend/mingw/proxymakefile.cpp index 9c4b5fc9406..3b409ec2b35 100644 --- a/reactos/tools/rbuild/backend/mingw/proxymakefile.cpp +++ b/reactos/tools/rbuild/backend/mingw/proxymakefile.cpp @@ -100,7 +100,6 @@ ProxyMakefile::GenerateProxyMakefileForModule ( Module& module, if ( outputTree.length () > 0 ) { base = outputTree + sSep + module.GetBasePath (); - Path path; pathToTopDirectory = working_directory; } else @@ -122,7 +121,7 @@ ProxyMakefile::GenerateProxyMakefileForModule ( Module& module, s = s + sprintf ( s, "DEFAULT = %s\n", defaultTarget.c_str () ); s = s + sprintf ( s, "include $(TOP)/proxy.mak\n" ); - FileSupportCode::WriteIfChanged ( buf, proxyMakefile ); + FileSupportCode::WriteIfChanged ( buf, proxyMakefile, true ); free ( buf ); } diff --git a/reactos/tools/rbuild/cdfile.cpp b/reactos/tools/rbuild/cdfile.cpp index 19a3f213dc1..fb5769bb6ba 100644 --- a/reactos/tools/rbuild/cdfile.cpp +++ b/reactos/tools/rbuild/cdfile.cpp @@ -34,38 +34,24 @@ CDFile::ReplaceVariable ( const string& name, return path; } -CDFile::CDFile ( const Project& project_, - const XMLElement& cdfileNode, - const string& path ) - : project ( project_ ), - node ( cdfileNode ) +CDFile::CDFile ( const Project& project, + const XMLElement& cdfileNode, + const string& path ) + : XmlNode ( project, cdfileNode ) { - const XMLAttribute* att = node.GetAttribute ( "base", false ); + const XMLAttribute* att = cdfileNode.GetAttribute ( "base", false ); + string target_relative_directory; if ( att != NULL ) - base = ReplaceVariable ( "$(CDOUTPUT)", Environment::GetCdOutputPath (), att->value ); + target_relative_directory = ReplaceVariable ( "$(CDOUTPUT)", Environment::GetCdOutputPath (), att->value ); else - base = ""; + target_relative_directory = ""; - att = node.GetAttribute ( "nameoncd", false ); - if ( att != NULL ) - nameoncd = att->value; - else - nameoncd = node.value; - name = node.value; - this->path = path; -} + const XMLAttribute* nameoncd = cdfileNode.GetAttribute ( "nameoncd", false ); -CDFile::~CDFile () -{ -} - -string -CDFile::GetPath () const -{ - return path + sSep + name; -} - -void -CDFile::ProcessXML() -{ + source = new FileLocation ( SourceDirectory, + path, + cdfileNode.value ); + target = new FileLocation ( OutputDirectory, + target_relative_directory, + nameoncd ? att->value : cdfileNode.value ); } diff --git a/reactos/tools/rbuild/compilationunit.cpp b/reactos/tools/rbuild/compilationunit.cpp index 022a43911c6..c74029d14e4 100644 --- a/reactos/tools/rbuild/compilationunit.cpp +++ b/reactos/tools/rbuild/compilationunit.cpp @@ -28,6 +28,7 @@ CompilationUnit::CompilationUnit ( File* file ) module(NULL), node(NULL) { + local_name = file->name; name = file->name; files.push_back ( file ); } @@ -41,6 +42,7 @@ CompilationUnit::CompilationUnit ( const Project* project, { const XMLAttribute* att = node->GetAttribute ( "name", true ); assert(att); + local_name = att->value; name = module->GetBasePath () + cSep + att->value; } @@ -92,16 +94,40 @@ CompilationUnit::IsFirstFile () const return file->first; } -FileLocation* -CompilationUnit::GetFilename ( Directory* intermediateDirectory ) const + +const FileLocation* +CompilationUnit::GetFilename () const { if ( files.size () == 0 || files.size () > 1 ) - return new FileLocation ( intermediateDirectory, name ); + { + return new FileLocation ( IntermediateDirectory, + module ? module->GetBasePath () : "", + local_name ); + } + File* file = files[0]; - if (file->path_prefix.length() > 0) - return new FileLocation ( intermediateDirectory, file->name ); + + DirectoryLocation directory; + if ( file->path_prefix.length () == 0 ) + directory = SourceDirectory; + else if ( file->path_prefix == "$(INTERMEDIATE)" ) + directory = IntermediateDirectory; else - return new FileLocation ( NULL, file->name ); + throw InvalidOperationException ( __FILE__, + __LINE__, + "Invalid path prefix '%s'", + file->path_prefix.c_str () ); + + size_t pos = file->name.find_last_of ( "/\\" ); + assert ( pos != string::npos ); + string relative_path = file->name.substr ( 0, pos ); + string name = file->name.substr ( pos + 1 ); + if ( relative_path.compare ( 0, 15, "$(INTERMEDIATE)") == 0 ) + { + directory = IntermediateDirectory; + relative_path.erase ( 0, 16 ); + } + return new FileLocation ( directory, relative_path, name ); } std::string diff --git a/reactos/tools/rbuild/filesupportcode.cpp b/reactos/tools/rbuild/filesupportcode.cpp index ad6a2311c03..e1078758478 100644 --- a/reactos/tools/rbuild/filesupportcode.cpp +++ b/reactos/tools/rbuild/filesupportcode.cpp @@ -24,7 +24,8 @@ using std::string; /* static */ void FileSupportCode::WriteIfChanged ( char* outbuf, - string filename ) + const string& filename, + bool ignoreError ) { FILE* out; unsigned int end; @@ -36,7 +37,11 @@ FileSupportCode::WriteIfChanged ( char* outbuf, { out = fopen ( filename.c_str (), "wb" ); if ( out == NULL ) + { + if ( ignoreError ) + return; throw AccessDeniedException ( filename ); + } fputs ( outbuf, out ); fclose ( out ); return; diff --git a/reactos/tools/rbuild/installfile.cpp b/reactos/tools/rbuild/installfile.cpp index 538e413a141..6ad5de558ee 100644 --- a/reactos/tools/rbuild/installfile.cpp +++ b/reactos/tools/rbuild/installfile.cpp @@ -22,32 +22,22 @@ using std::string; -InstallFile::InstallFile ( const Project& project_, +InstallFile::InstallFile ( const Project& project, const XMLElement& installfileNode, const string& path ) - : project ( project_ ), - node ( installfileNode ) + : XmlNode(project, installfileNode ) { - const XMLAttribute* att = node.GetAttribute ( "base", false ); - if ( att != NULL ) - base = att->value; - else - base = ""; + const XMLAttribute* base = node.GetAttribute ( "base", false ); + const XMLAttribute* newname = node.GetAttribute ( "newname", false ); - att = node.GetAttribute ( "newname", false ); - if ( att != NULL ) - newname = att->value; - else - newname = node.value; - name = node.value; - - att = node.GetAttribute ( "root", false ); + DirectoryLocation source_directory = SourceDirectory; + const XMLAttribute* att = node.GetAttribute ( "root", false ); if ( att != NULL) { if ( att->value == "intermediate" ) - this->path = "$(INTERMEDIATE)" + sSep + path; + source_directory = IntermediateDirectory; else if ( att->value == "output" ) - this->path = "$(OUTPUT)" + sSep + path; + source_directory = OutputDirectory; else { throw InvalidAttributeValueException ( @@ -56,21 +46,15 @@ InstallFile::InstallFile ( const Project& project_, att->value ); } } - else - this->path = path; -} -InstallFile::~InstallFile () -{ -} - -string -InstallFile::GetPath () const -{ - return path + sSep + name; -} - -void -InstallFile::ProcessXML() -{ + source = new FileLocation ( source_directory, + path, + node.value ); + target = new FileLocation ( InstallDirectory, + base && base->value != "." + ? base->value + : "", + newname + ? newname->value + : node.value ); } diff --git a/reactos/tools/rbuild/module.cpp b/reactos/tools/rbuild/module.cpp index bee1039fd95..5d2173cfb96 100644 --- a/reactos/tools/rbuild/module.cpp +++ b/reactos/tools/rbuild/module.cpp @@ -795,8 +795,19 @@ Module::ProcessXMLSubElement ( const XMLElement& e, e.location, "Only one is valid per module" ); } - pch = new PchFile ( - e, *this, File ( FixSeparator ( path + cSep + e.value ), false, "", true ) ); + size_t pos = e.value.find_last_of ( "/\\" ); + if ( pos == string::npos ) + { + pch = new PchFile ( + e, *this, FileLocation ( SourceDirectory, path, e.value ) ); + } + else + { + string dir = e.value.substr ( 0, pos ); + string name = e.value.substr ( pos + 1); + pch = new PchFile ( + e, *this, FileLocation ( SourceDirectory, path + sSep + dir, name ) ); + } subs_invalid = true; } else if ( e.name == "compilationunit" ) @@ -1146,6 +1157,15 @@ Module::GetDependencyPath () const return GetPath(); } +string +Module::GetDependencyTargetName () const +{ + if ( HasImportLibrary () ) + return "lib" + name + ".a"; + else + return GetTargetName(); +} + string Module::GetBasePath () const { @@ -1650,7 +1670,7 @@ Property::ProcessXML() PchFile::PchFile ( const XMLElement& node_, const Module& module_, - const File file_ ) + const FileLocation& file_ ) : node(node_), module(module_), file(file_) { } @@ -1659,93 +1679,3 @@ void PchFile::ProcessXML() { } - - -AutoRegister::AutoRegister ( const Project& project_, - const Module* module_, - const XMLElement& node_ ) - : project(project_), - module(module_), - node(node_) -{ - Initialize(); -} - -AutoRegister::~AutoRegister () -{ -} - -bool -AutoRegister::IsSupportedModuleType ( ModuleType type ) -{ - switch ( type ) - { - case Win32DLL: - case Win32OCX: - return true; - case Kernel: - case KernelModeDLL: - case NativeDLL: - case NativeCUI: - case Win32CUI: - case Win32GUI: - case Win32SCR: - case KernelModeDriver: - case BootSector: - case BootLoader: - case BootProgram: - case BuildTool: - case StaticLibrary: - case ObjectLibrary: - case Iso: - case LiveIso: - case IsoRegTest: - case LiveIsoRegTest: - case Test: - case RpcServer: - case RpcClient: - case Alias: - case IdlHeader: - case EmbeddedTypeLib: - case ElfExecutable: - return false; - } - throw InvalidOperationException ( __FILE__, - __LINE__ ); -} - -AutoRegisterType -AutoRegister::GetAutoRegisterType( string type ) -{ - if ( type == "DllRegisterServer" ) - return DllRegisterServer; - if ( type == "DllInstall" ) - return DllInstall; - if ( type == "Both" ) - return Both; - throw XMLInvalidBuildFileException ( - node.location, - " type attribute must be DllRegisterServer, DllInstall or Both." ); -} - -void -AutoRegister::Initialize () -{ - if ( !IsSupportedModuleType ( module->type ) ) - { - throw XMLInvalidBuildFileException ( - node.location, - " is not applicable for this module type." ); - } - - const XMLAttribute* att = node.GetAttribute ( "infsection", true ); - infSection = att->value; - - att = node.GetAttribute ( "type", true ); - type = GetAutoRegisterType ( att->value ); -} - -void -AutoRegister::ProcessXML() -{ -} diff --git a/reactos/tools/rbuild/project.cpp b/reactos/tools/rbuild/project.cpp index 2d0597bb934..16b6d5742c5 100644 --- a/reactos/tools/rbuild/project.cpp +++ b/reactos/tools/rbuild/project.cpp @@ -99,10 +99,40 @@ ParseContext::ParseContext () } -FileLocation::FileLocation ( Directory* directory, - std::string filename ) - : directory (directory), - filename (filename) +FileLocation::FileLocation ( const DirectoryLocation directory, + const std::string& relative_path, + const std::string& name ) + : directory ( directory ), + relative_path ( NormalizeFilename ( relative_path ) ), + name ( name ) +{ + if ( relative_path[0] == '/' || + relative_path[0] == '\\' || + relative_path.find ( '$' ) != string::npos || + ( relative_path.length () > 1 && ( relative_path[1] == ':' || + relative_path.find_last_of ( "/\\" ) == relative_path.length () - 1 ) ) + ) + { + throw InvalidOperationException ( __FILE__, + __LINE__, + "Invalid relative path '%s'", + relative_path.c_str () ); + } + + if ( strpbrk ( name.c_str (), "/\\:" ) ) + { + throw InvalidOperationException ( __FILE__, + __LINE__, + "Invalid file name '%s'", + name.c_str () ); + } +} + + +FileLocation::FileLocation ( const FileLocation& other ) + : directory ( other.directory ), + relative_path ( other.relative_path ), + name ( other.name ) { } diff --git a/reactos/tools/rbuild/rbuild.h b/reactos/tools/rbuild/rbuild.h index e4753022dd3..6e2d5a652b1 100644 --- a/reactos/tools/rbuild/rbuild.h +++ b/reactos/tools/rbuild/rbuild.h @@ -70,6 +70,7 @@ extern char cBadSep; #define MS_VS_DEF_VERSION "7.10" +class XmlNode; class Directory; class Project; class IfableData; @@ -105,6 +106,20 @@ class Metadata; typedef std::map directory_map; +class XmlNode +{ +protected: + const Project& project; + const XMLElement& node; + + XmlNode ( const Project& project_, + const XMLElement& node_ ); + virtual ~XmlNode(); + +public: + virtual void ProcessXML(); +}; + class Directory { public: @@ -168,7 +183,8 @@ class FileSupportCode { public: static void WriteIfChanged ( char* outbuf, - std::string filename ); + const std::string& filename, + bool ignoreError = false ); }; @@ -307,7 +323,7 @@ public: bool isUnicode; bool isDefaultEntryPoint; Bootstrap* bootstrap; - AutoRegister* autoRegister; + AutoRegister* autoRegister; // node IfableData non_if_data; std::vector invocations; std::vector dependencies; @@ -339,6 +355,7 @@ public: bool GenerateInOutputTree () const; std::string GetTargetName () const; // "foo.exe" std::string GetDependencyPath () const; // "path/foo.exe" or "path/libfoo.a" + std::string GetDependencyTargetName () const; // "foo.exe" or "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" @@ -814,22 +831,40 @@ private: }; -class CDFile +enum DirectoryLocation +{ + SourceDirectory, + IntermediateDirectory, + OutputDirectory, + InstallDirectory, + TemporaryDirectory, +}; + + +class FileLocation { public: - const Project& project; - const XMLElement& node; + DirectoryLocation directory; + std::string relative_path; std::string name; - std::string base; - std::string nameoncd; - std::string path; + + FileLocation ( const DirectoryLocation directory, + const std::string& relative_path, + const std::string& name ); + + FileLocation ( const FileLocation& other ); +}; + + +class CDFile : public XmlNode +{ +public: + FileLocation *source; + FileLocation *target; CDFile ( const Project& project, const XMLElement& bootstrapNode, const std::string& path ); - ~CDFile (); - void ProcessXML(); - std::string GetPath () const; private: static std::string ReplaceVariable ( const std::string& name, const std::string& value, @@ -837,22 +872,15 @@ private: }; -class InstallFile +class InstallFile : public XmlNode { public: - const Project& project; - const XMLElement& node; - std::string name; - std::string base; - std::string newname; - std::string path; + FileLocation *source; + FileLocation *target; InstallFile ( const Project& project, const XMLElement& bootstrapNode, const std::string& path ); - ~InstallFile (); - void ProcessXML (); - std::string GetPath () const; }; @@ -861,12 +889,12 @@ class PchFile public: const XMLElement& node; const Module& module; - File file; + FileLocation file; PchFile ( const XMLElement& node, const Module& module, - const File file ); + const FileLocation& file ); void ProcessXML(); }; @@ -921,8 +949,10 @@ public: bool IsGeneratedFile () const; bool HasFileWithExtension ( const std::string& extension ) const; bool IsFirstFile () const; - FileLocation* GetFilename ( Directory* intermediateDirectory ) const; + const FileLocation* GetFilename () const; std::string GetSwitches () const; +private: + std::string local_name; }; @@ -944,16 +974,6 @@ private: }; -class FileLocation -{ -public: - Directory* directory; - std::string filename; - FileLocation ( Directory* directory, - std::string filename ); -}; - - enum AutoRegisterType { DllRegisterServer, @@ -961,22 +981,18 @@ enum AutoRegisterType Both }; -class AutoRegister +class AutoRegister : public XmlNode { 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 ); + AutoRegisterType GetAutoRegisterType( const std::string& type ); void Initialize (); }; diff --git a/reactos/tools/rbuild/rbuild.mak b/reactos/tools/rbuild/rbuild.mak index 62477469138..f50b7e9c5fa 100644 --- a/reactos/tools/rbuild/rbuild.mak +++ b/reactos/tools/rbuild/rbuild.mak @@ -244,6 +244,7 @@ RBUILD_COMMON_SOURCES = \ $(addprefix $(RBUILD_BASE_), \ global.cpp \ automaticdependency.cpp \ + autoregister.cpp \ bootstrap.cpp \ cdfile.cpp \ compilationunit.cpp \ @@ -264,6 +265,7 @@ RBUILD_COMMON_SOURCES = \ syssetupgenerator.cpp \ testsupportcode.cpp \ wineresource.cpp \ + xmlnode.cpp \ ) RBUILD_SPECIAL_SOURCES = \ @@ -374,6 +376,10 @@ $(RBUILD_INT_)automaticdependency.o: $(RBUILD_BASE_)automaticdependency.cpp $(RB $(ECHO_CC) ${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@ +$(RBUILD_INT_)autoregister.o: $(RBUILD_BASE_)autoregister.cpp $(RBUILD_HEADERS) | $(RBUILD_INT) + $(ECHO_CC) + ${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@ + $(RBUILD_INT_)bootstrap.o: $(RBUILD_BASE_)bootstrap.cpp $(RBUILD_HEADERS) | $(RBUILD_INT) $(ECHO_CC) ${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@ @@ -454,6 +460,10 @@ $(RBUILD_INT_)wineresource.o: $(RBUILD_BASE_)wineresource.cpp $(RBUILD_HEADERS) $(ECHO_CC) ${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@ +$(RBUILD_INT_)xmlnode.o: $(RBUILD_BASE_)xmlnode.cpp $(RBUILD_HEADERS) | $(RBUILD_INT) + $(ECHO_CC) + ${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@ + $(RBUILD_INT_)testsupportcode.o: $(RBUILD_BASE_)testsupportcode.cpp $(RBUILD_HEADERS) | $(RBUILD_INT) $(ECHO_CC) ${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@ diff --git a/reactos/tools/rbuild/testsupportcode.cpp b/reactos/tools/rbuild/testsupportcode.cpp index c27cf7e481f..3d0fdb2311a 100644 --- a/reactos/tools/rbuild/testsupportcode.cpp +++ b/reactos/tools/rbuild/testsupportcode.cpp @@ -297,8 +297,8 @@ TestSupportCode::GetSourceFilenames ( string_list& list, const vector& compilationUnits = module.non_if_data.compilationUnits; for ( i = 0; i < compilationUnits.size (); i++ ) { - FileLocation* sourceFileLocation = compilationUnits[i]->GetFilename ( NULL ); - string filename = sourceFileLocation->filename; + const FileLocation* sourceFileLocation = compilationUnits[i]->GetFilename (); + string filename = sourceFileLocation->relative_path + sSep + sourceFileLocation->name; if ( !compilationUnits[i]->IsGeneratedFile () && IsTestFile ( filename ) ) list.push_back ( filename ); } @@ -317,8 +317,8 @@ TestSupportCode::GetSourceFilenames ( string_list& list, for ( j = 0; j < compilationUnits.size (); j++ ) { CompilationUnit& compilationUnit = *compilationUnits[j]; - FileLocation* sourceFileLocation = compilationUnits[j]->GetFilename ( NULL ); - string filename = sourceFileLocation->filename; + const FileLocation* sourceFileLocation = compilationUnits[j]->GetFilename (); + string filename = sourceFileLocation->relative_path + sSep + sourceFileLocation->name; if ( !compilationUnit.IsGeneratedFile () && IsTestFile ( filename ) ) list.push_back ( filename ); } diff --git a/reactos/tools/rbuild/xmlnode.cpp b/reactos/tools/rbuild/xmlnode.cpp new file mode 100644 index 00000000000..808610c498c --- /dev/null +++ b/reactos/tools/rbuild/xmlnode.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2007 Hervé Poussineau + * + * 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. + */ +#include "pch.h" + +#include "rbuild.h" + +using std::string; + +XmlNode::XmlNode ( const Project& project_, + const XMLElement& node ) + : project(project_), + node(node) +{ +} + +XmlNode::~XmlNode () +{ +} + +void +XmlNode::ProcessXML () +{ +}