From 9c85c4d5139903f4d028dfba3a76202ebb0b7842 Mon Sep 17 00:00:00 2001 From: Casper Hornstrup Date: Thu, 12 May 2005 19:32:15 +0000 Subject: [PATCH] Generate make rules for creating directories if they don't exist svn path=/branches/xmlbuildsystem/; revision=15244 --- reactos/tools/rbuild/backend/mingw/mingw.cpp | 66 ++++++++++++++++++- reactos/tools/rbuild/backend/mingw/mingw.h | 4 ++ .../rbuild/backend/mingw/modulehandler.cpp | 2 +- 3 files changed, 68 insertions(+), 4 deletions(-) diff --git a/reactos/tools/rbuild/backend/mingw/mingw.cpp b/reactos/tools/rbuild/backend/mingw/mingw.cpp index 0a02169fdab..93bb9e71752 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.cpp +++ b/reactos/tools/rbuild/backend/mingw/mingw.cpp @@ -179,7 +179,7 @@ Directory::GenerateTree ( const string& parent, { string path; - if ( parent.size() ) + if ( parent.size () > 0 ) { char buf[256]; @@ -191,11 +191,62 @@ Directory::GenerateTree ( const string& parent, else path = name; + for ( directory_map::iterator i = subdirs.begin (); + i != subdirs.end (); + ++i ) + { + i->second->GenerateTree ( path, verbose ); + } +} + +string +Directory::EscapeSpaces ( string path ) +{ + string newpath; + char* p = &path[0]; + while ( *p != 0 ) + { + if ( *p == ' ' ) + newpath = newpath + "\\ "; + else + newpath = newpath + *p; + *p++; + } + return newpath; +} + +void +Directory::CreateRule ( FILE* f, + const string& parent ) +{ + string path; + + if ( parent.size() > 0 ) + { + string escapedParent = EscapeSpaces ( parent ); + fprintf ( f, + "%s%c%s: | %s\n", + escapedParent.c_str (), + CSEP, + EscapeSpaces ( name ).c_str (), + escapedParent.c_str () ); + + fprintf ( f, + "\t$(ECHO_MKDIR)\n" ); + + fprintf ( f, + "\t${mkdir} $@\n" ); + + path = parent + SSEP + name; + } + else + path = name; + for ( directory_map::iterator i = subdirs.begin(); i != subdirs.end(); ++i ) { - i->second->GenerateTree ( path, verbose ); + i->second->CreateRule ( f, path ); } } @@ -302,6 +353,7 @@ MingwBackend::Process () GenerateXmlBuildFilesMacro (); ProcessModules (); GenerateInstallTarget (); + GenerateDirectoryTargets (); GenerateDirectories (); CheckAutomaticDependencies (); CloseMakefile (); @@ -723,7 +775,7 @@ MingwBackend::OutputInstallTarget ( const string& sourceFilename, NormalizeFilename ( targetDirectory ), installDirectory ); fprintf ( fMakefile, - "%s: %s %s\n", + "%s: %s | %s\n", normalizedTargetFilename.c_str (), sourceFilename.c_str (), normalizedTargetDirectory.c_str () ); @@ -832,3 +884,11 @@ MingwBackend::GenerateInstallTarget () fprintf ( fMakefile, "\n" ); } + +void +MingwBackend::GenerateDirectoryTargets () +{ + intermediateDirectory->CreateRule ( fMakefile, "" ); + outputDirectory->CreateRule ( fMakefile, "" ); + installDirectory->CreateRule ( fMakefile, "" ); +} diff --git a/reactos/tools/rbuild/backend/mingw/mingw.h b/reactos/tools/rbuild/backend/mingw/mingw.h index 84e706f9c90..ac72c0b11fd 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.h +++ b/reactos/tools/rbuild/backend/mingw/mingw.h @@ -34,6 +34,9 @@ public: void Add ( const char* subdir ); void GenerateTree ( const std::string& parent, bool verbose ); + std::string EscapeSpaces ( std::string path ); + void CreateRule ( FILE* f, + const std::string& parent ); private: bool mkdir_p ( const char* path ); std::string ReplaceVariable ( std::string name, @@ -105,6 +108,7 @@ private: std::string GetRegistryTargetFiles (); void OutputRegistryInstallTarget (); void GenerateInstallTarget (); + void GenerateDirectoryTargets (); FILE* fMakefile; bool use_pch; }; diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp index 14843b7e664..e31874639f2 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp @@ -129,7 +129,7 @@ MingwModuleHandler::GetTargetFilename ( { string target = PassThruCacheDirectory ( NormalizeFilename ( module.GetPath () ), - backend->intermediateDirectory ); + GetTargetDirectoryTree ( module ) ); if ( pclean_files ) { string_list& clean_files = *pclean_files;