Author: hpoussin
Date: Sat Sep 15 12:47:56 2007
New Revision: 29052
URL:
http://svn.reactos.org/svn/reactos?rev=29052&view=rev
Log:
Continue rbuild cleanup (Directory class)
Modified:
trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp
trunk/reactos/tools/rbuild/directory.cpp
trunk/reactos/tools/rbuild/rbuild.h
trunk/reactos/tools/rbuild/wineresource.cpp
Modified: trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/mingw…
==============================================================================
--- trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp (original)
+++ trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp Sat Sep 15 12:47:56 2007
@@ -172,9 +172,9 @@
Configuration& configuration )
: Backend ( project, configuration ),
manualBinutilsSetting( false ),
- intermediateDirectory ( new Directory ("$(INTERMEDIATE)" ) ),
- outputDirectory ( new Directory ( "$(OUTPUT)" ) ),
- installDirectory ( new Directory ( "$(INSTALL)" ) )
+ intermediateDirectory ( new Directory ( "" ) ),
+ outputDirectory ( new Directory ( "" ) ),
+ installDirectory ( new Directory ( "" ) )
{
compilerPrefix = "";
}
@@ -768,10 +768,10 @@
MingwBackend::GenerateDirectories ()
{
printf ( "Creating directories..." );
- intermediateDirectory->GenerateTree ( "", configuration.Verbose );
- outputDirectory->GenerateTree ( "", configuration.Verbose );
+ intermediateDirectory->GenerateTree ( IntermediateDirectory, configuration.Verbose
);
+ outputDirectory->GenerateTree ( OutputDirectory, configuration.Verbose );
if ( !configuration.MakeHandlesInstallDirectories )
- installDirectory->GenerateTree ( "", configuration.Verbose );
+ installDirectory->GenerateTree ( InstallDirectory, configuration.Verbose );
printf ( "done\n" );
}
@@ -1336,7 +1336,7 @@
void
MingwBackend::GenerateDirectoryTargets ()
{
- intermediateDirectory->CreateRule ( fMakefile, "" );
- outputDirectory->CreateRule ( fMakefile, "" );
- installDirectory->CreateRule ( fMakefile, "" );
-}
+ intermediateDirectory->CreateRule ( fMakefile, "$(INTERMEDIATE)" );
+ outputDirectory->CreateRule ( fMakefile, "$(OUTPUT)" );
+ installDirectory->CreateRule ( fMakefile, "$(INSTALL)" );
+}
Modified: trunk/reactos/tools/rbuild/directory.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/directory.cpp…
==============================================================================
--- trunk/reactos/tools/rbuild/directory.cpp (original)
+++ trunk/reactos/tools/rbuild/directory.cpp Sat Sep 15 12:47:56 2007
@@ -37,6 +37,29 @@
Directory::Directory ( const string& name_ )
: name(name_)
{
+ size_t pos = name.find_first_of ( "$:" );
+ if ( pos != string::npos )
+ {
+ throw InvalidOperationException ( __FILE__,
+ __LINE__,
+ "Invalid directory name '%s'",
+ name.c_str() );
+ }
+
+ const char* p = strpbrk ( name_.c_str (), "/\\" );
+ if ( name_.c_str () == p )
+ {
+ throw InvalidOperationException ( __FILE__,
+ __LINE__,
+ "Invalid relative path '%s'",
+ name_.c_str () );
+ }
+
+ if ( p )
+ {
+ name.erase ( p - name.c_str ());
+ Add ( p + 1 );
+ }
}
void
@@ -95,7 +118,7 @@
}
bool
-Directory::CreateDirectory ( string path )
+Directory::CreateDirectory ( const string& path )
{
size_t index = 0;
size_t nextIndex;
@@ -116,26 +139,24 @@
return directoryWasCreated;
}
-string
-Directory::ReplaceVariable ( const string& name,
- const string& value,
- string path )
-{
- size_t i = path.find ( name );
- if ( i != string::npos )
- return path.replace ( i, name.length (), value );
- else
- return path;
-}
-
-void
-Directory::ResolveVariablesInPath ( char* buf,
- const string& path )
-{
- string s = ReplaceVariable ( "$(INTERMEDIATE)",
Environment::GetIntermediatePath (), path );
- s = ReplaceVariable ( "$(OUTPUT)", Environment::GetOutputPath (), s );
- s = ReplaceVariable ( "$(INSTALL)", Environment::GetInstallPath (), s );
- strcpy ( buf, s.c_str () );
+void
+Directory::GenerateTree ( DirectoryLocation root,
+ bool verbose )
+{
+ switch ( root )
+ {
+ case IntermediateDirectory:
+ return GenerateTree ( Environment::GetIntermediatePath (), verbose );
+ case OutputDirectory:
+ return GenerateTree ( Environment::GetOutputPath (), verbose );
+ case InstallDirectory:
+ return GenerateTree ( Environment::GetInstallPath (), verbose );
+ default:
+ throw InvalidOperationException ( __FILE__,
+ __LINE__,
+ "Invalid directory %d.",
+ root );
+ }
}
void
@@ -147,12 +168,10 @@
if ( parent.size () > 0 )
{
char buf[256];
-
if ( name.size () > 0 )
path = parent + sSep + name;
else
path = parent;
- ResolveVariablesInPath ( buf, path );
if ( CreateDirectory ( buf ) && verbose )
printf ( "Created %s\n", buf );
}
@@ -168,10 +187,10 @@
}
string
-Directory::EscapeSpaces ( string path )
+Directory::EscapeSpaces ( const string& path )
{
string newpath;
- char* p = &path[0];
+ const char* p = &path[0];
while ( *p != 0 )
{
if ( *p == ' ' )
@@ -188,16 +207,16 @@
const string& parent )
{
string path;
-
- if ( parent.size() > 0 )
- {
- string escapedParent = EscapeSpaces ( parent );
+ string escapedName = EscapeSpaces ( name );
+
+ if ( escapedName.size() > 0 )
+ {
fprintf ( f,
"%s%c%s: | %s\n",
- escapedParent.c_str (),
+ parent.c_str (),
cSep,
- EscapeSpaces ( name ).c_str (),
- escapedParent.c_str () );
+ escapedName.c_str (),
+ parent.c_str () );
fprintf ( f,
"\t$(ECHO_MKDIR)\n" );
@@ -205,10 +224,10 @@
fprintf ( f,
"\t${mkdir} $@\n" );
- path = parent + sSep + name;
+ path = parent + sSep + escapedName;
}
else
- path = name;
+ path = parent;
for ( directory_map::iterator i = subdirs.begin();
i != subdirs.end();
Modified: trunk/reactos/tools/rbuild/rbuild.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/rbuild.h?rev=…
==============================================================================
--- trunk/reactos/tools/rbuild/rbuild.h (original)
+++ trunk/reactos/tools/rbuild/rbuild.h Sat Sep 15 12:47:56 2007
@@ -120,6 +120,15 @@
virtual void ProcessXML();
};
+enum DirectoryLocation
+{
+ SourceDirectory,
+ IntermediateDirectory,
+ OutputDirectory,
+ InstallDirectory,
+ TemporaryDirectory,
+};
+
class Directory
{
public:
@@ -127,20 +136,16 @@
directory_map subdirs;
Directory ( const std::string& name );
void Add ( const char* subdir );
+ void GenerateTree ( DirectoryLocation root,
+ bool verbose );
+ void CreateRule ( FILE* f,
+ const std::string& parent );
+private:
+ bool mkdir_p ( const char* path );
+ bool CreateDirectory ( const std::string& path );
+ std::string EscapeSpaces ( const std::string& path );
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 ( const std::string& name,
- const std::string& value,
- std::string path );
- std::string GetEnvironmentVariable ( const std::string& name );
- void ResolveVariablesInPath ( char* buf,
- const std::string& path );
- bool CreateDirectory ( std::string path );
};
@@ -300,15 +305,6 @@
HostFalse,
HostDefault,
HostTrue
-};
-
-enum DirectoryLocation
-{
- SourceDirectory,
- IntermediateDirectory,
- OutputDirectory,
- InstallDirectory,
- TemporaryDirectory,
};
class FileLocation
Modified: trunk/reactos/tools/rbuild/wineresource.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/wineresource.…
==============================================================================
--- trunk/reactos/tools/rbuild/wineresource.cpp (original)
+++ trunk/reactos/tools/rbuild/wineresource.cpp Sat Sep 15 12:47:56 2007
@@ -111,7 +111,7 @@
NormalizeFilename ( resourceFilename ).c_str () );
string command = FixSeparatorForSystemCommand(bin2res) + " " + parameters;
- Directory( relativeDirectory ).GenerateTree( Environment::GetIntermediatePath(), false
);
+ Directory( relativeDirectory ).GenerateTree( IntermediateDirectory,
project.configuration.Verbose );
int exitcode = system ( command.c_str () );
if ( exitcode != 0 )