Clean-as-you-go mode to remove generated files as soon as possible to minimize disk space requirements

svn path=/branches/xmlbuildsystem/; revision=14729
This commit is contained in:
Casper Hornstrup
2005-04-21 12:54:15 +00:00
parent 376f9fd35c
commit 4f605b66c3
9 changed files with 68 additions and 21 deletions
+8 -4
View File
@@ -34,7 +34,8 @@ Backend::Factory::~Factory ()
/*static*/ Backend*
Backend::Factory::Create ( const string& name,
Project& project,
bool verbose )
bool verbose,
bool cleanAsYouGo )
{
string sname ( name );
strlwr ( &sname[0] );
@@ -48,11 +49,14 @@ Backend::Factory::Create ( const string& name,
throw UnknownBackendException ( sname );
return NULL;
}
return (*f) ( project, verbose );
return (*f) ( project, verbose, cleanAsYouGo );
}
Backend::Backend ( Project& project, bool verbose )
Backend::Backend ( Project& project,
bool verbose,
bool cleanAsYouGo )
: ProjectNode ( project ),
verbose ( verbose )
verbose ( verbose ),
cleanAsYouGo ( cleanAsYouGo )
{
}
+9 -5
View File
@@ -21,23 +21,27 @@ public:
Factory ( const std::string& name_ );
virtual ~Factory();
virtual Backend* operator() ( Project&, bool verbose ) = 0;
virtual Backend* operator() ( Project&,
bool verbose,
bool cleanAsYouGo ) = 0;
public:
static Backend* Create ( const std::string& name,
Project& project,
bool verbose );
bool verbose,
bool cleanAsYouGo );
};
protected:
Backend ( Project& project, bool verbose );
Backend ( Project& project,
bool verbose,
bool cleanAsYouGo );
public:
virtual void Process () = 0;
protected:
Project& ProjectNode;
bool verbose;
bool cleanAsYouGo;
};
#endif /* __BACKEND_H */
+11 -4
View File
@@ -34,15 +34,19 @@ static class DevCppFactory : public Backend::Factory
public:
DevCppFactory() : Factory("devcpp") {}
Backend *operator() (Project &project, bool verbose)
Backend *operator() (Project &project,
bool verbose,
bool cleanAsYouGo)
{
return new DevCppBackend(project, verbose);
return new DevCppBackend(project, verbose, cleanAsYouGo);
}
} factory;
DevCppBackend::DevCppBackend(Project &project, bool verbose) : Backend(project, verbose)
DevCppBackend::DevCppBackend(Project &project,
bool verbose,
bool cleanAsYouGo) : Backend(project, verbose, cleanAsYouGo)
{
m_unitCount = 0;
}
@@ -107,7 +111,10 @@ void DevCppBackend::Process()
cout << "Creating Makefile: " << ProjectNode.makefile << endl;
Backend *backend = Backend::Factory::Create("mingw", ProjectNode, verbose );
Backend *backend = Backend::Factory::Create("mingw",
ProjectNode,
verbose,
cleanAsYouGo );
backend->Process();
delete backend;
+3 -1
View File
@@ -19,7 +19,9 @@ class DevCppBackend : public Backend
{
public:
DevCppBackend(Project &project, bool verbose);
DevCppBackend(Project &project,
bool verbose,
bool cleanAsYouGo);
virtual ~DevCppBackend() {}
virtual void Process();
+10 -4
View File
@@ -202,15 +202,21 @@ static class MingwFactory : public Backend::Factory
{
public:
MingwFactory() : Factory ( "mingw" ) {}
Backend* operator() ( Project& project, bool verbose )
Backend* operator() ( Project& project,
bool verbose,
bool cleanAsYouGo )
{
return new MingwBackend ( project, verbose );
return new MingwBackend ( project,
verbose,
cleanAsYouGo );
}
} factory;
MingwBackend::MingwBackend ( Project& project, bool verbose )
: Backend ( project, verbose ),
MingwBackend::MingwBackend ( Project& project,
bool verbose,
bool cleanAsYouGo )
: Backend ( project, verbose, cleanAsYouGo ),
intermediateDirectory ( new Directory ("$(INTERMEDIATE)" ) ),
outputDirectory ( new Directory ( "$(OUTPUT)" ) ),
installDirectory ( new Directory ( "$(INSTALL)" ) )
+3 -1
View File
@@ -54,7 +54,9 @@ private:
class MingwBackend : public Backend
{
public:
MingwBackend ( Project& project, bool verbose );
MingwBackend ( Project& project,
bool verbose,
bool cleanAsYouGo );
virtual ~MingwBackend ();
virtual void Process ();
std::string AddDirectoryTarget ( const std::string& directory,
@@ -8,7 +8,7 @@
using std::string;
using std::vector;
#define CLEAN_FILE(f) clean_files.push_back ( f ); /*if ( module.name == "crt" ) printf ( "%s(%i): clean: %s\n", __FILE__, __LINE__, f.c_str() )*/
#define CLEAN_FILE(f) clean_files.push_back ( f );
static string ros_temp = "$(TEMPORARY)";
MingwBackend*
@@ -1148,6 +1148,17 @@ MingwModuleHandler::GenerateBuildMapCode ()
"endif\n" );
}
void
MingwModuleHandler::GenerateCleanObjectsAsYouGoCode ( const string& files )
{
if ( backend->cleanAsYouGo )
{
fprintf ( fMakefile,
"\t-@${rm} %s 2>$(NUL)\n",
files.c_str () );
}
}
void
MingwModuleHandler::GenerateLinkerCommand (
const string& dependencies,
@@ -1216,6 +1227,8 @@ MingwModuleHandler::GenerateLinkerCommand (
fprintf ( fMakefile,
"\t-@${rm} %s 2>$(NUL)\n",
temp_exp.c_str () );
GenerateCleanObjectsAsYouGoCode ( objectsMacro );
}
else
{
@@ -1227,6 +1240,8 @@ MingwModuleHandler::GenerateLinkerCommand (
objectsMacro.c_str (),
libsMacro.c_str (),
GetLinkerMacro ().c_str () );
GenerateCleanObjectsAsYouGoCode ( objectsMacro );
}
GenerateBuildMapCode ();
@@ -77,6 +77,7 @@ protected:
std::string GetLinkingDependenciesMacro () const;
std::string GetLibsMacro () const;
std::string GetLinkerMacro () const;
void GenerateCleanObjectsAsYouGoCode ( const std::string& files );
void GenerateLinkerCommand ( const std::string& dependencies,
const std::string& linker,
const std::string& linkerParameters,
+7 -1
View File
@@ -19,6 +19,7 @@ using std::vector;
static string BuildSystem;
static string RootXmlFile = "ReactOS.xml";
static bool Verbose = false;
static bool CleanAsYouGo = false;
bool
ParseSwitch ( int argc, char** argv, int index )
@@ -29,6 +30,9 @@ ParseSwitch ( int argc, char** argv, int index )
case 'v':
Verbose = true;
break;
case 'c':
CleanAsYouGo = true;
break;
case 'r':
RootXmlFile = string(&argv[index][2]);
break;
@@ -69,6 +73,7 @@ main ( int argc, char** argv )
printf ( " rbuild [-v] [-rfile.xml] buildsystem\n\n" );
printf ( "Switches:\n" );
printf ( " -v Be verbose\n" );
printf ( " -c Clean as you go. Delete generated files as soon as they are not needed anymore\n" );
printf ( " -rfile.xml Name of the root xml file. Default is ReactOS.xml\n" );
printf ( "\n" );
printf ( " buildsystem Target build system. Can be one of:\n" );
@@ -86,7 +91,8 @@ main ( int argc, char** argv )
project.ExecuteInvocations ();
Backend* backend = Backend::Factory::Create ( BuildSystem,
project,
Verbose );
Verbose,
CleanAsYouGo );
backend->Process ();
delete backend;