- Add a NUL definition, as well as rmkdir - Create directory targets for intermediate files area - .def files are in the source tree in our current scheme Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp _____
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp --- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp 2005-01-17 14:30:31 UTC (rev 13097) +++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp 2005-01-17 16:26:11 UTC (rev 13098) @@ -1,4 +1,3 @@
- #include "../../pch.h" #include <assert.h>
@@ -9,9 +8,12 @@ using std::string; using std::vector; using std::map; +using std::set;
map<ModuleType,MingwModuleHandler*>* MingwModuleHandler::handler_map = NULL; +set<string> +MingwModuleHandler::directory_set; int MingwModuleHandler::ref = 0;
@@ -34,6 +36,13 @@ } }
+const string & +MingwModuleHandler::PassThruCacheDirectory( const string &file ) const +{ + directory_set.insert( ReplaceExtension( GetDirectory( file ), "" ) ); + return file; +} + void MingwModuleHandler::SetMakefile ( FILE* f ) { @@ -61,12 +70,23 @@ return "."; }
+string +MingwModuleHandler::GetDirectory ( const string& filename ) const +{ + size_t index = filename.find_last_of ( '/' ); + if (index == string::npos) return "."; + else return filename.substr ( 0, index ); +} + string MingwModuleHandler::GetExtension ( const string& filename ) const { - size_t index = filename.find_last_of ( '.' ); - if (index != string::npos) - return filename.substr ( index ); + size_t index = filename.find_last_of ( '/' ); + if (index == string::npos) index = 0; + string tmp = filename.substr( index, filename.size() - index ); + size_t ext_index = tmp.find_last_of( '.' ); + if (ext_index != string::npos) + return filename.substr ( index + ext_index, filename.size() ); return ""; }
@@ -83,10 +103,13 @@ MingwModuleHandler::ReplaceExtension ( const string& filename, const string& newExtension ) const { - size_t index = filename.find_last_of ( '.' ); - if (index != string::npos) - return filename.substr ( 0, index ) + newExtension; - return filename; + size_t index = filename.find_last_of ( '/' ); + if (index == string::npos) index = 0; + string tmp = filename.substr( index, filename.size() - index ); + size_t ext_index = tmp.find_last_of( '.' ); + if (ext_index != string::npos) + return filename.substr ( 0, index + ext_index ) + newExtension; + return filename + newExtension; }
string @@ -106,7 +129,7 @@ MingwModuleHandler::GetModuleArchiveFilename ( const Module& module ) const { return ReplaceExtension ( FixupTargetFilename ( module.GetPath () ), - ".a" ); + ".a" ); }
string @@ -122,7 +145,7 @@ dependencies += " "; const Module* importedModule = module.project.LocateModule ( module.libraries[i]->name ); assert ( importedModule != NULL ); - dependencies += FixupTargetFilename ( importedModule->GetDependencyPath () ).c_str (); + dependencies += PassThruCacheDirectory ( FixupTargetFilename ( importedModule->GetDependencyPath () ) ).c_str (); } return dependencies; } @@ -195,8 +218,9 @@ newExtension = ".stubs.o"; else newExtension = ".o"; - return FixupTargetFilename ( ReplaceExtension ( sourceFilename, - newExtension ) ); + return PassThruCacheDirectory + ( FixupTargetFilename ( ReplaceExtension ( sourceFilename, + newExtension ) ) ); }
string @@ -215,6 +239,32 @@ return objectFilenames; }
+void +MingwModuleHandler::GenerateDirectoryTargets() const +{ + fprintf( fMakefile, "ifneq ($(ROS_INTERMEDIATE),)\ndirectories::" ); + + for( set<string>::iterator i = directory_set.begin(); + i != directory_set.end(); + i++ ) + fprintf( fMakefile, " %s", i->c_str() ); + + fprintf( fMakefile, "\n\n" ); + + for( set<string>::iterator i = directory_set.begin(); + i != directory_set.end(); + i++ ) + fprintf( fMakefile, "%s ", i->c_str() ); + + fprintf ( fMakefile, + "::\n\t${mkdir} $@\n\n" + "else\n" + "directories::\n\n" + "endif\n\n" ); + + directory_set.clear(); +} + string MingwModuleHandler::GenerateGccDefineParametersFromVector ( const vector<Define*>& defines ) const { @@ -667,7 +717,7 @@ "\t${dlltool} --dllname %s --base-file %s --def %s --output-exp %s --kill-at\n", targetName.c_str (), base_tmp.c_str (), - FixupTargetFilename ( module.GetBasePath () + SSEP + module.importLibrary->definition ).c_str (), + (module.GetBasePath () + SSEP + module.importLibrary->definition ).c_str (), temp_exp.c_str () );
fprintf ( fMakefile, @@ -771,11 +821,11 @@ const string& ar, const string& objs_macro ) const { - string archiveFilename = GetModuleArchiveFilename ( module ); + string archiveFilename = GetModuleArchiveFilename ( module ); fprintf ( fMakefile, "%s: %s\n", - archiveFilename.c_str (), + archiveFilename.c_str (), objs_macro.c_str ());
fprintf ( fMakefile, @@ -864,10 +914,10 @@ for ( size_t i = 0; i < clean_files.size(); i++ ) { if ( 9==(i%10) ) - fprintf ( fMakefile, " 2>NUL\n\t-@$(rm)" ); + fprintf ( fMakefile, " 2>$(NUL)\n\t-@$(rm)" ); fprintf ( fMakefile, " %s", clean_files[i].c_str() ); } - fprintf ( fMakefile, " 2>NUL\n\n" ); + fprintf ( fMakefile, " 2>$(NUL)\n\n" ); }
void @@ -1035,13 +1085,13 @@ { string definitionDependencies = GetDefinitionDependencies ( module ); fprintf ( fMakefile, "%s: %s\n", - module.GetDependencyPath ().c_str (), + FixupTargetFilename( module.GetDependencyPath () ).c_str (), definitionDependencies.c_str () );
fprintf ( fMakefile, "\t${dlltool} --dllname %s --def %s --output-lib %s --kill-at\n\n", module.GetTargetName ().c_str (), - FixupTargetFilename ( module.GetBasePath () + SSEP + module.importLibrary->definition ).c_str (), + (module.GetBasePath () + SSEP + module.importLibrary->definition).c_str (), FixupTargetFilename ( module.GetDependencyPath () ).c_str () ); } } @@ -1282,7 +1332,7 @@
MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ( const Module& module ) { static string ros_junk ( "$(ROS_TEMPORARY)" ); - string target ( FixupTargetFilename ( module.GetPath () ) ); + string target ( PassThruCacheDirectory( FixupTargetFilename ( module.GetPath () ) ) ); string workingDirectory = GetWorkingDirectory ( ); string archiveFilename = GetModuleArchiveFilename ( module ); string importLibraryDependencies = GetImportLibraryDependencies ( module ); @@ -1297,7 +1347,7 @@ delete cflags;
fprintf ( fMakefile, "%s: %s %s\n", - target.c_str (), + target.c_str (), archiveFilename.c_str (), importLibraryDependencies.c_str () );
@@ -1310,7 +1360,7 @@ else { fprintf ( fMakefile, "%s:\n", - target.c_str ()); + target.c_str () ); fprintf ( fMakefile, ".PHONY: %s\n\n", target.c_str ()); } @@ -1346,6 +1396,16 @@
if ( module.files.size () > 0 ) { + + fprintf ( fMakefile, + "\t${dlltool} --dllname %s --def %s --output-lib %s --kill-at\n\n", + module.GetTargetName ().c_str (), + (module.GetBasePath () + SSEP + module.importLibrary->definition).c_str (), + FixupTargetFilename ( module.GetDependencyPath () ).c_str () ); + } + + if (module.files.size () > 0) + { GenerateMacrosAndTargetsTarget ( module );
fprintf ( fMakefile, "%s: %s %s\n", @@ -1394,7 +1454,6 @@ string linkingDependencies = GetLinkingDependencies ( module );
GenerateImportLibraryTargetIfNeeded ( module ); - if ( module.files.size () > 0 ) { GenerateMacrosAndTargetsTarget ( module );