* Name compilation unit

* Generate compilation unit support code


svn path=/trunk/; revision=19470
This commit is contained in:
Casper Hornstrup 2005-11-22 22:16:14 +00:00
parent dc1f52977d
commit b102fa96a8
12 changed files with 276 additions and 74 deletions

View file

@ -129,11 +129,11 @@ void DevCppBackend::ProcessModules()
{
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);
}
}
}

View file

@ -193,6 +193,7 @@ MingwBackend::ProcessNormal ()
GenerateDirectories ();
UnpackWineResources ();
GenerateTestSupportCode ();
GenerateCompilationUnitSupportCode ();
GenerateProxyMakefiles ();
CheckAutomaticDependencies ();
CloseMakefile ();
@ -523,6 +524,15 @@ MingwBackend::GenerateTestSupportCode ()
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
{

View file

@ -77,6 +77,7 @@ private:
std::string GetBin2ResExecutable ();
void UnpackWineResources ();
void GenerateTestSupportCode ();
void GenerateCompilationUnitSupportCode ();
std::string GetProxyMakefileTree () const;
void GenerateProxyMakefiles ();
void CheckAutomaticDependencies ();

View file

@ -121,6 +121,8 @@ MingwModuleHandler::PassThruCacheDirectory (
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 @@ MingwModuleHandler::PassThruCacheDirectory (
}
}
/*static*/ string
MingwModuleHandler::PassThruCacheDirectory (const FileLocation* fileLocation )
{
return PassThruCacheDirectory ( fileLocation->filename,
fileLocation->directory );
}
/*static*/ Directory*
MingwModuleHandler::GetTargetDirectoryTree (
const Module& module )
@ -264,16 +273,18 @@ MingwModuleHandler::GetBasename ( const string& filename ) const
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 @@ MingwModuleHandler::GetActualSourceFilename (
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
@ -304,6 +316,21 @@ MingwModuleHandler::GetExtraDependencies (
return "";
}
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
{
@ -393,7 +420,10 @@ MingwModuleHandler::GetSourceFilenames ( string_list& list,
{
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 @@ MingwModuleHandler::GetSourceFilenames ( string_list& list,
{
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 @@ MingwModuleHandler::GetSourceFilenamesWithoutGeneratedFiles (
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 @@ MingwModuleHandler::GetObjectFilenames ()
{
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 @@ MingwModuleHandler::GenerateObjectMacros (
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 @@ MingwModuleHandler::GenerateObjectMacros (
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 @@ MingwModuleHandler::GenerateObjectMacros (
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 @@ MingwModuleHandler::GetPrecompiledHeaderFilename () const
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 @@ MingwModuleHandler::GenerateGccCommand (
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 @@ MingwModuleHandler::GenerateGccCommand (
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 @@ MingwModuleHandler::GenerateGccAssemblerCommand (
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 @@ MingwModuleHandler::GenerateNasmCommand (
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 @@ MingwModuleHandler::GenerateWindresCommand (
void
MingwModuleHandler::GenerateWinebuildCommands (
const string& sourceFilename )
const FileLocation* sourceFileLocation )
{
string sourceFilename = PassThruCacheDirectory ( sourceFileLocation );
string dependencies = sourceFilename;
dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
@ -1113,7 +1152,8 @@ MingwModuleHandler::GenerateWidlCommandsServer (
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 @@ MingwModuleHandler::GenerateWidlCommandsClient (
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 @@ MingwModuleHandler::GenerateCommands (
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 @@ MingwModuleHandler::GenerateCommands (
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 @@ MingwModuleHandler::GenerateCommands (
{
GenerateWidlCommands ( compilationUnit,
widlflagsMacro );
GenerateGccCommand ( GetActualSourceFilename ( filename ),
GenerateGccCommand ( GetActualSourceFilename ( sourceFileLocation ),
GetExtraDependencies ( filename ),
cc,
cflagsMacro );
@ -1369,7 +1411,7 @@ MingwModuleHandler::GetObjectsVector ( const IfableData& data,
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 @@ MingwModuleHandler::GetRpcHeaderDependencies (
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 @@ MingwModuleHandler::GenerateOtherMacros ()
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 @@ MingwModuleHandler::GetDefinitionDependencies (
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 );
}
}

View file

@ -45,6 +45,8 @@ public:
const std::string &f,
Directory* directoryTree );
static std::string PassThruCacheDirectory (const FileLocation* fileLocation );
static Directory* GetTargetDirectoryTree (
const Module& module );
@ -84,8 +86,9 @@ protected:
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 @@ protected:
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 @@ private:
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,

View file

@ -28,6 +28,7 @@ CompilationUnit::CompilationUnit ( File* file )
module(NULL),
node(NULL)
{
name = file->name;
files.push_back ( file );
}
@ -38,6 +39,9 @@ CompilationUnit::CompilationUnit ( const Project* project,
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 @@ bool
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;
}

View file

@ -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 );
}

View file

@ -195,12 +195,12 @@ CompilationUnit element
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.

View file

@ -72,6 +72,15 @@ ParseContext::ParseContext ()
{
}
FileLocation::FileLocation ( Directory* directory,
std::string filename )
: directory (directory),
filename (filename)
{
}
Project::Project ( const string& filename )
: xmlfile (filename),
node (NULL),

View file

@ -93,6 +93,7 @@ class PchFile;
class StubbedComponent;
class StubbedSymbol;
class CompilationUnit;
class FileLocation;
class SourceFileTest;
@ -817,6 +818,7 @@ public:
const Project* project;
const Module* module;
const XMLElement* node;
std::string name;
std::vector<File*> files;
CompilationUnit ( File* file );
@ -828,11 +830,39 @@ public:
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 ();

View file

@ -157,6 +157,7 @@ RBUILD_COMMON_SOURCES = \
bootstrap.cpp \
cdfile.cpp \
compilationunit.cpp \
compilationunitsupportcode.cpp \
compilerflag.cpp \
configuration.cpp \
define.cpp \
@ -280,6 +281,10 @@ $(RBUILD_INT_)compilationunit.o: $(RBUILD_BASE_)compilationunit.cpp $(RBUILD_HEA
$(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 $@

View file

@ -297,7 +297,8 @@ TestSupportCode::GetSourceFilenames ( string_list& list,
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 @@ TestSupportCode::GetSourceFilenames ( string_list& list,
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 );
}