Verbose mode

svn path=/branches/xmlbuildsystem/; revision=14471
This commit is contained in:
Casper Hornstrup 2005-04-03 11:57:34 +00:00
parent 2c65178fde
commit c4387e8d7d
10 changed files with 362 additions and 303 deletions

View file

@ -28,6 +28,9 @@
# without source code) or no (to not build any map files). The variable
# defaults to no.
#
# ROS_RBUILDFLAGS
# Pass parameters to rbuild.
#
.PHONY: all
.PHONY: clean
@ -196,7 +199,7 @@ PREAUTO := \
makefile.auto: $(RBUILD_TARGET) $(PREAUTO) $(XMLBUILDFILES)
$(ECHO_RBUILD)
$(Q)$(RBUILD_TARGET) mingw
$(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) mingw
$(BUGCODES_H) $(BUGCODES_RC): $(WMC_TARGET) $(NTOSKRNL_MC)

View file

@ -65,9 +65,6 @@ SourceFile::Open ()
throw AccessDeniedException ( filename );
}
lastWriteTime = statbuf.st_mtime;
/* printf ( "lastWriteTime of %s is %s\n",
filename.c_str (),
ctime ( &lastWriteTime ) ); */
unsigned long len = (unsigned long) filelen ( f );
if ( len > MAX_BYTES_TO_READ )
@ -219,7 +216,6 @@ SourceFile::Parse ()
while ( p < end )
{
string includedFilename ( "" );
//printf ( "Parsing '%s'\n", filename.c_str () );
bool includeNext;
while ( ReadInclude ( includedFilename,
@ -387,13 +383,12 @@ AutomaticDependency::RetrieveFromCache ( const string& filename )
}
void
AutomaticDependency::CheckAutomaticDependencies ()
AutomaticDependency::CheckAutomaticDependencies ( bool verbose )
{
struct utimbuf timebuf;
for ( size_t mi = 0; mi < project.modules.size (); mi++ )
{
const vector<File*>& files = project.modules[mi]->non_if_data.files;
//Module& module = *project.modules[mi];
for ( size_t fi = 0; fi < files.size (); fi++ )
{
File& file = *files[fi];
@ -406,20 +401,16 @@ AutomaticDependency::CheckAutomaticDependencies ()
assert ( sourceFile->youngestLastWriteTime != 0 );
if ( sourceFile->youngestLastWriteTime > sourceFile->lastWriteTime )
{
printf ( "Marking %s for rebuild due to younger file %s\n",
sourceFile->filename.c_str (),
sourceFile->youngestFile->filename.c_str () );
if ( verbose )
{
printf ( "Marking %s for rebuild due to younger file %s\n",
sourceFile->filename.c_str (),
sourceFile->youngestFile->filename.c_str () );
}
timebuf.actime = sourceFile->youngestLastWriteTime;
timebuf.modtime = sourceFile->youngestLastWriteTime;
utime ( sourceFile->filename.c_str (),
&timebuf );
/*printf ( "lastWriteTime of %s is %s\n",
sourceFile->filename.c_str (),
ctime ( &sourceFile->lastWriteTime ) );
printf ( "youngestLastWriteTime is %s with %s\n",
sourceFile->youngestFile->filename.c_str (),
ctime ( &sourceFile->youngestLastWriteTime ) );*/
}
}
}

View file

@ -22,7 +22,7 @@ Backend::Factory::Factory ( const std::string& name_ )
(*factories)[name] = this;
}
Backend::Factory::~Factory()
Backend::Factory::~Factory ()
{
if ( !--ref )
{
@ -33,22 +33,26 @@ Backend::Factory::~Factory()
/*static*/ Backend*
Backend::Factory::Create ( const string& name,
Project& project )
Project& project,
bool verbose )
{
string sname ( name );
strlwr ( &sname[0] );
if ( !factories || !factories->size() )
throw Exception ( "internal tool error: no registered factories" );
if ( !factories || !factories->size () )
throw InvalidOperationException ( __FILE__,
__LINE__,
"No registered factories" );
Backend::Factory* f = (*factories)[sname];
if ( !f )
{
throw UnknownBackendException ( sname );
return NULL;
}
return (*f) ( project );
return (*f) ( project, verbose );
}
Backend::Backend ( Project& project )
: ProjectNode ( project )
Backend::Backend ( Project& project, bool verbose )
: ProjectNode ( project ),
verbose ( verbose )
{
}

View file

@ -5,7 +5,8 @@
class Backend;
typedef Backend* BackendFactory ( Project& project );
typedef Backend* BackendFactory ( Project& project,
bool verbose );
class Backend
{
@ -20,23 +21,23 @@ public:
Factory ( const std::string& name_ );
virtual ~Factory();
virtual Backend* operator() ( Project& ) = 0;
virtual Backend* operator() ( Project&, bool verbose ) = 0;
public:
static Backend* Create ( const std::string& name,
Project& project );
private:
Project& project,
bool verbose );
};
protected:
Backend ( Project& project );
Backend ( Project& project, bool verbose );
public:
virtual void Process () = 0;
protected:
Project& ProjectNode;
bool verbose;
};
#endif /* __BACKEND_H */

View file

@ -34,15 +34,15 @@ static class DevCppFactory : public Backend::Factory
public:
DevCppFactory() : Factory("devcpp") {}
Backend *operator() (Project &project)
Backend *operator() (Project &project, bool verbose)
{
return new DevCppBackend(project);
return new DevCppBackend(project, verbose);
}
} factory;
DevCppBackend::DevCppBackend(Project &project) : Backend(project)
DevCppBackend::DevCppBackend(Project &project, bool verbose) : Backend(project, verbose)
{
m_unitCount = 0;
}
@ -107,7 +107,7 @@ void DevCppBackend::Process()
cout << "Creating Makefile: " << ProjectNode.makefile << endl;
Backend *backend = Backend::Factory::Create("mingw", ProjectNode);
Backend *backend = Backend::Factory::Create("mingw", ProjectNode, verbose );
backend->Process();
delete backend;

