Replace File by CompilationUnit
Modified: trunk/reactos/tools/rbuild/backend/devcpp/devcpp.cpp
Modified: trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
Modified: trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h
Modified: trunk/reactos/tools/rbuild/compilationunit.cpp
Modified: trunk/reactos/tools/rbuild/module.cpp
Modified: trunk/reactos/tools/rbuild/rbuild.h
Modified: trunk/reactos/tools/rbuild/tests/compilationunittest.cpp
Modified: trunk/reactos/tools/rbuild/testsupportcode.cpp
_____
Modified: trunk/reactos/tools/rbuild/backend/devcpp/devcpp.cpp
--- trunk/reactos/tools/rbuild/backend/devcpp/devcpp.cpp
2005-11-22 14:07:34 UTC (rev 19465)
+++ trunk/reactos/tools/rbuild/backend/devcpp/devcpp.cpp
2005-11-22 14:23:17 UTC (rev 19466)
@@ -129,11 +129,11 @@
{
Module &module = *ProjectNode.modules[i];
- for(size_t k = 0; k < module.non_if_data.files.size();
k++)
+ for(size_t k = 0; k <
module.non_if_data.compilationUnits.size(); k++)
{
- File &file = *module.non_if_data.files[k];
-
- ProcessFile(file.name);
+ CompilationUnit &compilationUnit =
*module.non_if_data.compilationUnits[k];
+ string filename = compilationUnit.GetFilename();
+ ProcessFile(filename);
}
}
}
_____
Modified: trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
--- trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
2005-11-22 14:07:34 UTC (rev 19465)
+++ trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
2005-11-22 14:23:17 UTC (rev 19466)
@@ -388,13 +388,12 @@
{
size_t i;
- const vector<File*>& files = module.non_if_data.files;
- for ( i = 0; i < files.size (); i++ )
+ const vector<CompilationUnit*>& compilationUnits =
module.non_if_data.compilationUnits;
+ for ( i = 0; i < compilationUnits.size (); i++ )
{
- if ( includeGeneratedFiles || !files[i]->IsGeneratedFile
() )
+ if ( includeGeneratedFiles ||
!compilationUnits[i]->IsGeneratedFile () )
{
- list.push_back (
- GetActualSourceFilename ( files[i]->name
) );
+ list.push_back ( GetActualSourceFilename (
compilationUnits[i]->GetFilename () ) );
}
}
// intentionally make a copy so that we can append more work in
@@ -408,15 +407,12 @@
const vector<If*>& ifs = rIf.data.ifs;
for ( j = 0; j < ifs.size (); j++ )
v.push_back ( ifs[j] );
- const vector<File*>& files = rIf.data.files;
- for ( j = 0; j < files.size (); j++ )
+ const vector<CompilationUnit*>& compilationUnits =
rIf.data.compilationUnits;
+ for ( j = 0; j < compilationUnits.size (); j++ )
{
- File& file = *files[j];
- if ( includeGeneratedFiles ||
!file.IsGeneratedFile () )
- {
- list.push_back (
- GetActualSourceFilename (
file.name ) );
- }
+ CompilationUnit& compilationUnit =
*compilationUnits[j];
+ if ( includeGeneratedFiles ||
!compilationUnit.IsGeneratedFile () )
+ list.push_back ( GetActualSourceFilename
( compilationUnit.GetFilename () ) );
}
}
}
@@ -545,17 +541,16 @@
string
MingwModuleHandler::GetObjectFilenames ()
{
- const vector<File*>& files = module.non_if_data.files;
- if ( files.size () == 0 )
+ const vector<CompilationUnit*>& compilationUnits =
module.non_if_data.compilationUnits;
+ if ( compilationUnits.size () == 0 )
return "";
string objectFilenames ( "" );
- for ( size_t i = 0; i < files.size (); i++ )
+ for ( size_t i = 0; i < compilationUnits.size (); i++ )
{
if ( objectFilenames.size () > 0 )
objectFilenames += " ";
- objectFilenames +=
- GetObjectFilename ( files[i]->name, NULL );
+ objectFilenames += GetObjectFilename (
compilationUnits[i]->GetFilename (), NULL );
}
return objectFilenames;
}
@@ -804,7 +799,7 @@
if ( rIf.data.defines.size()
|| rIf.data.includes.size()
|| rIf.data.libraries.size()
- || rIf.data.files.size()
+ || rIf.data.compilationUnits.size()
|| rIf.data.compilerFlags.size()
|| rIf.data.ifs.size() )
{
@@ -826,14 +821,14 @@
}
void
-MingwModuleHandler::CleanupFileVector ( vector<File*>& sourceFiles )
+MingwModuleHandler::CleanupCompilationUnitVector (
vector<CompilationUnit*>& compilationUnits )
{
- for (size_t i = 0; i < sourceFiles.size (); i++)
- delete sourceFiles[i];
+ for (size_t i = 0; i < compilationUnits.size (); i++)
+ delete compilationUnits[i];
}
void
-MingwModuleHandler::GetModuleSpecificSourceFiles ( vector<File*>&
sourceFiles )
+MingwModuleHandler::GetModuleSpecificCompilationUnits (
vector<CompilationUnit*>& compilationUnits )
{
}
@@ -845,19 +840,18 @@
{
size_t i;
- const vector<File*>& files = data.files;
- if ( files.size () > 0 )
+ const vector<CompilationUnit*>& compilationUnits =
data.compilationUnits;
+ if ( compilationUnits.size () > 0 )
{
- for ( i = 0; i < files.size (); i++ )
+ for ( i = 0; i < compilationUnits.size (); i++ )
{
- File& file = *files[i];
- if ( file.first )
+ CompilationUnit& compilationUnit =
*compilationUnits[i];
+ if ( compilationUnit.IsFirstFile () )
{
fprintf ( fMakefile,
"%s := %s $(%s)\n",
objectsMacro.c_str(),
- GetObjectFilename (
- file.name, NULL ).c_str
(),
+ GetObjectFilename (
compilationUnit.GetFilename (), NULL ).c_str (),
objectsMacro.c_str() );
}
}
@@ -866,17 +860,16 @@
"%s %s",
objectsMacro.c_str (),
assignmentOperation );
- for ( i = 0; i < files.size(); i++ )
+ for ( i = 0; i < compilationUnits.size(); i++ )
{
- File& file = *files[i];
- if ( !file.first )
+ CompilationUnit& compilationUnit =
*compilationUnits[i];
+ if ( !compilationUnit.IsFirstFile () )
{
fprintf (
fMakefile,
"%s%s",
( i%10 == 9 ? " \\\n\t" : " " ),
- GetObjectFilename (
- file.name, NULL ).c_str
() );
+ GetObjectFilename (
compilationUnit.GetFilename (), NULL ).c_str () );
}
}
fprintf ( fMakefile, "\n" );
@@ -889,7 +882,7 @@
if ( rIf.data.defines.size()
|| rIf.data.includes.size()
|| rIf.data.libraries.size()
- || rIf.data.files.size()
+ || rIf.data.compilationUnits.size()
|| rIf.data.compilerFlags.size()
|| rIf.data.ifs.size() )
{
@@ -909,18 +902,17 @@
}
}
- vector<File*> sourceFiles;
- GetModuleSpecificSourceFiles ( sourceFiles );
- for ( i = 0; i < sourceFiles.size (); i++ )
+ vector<CompilationUnit*> sourceCompilationUnits;
+ GetModuleSpecificCompilationUnits ( sourceCompilationUnits );
+ for ( i = 0; i < sourceCompilationUnits.size (); i++ )
{
fprintf (
fMakefile,
"%s += %s\n",
objectsMacro.c_str(),
- GetObjectFilename (
- sourceFiles[i]->name, NULL ).c_str () );
+ GetObjectFilename (
sourceCompilationUnits[i]->GetFilename (), NULL ).c_str () );
}
- CleanupFileVector ( sourceFiles );
+ CleanupCompilationUnitVector ( sourceCompilationUnits );
}
string
@@ -1104,9 +1096,9 @@
}
string
-MingwModuleHandler::GetWidlFlags ( const File& file )
+MingwModuleHandler::GetWidlFlags ( const CompilationUnit&
compilationUnit )
{
- return file.switches;
+ return compilationUnit.GetSwitches ();
}
string
@@ -1118,13 +1110,14 @@
void
MingwModuleHandler::GenerateWidlCommandsServer (
- const File& file,
+ const CompilationUnit& compilationUnit,
const string& widlflagsMacro )
{
- string dependencies = file.name;
+ string filename = compilationUnit.GetFilename ();
+ string dependencies = filename;
dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
- string basename = GetBasename ( file.name );
+ string basename = GetBasename ( filename );
string generatedHeaderFilename = GetRpcServerHeaderFilename (
basename );
CLEAN_FILE(generatedHeaderFilename);
@@ -1144,11 +1137,11 @@
fprintf ( fMakefile,
"\t%s %s %s -h -H %s -s -S %s %s\n",
"$(Q)$(WIDL_TARGET)",
- GetWidlFlags ( file ).c_str (),
+ GetWidlFlags ( compilationUnit ).c_str (),
widlflagsMacro.c_str (),
generatedHeaderFilename.c_str (),
generatedServerFilename.c_str (),
- file.name.c_str () );
+ filename.c_str () );
}
string
@@ -1160,13 +1153,14 @@
void
MingwModuleHandler::GenerateWidlCommandsClient (
- const File& file,
+ const CompilationUnit& compilationUnit,
const string& widlflagsMacro )
{
- string dependencies = file.name;
+ string filename = compilationUnit.GetFilename ();
+ string dependencies = filename;
dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
- string basename = GetBasename ( file.name );
+ string basename = GetBasename ( filename );
string generatedHeaderFilename = GetRpcClientHeaderFilename (
basename );
CLEAN_FILE(generatedHeaderFilename);
@@ -1186,29 +1180,29 @@
fprintf ( fMakefile,
"\t%s %s %s -h -H %s -c -C %s %s\n",
"$(Q)$(WIDL_TARGET)",
- GetWidlFlags ( file ).c_str (),
+ GetWidlFlags ( compilationUnit ).c_str (),
widlflagsMacro.c_str (),
generatedHeaderFilename.c_str (),
generatedClientFilename.c_str (),
- file.name.c_str () );
+ filename.c_str () );
}
void
MingwModuleHandler::GenerateWidlCommands (
- const File& file,
+ const CompilationUnit& compilationUnit,
const string& widlflagsMacro )
{
if ( module.type == RpcServer )
- GenerateWidlCommandsServer ( file,
+ GenerateWidlCommandsServer ( compilationUnit,
widlflagsMacro );
else
- GenerateWidlCommandsClient ( file,
+ GenerateWidlCommandsClient ( compilationUnit,
widlflagsMacro );
}
void
MingwModuleHandler::GenerateCommands (
- const File& file,
+ const CompilationUnit& compilationUnit,
const string& cc,
const string& cppc,
const string& cflagsMacro,
@@ -1216,10 +1210,11 @@
const string& windresflagsMacro,
const string& widlflagsMacro )
{
- string extension = GetExtension ( file.name );
+ string filename = compilationUnit.GetFilename ();
+ string extension = GetExtension ( filename );
if ( extension == ".c" || extension == ".C" )
{
- GenerateGccCommand ( file.name,
+ GenerateGccCommand ( filename,
"",
cc,
cflagsMacro );
@@ -1229,7 +1224,7 @@
extension == ".cpp" || extension == ".CPP" ||
extension == ".cxx" || extension == ".CXX" )
{
- GenerateGccCommand ( file.name,
+ GenerateGccCommand ( filename,
"",
cppc,
cflagsMacro );
@@ -1237,27 +1232,27 @@
}
else if ( extension == ".s" || extension == ".S" )
{
- GenerateGccAssemblerCommand ( file.name,
+ GenerateGccAssemblerCommand ( filename,
cc,
cflagsMacro );
return;
}
else if ( extension == ".asm" || extension == ".ASM" )
{
- GenerateNasmCommand ( file.name,
+ GenerateNasmCommand ( filename,
nasmflagsMacro );
return;
}
else if ( extension == ".rc" || extension == ".RC" )
{
- GenerateWindresCommand ( file.name,
+ GenerateWindresCommand ( filename,
windresflagsMacro );
return;
}
else if ( extension == ".spec" || extension == ".SPEC" )
{
- GenerateWinebuildCommands ( file.name );
- GenerateGccCommand ( GetActualSourceFilename ( file.name
),
+ GenerateWinebuildCommands ( filename );
+ GenerateGccCommand ( GetActualSourceFilename ( filename
),
"",
cc,
cflagsMacro );
@@ -1265,10 +1260,10 @@
}
else if ( extension == ".idl" || extension == ".IDL" )
{
- GenerateWidlCommands ( file,
+ GenerateWidlCommands ( compilationUnit,
widlflagsMacro );
- GenerateGccCommand ( GetActualSourceFilename ( file.name
),
- GetExtraDependencies ( file.name ),
+ GenerateGccCommand ( GetActualSourceFilename ( filename
),
+ GetExtraDependencies ( filename ),
cc,
cflagsMacro );
return;
@@ -1278,7 +1273,7 @@
__LINE__,
"Unsupported filename
extension '%s' in file '%s'",
extension.c_str (),
- file.name.c_str () );
+ filename.c_str () );
}
void
@@ -1371,10 +1366,10 @@
MingwModuleHandler::GetObjectsVector ( const IfableData& data,
vector<string>& objectFiles )
const
{
- for ( size_t i = 0; i < data.files.size (); i++ )
+ for ( size_t i = 0; i < data.compilationUnits.size (); i++ )
{
- File& file = *data.files[i];
- objectFiles.push_back ( GetObjectFilename ( file.name,
NULL ) );
+ CompilationUnit& compilationUnit =
*data.compilationUnits[i];
+ objectFiles.push_back ( GetObjectFilename (
compilationUnit.GetFilename (), NULL ) );
}
}
@@ -1519,10 +1514,10 @@
{
size_t i;
- const vector<File*>& files = data.files;
- for ( i = 0; i < files.size (); i++ )
+ const vector<CompilationUnit*>& compilationUnits =
data.compilationUnits;
+ for ( i = 0; i < compilationUnits.size (); i++ )
{
- GenerateCommands ( *files[i],
+ GenerateCommands ( *compilationUnits[i],
cc,
cppc,
cflagsMacro,
@@ -1545,11 +1540,11 @@
widlflagsMacro );
}
- vector<File*> sourceFiles;
- GetModuleSpecificSourceFiles ( sourceFiles );
- for ( i = 0; i < sourceFiles.size (); i++ )
+ vector<CompilationUnit*> sourceCompilationUnits;
+ GetModuleSpecificCompilationUnits ( sourceCompilationUnits );
+ for ( i = 0; i < sourceCompilationUnits.size (); i++ )
{
- GenerateCommands ( *sourceFiles[i],
+ GenerateCommands ( *sourceCompilationUnits[i],
cc,
cppc,
cflagsMacro,
@@ -1557,7 +1552,7 @@
windresflagsMacro,
widlflagsMacro );
}
- CleanupFileVector ( sourceFiles );
+ CleanupCompilationUnitVector ( sourceCompilationUnits );
}
void
@@ -1703,13 +1698,14 @@
if ( library.importedModule->type == RpcServer ||
library.importedModule->type == RpcClient )
{
- for ( size_t j = 0; j <
library.importedModule->non_if_data.files.size (); j++ )
+ for ( size_t j = 0; j <
library.importedModule->non_if_data.compilationUnits.size (); j++ )
{
- File& file =
*library.importedModule->non_if_data.files[j];
- string extension = GetExtension (
file.name );
+ CompilationUnit& compilationUnit =
*library.importedModule->non_if_data.compilationUnits[j];
+ string filename =
compilationUnit.GetFilename ();
+ string extension = GetExtension (
filename );
if ( extension == ".idl" || extension ==
".IDL" )
{
- string basename = GetBasename (
file.name );
+ string basename = GetBasename (
filename );
if (
library.importedModule->type == RpcServer )
dependencies.push_back (
GetRpcServerHeaderFilename ( basename ) );
if (
library.importedModule->type == RpcClient )
@@ -1739,13 +1735,14 @@
vector<string> s;
if ( module.importLibrary )
{
- const vector<File*>& files = module.non_if_data.files;
- for ( size_t i = 0; i < files.size (); i++ )
+ const vector<CompilationUnit*>& compilationUnits =
module.non_if_data.compilationUnits;
+ for ( size_t i = 0; i < compilationUnits.size (); i++ )
{
- File& file = *files[i];
- string extension = GetExtension ( file.name );
+ CompilationUnit& compilationUnit =
*compilationUnits[i];
+ string filename = compilationUnit.GetFilename
();
+ string extension = GetExtension ( filename );
if ( extension == ".spec" || extension ==
".SPEC" )
- GetSpecObjectDependencies ( s, file.name
);
+ GetSpecObjectDependencies ( s, filename
);
}
}
if ( s.size () > 0 )
@@ -2093,19 +2090,16 @@
string_list& dependencies ) const
{
string dkNkmLibNoFixup = "dk/nkm/lib";
- const vector<File*>& files = module.non_if_data.files;
- for ( size_t i = 0; i < files.size (); i++ )
+ const vector<CompilationUnit*>& compilationUnits =
module.non_if_data.compilationUnits;
+ for ( size_t i = 0; i < compilationUnits.size (); i++ )
{
- File& file = *files[i];
- string extension = GetExtension ( file.name );
+ CompilationUnit& compilationUnit = *compilationUnits[i];
+ string filename = compilationUnit.GetFilename ();
+ string extension = GetExtension ( filename );
if ( extension == ".spec" || extension == ".SPEC" )
- {
- GetSpecObjectDependencies ( dependencies,
file.name );
- }
+ GetSpecObjectDependencies ( dependencies,
filename );
if ( extension == ".idl" || extension == ".IDL" )
- {
- GetWidlObjectDependencies ( dependencies,
file.name );
- }
+ GetWidlObjectDependencies ( dependencies,
filename );
}
}
@@ -2176,7 +2170,7 @@
GenerateImportLibraryTargetIfNeeded ();
- if ( module.non_if_data.files.size () > 0 )
+ if ( module.non_if_data.compilationUnits.size () > 0 )
{
GenerateRules ();
@@ -2265,7 +2259,7 @@
GenerateImportLibraryTargetIfNeeded ();
- if ( module.non_if_data.files.size () > 0 )
+ if ( module.non_if_data.compilationUnits.size () > 0 )
{
GenerateRules ();
@@ -2313,7 +2307,7 @@
GenerateImportLibraryTargetIfNeeded ();
- if ( module.non_if_data.files.size () > 0 )
+ if ( module.non_if_data.compilationUnits.size () > 0 )
{
GenerateRules ();
@@ -2360,7 +2354,7 @@
GenerateImportLibraryTargetIfNeeded ();
- if ( module.non_if_data.files.size () > 0 )
+ if ( module.non_if_data.compilationUnits.size () > 0 )
{
GenerateRules ();
@@ -2407,7 +2401,7 @@
GenerateImportLibraryTargetIfNeeded ();
- if ( module.non_if_data.files.size () > 0 )
+ if ( module.non_if_data.compilationUnits.size () > 0 )
{
GenerateRules ();
@@ -2454,7 +2448,7 @@
GenerateImportLibraryTargetIfNeeded ();
- if ( module.non_if_data.files.size () > 0 )
+ if ( module.non_if_data.compilationUnits.size () > 0 )
{
GenerateRules ();
@@ -2507,7 +2501,7 @@
GenerateImportLibraryTargetIfNeeded ();
- if ( module.non_if_data.files.size () > 0 )
+ if ( module.non_if_data.compilationUnits.size () > 0 )
{
GenerateRules ();
@@ -2560,7 +2554,7 @@
GenerateImportLibraryTargetIfNeeded ();
- if ( module.non_if_data.files.size () > 0 )
+ if ( module.non_if_data.compilationUnits.size () > 0 )
{
GenerateRules ();
@@ -3043,12 +3037,12 @@
}
void
-MingwTestModuleHandler::GetModuleSpecificSourceFiles ( vector<File*>&
sourceFiles )
+MingwTestModuleHandler::GetModuleSpecificCompilationUnits (
vector<CompilationUnit*>& compilationUnits )
{
string basePath = "$(INTERMEDIATE)" + sSep + module.GetBasePath
();
- sourceFiles.push_back ( new File ( basePath + sSep + "_hooks.c",
false, "", false ) );
- sourceFiles.push_back ( new File ( basePath + sSep + "_stubs.S",
false, "", false ) );
- sourceFiles.push_back ( new File ( basePath + sSep +
"_startup.c", false, "", false ) );
+ compilationUnits.push_back ( new CompilationUnit ( new File (
basePath + sSep + "_hooks.c", false, "", false ) ) );
+ compilationUnits.push_back ( new CompilationUnit ( new File (
basePath + sSep + "_stubs.S", false, "", false ) ) );
+ compilationUnits.push_back ( new CompilationUnit ( new File (
basePath + sSep + "_startup.c", false, "", false ) ) );
}
void
@@ -3062,7 +3056,7 @@
GenerateImportLibraryTargetIfNeeded ();
- if ( module.non_if_data.files.size () > 0 )
+ if ( module.non_if_data.compilationUnits.size () > 0 )
{
GenerateRules ();
_____
Modified: trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h
--- trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h
2005-11-22 14:07:34 UTC (rev 19465)
+++ trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h
2005-11-22 14:23:17 UTC (rev 19466)
@@ -81,7 +81,7 @@
void GenerateDependsTarget () const;
static bool ReferenceObjects ( const Module& module );
protected:
- virtual void GetModuleSpecificSourceFiles ( std::vector<File*>&
sourceFiles );
+ virtual void GetModuleSpecificCompilationUnits (
std::vector<CompilationUnit*>& compilationUnits );
std::string GetWorkingDirectory () const;
std::string GetBasename ( const std::string& filename ) const;
std::string GetActualSourceFilename ( const std::string&
filename ) const;
@@ -156,16 +156,16 @@
void GenerateWindresCommand ( const std::string& sourceFilename,
const std::string&
windresflagsMacro );
void GenerateWinebuildCommands ( const std::string&
sourceFilename );
- std::string GetWidlFlags ( const File& file );
+ std::string GetWidlFlags ( const CompilationUnit&
compilationUnit );
void GenerateWidlCommandsServer (
- const File& file,
+ const CompilationUnit& compilationUnit,
const std::string& widlflagsMacro );
void GenerateWidlCommandsClient (
- const File& file,
+ const CompilationUnit& compilationUnit,
const std::string& widlflagsMacro );
- void GenerateWidlCommands ( const File& file,
+ void GenerateWidlCommands ( const CompilationUnit&
compilationUnit,
const std::string& widlflagsMacro );
- void GenerateCommands ( const File& file,
+ void GenerateCommands ( const CompilationUnit& compilationUnit,
const std::string& cc,
const std::string& cppc,
const std::string& cflagsMacro,
@@ -198,7 +198,7 @@
static std::string RemoveVariables ( std::string path);
void GenerateBuildMapCode ();
void GenerateBuildNonSymbolStrippedCode ();
- void CleanupFileVector ( std::vector<File*>& sourceFiles );
+ void CleanupCompilationUnitVector (
std::vector<CompilationUnit*>& compilationUnits );
void GetRpcHeaderDependencies ( std::vector<std::string>&
dependencies ) const;
std::string GetRpcServerHeaderFilename ( std::string basename )
const;
std::string GetRpcClientHeaderFilename ( std::string basename )
const;
@@ -420,7 +420,7 @@
virtual HostType DefaultHost() { return HostFalse; }
virtual void Process ();
protected:
- virtual void GetModuleSpecificSourceFiles ( std::vector<File*>&
sourceFiles );
+ virtual void GetModuleSpecificCompilationUnits (
std::vector<CompilationUnit*>& compilationUnits );
private:
void GenerateTestModuleTarget ();
};
_____
Modified: trunk/reactos/tools/rbuild/compilationunit.cpp
--- trunk/reactos/tools/rbuild/compilationunit.cpp 2005-11-22
14:07:34 UTC (rev 19465)
+++ trunk/reactos/tools/rbuild/compilationunit.cpp 2005-11-22
14:23:17 UTC (rev 19466)
@@ -23,9 +23,17 @@
using std::string;
using std::vector;
-CompilationUnit::CompilationUnit ( const Project& project,
+CompilationUnit::CompilationUnit ( File* file )
+ : project(NULL),
+ module(NULL),
+ node(NULL)
+{
+ files.push_back ( file );
+}
+
+CompilationUnit::CompilationUnit ( const Project* project,
const Module* module,
- const XMLElement& node )
+ const XMLElement* node )
: project(project),
module(module),
node(node)
@@ -34,9 +42,69 @@
CompilationUnit::~CompilationUnit ()
{
+ size_t i;
+ for ( i = 0; i < files.size (); i++ )
+ delete files[i];
}
void
CompilationUnit::ProcessXML ()
{
+ size_t i;
+ for ( i = 0; i < files.size (); i++ )
+ files[i]->ProcessXML ();
}
+
+bool
+CompilationUnit::IsGeneratedFile () const
+{
+ if ( files.size () != 1 )
+ return false;
+ File* file = files[0];
+ string extension = GetExtension ( file->name );
+ return ( extension == ".spec" || extension == ".SPEC" );
+}
+
+bool
+CompilationUnit::HasFileWithExtension ( const std::string& extension )
const
+{
+ size_t i;
+ for ( i = 0; i < files.size (); i++ )
+ {
+ File& file = *files[i];
+ string fileExtension = GetExtension ( file.name );
+ if ( !stricmp ( fileExtension.c_str (), extension.c_str
() ) )
+ return true;
+ }
+ return false;
+}
+
+bool
+CompilationUnit::IsFirstFile () const
+{
+ if ( files.size () == 0 || files.size () > 1 )
+{
+printf("fs:'%d'\n", files.size ());
+ throw InvalidOperationException ( __FILE__, __LINE__ );
+}
+ File* file = files[0];
+ return file->first;
+}
+
+std::string
+CompilationUnit::GetFilename () const
+{
+ if ( files.size () == 0 || files.size () > 1 )
+ throw InvalidOperationException ( __FILE__, __LINE__ );
+ File* file = files[0];
+ return file->name;
+}
+
+std::string
+CompilationUnit::GetSwitches () const
+{
+ if ( files.size () == 0 || files.size () > 1 )
+ throw InvalidOperationException ( __FILE__, __LINE__ );
+ File* file = files[0];
+ return file->switches;
+}
_____
Modified: trunk/reactos/tools/rbuild/module.cpp
--- trunk/reactos/tools/rbuild/module.cpp 2005-11-22 14:07:34 UTC
(rev 19465)
+++ trunk/reactos/tools/rbuild/module.cpp 2005-11-22 14:23:17 UTC
(rev 19466)
@@ -182,8 +182,6 @@
IfableData::~IfableData()
{
size_t i;
- for ( i = 0; i < files.size (); i++ )
- delete files[i];
for ( i = 0; i < includes.size (); i++ )
delete includes[i];
for ( i = 0; i < defines.size (); i++ )
@@ -203,8 +201,6 @@
void IfableData::ProcessXML ()
{
size_t i;
- for ( i = 0; i < files.size (); i++ )
- files[i]->ProcessXML ();
for ( i = 0; i < includes.size (); i++ )
includes[i]->ProcessXML ();
for ( i = 0; i < defines.size (); i++ )
@@ -478,12 +474,20 @@
first,
switches,
false );
+ if ( parseContext.compilationUnit )
+ parseContext.compilationUnit->files.push_back (
pFile );
+ else
+ {
+ CompilationUnit* pCompilationUnit = new
CompilationUnit ( pFile );
+ if ( parseContext.ifData )
+
parseContext.ifData->data.compilationUnits.push_back ( pCompilationUnit
);
+ else
+ non_if_data.compilationUnits.push_back (
pCompilationUnit );
+ }
if ( parseContext.ifData )
parseContext.ifData->data.files.push_back (
pFile );
else
non_if_data.files.push_back ( pFile );
- if ( parseContext.compilationUnit )
- parseContext.compilationUnit->files.push_back (
pFile );
subs_invalid = true;
}
else if ( e.name == "library" && e.value.size () )
@@ -623,7 +627,7 @@
}
else if ( e.name == "compilationunit" )
{
- CompilationUnit* pCompilationUnit = new CompilationUnit
( project, this, e );
+ CompilationUnit* pCompilationUnit = new CompilationUnit
( &project, this, &e );
if ( parseContext.ifData )
parseContext.ifData->data.compilationUnits.push_back ( pCompilationUnit
);
else
@@ -925,11 +929,10 @@
const std::string& extension ) const
{
size_t i;
- for ( i = 0; i < data.files.size (); i++ )
+ for ( i = 0; i < data.compilationUnits.size (); i++ )
{
- File& file = *data.files[i];
- string file_ext = GetExtension ( file.name );
- if ( !stricmp ( file_ext.c_str (), extension.c_str () )
)
+ CompilationUnit* compilationUnit =
data.compilationUnits[i];
+ if ( compilationUnit->HasFileWithExtension ( extension )
)
return true;
}
for ( i = 0; i < data.ifs.size (); i++ )
@@ -971,14 +974,7 @@
{
}
-bool
-File::IsGeneratedFile () const
-{
- string extension = GetExtension ( name );
- return ( extension == ".spec" || extension == ".SPEC" );
-}
-
Library::Library ( const XMLElement& _node,
const Module& _module,
const string& _name )
_____
Modified: trunk/reactos/tools/rbuild/rbuild.h
--- trunk/reactos/tools/rbuild/rbuild.h 2005-11-22 14:07:34 UTC (rev
19465)
+++ trunk/reactos/tools/rbuild/rbuild.h 2005-11-22 14:23:17 UTC (rev
19466)
@@ -353,7 +353,6 @@
bool _isPreCompiledHeader );
void ProcessXML();
- bool IsGeneratedFile () const;
};
@@ -788,16 +787,22 @@
class CompilationUnit
{
public:
- const Project& project;
+ const Project* project;
const Module* module;
- const XMLElement& node;
+ const XMLElement* node;
std::vector<File*> files;
- CompilationUnit ( const Project& project,
+ CompilationUnit ( File* file );
+ CompilationUnit ( const Project* project,
const Module* module,
- const XMLElement& node );
+ const XMLElement* node );
~CompilationUnit ();
void ProcessXML();
+ bool IsGeneratedFile () const;
+ bool HasFileWithExtension ( const std::string& extension )
const;
+ bool IsFirstFile () const;
+ std::string GetFilename () const;
+ std::string GetSwitches () const;
};
_____
Modified: trunk/reactos/tools/rbuild/tests/compilationunittest.cpp
--- trunk/reactos/tools/rbuild/tests/compilationunittest.cpp
2005-11-22 14:07:34 UTC (rev 19465)
+++ trunk/reactos/tools/rbuild/tests/compilationunittest.cpp
2005-11-22 14:23:17 UTC (rev 19466)
@@ -29,8 +29,14 @@
IS_TRUE ( module1.type == BuildTool );
ARE_EQUAL ( 2, module1.non_if_data.files.size());
+ ARE_EQUAL ( "dir1" SSEP "file1.c",
module1.non_if_data.files[0]->name );
+ ARE_EQUAL ( "dir1" SSEP "file2.c",
module1.non_if_data.files[1]->name );
+
ARE_EQUAL ( 1, module1.non_if_data.compilationUnits.size () );
CompilationUnit& compilationUnit1 =
*module1.non_if_data.compilationUnits[0];
ARE_EQUAL ( 2, compilationUnit1.files.size () );
+
+ ARE_EQUAL ( "dir1" SSEP "file1.c",
compilationUnit1.files[0]->name );
+ ARE_EQUAL ( "dir1" SSEP "file2.c",
compilationUnit1.files[1]->name );
}
_____
Modified: trunk/reactos/tools/rbuild/testsupportcode.cpp
--- trunk/reactos/tools/rbuild/testsupportcode.cpp 2005-11-22
14:07:34 UTC (rev 19465)
+++ trunk/reactos/tools/rbuild/testsupportcode.cpp 2005-11-22
14:23:17 UTC (rev 19466)
@@ -294,11 +294,12 @@
{
size_t i;
- const vector<File*>& files = module.non_if_data.files;
- for ( i = 0; i < files.size (); i++ )
+ const vector<CompilationUnit*>& compilationUnits =
module.non_if_data.compilationUnits;
+ for ( i = 0; i < compilationUnits.size (); i++ )
{
- if ( !files[i]->IsGeneratedFile () && IsTestFile (
files[i]->name ) )
- list.push_back ( files[i]->name );
+ string filename = compilationUnits[i]->GetFilename();
+ if ( !compilationUnits[i]->IsGeneratedFile () &&
IsTestFile ( filename ) )
+ list.push_back ( filename );
}
// intentionally make a copy so that we can append more work in
// the middle of processing without having to go recursive
@@ -311,14 +312,13 @@
const vector<If*>& ifs = rIf.data.ifs;
for ( j = 0; j < ifs.size (); j++ )
v.push_back ( ifs[j] );
- const vector<File*>& files = rIf.data.files;
- for ( j = 0; j < files.size (); j++ )
+ const vector<CompilationUnit*>& compilationUnits =
rIf.data.compilationUnits;
+ for ( j = 0; j < compilationUnits.size (); j++ )
{
- File& file = *files[j];
- if ( !file.IsGeneratedFile () && IsTestFile (
file.name ) )
- {
- list.push_back ( file.name );
- }
+ CompilationUnit& compilationUnit =
*compilationUnits[j];
+ string filename =
compilationUnits[j]->GetFilename();
+ if ( !compilationUnit.IsGeneratedFile () &&
IsTestFile ( filename ) )
+ list.push_back ( filename );
}
}
}