* Name compilation unit
* Generate compilation unit support code
Modified: trunk/reactos/tools/rbuild/backend/devcpp/devcpp.cpp
Modified: trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp
Modified: trunk/reactos/tools/rbuild/backend/mingw/mingw.h
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
Added: trunk/reactos/tools/rbuild/compilationunitsupportcode.cpp
Modified: trunk/reactos/tools/rbuild/doc/rbuild.txt
Modified: trunk/reactos/tools/rbuild/project.cpp
Modified: trunk/reactos/tools/rbuild/rbuild.h
Modified: trunk/reactos/tools/rbuild/rbuild.mak
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 21:58:50 UTC (rev 19469)
+++ trunk/reactos/tools/rbuild/backend/devcpp/devcpp.cpp
2005-11-22 22:16:14 UTC (rev 19470)
@@ -129,11 +129,11 @@
{
Module &module = *ProjectNode.modules[i];
- for(size_t k = 0; k <
module.non_if_data.compilationUnits.size(); k++)
+ for(size_t k = 0; k < module.non_if_data.files.size();
k++)
{
- CompilationUnit &compilationUnit =
*module.non_if_data.compilationUnits[k];
- string filename = compilationUnit.GetFilename();
- ProcessFile(filename);
+ File &file = *module.non_if_data.files[k];
+
+ ProcessFile(file.name);
}
}
}
_____
Modified: trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp
--- trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp 2005-11-22
21:58:50 UTC (rev 19469)
+++ trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp 2005-11-22
22:16:14 UTC (rev 19470)
@@ -193,6 +193,7 @@
GenerateDirectories ();
UnpackWineResources ();
GenerateTestSupportCode ();
+ GenerateCompilationUnitSupportCode ();
GenerateProxyMakefiles ();
CheckAutomaticDependencies ();
CloseMakefile ();
@@ -523,6 +524,15 @@
printf ( "done\n" );
}
+void
+MingwBackend::GenerateCompilationUnitSupportCode ()
+{
+ printf ( "Generating compilation unit support code..." );
+ CompilationUnitSupportCode compilationUnitSupportCode (
ProjectNode );
+ compilationUnitSupportCode.Generate ( configuration.Verbose );
+ printf ( "done\n" );
+}
+
string
MingwBackend::GetProxyMakefileTree () const
{
_____
Modified: trunk/reactos/tools/rbuild/backend/mingw/mingw.h
--- trunk/reactos/tools/rbuild/backend/mingw/mingw.h 2005-11-22
21:58:50 UTC (rev 19469)
+++ trunk/reactos/tools/rbuild/backend/mingw/mingw.h 2005-11-22
22:16:14 UTC (rev 19470)
@@ -77,6 +77,7 @@
std::string GetBin2ResExecutable ();
void UnpackWineResources ();
void GenerateTestSupportCode ();
+ void GenerateCompilationUnitSupportCode ();
std::string GetProxyMakefileTree () const;
void GenerateProxyMakefiles ();
void CheckAutomaticDependencies ();
_____
Modified: trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
--- trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
2005-11-22 21:58:50 UTC (rev 19469)
+++ trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
2005-11-22 22:16:14 UTC (rev 19470)
@@ -121,6 +121,8 @@
Directory* directoryTree )
{
string directory ( GetDirectory ( RemoveVariables ( file ) ) );
+ if ( directoryTree == NULL )
+ return file;
string generatedFilesDirectory = backend->AddDirectoryTarget (
directory,
directoryTree );
if ( directory.find ( generatedFilesDirectory ) != string::npos
)
@@ -134,6 +136,13 @@
}
}
+/*static*/ string
+MingwModuleHandler::PassThruCacheDirectory (const FileLocation*
fileLocation )
+{
+ return PassThruCacheDirectory ( fileLocation->filename,
+ fileLocation->directory );
+}
+
/*static*/ Directory*
MingwModuleHandler::GetTargetDirectoryTree (
const Module& module )
@@ -264,16 +273,18 @@
return "";
}
-string
+FileLocation*
MingwModuleHandler::GetActualSourceFilename (
- const string& filename ) const
+ const FileLocation* fileLocation ) const
{
+ string filename = fileLocation->filename;
string extension = GetExtension ( filename );
if ( extension == ".spec" || extension == ".SPEC" )
{
string basename = GetBasename ( filename );
- return PassThruCacheDirectory ( NormalizeFilename (
basename + ".stubs.c" ),
-
backend->intermediateDirectory );
+ PassThruCacheDirectory ( NormalizeFilename ( basename +
".stubs.c" ),
+ backend->intermediateDirectory
);
+ return new FileLocation (
backend->intermediateDirectory, NormalizeFilename ( basename +
".stubs.c" ) );
}
else if ( extension == ".idl" || extension == ".IDL" )
{
@@ -283,11 +294,12 @@
newname = basename + "_s.c";
else
newname = basename + "_c.c";
- return PassThruCacheDirectory ( NormalizeFilename (
newname ),
-
backend->intermediateDirectory );
+ PassThruCacheDirectory ( NormalizeFilename ( newname ),
+ backend->intermediateDirectory
);
+ return new FileLocation (
backend->intermediateDirectory, NormalizeFilename ( newname ) );
}
else
- return filename;
+ return new FileLocation ( fileLocation->directory,
filename );
}
string
@@ -305,6 +317,21 @@
}
string
+MingwModuleHandler::GetCompilationUnitDependencies (
+ const CompilationUnit& compilationUnit ) const
+{
+ if ( compilationUnit.files.size () <= 1 )
+ return "";
+ vector<string> sourceFiles;
+ for ( size_t i = 0; i < compilationUnit.files.size (); i++ )
+ {
+ File& file = *compilationUnit.files[i];
+ sourceFiles.push_back ( NormalizeFilename ( file.name )
);
+ }
+ return v2s ( sourceFiles, 10 );
+}
+
+string
MingwModuleHandler::GetModuleArchiveFilename () const
{
if ( module.type == StaticLibrary )
@@ -393,7 +420,10 @@
{
if ( includeGeneratedFiles ||
!compilationUnits[i]->IsGeneratedFile () )
{
- list.push_back ( GetActualSourceFilename (
compilationUnits[i]->GetFilename () ) );
+ FileLocation* sourceFileLocation =
GetActualSourceFilename (
+ compilationUnits[i]->GetFilename (
backend->intermediateDirectory ) );
+ list.push_back ( PassThruCacheDirectory (
sourceFileLocation->filename,
+
sourceFileLocation->directory ) );
}
}
// intentionally make a copy so that we can append more work in
@@ -412,7 +442,12 @@
{
CompilationUnit& compilationUnit =
*compilationUnits[j];
if ( includeGeneratedFiles ||
!compilationUnit.IsGeneratedFile () )
- list.push_back ( GetActualSourceFilename
( compilationUnit.GetFilename () ) );
+ {
+ FileLocation* sourceFileLocation =
GetActualSourceFilename (
+ compilationUnit.GetFilename (
backend->intermediateDirectory ) );
+ list.push_back ( PassThruCacheDirectory
( sourceFileLocation->filename,
+
sourceFileLocation->directory ) );
+ }
}
}
}
@@ -426,11 +461,11 @@
string
MingwModuleHandler::GetObjectFilename (
- const string& sourceFilename,
+ const FileLocation* sourceFileLocation,
string_list* pclean_files ) const
{
+ string sourceFilename = sourceFileLocation->filename;
Directory* directoryTree;
-
string newExtension;
string extension = GetExtension ( sourceFilename );
if ( extension == ".rc" || extension == ".RC" )
@@ -550,7 +585,7 @@
{
if ( objectFilenames.size () > 0 )
objectFilenames += " ";
- objectFilenames += GetObjectFilename (
compilationUnits[i]->GetFilename (), NULL );
+ objectFilenames += GetObjectFilename (
compilationUnits[i]->GetFilename ( backend->intermediateDirectory ),
NULL );
}
return objectFilenames;
}
@@ -851,7 +886,7 @@
fprintf ( fMakefile,
"%s := %s $(%s)\n",
objectsMacro.c_str(),
- GetObjectFilename (
compilationUnit.GetFilename (), NULL ).c_str (),
+ GetObjectFilename (
compilationUnit.GetFilename ( backend->intermediateDirectory ), NULL
).c_str (),
objectsMacro.c_str() );
}
}
@@ -869,7 +904,7 @@
fMakefile,
"%s%s",
( i%10 == 9 ? " \\\n\t" : " " ),
- GetObjectFilename (
compilationUnit.GetFilename (), NULL ).c_str () );
+ GetObjectFilename (
compilationUnit.GetFilename ( backend->intermediateDirectory ), NULL
).c_str () );
}
}
fprintf ( fMakefile, "\n" );
@@ -910,7 +945,7 @@
fMakefile,
"%s += %s\n",
objectsMacro.c_str(),
- GetObjectFilename (
sourceCompilationUnits[i]->GetFilename (), NULL ).c_str () );
+ GetObjectFilename (
sourceCompilationUnits[i]->GetFilename ( backend->intermediateDirectory
), NULL ).c_str () );
}
CleanupCompilationUnitVector ( sourceCompilationUnits );
}
@@ -925,11 +960,12 @@
void
MingwModuleHandler::GenerateGccCommand (
- const string& sourceFilename,
+ const FileLocation* sourceFileLocation,
const string& extraDependencies,
const string& cc,
const string& cflagsMacro )
{
+ string sourceFilename = PassThruCacheDirectory (
sourceFileLocation );
string dependencies = sourceFilename;
if ( extraDependencies != "" )
dependencies += " " + extraDependencies;
@@ -943,7 +979,7 @@
dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
string objectFilename = GetObjectFilename (
- sourceFilename, &clean_files );
+ sourceFileLocation, &clean_files );
fprintf ( fMakefile,
"%s: %s | %s\n",
objectFilename.c_str (),
@@ -958,14 +994,15 @@
void
MingwModuleHandler::GenerateGccAssemblerCommand (
- const string& sourceFilename,
+ const FileLocation* sourceFileLocation,
const string& cc,
const string& cflagsMacro )
{
+ string sourceFilename = PassThruCacheDirectory (
sourceFileLocation );
string dependencies = sourceFilename;
dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
string objectFilename = GetObjectFilename (
- sourceFilename, &clean_files );
+ sourceFileLocation, &clean_files );
fprintf ( fMakefile,
"%s: %s | %s\n",
objectFilename.c_str (),
@@ -980,13 +1017,14 @@
void
MingwModuleHandler::GenerateNasmCommand (
- const string& sourceFilename,
+ const FileLocation* sourceFileLocation,
const string& nasmflagsMacro )
{
+ string sourceFilename = PassThruCacheDirectory (
sourceFileLocation );
string dependencies = sourceFilename;
dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
string objectFilename = GetObjectFilename (
- sourceFilename, &clean_files );
+ sourceFileLocation, &clean_files );
fprintf ( fMakefile,
"%s: %s | %s\n",
objectFilename.c_str (),
@@ -1001,13 +1039,13 @@
void
MingwModuleHandler::GenerateWindresCommand (
- const string& sourceFilename,
+ const FileLocation* sourceFileLocation,
const string& windresflagsMacro )
{
+ string sourceFilename = PassThruCacheDirectory (
sourceFileLocation );
string dependencies = sourceFilename;
dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
- string objectFilename =
- GetObjectFilename ( sourceFilename, &clean_files );
+ string objectFilename = GetObjectFilename ( sourceFileLocation,
&clean_files );
string sourceFilenamePart = ReplaceExtension ( GetFilename (
sourceFilename ), "" );
string rciFilename = ros_temp + module.name + "." +
sourceFilenamePart + ".rci.tmp";
string resFilename = ros_temp + module.name + "." +
sourceFilenamePart + ".res.tmp";
@@ -1056,8 +1094,9 @@
void
MingwModuleHandler::GenerateWinebuildCommands (
- const string& sourceFilename )
+ const FileLocation* sourceFileLocation )
{
+ string sourceFilename = PassThruCacheDirectory (
sourceFileLocation );
string dependencies = sourceFilename;
dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
@@ -1113,7 +1152,8 @@
const CompilationUnit& compilationUnit,
const string& widlflagsMacro )
{
- string filename = compilationUnit.GetFilename ();
+ FileLocation* sourceFileLocation = compilationUnit.GetFilename (
backend->intermediateDirectory );
+ string filename = sourceFileLocation->filename;
string dependencies = filename;
dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
@@ -1156,7 +1196,8 @@
const CompilationUnit& compilationUnit,
const string& widlflagsMacro )
{
- string filename = compilationUnit.GetFilename ();
+ FileLocation* sourceFileLocation = compilationUnit.GetFilename (
backend->intermediateDirectory );
+ string filename = sourceFileLocation->filename;
string dependencies = filename;
dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
@@ -1210,12 +1251,13 @@
const string& windresflagsMacro,
const string& widlflagsMacro )
{
- string filename = compilationUnit.GetFilename ();
+ FileLocation* sourceFileLocation = compilationUnit.GetFilename (
backend->intermediateDirectory );
+ string filename = sourceFileLocation->filename;
string extension = GetExtension ( filename );
if ( extension == ".c" || extension == ".C" )
{
- GenerateGccCommand ( filename,
- "",
+ GenerateGccCommand ( sourceFileLocation,
+ GetCompilationUnitDependencies (
compilationUnit ),
cc,
cflagsMacro );
return;
@@ -1224,35 +1266,35 @@
extension == ".cpp" || extension == ".CPP" ||
extension == ".cxx" || extension == ".CXX" )
{
- GenerateGccCommand ( filename,
- "",
+ GenerateGccCommand ( sourceFileLocation,
+ GetCompilationUnitDependencies (
compilationUnit ),
cppc,
cflagsMacro );
return;
}
else if ( extension == ".s" || extension == ".S" )
{
- GenerateGccAssemblerCommand ( filename,
+ GenerateGccAssemblerCommand ( sourceFileLocation,
cc,
cflagsMacro );
return;
}
else if ( extension == ".asm" || extension == ".ASM" )
{
- GenerateNasmCommand ( filename,
+ GenerateNasmCommand ( sourceFileLocation,
nasmflagsMacro );
return;
}
else if ( extension == ".rc" || extension == ".RC" )
{
- GenerateWindresCommand ( filename,
+ GenerateWindresCommand ( sourceFileLocation,
windresflagsMacro );
return;
}
else if ( extension == ".spec" || extension == ".SPEC" )
{
- GenerateWinebuildCommands ( filename );
- GenerateGccCommand ( GetActualSourceFilename ( filename
),
+ GenerateWinebuildCommands ( sourceFileLocation );
+ GenerateGccCommand ( GetActualSourceFilename (
sourceFileLocation ),
"",
cc,
cflagsMacro );
@@ -1262,7 +1304,7 @@
{
GenerateWidlCommands ( compilationUnit,
widlflagsMacro );
- GenerateGccCommand ( GetActualSourceFilename ( filename
),
+ GenerateGccCommand ( GetActualSourceFilename (
sourceFileLocation ),
GetExtraDependencies ( filename ),
cc,
cflagsMacro );
@@ -1369,7 +1411,7 @@
for ( size_t i = 0; i < data.compilationUnits.size (); i++ )
{
CompilationUnit& compilationUnit =
*data.compilationUnits[i];
- objectFiles.push_back ( GetObjectFilename (
compilationUnit.GetFilename (), NULL ) );
+ objectFiles.push_back ( GetObjectFilename (
compilationUnit.GetFilename ( backend->intermediateDirectory ), NULL )
);
}
}
@@ -1701,11 +1743,11 @@
for ( size_t j = 0; j <
library.importedModule->non_if_data.compilationUnits.size (); j++ )
{
CompilationUnit& compilationUnit =
*library.importedModule->non_if_data.compilationUnits[j];
- string filename =
compilationUnit.GetFilename ();
- string extension = GetExtension (
filename );
+ FileLocation* sourceFileLocation =
compilationUnit.GetFilename ( backend->intermediateDirectory );
+ string extension = GetExtension (
sourceFileLocation->filename );
if ( extension == ".idl" || extension ==
".IDL" )
{
- string basename = GetBasename (
filename );
+ string basename = GetBasename (
sourceFileLocation->filename );
if (
library.importedModule->type == RpcServer )
dependencies.push_back (
GetRpcServerHeaderFilename ( basename ) );
if (
library.importedModule->type == RpcClient )
@@ -1739,10 +1781,10 @@
for ( size_t i = 0; i < compilationUnits.size (); i++ )
{
CompilationUnit& compilationUnit =
*compilationUnits[i];
- string filename = compilationUnit.GetFilename
();
- string extension = GetExtension ( filename );
+ FileLocation* sourceFileLocation =
compilationUnit.GetFilename ( backend->intermediateDirectory );
+ string extension = GetExtension (
sourceFileLocation->filename );
if ( extension == ".spec" || extension ==
".SPEC" )
- GetSpecObjectDependencies ( s, filename
);
+ GetSpecObjectDependencies ( s,
sourceFileLocation->filename );
}
}
if ( s.size () > 0 )
@@ -2094,12 +2136,12 @@
for ( size_t i = 0; i < compilationUnits.size (); i++ )
{
CompilationUnit& compilationUnit = *compilationUnits[i];
- string filename = compilationUnit.GetFilename ();
- string extension = GetExtension ( filename );
+ FileLocation* sourceFileLocation =
compilationUnit.GetFilename ( backend->intermediateDirectory );
+ string extension = GetExtension (
sourceFileLocation->filename );
if ( extension == ".spec" || extension == ".SPEC" )
- GetSpecObjectDependencies ( dependencies,
filename );
+ GetSpecObjectDependencies ( dependencies,
sourceFileLocation->filename );
if ( extension == ".idl" || extension == ".IDL" )
- GetWidlObjectDependencies ( dependencies,
filename );
+ GetWidlObjectDependencies ( dependencies,
sourceFileLocation->filename );
}
}
_____
Modified: trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h
--- trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h
2005-11-22 21:58:50 UTC (rev 19469)
+++ trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h
2005-11-22 22:16:14 UTC (rev 19470)
@@ -45,6 +45,8 @@
const std::string &f,
Directory* directoryTree );
+ static std::string PassThruCacheDirectory (const FileLocation*
fileLocation );
+
static Directory* GetTargetDirectoryTree (
const Module& module );
@@ -84,8 +86,9 @@
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;
+ FileLocation* GetActualSourceFilename ( const FileLocation*
fileLocation ) const;
std::string GetExtraDependencies ( const std::string& filename )
const;
+ std::string MingwModuleHandler::GetCompilationUnitDependencies (
const CompilationUnit& compilationUnit ) const;
std::string GetModuleArchiveFilename () const;
bool IsGeneratedFile ( const File& file ) const;
std::string GetImportLibraryDependency ( const Module&
importedModule );
@@ -96,7 +99,7 @@
void GetSourceFilenames ( string_list& list,
bool includeGeneratedFiles ) const;
void GetSourceFilenamesWithoutGeneratedFiles ( string_list& list
) const;
- std::string GetObjectFilename ( const std::string&
sourceFilename,
+ std::string GetObjectFilename ( const FileLocation*
sourceFileLocation,
string_list* pclean_files )
const;
std::string GetObjectFilenames ();
@@ -144,18 +147,18 @@
std::string GenerateGccParameters () const;
std::string GenerateNasmParameters () const;
std::string MingwModuleHandler::GetPrecompiledHeaderFilename ()
const;
- void GenerateGccCommand ( const std::string& sourceFilename,
+ void GenerateGccCommand ( const FileLocation*
sourceFileLocation,
const std::string& extraDependencies,
const std::string& cc,
const std::string& cflagsMacro );
- void GenerateGccAssemblerCommand ( const std::string&
sourceFilename,
+ void GenerateGccAssemblerCommand ( const FileLocation*
sourceFileLocation,
const std::string& cc,
const std::string&
cflagsMacro );
- void GenerateNasmCommand ( const std::string& sourceFilename,
+ void GenerateNasmCommand ( const FileLocation*
sourceFileLocation,
const std::string& nasmflagsMacro );
- void GenerateWindresCommand ( const std::string& sourceFilename,
+ void GenerateWindresCommand ( const FileLocation*
sourceFileLocation,
const std::string&
windresflagsMacro );
- void GenerateWinebuildCommands ( const std::string&
sourceFilename );
+ void GenerateWinebuildCommands ( const FileLocation*
sourceFileLocation );
std::string GetWidlFlags ( const CompilationUnit&
compilationUnit );
void GenerateWidlCommandsServer (
const CompilationUnit& compilationUnit,
_____
Modified: trunk/reactos/tools/rbuild/compilationunit.cpp
--- trunk/reactos/tools/rbuild/compilationunit.cpp 2005-11-22
21:58:50 UTC (rev 19469)
+++ trunk/reactos/tools/rbuild/compilationunit.cpp 2005-11-22
22:16:14 UTC (rev 19470)
@@ -28,6 +28,7 @@
module(NULL),
node(NULL)
{
+ name = file->name;
files.push_back ( file );
}
@@ -38,6 +39,9 @@
module(module),
node(node)
{
+ const XMLAttribute* att = node->GetAttribute ( "name", true );
+ assert(att);
+ name = module->GetBasePath () + cSep + att->value;
}
CompilationUnit::~CompilationUnit ()
@@ -83,28 +87,25 @@
CompilationUnit::IsFirstFile () const
{
if ( files.size () == 0 || files.size () > 1 )
-{
-printf("fs:'%d'\n", files.size ());
- throw InvalidOperationException ( __FILE__, __LINE__ );
-}
+ return false;
File* file = files[0];
return file->first;
}
-std::string
-CompilationUnit::GetFilename () const
+FileLocation*
+CompilationUnit::GetFilename ( Directory* intermediateDirectory ) const
{
if ( files.size () == 0 || files.size () > 1 )
- throw InvalidOperationException ( __FILE__, __LINE__ );
+ return new FileLocation ( intermediateDirectory, name );
File* file = files[0];
- return file->name;
+ return new FileLocation ( NULL, file->name );
}
std::string
CompilationUnit::GetSwitches () const
{
if ( files.size () == 0 || files.size () > 1 )
- throw InvalidOperationException ( __FILE__, __LINE__ );
+ return "";
File* file = files[0];
return file->switches;
}
_____
Added: trunk/reactos/tools/rbuild/compilationunitsupportcode.cpp
--- trunk/reactos/tools/rbuild/compilationunitsupportcode.cpp
2005-11-22 21:58:50 UTC (rev 19469)
+++ trunk/reactos/tools/rbuild/compilationunitsupportcode.cpp
2005-11-22 22:16:14 UTC (rev 19470)
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2005 Casper S. Hornstrup
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#include "pch.h"
+#include <assert.h>
+
+#include "rbuild.h"
+
+using std::string;
+using std::vector;
+
+CompilationUnitSupportCode::CompilationUnitSupportCode ( const Project&
project )
+ : project ( project )
+{
+}
+
+CompilationUnitSupportCode::~CompilationUnitSupportCode ()
+{
+}
+
+void
+CompilationUnitSupportCode::Generate ( bool verbose )
+{
+ for ( size_t i = 0; i < project.modules.size (); i++ )
+ {
+ GenerateForModule ( *project.modules[i],
+ verbose );
+ }
+}
+
+void
+CompilationUnitSupportCode::GenerateForModule ( Module& module,
+ bool verbose )
+{
+ if ( verbose )
+ {
+ printf ( "\nGenerating compilation unit support code for
%s",
+ module.name.c_str () );
+ }
+
+ for ( size_t i = 0; i < module.non_if_data.compilationUnits.size
() ; i++ )
+ {
+ CompilationUnit& compilationUnit =
*module.non_if_data.compilationUnits[i];
+ if ( compilationUnit.files.size () <= 1 )
+ continue;
+ WriteCompilationUnitFile ( module, compilationUnit );
+ }
+}
+
+string
+CompilationUnitSupportCode::GetCompilationUnitFilename ( Module&
module,
+
CompilationUnit& compilationUnit )
+{
+ return NormalizeFilename ( Environment::GetIntermediatePath () +
sSep + compilationUnit.name );
+}
+
+void
+CompilationUnitSupportCode::WriteCompilationUnitFile ( Module& module,
+ CompilationUnit&
compilationUnit )
+{
+ char* buf;
+ char* s;
+
+ buf = (char*) malloc ( 512*1024 );
+ if ( buf == NULL )
+ throw OutOfMemoryException ();
+
+ s = buf;
+ s = s + sprintf ( s, "/* This file is automatically generated.
*/\n" );
+ s = s + sprintf ( s, "#define ONE_COMPILATION_UNIT\n" );
+ if ( module.pch )
+ s = s + sprintf ( s, "#include <%s>\n",
NormalizeFilename ( module.pch->file.name ).c_str () );
+
+ for ( size_t i = 0; i < compilationUnit.files.size () ; i++ )
+ {
+ File& file = *compilationUnit.files[i];
+ s = s + sprintf ( s, "#include \"%s\"\n",
file.name.c_str () );
+ }
+
+ s = s + sprintf ( s, "\n" );
+
+ FileSupportCode::WriteIfChanged ( buf,
GetCompilationUnitFilename ( module, compilationUnit ) );
+
+ free ( buf );
+}
Property changes on:
trunk/reactos/tools/rbuild/compilationunitsupportcode.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
_____
Modified: trunk/reactos/tools/rbuild/doc/rbuild.txt
--- trunk/reactos/tools/rbuild/doc/rbuild.txt 2005-11-22 21:58:50 UTC
(rev 19469)
+++ trunk/reactos/tools/rbuild/doc/rbuild.txt 2005-11-22 22:16:14 UTC
(rev 19470)
@@ -195,12 +195,12 @@
A compilationunit element specifies that one or more source code files
are to be compiled as a single compilation unit.
Syntax:
- <compilationunit>
+ <compilationunit name="kernel32.c">
...
</compilationunit>
Attributes:
- None.
+ name - Name of generated source code file.
Value:
None.
_____
Modified: trunk/reactos/tools/rbuild/project.cpp
--- trunk/reactos/tools/rbuild/project.cpp 2005-11-22 21:58:50 UTC
(rev 19469)
+++ trunk/reactos/tools/rbuild/project.cpp 2005-11-22 22:16:14 UTC
(rev 19470)
@@ -72,6 +72,15 @@
{
}
+
+FileLocation::FileLocation ( Directory* directory,
+ std::string filename )
+ : directory (directory),
+ filename (filename)
+{
+}
+
+
Project::Project ( const string& filename )
: xmlfile (filename),
node (NULL),
_____
Modified: trunk/reactos/tools/rbuild/rbuild.h
--- trunk/reactos/tools/rbuild/rbuild.h 2005-11-22 21:58:50 UTC (rev
19469)
+++ trunk/reactos/tools/rbuild/rbuild.h 2005-11-22 22:16:14 UTC (rev
19470)
@@ -93,6 +93,7 @@
class StubbedComponent;
class StubbedSymbol;
class CompilationUnit;
+class FileLocation;
class SourceFileTest;
@@ -817,6 +818,7 @@
const Project* project;
const Module* module;
const XMLElement* node;
+ std::string name;
std::vector<File*> files;
CompilationUnit ( File* file );
@@ -828,11 +830,39 @@
bool IsGeneratedFile () const;
bool HasFileWithExtension ( const std::string& extension )
const;
bool IsFirstFile () const;
- std::string GetFilename () const;
+ FileLocation* GetFilename ( Directory* intermediateDirectory )
const;
std::string GetSwitches () const;
};
+class CompilationUnitSupportCode
+{
+public:
+ const Project& project;
+
+ CompilationUnitSupportCode ( const Project& project );
+ ~CompilationUnitSupportCode ();
+ void Generate ( bool verbose );
+private:
+ void GenerateForModule ( Module& module,
+ bool verbose );
+ std::string GetCompilationUnitFilename ( Module& module,
+ CompilationUnit&
compilationUnit );
+ void WriteCompilationUnitFile ( Module& module,
+ CompilationUnit& compilationUnit
);
+};
+
+
+class FileLocation
+{
+public:
+ Directory* directory;
+ std::string filename;
+ FileLocation ( Directory* directory,
+ std::string filename );
+};
+
+
extern void
InitializeEnvironment ();
_____
Modified: trunk/reactos/tools/rbuild/rbuild.mak
--- trunk/reactos/tools/rbuild/rbuild.mak 2005-11-22 21:58:50 UTC
(rev 19469)
+++ trunk/reactos/tools/rbuild/rbuild.mak 2005-11-22 22:16:14 UTC
(rev 19470)
@@ -157,6 +157,7 @@
bootstrap.cpp \
cdfile.cpp \
compilationunit.cpp \
+ compilationunitsupportcode.cpp \
compilerflag.cpp \
configuration.cpp \
define.cpp \
@@ -280,6 +281,10 @@
$(ECHO_CC)
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
+$(RBUILD_INT_)compilationunitsupportcode.o:
$(RBUILD_BASE_)compilationunitsupportcode.cpp $(RBUILD_HEADERS) |
$(RBUILD_INT)
+ $(ECHO_CC)
+ ${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
+
$(RBUILD_INT_)compilerflag.o: $(RBUILD_BASE_)compilerflag.cpp
$(RBUILD_HEADERS) | $(RBUILD_INT)
$(ECHO_CC)
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
_____
Modified: trunk/reactos/tools/rbuild/testsupportcode.cpp
--- trunk/reactos/tools/rbuild/testsupportcode.cpp 2005-11-22
21:58:50 UTC (rev 19469)
+++ trunk/reactos/tools/rbuild/testsupportcode.cpp 2005-11-22
22:16:14 UTC (rev 19470)
@@ -297,7 +297,8 @@
const vector<CompilationUnit*>& compilationUnits =
module.non_if_data.compilationUnits;
for ( i = 0; i < compilationUnits.size (); i++ )
{
- string filename = compilationUnits[i]->GetFilename();
+ FileLocation* sourceFileLocation =
compilationUnits[i]->GetFilename ( NULL );
+ string filename = sourceFileLocation->filename;
if ( !compilationUnits[i]->IsGeneratedFile () &&
IsTestFile ( filename ) )
list.push_back ( filename );
}
@@ -316,7 +317,8 @@
for ( j = 0; j < compilationUnits.size (); j++ )
{
CompilationUnit& compilationUnit =
*compilationUnits[j];
- string filename =
compilationUnits[j]->GetFilename();
+ FileLocation* sourceFileLocation =
compilationUnits[j]->GetFilename ( NULL );
+ string filename = sourceFileLocation->filename;
if ( !compilationUnit.IsGeneratedFile () &&
IsTestFile ( filename ) )
list.push_back ( filename );
}