Generate make rules for creating directories if they don't exist

svn path=/branches/xmlbuildsystem/; revision=15244
This commit is contained in:
Casper Hornstrup 2005-05-12 19:32:15 +00:00
parent d927b8d8fe
commit 9c85c4d513
3 changed files with 68 additions and 4 deletions

View file

@ -179,7 +179,7 @@ Directory::GenerateTree ( const string& parent,
{ {
string path; string path;
if ( parent.size() ) if ( parent.size () > 0 )
{ {
char buf[256]; char buf[256];
@ -199,6 +199,57 @@ Directory::GenerateTree ( const string& parent,
} }
} }
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->CreateRule ( f, path );
}
}
static class MingwFactory : public Backend::Factory static class MingwFactory : public Backend::Factory
{ {
@ -302,6 +353,7 @@ MingwBackend::Process ()
GenerateXmlBuildFilesMacro (); GenerateXmlBuildFilesMacro ();
ProcessModules (); ProcessModules ();
GenerateInstallTarget (); GenerateInstallTarget ();
GenerateDirectoryTargets ();
GenerateDirectories (); GenerateDirectories ();
CheckAutomaticDependencies (); CheckAutomaticDependencies ();
CloseMakefile (); CloseMakefile ();
@ -723,7 +775,7 @@ MingwBackend::OutputInstallTarget ( const string& sourceFilename,
NormalizeFilename ( targetDirectory ), NormalizeFilename ( targetDirectory ),
installDirectory ); installDirectory );
fprintf ( fMakefile, fprintf ( fMakefile,
"%s: %s %s\n", "%s: %s | %s\n",
normalizedTargetFilename.c_str (), normalizedTargetFilename.c_str (),
sourceFilename.c_str (), sourceFilename.c_str (),
normalizedTargetDirectory.c_str () ); normalizedTargetDirectory.c_str () );
@ -832,3 +884,11 @@ MingwBackend::GenerateInstallTarget ()
fprintf ( fMakefile, fprintf ( fMakefile,
"\n" ); "\n" );
} }
void
MingwBackend::GenerateDirectoryTargets ()
{
intermediateDirectory->CreateRule ( fMakefile, "" );
outputDirectory->CreateRule ( fMakefile, "" );
installDirectory->CreateRule ( fMakefile, "" );
}

View file

@ -34,6 +34,9 @@ public:
void Add ( const char* subdir ); void Add ( const char* subdir );
void GenerateTree ( const std::string& parent, void GenerateTree ( const std::string& parent,
bool verbose ); bool verbose );
std::string EscapeSpaces ( std::string path );
void CreateRule ( FILE* f,
const std::string& parent );
private: private:
bool mkdir_p ( const char* path ); bool mkdir_p ( const char* path );
std::string ReplaceVariable ( std::string name, std::string ReplaceVariable ( std::string name,
@ -105,6 +108,7 @@ private:
std::string GetRegistryTargetFiles (); std::string GetRegistryTargetFiles ();
void OutputRegistryInstallTarget (); void OutputRegistryInstallTarget ();
void GenerateInstallTarget (); void GenerateInstallTarget ();
void GenerateDirectoryTargets ();
FILE* fMakefile; FILE* fMakefile;
bool use_pch; bool use_pch;
}; };

View file

@ -129,7 +129,7 @@ MingwModuleHandler::GetTargetFilename (
{ {
string target = PassThruCacheDirectory ( string target = PassThruCacheDirectory (
NormalizeFilename ( module.GetPath () ), NormalizeFilename ( module.GetPath () ),
backend->intermediateDirectory ); GetTargetDirectoryTree ( module ) );
if ( pclean_files ) if ( pclean_files )
{ {
string_list& clean_files = *pclean_files; string_list& clean_files = *pclean_files;