Release memory when not needed anymore

Do not display errors when checking for binutils
Cleanup PCH handling

svn path=/trunk/; revision=31562
This commit is contained in:
Hervé Poussineau 2008-01-02 14:04:35 +00:00
parent f7b85736c3
commit 09b813c184
2 changed files with 179 additions and 53 deletions

View file

@ -929,7 +929,7 @@ bool
MingwBackend::TryToDetectThisBinutils ( const string& binutils ) MingwBackend::TryToDetectThisBinutils ( const string& binutils )
{ {
string command = ssprintf ( string command = ssprintf (
"%s -v 1>%s", "%s -v 1>%s 2>%s",
FixSeparatorForSystemCommand(binutils).c_str (), FixSeparatorForSystemCommand(binutils).c_str (),
NUL, NUL,
NUL ); NUL );

View file

@ -122,7 +122,8 @@ MingwModuleHandler::PassThruCacheDirectory (const FileLocation* file )
return file; return file;
} }
/*static*/ const FileLocation* /* caller needs to delete the returned object */
const FileLocation*
MingwModuleHandler::GetTargetFilename ( MingwModuleHandler::GetTargetFilename (
const Module& module, const Module& module,
string_list* pclean_files ) string_list* pclean_files )
@ -136,7 +137,8 @@ MingwModuleHandler::GetTargetFilename (
return target; return target;
} }
/*static*/ const FileLocation* /* caller needs to delete the returned object */
const FileLocation*
MingwModuleHandler::GetImportLibraryFilename ( MingwModuleHandler::GetImportLibraryFilename (
const Module& module, const Module& module,
string_list* pclean_files ) string_list* pclean_files )
@ -150,7 +152,8 @@ MingwModuleHandler::GetImportLibraryFilename (
return target; return target;
} }
/*static*/ MingwModuleHandler* /* caller needs to delete the returned object */
MingwModuleHandler*
MingwModuleHandler::InstanciateHandler ( MingwModuleHandler::InstanciateHandler (
const Module& module, const Module& module,
MingwBackend* backend ) MingwBackend* backend )
@ -261,6 +264,7 @@ MingwModuleHandler::GetBasename ( const string& filename ) const
return ""; return "";
} }
/* caller needs to delete the returned object */
const FileLocation* const FileLocation*
MingwModuleHandler::GetActualSourceFilename ( MingwModuleHandler::GetActualSourceFilename (
const FileLocation* file ) const const FileLocation* file ) const
@ -311,11 +315,22 @@ MingwModuleHandler::GetExtraDependencies (
if ( extension == ".idl" || extension == ".IDL" ) if ( extension == ".idl" || extension == ".IDL" )
{ {
if ( (module.type == RpcServer) || (module.type == RpcClient) ) if ( (module.type == RpcServer) || (module.type == RpcClient) )
return backend->GetFullName ( *GetRpcServerHeaderFilename ( file ) ) {
+ " " const FileLocation *server_header = GetRpcServerHeaderFilename ( file );
+ backend->GetFullName ( *GetRpcClientHeaderFilename ( file ) ); const FileLocation *client_header = GetRpcClientHeaderFilename ( file );
string dependencies = backend->GetFullName ( *server_header ) + " " +
backend->GetFullName ( *client_header );
delete server_header;
delete client_header;
return dependencies;
}
else if ( module.type == IdlHeader ) else if ( module.type == IdlHeader )
return backend->GetFullName ( *GetIdlHeaderFilename ( file ) ); {
const FileLocation *idl_header = GetIdlHeaderFilename ( file );
string dependencies = backend->GetFullName ( *idl_header );
delete idl_header;
return dependencies;
}
else else
return ""; return "";
} }
@ -338,11 +353,12 @@ MingwModuleHandler::GetCompilationUnitDependencies (
return v2s ( sourceFiles, 10 ); return v2s ( sourceFiles, 10 );
} }
/* caller needs to delete the returned object */
const FileLocation* const FileLocation*
MingwModuleHandler::GetModuleArchiveFilename () const MingwModuleHandler::GetModuleArchiveFilename () const
{ {
if ( module.type == StaticLibrary ) if ( module.type == StaticLibrary )
return new FileLocation ( *GetTargetFilename ( module, NULL ) ); return GetTargetFilename ( module, NULL );
return new FileLocation ( IntermediateDirectory, return new FileLocation ( IntermediateDirectory,
module.output->relative_path, module.output->relative_path,
ReplaceExtension ( module.name, ".temp.a" ) ); ReplaceExtension ( module.name, ".temp.a" ) );
@ -410,7 +426,11 @@ MingwModuleHandler::GetImportLibraryDependency (
} }
} }
else else
dep = backend->GetFullName ( *GetImportLibraryFilename ( importedModule, NULL ) ); {
const FileLocation *library_target = GetImportLibraryFilename ( importedModule, NULL );
dep = backend->GetFullName ( *library_target );
delete library_target;
}
return dep; return dep;
} }
@ -470,6 +490,7 @@ MingwModuleHandler::GetSourceFilenames ( vector<FileLocation>& list,
const FileLocation* sourceFileLocation = GetActualSourceFilename ( const FileLocation* sourceFileLocation = GetActualSourceFilename (
compilationUnits[i]->GetFilename () ); compilationUnits[i]->GetFilename () );
list.push_back ( *sourceFileLocation ); list.push_back ( *sourceFileLocation );
delete sourceFileLocation;
} }
} }
// intentionally make a copy so that we can append more work in // intentionally make a copy so that we can append more work in
@ -492,6 +513,7 @@ MingwModuleHandler::GetSourceFilenames ( vector<FileLocation>& list,
const FileLocation* sourceFileLocation = GetActualSourceFilename ( const FileLocation* sourceFileLocation = GetActualSourceFilename (
compilationUnit.GetFilename () ); compilationUnit.GetFilename () );
list.push_back ( *sourceFileLocation ); list.push_back ( *sourceFileLocation );
delete sourceFileLocation;
} }
} }
} }
@ -504,6 +526,7 @@ MingwModuleHandler::GetSourceFilenamesWithoutGeneratedFiles (
GetSourceFilenames ( list, false ); GetSourceFilenames ( list, false );
} }
/* caller needs to delete the returned object */
const FileLocation* const FileLocation*
MingwModuleHandler::GetObjectFilename ( MingwModuleHandler::GetObjectFilename (
const FileLocation* sourceFile, const FileLocation* sourceFile,
@ -649,7 +672,9 @@ MingwModuleHandler::GetObjectFilenames ()
{ {
if ( objectFilenames.size () > 0 ) if ( objectFilenames.size () > 0 )
objectFilenames += " "; objectFilenames += " ";
objectFilenames += backend->GetFullName ( *GetObjectFilename ( compilationUnits[i]->GetFilename (), module, NULL ) ); const FileLocation *object_file = GetObjectFilename ( compilationUnits[i]->GetFilename (), module, NULL );
objectFilenames += backend->GetFullName ( *object_file );
delete object_file;
} }
return objectFilenames; return objectFilenames;
} }
@ -812,11 +837,13 @@ MingwModuleHandler::GenerateMacro (
assignmentOperation ); assignmentOperation );
} }
if ( use_pch && module.pch != NULL ) const FileLocation *pchFilename = GetPrecompiledHeaderFilename ();
if ( pchFilename )
{ {
fprintf ( fMakefile, fprintf ( fMakefile,
" -I%s", " -I%s",
backend->GetFullPath ( *GetPrecompiledHeaderFilename () ).c_str () ); backend->GetFullPath ( *pchFilename ).c_str () );
delete pchFilename;
} }
if ( generatingCompilerMacro ) if ( generatingCompilerMacro )
@ -966,7 +993,7 @@ MingwModuleHandler::GenerateMacros (
void void
MingwModuleHandler::CleanupCompilationUnitVector ( vector<CompilationUnit*>& compilationUnits ) MingwModuleHandler::CleanupCompilationUnitVector ( vector<CompilationUnit*>& compilationUnits )
{ {
for (size_t i = 0; i < compilationUnits.size (); i++) for ( size_t i = 0; i < compilationUnits.size (); i++ )
delete compilationUnits[i]; delete compilationUnits[i];
} }
@ -1051,7 +1078,7 @@ MingwModuleHandler::GenerateObjectMacros (
const vector<CompilationUnit*>& compilationUnits = data.compilationUnits; const vector<CompilationUnit*>& compilationUnits = data.compilationUnits;
vector<const FileLocation *> headers; vector<const FileLocation *> headers;
vector<const FileLocation *> mcheaders; vector<const FileLocation *> mcheaders;
vector<const FileLocation *> mcresources; vector<const FileLocation *> mcresources;
if ( compilationUnits.size () > 0 ) if ( compilationUnits.size () > 0 )
{ {
@ -1060,11 +1087,13 @@ MingwModuleHandler::GenerateObjectMacros (
CompilationUnit& compilationUnit = *compilationUnits[i]; CompilationUnit& compilationUnit = *compilationUnits[i];
if ( compilationUnit.IsFirstFile () ) if ( compilationUnit.IsFirstFile () )
{ {
const FileLocation *object_file = GetObjectFilename ( compilationUnit.GetFilename (), module, NULL );
fprintf ( fMakefile, fprintf ( fMakefile,
"%s := %s $(%s)\n", "%s := %s $(%s)\n",
objectsMacro.c_str(), objectsMacro.c_str(),
backend->GetFullName ( *GetObjectFilename ( compilationUnit.GetFilename (), module, NULL ) ).c_str (), backend->GetFullName ( *object_file ).c_str (),
objectsMacro.c_str() ); objectsMacro.c_str() );
delete object_file;
} }
} }
fprintf ( fprintf (
@ -1080,18 +1109,21 @@ MingwModuleHandler::GenerateObjectMacros (
const FileLocation *objectFilename = GetObjectFilename ( compilationUnit.GetFilename (), module, NULL ); const FileLocation *objectFilename = GetObjectFilename ( compilationUnit.GetFilename (), module, NULL );
if ( GetExtension ( *objectFilename ) == ".h" ) if ( GetExtension ( *objectFilename ) == ".h" )
headers.push_back ( objectFilename ); headers.push_back ( objectFilename );
else if ( GetExtension ( *objectFilename ) == ".rc" ) else if ( GetExtension ( *objectFilename ) == ".rc" )
{ {
const FileLocation *headerFilename = GetMcHeaderFilename ( compilationUnit.GetFilename () ); const FileLocation *headerFilename = GetMcHeaderFilename ( compilationUnit.GetFilename () );
mcheaders.push_back ( headerFilename ); mcheaders.push_back ( headerFilename );
mcresources.push_back ( objectFilename ); mcresources.push_back ( objectFilename );
} }
else else
{
fprintf ( fprintf (
fMakefile, fMakefile,
"%s%s", "%s%s",
( i%10 == 9 ? " \\\n\t" : " " ), ( i%10 == 9 ? " \\\n\t" : " " ),
backend->GetFullName ( *objectFilename ).c_str () ); backend->GetFullName ( *objectFilename ).c_str () );
delete objectFilename;
}
} }
} }
fprintf ( fMakefile, "\n" ); fprintf ( fMakefile, "\n" );
@ -1104,15 +1136,18 @@ MingwModuleHandler::GenerateObjectMacros (
module.name.c_str (), module.name.c_str (),
assignmentOperation ); assignmentOperation );
for ( i = 0; i < headers.size (); i++ ) for ( i = 0; i < headers.size (); i++ )
{
fprintf ( fprintf (
fMakefile, fMakefile,
"%s%s", "%s%s",
( i%10 == 9 ? " \\\n\t" : " " ), ( i%10 == 9 ? " \\\n\t" : " " ),
backend->GetFullName ( *headers[i] ).c_str () ); backend->GetFullName ( *headers[i] ).c_str () );
delete headers[i];
}
fprintf ( fMakefile, "\n" ); fprintf ( fMakefile, "\n" );
} }
if ( mcheaders.size () > 0 ) if ( mcheaders.size () > 0 )
{ {
fprintf ( fprintf (
fMakefile, fMakefile,
@ -1120,15 +1155,18 @@ MingwModuleHandler::GenerateObjectMacros (
module.name.c_str (), module.name.c_str (),
assignmentOperation ); assignmentOperation );
for ( i = 0; i < mcheaders.size (); i++ ) for ( i = 0; i < mcheaders.size (); i++ )
{
fprintf ( fprintf (
fMakefile, fMakefile,
"%s%s", "%s%s",
( i%10 == 9 ? " \\\n\t" : " " ), ( i%10 == 9 ? " \\\n\t" : " " ),
backend->GetFullName ( *mcheaders[i] ).c_str () ); backend->GetFullName ( *mcheaders[i] ).c_str () );
delete mcheaders[i];
}
fprintf ( fMakefile, "\n" ); fprintf ( fMakefile, "\n" );
} }
if ( mcresources.size () > 0 ) if ( mcresources.size () > 0 )
{ {
fprintf ( fprintf (
fMakefile, fMakefile,
@ -1136,11 +1174,14 @@ MingwModuleHandler::GenerateObjectMacros (
module.name.c_str (), module.name.c_str (),
assignmentOperation ); assignmentOperation );
for ( i = 0; i < mcresources.size (); i++ ) for ( i = 0; i < mcresources.size (); i++ )
{
fprintf ( fprintf (
fMakefile, fMakefile,
"%s%s", "%s%s",
( i%10 == 9 ? " \\\n\t" : " " ), ( i%10 == 9 ? " \\\n\t" : " " ),
backend->GetFullName ( *mcresources[i] ).c_str () ); backend->GetFullName ( *mcresources[i] ).c_str () );
delete mcresources[i];
}
fprintf ( fMakefile, "\n" ); fprintf ( fMakefile, "\n" );
} }
@ -1174,18 +1215,23 @@ MingwModuleHandler::GenerateObjectMacros (
GetModuleSpecificCompilationUnits ( sourceCompilationUnits ); GetModuleSpecificCompilationUnits ( sourceCompilationUnits );
for ( i = 0; i < sourceCompilationUnits.size (); i++ ) for ( i = 0; i < sourceCompilationUnits.size (); i++ )
{ {
const FileLocation *object_file = GetObjectFilename ( sourceCompilationUnits[i]->GetFilename (), module, NULL );
fprintf ( fprintf (
fMakefile, fMakefile,
"%s += %s\n", "%s += %s\n",
objectsMacro.c_str(), objectsMacro.c_str(),
backend->GetFullName ( *GetObjectFilename ( sourceCompilationUnits[i]->GetFilename (), module, NULL ) ).c_str () ); backend->GetFullName ( *object_file ).c_str () );
delete object_file;
} }
CleanupCompilationUnitVector ( sourceCompilationUnits ); CleanupCompilationUnitVector ( sourceCompilationUnits );
} }
/* caller needs to delete the returned object */
const FileLocation* const FileLocation*
MingwModuleHandler::GetPrecompiledHeaderFilename () const MingwModuleHandler::GetPrecompiledHeaderFilename () const
{ {
if ( !module.pch || !use_pch )
return NULL;
return new FileLocation ( IntermediateDirectory, return new FileLocation ( IntermediateDirectory,
module.pch->file.relative_path, module.pch->file.relative_path,
ReplaceExtension ( module.pch->file.name, "_" + module.name + ".gch" ) ); ReplaceExtension ( module.pch->file.name, "_" + module.name + ".gch" ) );
@ -1199,11 +1245,13 @@ MingwModuleHandler::GenerateGccCommand (
const string& cflagsMacro ) const string& cflagsMacro )
{ {
const FileLocation *generatedSourceFileName = GetActualSourceFilename ( sourceFile ); const FileLocation *generatedSourceFileName = GetActualSourceFilename ( sourceFile );
const FileLocation *pchFilename = GetPrecompiledHeaderFilename ();
string dependencies = backend->GetFullName ( *generatedSourceFileName ); string dependencies = backend->GetFullName ( *generatedSourceFileName );
if ( extraDependencies != "" ) if ( extraDependencies != "" )
dependencies += " " + extraDependencies; dependencies += " " + extraDependencies;
if ( module.pch && use_pch ) if ( pchFilename )
dependencies += " " + backend->GetFullName ( *GetPrecompiledHeaderFilename () ); dependencies += " " + backend->GetFullName ( *pchFilename );
/* WIDL generated headers may be used */ /* WIDL generated headers may be used */
vector<FileLocation> rpcDependencies; vector<FileLocation> rpcDependencies;
@ -1223,6 +1271,11 @@ MingwModuleHandler::GenerateGccCommand (
"\t%s -c $< -o $@ %s\n", "\t%s -c $< -o $@ %s\n",
cc.c_str (), cc.c_str (),
cflagsMacro.c_str () ); cflagsMacro.c_str () );
delete objectFilename;
delete generatedSourceFileName;
if ( pchFilename )
delete pchFilename;
} }
void void
@ -1246,6 +1299,8 @@ MingwModuleHandler::GenerateGccAssemblerCommand (
"\t%s -x assembler-with-cpp -c $< -o $@ -D__ASM__ %s\n", "\t%s -x assembler-with-cpp -c $< -o $@ -D__ASM__ %s\n",
cc.c_str (), cc.c_str (),
cflagsMacro.c_str () ); cflagsMacro.c_str () );
delete objectFilename;
} }
void void
@ -1268,6 +1323,8 @@ MingwModuleHandler::GenerateNasmCommand (
"\t%s -f win32 $< -o $@ %s\n", "\t%s -f win32 $< -o $@ %s\n",
"$(Q)${nasm}", "$(Q)${nasm}",
nasmflagsMacro.c_str () ); nasmflagsMacro.c_str () );
delete objectFilename;
} }
void void
@ -1313,6 +1370,8 @@ MingwModuleHandler::GenerateWindresCommand (
fprintf ( fMakefile, fprintf ( fMakefile,
"\t-@${rm} %s 2>$(NUL)\n", "\t-@${rm} %s 2>$(NUL)\n",
backend->GetFullName ( resFilename ).c_str () ); backend->GetFullName ( resFilename ).c_str () );
delete objectFilename;
} }
void void
@ -1328,8 +1387,8 @@ MingwModuleHandler::GenerateWinebuildCommands (
basename + ".spec.def" ); basename + ".spec.def" );
CLEAN_FILE ( def_file ); CLEAN_FILE ( def_file );
FileLocation stub_file ( *GetActualSourceFilename ( sourceFile ) ); const FileLocation *stub_file = GetActualSourceFilename ( sourceFile );
CLEAN_FILE ( stub_file ); CLEAN_FILE ( *stub_file );
fprintf ( fMakefile, fprintf ( fMakefile,
"%s: %s $(WINEBUILD_TARGET) | %s\n", "%s: %s $(WINEBUILD_TARGET) | %s\n",
@ -1344,14 +1403,16 @@ MingwModuleHandler::GenerateWinebuildCommands (
backend->GetFullName ( *sourceFile ).c_str () ); backend->GetFullName ( *sourceFile ).c_str () );
fprintf ( fMakefile, fprintf ( fMakefile,
"%s: %s $(WINEBUILD_TARGET)\n", "%s: %s $(WINEBUILD_TARGET)\n",
backend->GetFullName ( stub_file ).c_str (), backend->GetFullName ( *stub_file ).c_str (),
backend->GetFullName ( *sourceFile ).c_str () ); backend->GetFullName ( *sourceFile ).c_str () );
fprintf ( fMakefile, "\t$(ECHO_WINEBLD)\n" ); fprintf ( fMakefile, "\t$(ECHO_WINEBLD)\n" );
fprintf ( fMakefile, fprintf ( fMakefile,
"\t%s -o %s --pedll %s\n", "\t%s -o %s --pedll %s\n",
"$(Q)$(WINEBUILD_TARGET)", "$(Q)$(WINEBUILD_TARGET)",
backend->GetFullName ( stub_file ).c_str (), backend->GetFullName ( *stub_file ).c_str (),
backend->GetFullName ( *sourceFile ).c_str () ); backend->GetFullName ( *sourceFile ).c_str () );
delete stub_file;
} }
void void
@ -1403,6 +1464,7 @@ MingwModuleHandler::GetPropertyValue ( const Module& module, const std::string&
return string ( "" ); return string ( "" );
} }
/* caller needs to delete the returned object */
const FileLocation* const FileLocation*
MingwModuleHandler::GetRpcServerHeaderFilename ( const FileLocation *base ) const MingwModuleHandler::GetRpcServerHeaderFilename ( const FileLocation *base ) const
{ {
@ -1444,8 +1506,11 @@ MingwModuleHandler::GenerateWidlCommandsServer (
backend->GetFullName ( *generatedHeaderFilename ).c_str (), backend->GetFullName ( *generatedHeaderFilename ).c_str (),
backend->GetFullName ( generatedServerFilename ).c_str (), backend->GetFullName ( generatedServerFilename ).c_str (),
backend->GetFullName ( *sourceFile ).c_str () ); backend->GetFullName ( *sourceFile ).c_str () );
delete generatedHeaderFilename;
} }
/* caller needs to delete the returned object */
const FileLocation* const FileLocation*
MingwModuleHandler::GetRpcClientHeaderFilename ( const FileLocation *base ) const MingwModuleHandler::GetRpcClientHeaderFilename ( const FileLocation *base ) const
{ {
@ -1453,6 +1518,7 @@ MingwModuleHandler::GetRpcClientHeaderFilename ( const FileLocation *base ) cons
return new FileLocation ( IntermediateDirectory, base->relative_path, newname ); return new FileLocation ( IntermediateDirectory, base->relative_path, newname );
} }
/* caller needs to delete the returned object */
const FileLocation* const FileLocation*
MingwModuleHandler::GetIdlHeaderFilename ( const FileLocation *base ) const MingwModuleHandler::GetIdlHeaderFilename ( const FileLocation *base ) const
{ {
@ -1460,6 +1526,7 @@ MingwModuleHandler::GetIdlHeaderFilename ( const FileLocation *base ) const
return new FileLocation ( IntermediateDirectory, base->relative_path, newname ); return new FileLocation ( IntermediateDirectory, base->relative_path, newname );
} }
/* caller needs to delete the returned object */
const FileLocation* const FileLocation*
MingwModuleHandler::GetMcHeaderFilename ( const FileLocation *base ) const MingwModuleHandler::GetMcHeaderFilename ( const FileLocation *base ) const
{ {
@ -1531,6 +1598,8 @@ MingwModuleHandler::GenerateWidlCommandsClient (
backend->GetFullName ( *generatedHeaderFilename ).c_str (), backend->GetFullName ( *generatedHeaderFilename ).c_str (),
backend->GetFullName ( generatedClientFilename ).c_str (), backend->GetFullName ( generatedClientFilename ).c_str (),
backend->GetFullName ( *sourceFile ).c_str () ); backend->GetFullName ( *sourceFile ).c_str () );
delete generatedHeaderFilename;
} }
void void
@ -1560,6 +1629,8 @@ MingwModuleHandler::GenerateWidlCommandsIdlHeader (
widlflagsMacro.c_str (), widlflagsMacro.c_str (),
backend->GetFullName ( *generatedHeader ).c_str (), backend->GetFullName ( *generatedHeader ).c_str (),
backend->GetFullName ( *sourceFile ).c_str () ); backend->GetFullName ( *sourceFile ).c_str () );
delete generatedHeader;
} }
void void
@ -1751,7 +1822,9 @@ MingwModuleHandler::GetObjectsVector ( const IfableData& data,
for ( size_t i = 0; i < data.compilationUnits.size (); i++ ) for ( size_t i = 0; i < data.compilationUnits.size (); i++ )
{ {
CompilationUnit& compilationUnit = *data.compilationUnits[i]; CompilationUnit& compilationUnit = *data.compilationUnits[i];
objectFiles.push_back ( *GetObjectFilename ( compilationUnit.GetFilename (), module, NULL ) ); const FileLocation *object_file = GetObjectFilename ( compilationUnit.GetFilename (), module, NULL );
objectFiles.push_back ( *object_file );
delete object_file;
} }
} }
@ -1807,10 +1880,12 @@ MingwModuleHandler::GenerateLinkerCommand (
const string& libsMacro, const string& libsMacro,
const string& pefixupParameters ) const string& pefixupParameters )
{ {
string target ( GetTargetMacro ( module ) ); const FileLocation *target_file = GetTargetFilename ( module, NULL );
string target_folder ( backend->GetFullPath ( *GetTargetFilename ( module, NULL ) ) );
const FileLocation *definitionFilename = GetDefinitionFilename (); const FileLocation *definitionFilename = GetDefinitionFilename ();
string target_macro ( GetTargetMacro ( module ) );
string target_folder ( backend->GetFullPath ( *target_file ) );
string linkerScriptArgument; string linkerScriptArgument;
if ( module.linkerScript != NULL ) if ( module.linkerScript != NULL )
linkerScriptArgument = ssprintf ( "-Wl,-T,%s", backend->GetFullName ( module.linkerScript->file ).c_str () ); linkerScriptArgument = ssprintf ( "-Wl,-T,%s", backend->GetFullName ( module.linkerScript->file ).c_str () );
@ -1819,7 +1894,7 @@ MingwModuleHandler::GenerateLinkerCommand (
fprintf ( fMakefile, fprintf ( fMakefile,
"%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n", "%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n",
target.c_str (), target_macro.c_str (),
backend->GetFullName ( *definitionFilename ).c_str (), backend->GetFullName ( *definitionFilename ).c_str (),
dependencies.c_str (), dependencies.c_str (),
target_folder.c_str () ); target_folder.c_str () );
@ -1833,7 +1908,7 @@ MingwModuleHandler::GenerateLinkerCommand (
linker.c_str (), linker.c_str (),
linkerParameters.c_str (), linkerParameters.c_str (),
linkerScriptArgument.c_str (), linkerScriptArgument.c_str (),
target.c_str (), target_macro.c_str (),
objectsMacro.c_str (), objectsMacro.c_str (),
libsMacro.c_str (), libsMacro.c_str (),
GetLinkerMacro ().c_str () ); GetLinkerMacro ().c_str () );
@ -1859,14 +1934,14 @@ MingwModuleHandler::GenerateLinkerCommand (
linkerParameters.c_str (), linkerParameters.c_str (),
linkerScriptArgument.c_str (), linkerScriptArgument.c_str (),
backend->GetFullName ( temp_exp ).c_str (), backend->GetFullName ( temp_exp ).c_str (),
target.c_str (), target_macro.c_str (),
objectsMacro.c_str (), objectsMacro.c_str (),
libsMacro.c_str (), libsMacro.c_str (),
GetLinkerMacro ().c_str () ); GetLinkerMacro ().c_str () );
fprintf ( fMakefile, fprintf ( fMakefile,
"\t$(Q)$(PEFIXUP_TARGET) %s -exports %s\n", "\t$(Q)$(PEFIXUP_TARGET) %s -exports %s\n",
target.c_str (), target_macro.c_str (),
pefixupParameters.c_str() ); pefixupParameters.c_str() );
fprintf ( fMakefile, fprintf ( fMakefile,
@ -1886,7 +1961,7 @@ MingwModuleHandler::GenerateLinkerCommand (
linker.c_str (), linker.c_str (),
linkerParameters.c_str (), linkerParameters.c_str (),
linkerScriptArgument.c_str (), linkerScriptArgument.c_str (),
target.c_str (), target_macro.c_str (),
objectsMacro.c_str (), objectsMacro.c_str (),
libsMacro.c_str (), libsMacro.c_str (),
GetLinkerMacro ().c_str () ); GetLinkerMacro ().c_str () );
@ -1897,18 +1972,25 @@ MingwModuleHandler::GenerateLinkerCommand (
GenerateRunRsymCode (); GenerateRunRsymCode ();
GenerateRunStripCode (); GenerateRunStripCode ();
GenerateCleanObjectsAsYouGoCode (); GenerateCleanObjectsAsYouGoCode ();
delete definitionFilename;
delete target_file;
} }
void void
MingwModuleHandler::GeneratePhonyTarget() const MingwModuleHandler::GeneratePhonyTarget() const
{ {
string targetMacro ( GetTargetMacro ( module ) ); string targetMacro ( GetTargetMacro ( module ) );
const FileLocation *target_file = GetTargetFilename ( module, NULL );
fprintf ( fMakefile, fprintf ( fMakefile,
".PHONY: %s\n\n", ".PHONY: %s\n\n",
targetMacro.c_str ()); targetMacro.c_str ());
fprintf ( fMakefile, "%s: | %s\n", fprintf ( fMakefile, "%s: | %s\n",
targetMacro.c_str (), targetMacro.c_str (),
backend->GetFullPath ( *GetTargetFilename ( module, NULL ) ).c_str () ); backend->GetFullPath ( *target_file ).c_str () );
delete target_file;
} }
void void
@ -1939,6 +2021,7 @@ MingwModuleHandler::GenerateObjectFileTargets (
moduleDependencies += ssprintf ( " $(%s_RESOURCES)", module.name.c_str () ); moduleDependencies += ssprintf ( " $(%s_RESOURCES)", module.name.c_str () );
break; break;
} }
delete objectFilename;
} }
for ( i = 0; i < compilationUnits.size (); i++ ) for ( i = 0; i < compilationUnits.size (); i++ )
@ -1992,10 +2075,11 @@ MingwModuleHandler::GenerateObjectFileTargets (
const string& windresflagsMacro, const string& windresflagsMacro,
const string& widlflagsMacro ) const string& widlflagsMacro )
{ {
if ( module.pch && use_pch ) const FileLocation *pchFilename = GetPrecompiledHeaderFilename ();
if ( pchFilename )
{ {
const FileLocation& baseHeaderFile = module.pch->file; const FileLocation& baseHeaderFile = module.pch->file;
const FileLocation *pchFilename = GetPrecompiledHeaderFilename ();
CLEAN_FILE ( *pchFilename ); CLEAN_FILE ( *pchFilename );
string dependencies = backend->GetFullName ( baseHeaderFile ); string dependencies = backend->GetFullName ( baseHeaderFile );
/* WIDL generated headers may be used */ /* WIDL generated headers may be used */
@ -2014,6 +2098,7 @@ MingwModuleHandler::GenerateObjectFileTargets (
backend->GetFullName ( *pchFilename ).c_str(), backend->GetFullName ( *pchFilename ).c_str(),
cflagsMacro.c_str(), cflagsMacro.c_str(),
backend->GetFullName ( baseHeaderFile ).c_str() ); backend->GetFullName ( baseHeaderFile ).c_str() );
delete pchFilename;
} }
GenerateObjectFileTargets ( module.non_if_data, GenerateObjectFileTargets ( module.non_if_data,
@ -2026,6 +2111,7 @@ MingwModuleHandler::GenerateObjectFileTargets (
fprintf ( fMakefile, "\n" ); fprintf ( fMakefile, "\n" );
} }
/* caller needs to delete the returned object */
const FileLocation* const FileLocation*
MingwModuleHandler::GenerateArchiveTarget ( const string& ar, MingwModuleHandler::GenerateArchiveTarget ( const string& ar,
const string& objs_macro ) const const string& objs_macro ) const
@ -2040,7 +2126,7 @@ MingwModuleHandler::GenerateArchiveTarget ( const string& ar,
if ( module.type == StaticLibrary && module.importLibrary ) if ( module.type == StaticLibrary && module.importLibrary )
{ {
const FileLocation *definitionFilename ( GetDefinitionFilename () ); const FileLocation *definitionFilename = GetDefinitionFilename ();
fprintf ( fMakefile, fprintf ( fMakefile,
"\t${dlltool} --dllname %s --def %s --output-lib $@ %s %s\n", "\t${dlltool} --dllname %s --def %s --output-lib $@ %s %s\n",
@ -2048,6 +2134,8 @@ MingwModuleHandler::GenerateArchiveTarget ( const string& ar,
backend->GetFullName ( *definitionFilename ).c_str (), backend->GetFullName ( *definitionFilename ).c_str (),
module.mangledSymbols ? "" : "--kill-at", module.mangledSymbols ? "" : "--kill-at",
module.underscoreSymbols ? "--add-underscore" : "" ); module.underscoreSymbols ? "--add-underscore" : "" );
delete definitionFilename;
} }
fprintf ( fMakefile, "\t$(ECHO_AR)\n" ); fprintf ( fMakefile, "\t$(ECHO_AR)\n" );
@ -2103,7 +2191,12 @@ MingwModuleHandler::GetModuleTargets ( const Module& module )
if ( ReferenceObjects ( module ) ) if ( ReferenceObjects ( module ) )
return GetObjectsMacro ( module ); return GetObjectsMacro ( module );
else else
return backend->GetFullName ( *GetTargetFilename ( module, NULL ) ).c_str (); {
const FileLocation *target_file = GetTargetFilename ( module, NULL );
string target = backend->GetFullName ( *target_file ).c_str ();
delete target_file;
return target;
}
} }
void void
@ -2161,11 +2254,23 @@ MingwModuleHandler::GetRpcHeaderDependencies (
{ {
string basename = GetBasename ( sourceFile->name ); string basename = GetBasename ( sourceFile->name );
if ( library.importedModule->type == RpcServer ) if ( library.importedModule->type == RpcServer )
dependencies.push_back ( *GetRpcServerHeaderFilename ( sourceFile ) ); {
const FileLocation *header = GetRpcServerHeaderFilename ( sourceFile );
dependencies.push_back ( *header );
delete header;
}
if ( library.importedModule->type == RpcClient ) if ( library.importedModule->type == RpcClient )
dependencies.push_back ( *GetRpcClientHeaderFilename ( sourceFile ) ); {
const FileLocation *header = GetRpcClientHeaderFilename ( sourceFile );
dependencies.push_back ( *header );
delete header;
}
if ( library.importedModule->type == IdlHeader ) if ( library.importedModule->type == IdlHeader )
dependencies.push_back ( *GetIdlHeaderFilename ( sourceFile ) ); {
const FileLocation *header = GetIdlHeaderFilename ( sourceFile );
dependencies.push_back ( *header );
delete header;
}
} }
} }
} }
@ -2351,6 +2456,7 @@ MingwModuleHandler::GenerateRules ()
{ {
const FileLocation* ar_target = GenerateArchiveTarget ( ar, objectsMacro ); const FileLocation* ar_target = GenerateArchiveTarget ( ar, objectsMacro );
CLEAN_FILE ( *ar_target ); CLEAN_FILE ( *ar_target );
delete ar_target;
} }
GenerateObjectFileTargets ( cc, GenerateObjectFileTargets ( cc,
@ -2511,6 +2617,7 @@ MingwModuleHandler::IsWineModule () const
return ( index != string::npos ); return ( index != string::npos );
} }
/* caller needs to delete the returned object */
const FileLocation* const FileLocation*
MingwModuleHandler::GetDefinitionFilename () const MingwModuleHandler::GetDefinitionFilename () const
{ {
@ -2540,7 +2647,7 @@ MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
vector<FileLocation> deps; vector<FileLocation> deps;
GetDefinitionDependencies ( deps ); GetDefinitionDependencies ( deps );
fprintf ( fMakefile, "# IMPORT LIBRARY RULE:\n" ); fprintf ( fMakefile, "# IMPORT LIBRARY RULE:\n" );
fprintf ( fMakefile, "%s: %s", fprintf ( fMakefile, "%s: %s",
@ -2553,7 +2660,7 @@ MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
backend->GetFullName ( deps[i] ).c_str () ); backend->GetFullName ( deps[i] ).c_str () );
fprintf ( fMakefile, " | %s\n", fprintf ( fMakefile, " | %s\n",
backend->GetFullPath ( *GetImportLibraryFilename ( module, NULL ) ).c_str () ); backend->GetFullPath ( *library_target ).c_str () );
fprintf ( fMakefile, "\t$(ECHO_DLLTOOL)\n" ); fprintf ( fMakefile, "\t$(ECHO_DLLTOOL)\n" );
@ -2564,6 +2671,9 @@ MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
backend->GetFullName ( *library_target ).c_str (), backend->GetFullName ( *library_target ).c_str (),
module.mangledSymbols ? "" : "--kill-at", module.mangledSymbols ? "" : "--kill-at",
module.underscoreSymbols ? "--add-underscore" : "" ); module.underscoreSymbols ? "--add-underscore" : "" );
delete defFilename;
delete library_target;
} }
} }
@ -2609,12 +2719,15 @@ MingwModuleHandler::GetWidlObjectDependencies (
const FileLocation *file ) const const FileLocation *file ) const
{ {
string basename = GetBasename ( file->name ); string basename = GetBasename ( file->name );
const FileLocation *generatedHeaderFilename = GetRpcServerHeaderFilename ( file );
FileLocation serverSourceDependency ( IntermediateDirectory, FileLocation serverSourceDependency ( IntermediateDirectory,
file->relative_path, file->relative_path,
basename + "_s.c" ); basename + "_s.c" );
dependencies.push_back ( serverSourceDependency ); dependencies.push_back ( serverSourceDependency );
dependencies.push_back ( *GetRpcServerHeaderFilename ( file ) ); dependencies.push_back ( *generatedHeaderFilename );
delete generatedHeaderFilename;
} }
void void
@ -2692,11 +2805,12 @@ MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
else else
linker = "${host_gcc}"; linker = "${host_gcc}";
const FileLocation *target_file = GetTargetFilename ( module, NULL );
fprintf ( fMakefile, "%s: %s %s | %s\n", fprintf ( fMakefile, "%s: %s %s | %s\n",
targetMacro.c_str (), targetMacro.c_str (),
objectsMacro.c_str (), objectsMacro.c_str (),
linkDepsMacro.c_str (), linkDepsMacro.c_str (),
backend->GetFullPath ( *GetTargetFilename ( module, NULL ) ).c_str () ); backend->GetFullPath ( *target_file ).c_str () );
fprintf ( fMakefile, "\t$(ECHO_LD)\n" ); fprintf ( fMakefile, "\t$(ECHO_LD)\n" );
fprintf ( fMakefile, fprintf ( fMakefile,
"\t%s %s -o $@ %s %s\n\n", "\t%s %s -o $@ %s %s\n\n",
@ -2704,6 +2818,8 @@ MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()
GetLinkerMacro ().c_str (), GetLinkerMacro ().c_str (),
objectsMacro.c_str (), objectsMacro.c_str (),
libsMacro.c_str () ); libsMacro.c_str () );
delete target_file;
} }
@ -3359,11 +3475,12 @@ MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
GenerateRules (); GenerateRules ();
const FileLocation *target_file = GetTargetFilename ( module, NULL );
fprintf ( fMakefile, "%s: %s %s | %s\n", fprintf ( fMakefile, "%s: %s %s | %s\n",
targetMacro.c_str (), targetMacro.c_str (),
objectsMacro.c_str (), objectsMacro.c_str (),
linkDepsMacro.c_str (), linkDepsMacro.c_str (),
backend->GetFullPath ( *GetTargetFilename ( module, NULL ) ).c_str () ); backend->GetFullPath ( *target_file ).c_str () );
fprintf ( fMakefile, "\t$(ECHO_LD)\n" ); fprintf ( fMakefile, "\t$(ECHO_LD)\n" );
@ -3380,6 +3497,8 @@ MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
fprintf ( fMakefile, fprintf ( fMakefile,
"\t-@${rm} %s 2>$(NUL)\n", "\t-@${rm} %s 2>$(NUL)\n",
backend->GetFullName ( junk_tmp ).c_str () ); backend->GetFullName ( junk_tmp ).c_str () );
delete target_file;
} }
@ -3449,12 +3568,13 @@ MingwBootProgramModuleHandler::GenerateBootProgramModuleTarget ()
GenerateRules (); GenerateRules ();
const FileLocation *target_file = GetTargetFilename ( module, NULL );
fprintf ( fMakefile, "%s: %s %s %s | %s\n", fprintf ( fMakefile, "%s: %s %s %s | %s\n",
targetMacro.c_str (), targetMacro.c_str (),
objectsMacro.c_str (), objectsMacro.c_str (),
linkDepsMacro.c_str (), linkDepsMacro.c_str (),
payload->name.c_str (), payload->name.c_str (),
backend->GetFullPath ( *GetTargetFilename ( module, NULL ) ).c_str () ); backend->GetFullPath ( *target_file ).c_str () );
fprintf ( fMakefile, "\t$(ECHO_BOOTPROG)\n" ); fprintf ( fMakefile, "\t$(ECHO_BOOTPROG)\n" );
@ -3484,6 +3604,8 @@ MingwBootProgramModuleHandler::GenerateBootProgramModuleTarget ()
backend->GetFullName ( junk_tmp ).c_str (), backend->GetFullName ( junk_tmp ).c_str (),
backend->GetFullName ( junk_elf ).c_str (), backend->GetFullName ( junk_elf ).c_str (),
backend->GetFullName ( junk_cpy ).c_str () ); backend->GetFullName ( junk_cpy ).c_str () );
delete target_file;
} }
@ -3883,6 +4005,7 @@ MingwTestModuleHandler::Process ()
GenerateTestModuleTarget (); GenerateTestModuleTarget ();
} }
/* caller needs to delete the returned object */
void void
MingwTestModuleHandler::GetModuleSpecificCompilationUnits ( vector<CompilationUnit*>& compilationUnits ) MingwTestModuleHandler::GetModuleSpecificCompilationUnits ( vector<CompilationUnit*>& compilationUnits )
{ {
@ -4003,11 +4126,12 @@ MingwElfExecutableModuleHandler::Process ()
GenerateRules (); GenerateRules ();
const FileLocation *target_file = GetTargetFilename ( module, NULL );
fprintf ( fMakefile, "%s: %s %s | %s\n", fprintf ( fMakefile, "%s: %s %s | %s\n",
targetMacro.c_str (), targetMacro.c_str (),
objectsMacro.c_str (), objectsMacro.c_str (),
linkDepsMacro.c_str (), linkDepsMacro.c_str (),
backend->GetFullPath ( *GetTargetFilename ( module, NULL ) ).c_str () ); backend->GetFullPath ( *target_file ).c_str () );
fprintf ( fMakefile, "\t$(ECHO_BOOTPROG)\n" ); fprintf ( fMakefile, "\t$(ECHO_BOOTPROG)\n" );
@ -4016,4 +4140,6 @@ MingwElfExecutableModuleHandler::Process ()
objectsMacro.c_str(), objectsMacro.c_str(),
libsMacro.c_str(), libsMacro.c_str(),
targetMacro.c_str () ); targetMacro.c_str () );
delete target_file;
} }