View file

@ -19,7 +19,7 @@ class DevCppBackend : public Backend
{
public:
DevCppBackend(Project &project);
DevCppBackend(Project &project, bool verbose);
virtual ~DevCppBackend() {}
virtual void Process();

View file

@ -27,7 +27,8 @@ public:
directory_map subdirs;
Directory ( const string& name );
void Add ( const char* subdir );
void GenerateTree ( const string& parent );
void GenerateTree ( const string& parent,
bool verbose );
private:
bool mkdir_p ( const char* path );
string ReplaceVariable ( string name,
@ -139,7 +140,8 @@ Directory::ResolveVariablesInPath ( char* buf,
}
void
Directory::GenerateTree ( const string& parent )
Directory::GenerateTree ( const string& parent,
bool verbose )
{
string path;
@ -149,7 +151,7 @@ Directory::GenerateTree ( const string& parent )
path = parent + SSEP + name;
ResolveVariablesInPath ( buf, path );
if ( CreateDirectory ( buf ) )
if ( CreateDirectory ( buf ) && verbose )
printf ( "Created %s\n", buf );
}
else
@ -159,7 +161,7 @@ Directory::GenerateTree ( const string& parent )
i != subdirs.end();
++i )
{
i->second->GenerateTree ( path );
i->second->GenerateTree ( path, verbose );
}
}
@ -167,15 +169,15 @@ static class MingwFactory : public Backend::Factory
{
public:
MingwFactory() : Factory ( "mingw" ) {}
Backend* operator() ( Project& project )
Backend* operator() ( Project& project, bool verbose )
{
return new MingwBackend ( project );
return new MingwBackend ( project, verbose );
}
} factory;
MingwBackend::MingwBackend ( Project& project )
: Backend ( project ),
MingwBackend::MingwBackend ( Project& project, bool verbose )
: Backend ( project, verbose ),
int_directories ( new Directory("$(INTERMEDIATE)") ),
out_directories ( new Directory("$(OUTPUT)") )
{
@ -202,20 +204,12 @@ MingwBackend::AddDirectoryTarget ( const string& directory, bool out )
}
void
MingwBackend::Process ()
MingwBackend::ProcessModules ()
{
size_t i;
DetectPipeSupport ();
DetectPCHSupport ();
CreateMakefile ();
GenerateHeader ();
GenerateGlobalVariables ();
GenerateXmlBuildFilesMacro();
printf ( "Processing modules..." );
vector<MingwModuleHandler*> v;
size_t i;
for ( i = 0; i < ProjectNode.modules.size (); i++ )
{
Module& module = *ProjectNode.modules[i];
@ -255,6 +249,19 @@ MingwBackend::Process ()
delete v[i];
}
printf ( "done\n" );
}
void
MingwBackend::Process ()
{
DetectPipeSupport ();
DetectPCHSupport ();
CreateMakefile ();
GenerateHeader ();
GenerateGlobalVariables ();
GenerateXmlBuildFilesMacro ();
ProcessModules ();
GenerateDirectories ();
CheckAutomaticDependencies ();
CloseMakefile ();
@ -488,9 +495,11 @@ MingwBackend::GenerateXmlBuildFilesMacro() const
void
MingwBackend::CheckAutomaticDependencies ()
{
printf ( "Checking automatic dependencies..." );
AutomaticDependency automaticDependency ( ProjectNode );
automaticDependency.Process ();
automaticDependency.CheckAutomaticDependencies ();
automaticDependency.CheckAutomaticDependencies ( verbose );
printf ( "done\n" );
}
bool
@ -505,8 +514,10 @@ MingwBackend::IncludeDirectoryTarget ( const string& directory ) const
void
MingwBackend::GenerateDirectories ()
{
int_directories->GenerateTree ( "" );
out_directories->GenerateTree ( "" );
printf ( "Creating directories..." );
int_directories->GenerateTree ( "", verbose );
out_directories->GenerateTree ( "", verbose );
printf ( "done\n" );
}
string

View file

@ -15,7 +15,7 @@ class MingwModuleHandler;
class MingwBackend : public Backend
{
public:
MingwBackend ( Project& project );
MingwBackend ( Project& project, bool verbose );
virtual ~MingwBackend ();
virtual void Process ();
std::string AddDirectoryTarget ( const std::string& directory, bool out );
@ -40,6 +40,7 @@ private:
bool IncludeDirectoryTarget ( const std::string& directory ) const;
void DetectPipeSupport ();
void DetectPCHSupport ();
void ProcessModules ();
FILE* fMakefile;
bool use_pch;
Directory *int_directories, *out_directories;

View file

@ -16,24 +16,72 @@
using std::string;
using std::vector;
static string BuildSystem;
static bool Verbose = false;
bool
ParseSwitch ( int argc, char** argv, int index )
{
char switchChar = argv[index][1];
switch ( switchChar )
{
case 'v':
Verbose = true;
break;
default:
printf ( "Unknown switch -%c",
switchChar );
return false;
}
return true;
}
bool
ParseArguments ( int argc, char** argv )
{
if ( argc < 2 )
return false;
for ( int i = 1; i < argc; i++ )
{
if ( argv[i][0] == '-' )
{
if ( !ParseSwitch ( argc, argv, i ) )
return false;
}
else
BuildSystem = argv[i];
}
return true;
}
int
main ( int argc, char** argv )
{
if ( argc != 2 )
if ( !ParseArguments ( argc, argv ) )
{
printf ( "syntax: rbuild {buildtarget}\n" );
printf ( "Generates project files for buildsystems\n\n" );
printf ( " rbuild [-v] buildsystem\n\n" );
printf ( "Switches:\n" );
printf ( " -v Be verbose\n" );
printf ( "\n" );
printf ( " buildsystem Target build system. Can be one of:\n" );
printf ( " mingw MinGW\n" );
printf ( " devcpp DevC++\n" );
return 1;
}
string buildtarget ( argv[1] );
strlwr ( &buildtarget[0] );
try
{
string projectFilename ( "ReactOS.xml" );
printf ( "Reading build files..." );
Project project ( projectFilename );
printf ( "done\n" );
project.WriteConfigurationFile ();
project.ExecuteInvocations ();
Backend* backend = Backend::Factory::Create ( buildtarget,
project );
Backend* backend = Backend::Factory::Create ( BuildSystem,
project,
Verbose );
backend->Process ();
delete backend;
@ -41,8 +89,8 @@ main ( int argc, char** argv )
}
catch (Exception& ex)
{
printf ( "%s: %s\n",
typeid(ex).name(), ex.Message.c_str() );
printf ( "%s\n",
ex.Message.c_str () );
return 1;
}
}

View file

@ -469,7 +469,7 @@ public:
const std::string& filename,
SourceFile* parentSourceFile );
SourceFile* RetrieveFromCache ( const std::string& filename );
void CheckAutomaticDependencies ();
void CheckAutomaticDependencies ( bool verbose );
void CheckAutomaticDependenciesForFile ( SourceFile* sourceFile );
private:
void ProcessModule ( Module& module );