--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp 2005-03-11 07:41:19 UTC (rev 13923)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp 2005-03-11 07:46:22 UTC (rev 13924)
@@ -31,15 +31,41 @@
const string& newExtension )
{
size_t index = filename.find_last_of ( '/' );
- if (index == string::npos) index = 0;
- string tmp = filename.substr( index, filename.size() - index );
+ if ( index == string::npos )
+ index = 0;
+ size_t index2 = filename.find_last_of ( '\\' );
+ if ( index2 != string::npos && index2 > index )
+ index = index2;
+ string tmp = filename.substr( index /*, filename.size() - index*/ );
size_t ext_index = tmp.find_last_of( '.' );
- if (ext_index != string::npos)
+ if ( ext_index != string::npos )
return filename.substr ( 0, index + ext_index ) + newExtension;
return filename + newExtension;
}
+string
+PrefixFilename (
+ const string& filename,
+ const string& prefix )
+{
+ if ( !prefix.length() )
+ return filename;
+ string out;
+ const char* pfilename = filename.c_str();
+ const char* p1 = strrchr ( pfilename, '/' );
+ const char* p2 = strrchr ( pfilename, '\\' );
+ if ( p1 || p2 )
+ {
+ if ( p2 > p1 )
+ p1 = p2;
+ out += string(pfilename,p1-pfilename) + CSEP;
+ pfilename = p1 + 1;
+ }
+ out += prefix + pfilename;
+ return out;
+}
+
MingwModuleHandler::MingwModuleHandler ( ModuleType moduletype )
{
if ( !ref++ )
@@ -167,22 +193,9 @@
return dependencies;
}
-/*string
-MingwModuleHandler::GetAllDependencies ( const Module& module ) const
-{
- string dependencies = GetImportMacro ( module );
- string s = GetModuleDependencies ( module );
- if ( s.length () > 0 )
- {
- dependencies += " ";
- dependencies += s;
- }
- return dependencies;
-}*/
-
string
MingwModuleHandler::GetSourceFilenames ( const Module& module,
- bool includeGeneratedFiles ) const
+ bool includeGeneratedFiles ) const
{
size_t i;
@@ -229,8 +242,8 @@
false );
}
-string
-MingwModuleHandler::GetObjectFilename ( const string& sourceFilename )
+static string
+GetObjectFilename ( const Module& module, const string& sourceFilename )
{
string newExtension;
string extension = GetExtension ( sourceFilename );
@@ -240,7 +253,10 @@
newExtension = ".stubs.o";
else
newExtension = ".o";
- return FixupTargetFilename ( ReplaceExtension ( sourceFilename, newExtension ) );
+ return FixupTargetFilename (
+ ReplaceExtension (
+ PrefixFilename(sourceFilename,module.prefix),
+ newExtension ) );
}
void
@@ -274,7 +290,8 @@
{
if ( objectFilenames.size () > 0 )
objectFilenames += " ";
- objectFilenames += PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( files[i]->name ) );
+ objectFilenames += PassThruCacheDirectory (
+ GetObjectFilename ( module, files[i]->name ) );
}
return objectFilenames;
}
@@ -514,6 +531,7 @@
void
MingwModuleHandler::GenerateMacros (
+ const Module& module,
const char* assignmentOperation,
const IfableData& data,
const vector<CompilerFlag*>* compilerFlags,
@@ -580,7 +598,7 @@
"%s := %s $(%s)\n",
objs_macro.c_str(),
PassThruCacheDirectory (
- MingwModuleHandler::GetObjectFilename ( file.name ) ).c_str (),
+ GetObjectFilename ( module, file.name ) ).c_str (),
objs_macro.c_str() );
}
}
@@ -599,7 +617,7 @@
"%s%s",
( i%10 == 9 ? "\\\n\t" : " " ),
PassThruCacheDirectory (
- MingwModuleHandler::GetObjectFilename ( file.name ) ).c_str () );
+ GetObjectFilename ( module, file.name ) ).c_str () );
}
}
fprintf ( fMakefile, "\n" );
@@ -621,6 +639,7 @@
rIf.property.c_str(),
rIf.value.c_str() );
GenerateMacros (
+ module,
"+=",
rIf.data,
NULL,
@@ -651,6 +670,7 @@
const string& linkdeps_macro ) const
{
GenerateMacros (
+ module,
"=",
module.non_if_data,
&module.compilerFlags,
@@ -721,7 +741,8 @@
string deps = sourceFilename;
if ( module.pch && use_pch )
deps += " " + module.pch->header + ".gch";
- string objectFilename = PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename ) );
+ string objectFilename = PassThruCacheDirectory (
+ GetObjectFilename ( module, sourceFilename ) );
fprintf ( fMakefile,
"%s: %s\n",
objectFilename.c_str (),
@@ -741,7 +762,8 @@
const string& cc,
const string& cflagsMacro ) const
{
- string objectFilename = PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename ) );
+ string objectFilename = PassThruCacheDirectory (
+ GetObjectFilename ( module, sourceFilename ) );
fprintf ( fMakefile,
"%s: %s\n",
objectFilename.c_str (),
@@ -760,7 +782,8 @@
const string& sourceFilename,
const string& nasmflagsMacro ) const
{
- string objectFilename = PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename ) );
+ string objectFilename = PassThruCacheDirectory (
+ GetObjectFilename ( module, sourceFilename ) );
fprintf ( fMakefile,
"%s: %s\n",
objectFilename.c_str (),
@@ -779,7 +802,8 @@
const string& sourceFilename,
const string& windresflagsMacro ) const
{
- string objectFilename = PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename ) );
+ string objectFilename = PassThruCacheDirectory (
+ GetObjectFilename ( module, sourceFilename ) );
string rciFilename = ReplaceExtension ( sourceFilename,
".rci" );
string resFilename = ReplaceExtension ( sourceFilename,
@@ -859,7 +883,7 @@
const string& windresflagsMacro,
string_list& clean_files ) const
{
- CLEAN_FILE ( GetObjectFilename(sourceFilename) );
+ CLEAN_FILE ( GetObjectFilename(module,sourceFilename) );
string extension = GetExtension ( sourceFilename );
if ( extension == ".c" || extension == ".C" )
{
@@ -1090,22 +1114,6 @@
fprintf ( fMakefile, "\n" );
}
-void
-MingwModuleHandler::GetCleanTargets (
- string_list& out,
- const IfableData& data ) const
-{
- size_t i;
-
- const vector<File*>& files = data.files;
- for ( i = 0; i < files.size(); i++ )
- out.push_back ( PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( files[i]->name ) ) );
-
- const vector<If*>& ifs = data.ifs;
- for ( i = 0; i < ifs.size(); i++ )
- GetCleanTargets ( out, ifs[i]->data );
-}
-
string
MingwModuleHandler::GenerateArchiveTarget ( const Module& module,
const string& ar,
@@ -1165,13 +1173,14 @@
void
MingwModuleHandler::GenerateMacrosAndTargets (
const Module& module,
- const string& cc,
- const string& cppc,
- const string& ar,
const string* cflags,
const string* nasmflags,
string_list& clean_files ) const
{
+ string cc = ( module.host ? "${host_gcc}" : "${gcc}" );
+ string cppc = ( module.host ? "${host_gpp}" : "${gpp}" );
+ string ar = ( module.host ? "${host_ar}" : "${ar}" );
+
string cflagsMacro = ssprintf ("%s_CFLAGS", module.name.c_str ());
string nasmflagsMacro = ssprintf ("%s_NASMFLAGS", module.name.c_str ());
string windresflagsMacro = ssprintf ("%s_RCFLAGS", module.name.c_str ());
@@ -1234,50 +1243,6 @@
}
}
-void
-MingwModuleHandler::GenerateMacrosAndTargetsHost (
- const Module& module,
- string_list& clean_files ) const
-{
- GenerateMacrosAndTargets (
- module,
- "${host_gcc}",
- "${host_gpp}",
- "${host_ar}",
- NULL,
- NULL,
- clean_files );
-}
-
-void
-MingwModuleHandler::GenerateMacrosAndTargetsTarget (
- const Module& module,
- string_list& clean_files ) const
-{
- GenerateMacrosAndTargetsTarget (
- module,
- NULL,
- NULL,
- clean_files );
-}
-
-void
-MingwModuleHandler::GenerateMacrosAndTargetsTarget (
- const Module& module,
- const string* cflags,
- const string* nasmflags,
- string_list& clean_files ) const
-{
- GenerateMacrosAndTargets (
- module,
- "${gcc}",
- "${gpp}",
- "${ar}",
- cflags,
- nasmflags,
- clean_files );
-}
-
string
MingwModuleHandler::GetInvocationDependencies ( const Module& module ) const
{
@@ -1489,7 +1454,11 @@
string linkDepsMacro = GetLinkingDependenciesMacro ( module );
string libsMacro = GetLibsMacro ( module );
- GenerateMacrosAndTargetsHost ( module, clean_files );
+ GenerateMacrosAndTargets (
+ module,
+ NULL,
+ NULL,
+ clean_files );
string linker;
if ( IsCPlusPlusModule ( module ) )
@@ -1548,7 +1517,7 @@
module.entrypoint.c_str (),
module.baseaddress.c_str () );
- GenerateMacrosAndTargetsTarget ( module, clean_files );
+ GenerateMacrosAndTargets ( module, NULL, NULL, clean_files );
GenerateImportLibraryTargetIfNeeded ( module, clean_files );
@@ -1615,7 +1584,7 @@
void
MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ( const Module& module, string_list& clean_files )
{
- GenerateMacrosAndTargetsTarget ( module, clean_files );
+ GenerateMacrosAndTargets ( module, NULL, NULL, clean_files );
}
@@ -1637,7 +1606,7 @@
void
MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget ( const Module& module, string_list& clean_files )
{
- GenerateMacrosAndTargetsTarget ( module, clean_files );
+ GenerateMacrosAndTargets ( module, NULL, NULL, clean_files );
}
@@ -1672,7 +1641,7 @@
if ( module.non_if_data.files.size () > 0 )
{
- GenerateMacrosAndTargetsTarget ( module, clean_files );
+ GenerateMacrosAndTargets ( module, NULL, NULL, clean_files );
fprintf ( fMakefile, "%s: %s %s\n",
target.c_str (),
@@ -1732,10 +1701,10 @@
if ( module.non_if_data.files.size () > 0 )
{
string cflags ( "-D__NTDRIVER__" );
- GenerateMacrosAndTargetsTarget ( module,
- &cflags,
- NULL,
- clean_files);
+ GenerateMacrosAndTargets ( module,
+ &cflags,
+ NULL,
+ clean_files );
fprintf ( fMakefile, "%s: %s %s\n",
target.c_str (),
@@ -1791,7 +1760,7 @@
if ( module.non_if_data.files.size () > 0 )
{
- GenerateMacrosAndTargetsTarget ( module, clean_files );
+ GenerateMacrosAndTargets ( module, NULL, NULL, clean_files );
fprintf ( fMakefile, "%s: %s %s\n",
target.c_str (),
@@ -1848,10 +1817,10 @@
if ( module.non_if_data.files.size () > 0 )
{
string cflags ( "-D__NTAPP__" );
- GenerateMacrosAndTargetsTarget ( module,
- &cflags,
- NULL,
- clean_files );
+ GenerateMacrosAndTargets ( module,
+ &cflags,
+ NULL,
+ clean_files );
fprintf ( fMakefile, "%s: %s %s\n",
target.c_str (),
@@ -1931,7 +1900,7 @@
if ( module.non_if_data.files.size () > 0 )
{
- GenerateMacrosAndTargetsTarget ( module, clean_files );
+ GenerateMacrosAndTargets ( module, NULL, NULL, clean_files );
fprintf ( fMakefile, "%s: %s %s\n",
target.c_str (),
@@ -1939,7 +1908,7 @@
linkDepsMacro.c_str () );
string linker;
- if ( IsCPlusPlusModule ( module ) )
+ if ( module.cplusplus )
linker = "${gpp}";
else
linker = "${gcc}";
@@ -1993,7 +1962,7 @@
if ( module.non_if_data.files.size () > 0 )
{
- GenerateMacrosAndTargetsTarget ( module, clean_files );
+ GenerateMacrosAndTargets ( module, NULL, NULL, clean_files );
fprintf ( fMakefile, "%s: %s %s\n",
target.c_str (),
@@ -2001,7 +1970,7 @@
linkDepsMacro.c_str () );
string linker;
- if ( IsCPlusPlusModule ( module ) )
+ if ( module.cplusplus )
linker = "${gpp}";
else
linker = "${gcc}";
@@ -2055,7 +2024,7 @@
if ( module.non_if_data.files.size () > 0 )
{
- GenerateMacrosAndTargetsTarget ( module, clean_files );
+ GenerateMacrosAndTargets ( module, NULL, NULL, clean_files );
fprintf ( fMakefile, "%s: %s %s\n",
target.c_str (),
@@ -2063,7 +2032,7 @@
linkDepsMacro.c_str () );
string linker;
- if ( IsCPlusPlusModule ( module ) )
+ if ( module.cplusplus )
linker = "${gpp}";
else
linker = "${gcc}";
@@ -2118,7 +2087,7 @@
string linkDepsMacro = GetLinkingDependenciesMacro ( module );
string libsMacro = GetLibsMacro ( module );
- GenerateMacrosAndTargetsTarget ( module, clean_files );
+ GenerateMacrosAndTargets ( module, NULL, NULL, clean_files );
fprintf ( fMakefile, "%s: %s %s\n",
target.c_str (),
@@ -2164,10 +2133,10 @@
string objectsMacro = GetObjectsMacro ( module );
string* nasmflags = new string ( "-f bin" );
- GenerateMacrosAndTargetsTarget ( module,
- NULL,
- nasmflags,
- clean_files );
+ GenerateMacrosAndTargets ( module,
+ NULL,
+ nasmflags,
+ clean_files );
fprintf ( fMakefile, ".PHONY: %s\n\n",
module.name.c_str ());
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h 2005-03-11 07:41:19 UTC (rev 13923)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h 2005-03-11 07:46:22 UTC (rev 13924)
@@ -7,6 +7,10 @@
ReplaceExtension ( const std::string& filename,
const std::string& newExtension );
+extern std::string
+PrefixFilename (
+ const std::string& filename,
+ const std::string& prefix );
class MingwModuleHandler
{
@@ -23,10 +27,10 @@
static void SetUsePch ( bool use_pch );
static MingwModuleHandler* LookupHandler ( const std::string& location,
ModuleType moduletype_ );
+ virtual HostType DefaultHost() = 0;
virtual void Process ( const Module& module, string_list& clean_files ) = 0;
bool IncludeDirectoryTarget ( const std::string& directory ) const;
void GenerateDirectoryTargets () const;
- static std::string GetObjectFilename ( const std::string& sourceFilename );
void GenerateCleanTarget ( const Module& module,
const string_list& clean_files ) const;
protected:
@@ -45,14 +49,6 @@
std::string GetSourceFilenamesWithoutGeneratedFiles ( const Module& module ) const;
std::string GetObjectFilenames ( const Module& module ) const;
- void GenerateMacrosAndTargetsHost ( const Module& module,
- string_list& clean_files ) const;
- void GenerateMacrosAndTargetsTarget ( const Module& module,
- string_list& clean_files ) const;
- void GenerateMacrosAndTargetsTarget ( const Module& module,
- const std::string* cflags,
- const std::string* nasmflags,
- string_list& clean_files ) const;
std::string GetInvocationDependencies ( const Module& module ) const;
void GenerateInvocations ( const Module& module ) const;
@@ -69,6 +65,10 @@
const std::string& objectsMacro,
const std::string& libsMacro,
string_list& clean_files ) const;
+ void GenerateMacrosAndTargets ( const Module& module,
+ const std::string* clags,
+ const std::string* nasmflags,
+ string_list& clean_files ) const;
void GenerateImportLibraryTargetIfNeeded ( const Module& module, string_list& clean_files ) const;
std::string GetDefinitionDependencies ( const Module& module ) const;
std::string GetLinkingDependencies ( const Module& module ) const;
@@ -90,7 +90,9 @@
const std::string& macro,
const IfableData& data,
const std::vector<CompilerFlag*>* compilerFlags ) const;
- void GenerateMacros ( const char* op,
+ void GenerateMacros (
+ const Module& module,
+ const char* op,
const IfableData& data,
const std::vector<CompilerFlag*>* compilerFlags,
const std::vector<LinkerFlag*>* linkerFlags,
@@ -152,18 +154,9 @@
const std::string& nasmflagsMacro,
const std::string& windresflagsMacro,
string_list& clean_files ) const;
- void GetCleanTargets ( string_list& out,
- const IfableData& data ) const;
std::string GenerateArchiveTarget ( const Module& module,
const std::string& ar,
const std::string& objs_macro ) const;
- void GenerateMacrosAndTargets ( const Module& module,
- const std::string& cc,
- const std::string& cppc,
- const std::string& ar,
- const std::string* clags,
- const std::string* nasmflags,
- string_list& clean_files ) const;
std::string GetSpecObjectDependencies ( const std::string& filename ) const;
std::string GetDefaultDependencies ( const Module& module ) const;
};
@@ -173,6 +166,7 @@
{
public:
MingwBuildToolModuleHandler ();
+ virtual HostType DefaultHost() { return HostTrue; }
virtual void Process ( const Module& module, string_list& clean_files );
private:
void GenerateBuildToolModuleTarget ( const Module& module, string_list& clean_files );
@@ -183,6 +177,7 @@
{
public:
MingwKernelModuleHandler ();
+ virtual HostType DefaultHost() { return HostFalse; }
virtual void Process ( const Module& module, string_list& clean_files );
private:
void GenerateKernelModuleTarget ( const Module& module, string_list& clean_files );
@@ -193,6 +188,7 @@
{
public:
MingwStaticLibraryModuleHandler ();
+ virtual HostType DefaultHost() { return HostFalse; }
virtual void Process ( const Module& module, string_list& clean_files );
private:
void GenerateStaticLibraryModuleTarget ( const Module& module, string_list& clean_files );
@@ -203,6 +199,7 @@
{
public:
MingwObjectLibraryModuleHandler ();
+ virtual HostType DefaultHost() { return HostFalse; }
virtual void Process ( const Module& module, string_list& clean_files );
private:
void GenerateObjectLibraryModuleTarget ( const Module& module, string_list& clean_files );
@@ -213,6 +210,7 @@
{
public:
MingwKernelModeDLLModuleHandler ();
+ virtual HostType DefaultHost() { return HostFalse; }
virtual void Process ( const Module& module, string_list& clean_files );
private:
void GenerateKernelModeDLLModuleTarget ( const Module& module, string_list& clean_files );
@@ -223,6 +221,7 @@
{
public:
MingwKernelModeDriverModuleHandler ();
+ virtual HostType DefaultHost() { return HostFalse; }
virtual void Process ( const Module& module, string_list& clean_files );
private:
void GenerateKernelModeDriverModuleTarget ( const Module& module, string_list& clean_files );
@@ -233,6 +232,7 @@
{
public:
MingwNativeDLLModuleHandler ();
+ virtual HostType DefaultHost() { return HostFalse; }
virtual void Process ( const Module& module, string_list& clean_files );
private:
void GenerateNativeDLLModuleTarget ( const Module& module, string_list& clean_files );
@@ -243,6 +243,7 @@
{
public:
MingwNativeCUIModuleHandler ();
+ virtual HostType DefaultHost() { return HostFalse; }
virtual void Process ( const Module& module, string_list& clean_files );
private:
void GenerateNativeCUIModuleTarget ( const Module& module, string_list& clean_files );
@@ -253,6 +254,7 @@
{
public:
MingwWin32DLLModuleHandler ();
+ virtual HostType DefaultHost() { return HostFalse; }
virtual void Process ( const Module& module, string_list& clean_files );
private:
void GenerateExtractWineDLLResourcesTarget ( const Module& module, string_list& clean_files );
@@ -264,6 +266,7 @@
{
public:
MingwWin32CUIModuleHandler ();
+ virtual HostType DefaultHost() { return HostFalse; }
virtual void Process ( const Module& module, string_list& clean_files );
private:
void GenerateWin32CUIModuleTarget ( const Module& module, string_list& clean_files );
@@ -274,6 +277,7 @@
{
public:
MingwWin32GUIModuleHandler ();
+ virtual HostType DefaultHost() { return HostFalse; }
virtual void Process ( const Module& module, string_list& clean_files );
private:
void GenerateWin32GUIModuleTarget ( const Module& module, string_list& clean_files );
@@ -284,6 +288,7 @@
{
public:
MingwBootLoaderModuleHandler ();
+ virtual HostType DefaultHost() { return HostFalse; }
virtual void Process ( const Module& module, string_list& clean_files );
private:
void GenerateBootLoaderModuleTarget ( const Module& module, string_list& clean_files );
@@ -294,6 +299,7 @@
{
public:
MingwBootSectorModuleHandler ();
+ virtual HostType DefaultHost() { return HostFalse; }
virtual void Process ( const Module& module, string_list& clean_files );
private:
void GenerateBootSectorModuleTarget ( const Module& module, string_list& clean_files );
@@ -304,6 +310,7 @@
{
public:
MingwIsoModuleHandler ();
+ virtual HostType DefaultHost() { return HostFalse; }
virtual void Process ( const Module& module, string_list& clean_files );
private:
void GenerateIsoModuleTarget ( const Module& module, string_list& clean_files );