- Add a NUL definition, as well as rmkdir

- Create directory targets for intermediate files area
- .def files are in the source tree in our current scheme

svn path=/branches/xmlbuildsystem/; revision=13098
This commit is contained in:
Art Yerkes 2005-01-17 16:26:11 +00:00
parent b71ea907b8
commit 076c15efdb

View file

@ -1,4 +1,3 @@
#include "../../pch.h" #include "../../pch.h"
#include <assert.h> #include <assert.h>
@ -9,9 +8,12 @@
using std::string; using std::string;
using std::vector; using std::vector;
using std::map; using std::map;
using std::set;
map<ModuleType,MingwModuleHandler*>* map<ModuleType,MingwModuleHandler*>*
MingwModuleHandler::handler_map = NULL; MingwModuleHandler::handler_map = NULL;
set<string>
MingwModuleHandler::directory_set;
int int
MingwModuleHandler::ref = 0; MingwModuleHandler::ref = 0;
@ -34,6 +36,13 @@ MingwModuleHandler::~MingwModuleHandler()
} }
} }
const string &
MingwModuleHandler::PassThruCacheDirectory( const string &file ) const
{
directory_set.insert( ReplaceExtension( GetDirectory( file ), "" ) );
return file;
}
void void
MingwModuleHandler::SetMakefile ( FILE* f ) MingwModuleHandler::SetMakefile ( FILE* f )
{ {
@ -61,12 +70,23 @@ MingwModuleHandler::GetWorkingDirectory () const
return "."; return ".";
} }
string
MingwModuleHandler::GetDirectory ( const string& filename ) const
{
size_t index = filename.find_last_of ( '/' );
if (index == string::npos) return ".";
else return filename.substr ( 0, index );
}
string string
MingwModuleHandler::GetExtension ( const string& filename ) const MingwModuleHandler::GetExtension ( const string& filename ) const
{ {
size_t index = filename.find_last_of ( '.' ); size_t index = filename.find_last_of ( '/' );
if (index != string::npos) if (index == string::npos) index = 0;
return filename.substr ( index ); string tmp = filename.substr( index, filename.size() - index );
size_t ext_index = tmp.find_last_of( '.' );
if (ext_index != string::npos)
return filename.substr ( index + ext_index, filename.size() );
return ""; return "";
} }
@ -83,10 +103,13 @@ string
MingwModuleHandler::ReplaceExtension ( const string& filename, MingwModuleHandler::ReplaceExtension ( const string& filename,
const string& newExtension ) const const string& newExtension ) const
{ {
size_t index = filename.find_last_of ( '.' ); size_t index = filename.find_last_of ( '/' );
if (index != string::npos) if (index == string::npos) index = 0;
return filename.substr ( 0, index ) + newExtension; string tmp = filename.substr( index, filename.size() - index );
return filename; size_t ext_index = tmp.find_last_of( '.' );
if (ext_index != string::npos)
return filename.substr ( 0, index + ext_index ) + newExtension;
return filename + newExtension;
} }
string string
@ -122,7 +145,7 @@ MingwModuleHandler::GetImportLibraryDependencies ( const Module& module ) const
dependencies += " "; dependencies += " ";
const Module* importedModule = module.project.LocateModule ( module.libraries[i]->name ); const Module* importedModule = module.project.LocateModule ( module.libraries[i]->name );
assert ( importedModule != NULL ); assert ( importedModule != NULL );
dependencies += FixupTargetFilename ( importedModule->GetDependencyPath () ).c_str (); dependencies += PassThruCacheDirectory ( FixupTargetFilename ( importedModule->GetDependencyPath () ) ).c_str ();
} }
return dependencies; return dependencies;
} }
@ -195,8 +218,9 @@ MingwModuleHandler::GetObjectFilename ( const string& sourceFilename ) const
newExtension = ".stubs.o"; newExtension = ".stubs.o";
else else
newExtension = ".o"; newExtension = ".o";
return FixupTargetFilename ( ReplaceExtension ( sourceFilename, return PassThruCacheDirectory
newExtension ) ); ( FixupTargetFilename ( ReplaceExtension ( sourceFilename,
newExtension ) ) );
} }
string string
@ -215,6 +239,32 @@ MingwModuleHandler::GetObjectFilenames ( const Module& module ) const
return objectFilenames; return objectFilenames;
} }
void
MingwModuleHandler::GenerateDirectoryTargets() const
{
fprintf( fMakefile, "ifneq ($(ROS_INTERMEDIATE),)\ndirectories::" );
for( set<string>::iterator i = directory_set.begin();
i != directory_set.end();
i++ )
fprintf( fMakefile, " %s", i->c_str() );
fprintf( fMakefile, "\n\n" );
for( set<string>::iterator i = directory_set.begin();
i != directory_set.end();
i++ )
fprintf( fMakefile, "%s ", i->c_str() );
fprintf ( fMakefile,
"::\n\t${mkdir} $@\n\n"
"else\n"
"directories::\n\n"
"endif\n\n" );
directory_set.clear();
}
string string
MingwModuleHandler::GenerateGccDefineParametersFromVector ( const vector<Define*>& defines ) const MingwModuleHandler::GenerateGccDefineParametersFromVector ( const vector<Define*>& defines ) const
{ {
@ -667,7 +717,7 @@ MingwModuleHandler::GenerateLinkerCommand ( const Module& module,
"\t${dlltool} --dllname %s --base-file %s --def %s --output-exp %s --kill-at\n", "\t${dlltool} --dllname %s --base-file %s --def %s --output-exp %s --kill-at\n",
targetName.c_str (), targetName.c_str (),
base_tmp.c_str (), base_tmp.c_str (),
FixupTargetFilename ( module.GetBasePath () + SSEP + module.importLibrary->definition ).c_str (), (module.GetBasePath () + SSEP + module.importLibrary->definition ).c_str (),
temp_exp.c_str () ); temp_exp.c_str () );
fprintf ( fMakefile, fprintf ( fMakefile,
@ -864,10 +914,10 @@ MingwModuleHandler::GenerateMacrosAndTargets (
for ( size_t i = 0; i < clean_files.size(); i++ ) for ( size_t i = 0; i < clean_files.size(); i++ )
{ {
if ( 9==(i%10) ) if ( 9==(i%10) )
fprintf ( fMakefile, " 2>NUL\n\t-@$(rm)" ); fprintf ( fMakefile, " 2>$(NUL)\n\t-@$(rm)" );
fprintf ( fMakefile, " %s", clean_files[i].c_str() ); fprintf ( fMakefile, " %s", clean_files[i].c_str() );
} }
fprintf ( fMakefile, " 2>NUL\n\n" ); fprintf ( fMakefile, " 2>$(NUL)\n\n" );
} }
void void
@ -1035,13 +1085,13 @@ MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ( const Module& module )
{ {
string definitionDependencies = GetDefinitionDependencies ( module ); string definitionDependencies = GetDefinitionDependencies ( module );
fprintf ( fMakefile, "%s: %s\n", fprintf ( fMakefile, "%s: %s\n",
module.GetDependencyPath ().c_str (), FixupTargetFilename( module.GetDependencyPath () ).c_str (),
definitionDependencies.c_str () ); definitionDependencies.c_str () );
fprintf ( fMakefile, fprintf ( fMakefile,
"\t${dlltool} --dllname %s --def %s --output-lib %s --kill-at\n\n", "\t${dlltool} --dllname %s --def %s --output-lib %s --kill-at\n\n",
module.GetTargetName ().c_str (), module.GetTargetName ().c_str (),
FixupTargetFilename ( module.GetBasePath () + SSEP + module.importLibrary->definition ).c_str (), (module.GetBasePath () + SSEP + module.importLibrary->definition).c_str (),
FixupTargetFilename ( module.GetDependencyPath () ).c_str () ); FixupTargetFilename ( module.GetDependencyPath () ).c_str () );
} }
} }
@ -1282,7 +1332,7 @@ void
MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ( const Module& module ) MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ( const Module& module )
{ {
static string ros_junk ( "$(ROS_TEMPORARY)" ); static string ros_junk ( "$(ROS_TEMPORARY)" );
string target ( FixupTargetFilename ( module.GetPath () ) ); string target ( PassThruCacheDirectory( FixupTargetFilename ( module.GetPath () ) ) );
string workingDirectory = GetWorkingDirectory ( ); string workingDirectory = GetWorkingDirectory ( );
string archiveFilename = GetModuleArchiveFilename ( module ); string archiveFilename = GetModuleArchiveFilename ( module );
string importLibraryDependencies = GetImportLibraryDependencies ( module ); string importLibraryDependencies = GetImportLibraryDependencies ( module );
@ -1344,6 +1394,16 @@ MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ( const Module& modul
GenerateImportLibraryTargetIfNeeded ( module ); GenerateImportLibraryTargetIfNeeded ( module );
if ( module.files.size () > 0 )
{
fprintf ( fMakefile,
"\t${dlltool} --dllname %s --def %s --output-lib %s --kill-at\n\n",
module.GetTargetName ().c_str (),
(module.GetBasePath () + SSEP + module.importLibrary->definition).c_str (),
FixupTargetFilename ( module.GetDependencyPath () ).c_str () );
}
if (module.files.size () > 0) if (module.files.size () > 0)
{ {
GenerateMacrosAndTargetsTarget ( module ); GenerateMacrosAndTargetsTarget ( module );
@ -1394,7 +1454,6 @@ MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ( const Module& module
string linkingDependencies = GetLinkingDependencies ( module ); string linkingDependencies = GetLinkingDependencies ( module );
GenerateImportLibraryTargetIfNeeded ( module ); GenerateImportLibraryTargetIfNeeded ( module );
if ( module.files.size () > 0 ) if ( module.files.size () > 0 )
{ {
GenerateMacrosAndTargetsTarget ( module ); GenerateMacrosAndTargetsTarget ( module );