mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 22:23:05 +00:00
- 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:
parent
b71ea907b8
commit
076c15efdb
1 changed files with 82 additions and 23 deletions
|
@ -1,4 +1,3 @@
|
|||
|
||||
#include "../../pch.h"
|
||||
#include <assert.h>
|
||||
|
||||
|
@ -9,9 +8,12 @@
|
|||
using std::string;
|
||||
using std::vector;
|
||||
using std::map;
|
||||
using std::set;
|
||||
|
||||
map<ModuleType,MingwModuleHandler*>*
|
||||
MingwModuleHandler::handler_map = NULL;
|
||||
set<string>
|
||||
MingwModuleHandler::directory_set;
|
||||
int
|
||||
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
|
||||
MingwModuleHandler::SetMakefile ( FILE* f )
|
||||
{
|
||||
|
@ -61,12 +70,23 @@ MingwModuleHandler::GetWorkingDirectory () const
|
|||
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
|
||||
MingwModuleHandler::GetExtension ( const string& filename ) const
|
||||
{
|
||||
size_t index = filename.find_last_of ( '.' );
|
||||
if (index != string::npos)
|
||||
return filename.substr ( index );
|
||||
size_t index = filename.find_last_of ( '/' );
|
||||
if (index == string::npos) index = 0;
|
||||
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 "";
|
||||
}
|
||||
|
||||
|
@ -83,10 +103,13 @@ string
|
|||
MingwModuleHandler::ReplaceExtension ( const string& filename,
|
||||
const string& newExtension ) const
|
||||
{
|
||||
size_t index = filename.find_last_of ( '.' );
|
||||
if (index != string::npos)
|
||||
return filename.substr ( 0, index ) + newExtension;
|
||||
return filename;
|
||||
size_t index = filename.find_last_of ( '/' );
|
||||
if (index == string::npos) index = 0;
|
||||
string tmp = filename.substr( index, filename.size() - index );
|
||||
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
|
||||
|
@ -122,7 +145,7 @@ MingwModuleHandler::GetImportLibraryDependencies ( const Module& module ) const
|
|||
dependencies += " ";
|
||||
const Module* importedModule = module.project.LocateModule ( module.libraries[i]->name );
|
||||
assert ( importedModule != NULL );
|
||||
dependencies += FixupTargetFilename ( importedModule->GetDependencyPath () ).c_str ();
|
||||
dependencies += PassThruCacheDirectory ( FixupTargetFilename ( importedModule->GetDependencyPath () ) ).c_str ();
|
||||
}
|
||||
return dependencies;
|
||||
}
|
||||
|
@ -195,8 +218,9 @@ MingwModuleHandler::GetObjectFilename ( const string& sourceFilename ) const
|
|||
newExtension = ".stubs.o";
|
||||
else
|
||||
newExtension = ".o";
|
||||
return FixupTargetFilename ( ReplaceExtension ( sourceFilename,
|
||||
newExtension ) );
|
||||
return PassThruCacheDirectory
|
||||
( FixupTargetFilename ( ReplaceExtension ( sourceFilename,
|
||||
newExtension ) ) );
|
||||
}
|
||||
|
||||
string
|
||||
|
@ -215,6 +239,32 @@ MingwModuleHandler::GetObjectFilenames ( const Module& module ) const
|
|||
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
|
||||
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",
|
||||
targetName.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 () );
|
||||
|
||||
fprintf ( fMakefile,
|
||||
|
@ -864,10 +914,10 @@ MingwModuleHandler::GenerateMacrosAndTargets (
|
|||
for ( size_t i = 0; i < clean_files.size(); i++ )
|
||||
{
|
||||
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, " 2>NUL\n\n" );
|
||||
fprintf ( fMakefile, " 2>$(NUL)\n\n" );
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1035,13 +1085,13 @@ MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ( const Module& module )
|
|||
{
|
||||
string definitionDependencies = GetDefinitionDependencies ( module );
|
||||
fprintf ( fMakefile, "%s: %s\n",
|
||||
module.GetDependencyPath ().c_str (),
|
||||
FixupTargetFilename( module.GetDependencyPath () ).c_str (),
|
||||
definitionDependencies.c_str () );
|
||||
|
||||
fprintf ( fMakefile,
|
||||
"\t${dlltool} --dllname %s --def %s --output-lib %s --kill-at\n\n",
|
||||
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 () );
|
||||
}
|
||||
}
|
||||
|
@ -1282,7 +1332,7 @@ void
|
|||
MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ( const Module& module )
|
||||
{
|
||||
static string ros_junk ( "$(ROS_TEMPORARY)" );
|
||||
string target ( FixupTargetFilename ( module.GetPath () ) );
|
||||
string target ( PassThruCacheDirectory( FixupTargetFilename ( module.GetPath () ) ) );
|
||||
string workingDirectory = GetWorkingDirectory ( );
|
||||
string archiveFilename = GetModuleArchiveFilename ( module );
|
||||
string importLibraryDependencies = GetImportLibraryDependencies ( module );
|
||||
|
@ -1310,7 +1360,7 @@ MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ( const
|
|||
else
|
||||
{
|
||||
fprintf ( fMakefile, "%s:\n",
|
||||
target.c_str ());
|
||||
target.c_str () );
|
||||
fprintf ( fMakefile, ".PHONY: %s\n\n",
|
||||
target.c_str ());
|
||||
}
|
||||
|
@ -1345,6 +1395,16 @@ MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ( const Module& modul
|
|||
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)
|
||||
{
|
||||
GenerateMacrosAndTargetsTarget ( module );
|
||||
|
||||
|
@ -1394,7 +1454,6 @@ MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ( const Module& module
|
|||
string linkingDependencies = GetLinkingDependencies ( module );
|
||||
|
||||
GenerateImportLibraryTargetIfNeeded ( module );
|
||||
|
||||
if ( module.files.size () > 0 )
|
||||
{
|
||||
GenerateMacrosAndTargetsTarget ( module );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue