const string& newExtension )\r
{\r
size_t index = filename.find_last_of ( '/' );\r
- if (index == string::npos) index = 0;\r
- string tmp = filename.substr( index, filename.size() - index );\r
+ if ( index == string::npos )\r
+ index = 0;\r
+ size_t index2 = filename.find_last_of ( '\\' );\r
+ if ( index2 != string::npos && index2 > index )\r
+ index = index2;\r
+ string tmp = filename.substr( index /*, filename.size() - index*/ );\r
size_t ext_index = tmp.find_last_of( '.' );\r
- if (ext_index != string::npos) \r
+ if ( ext_index != string::npos )\r
return filename.substr ( 0, index + ext_index ) + newExtension;\r
return filename + newExtension;\r
}\r
\r
+string\r
+PrefixFilename (\r
+ const string& filename,\r
+ const string& prefix )\r
+{\r
+ if ( !prefix.length() )\r
+ return filename;\r
+ string out;\r
+ const char* pfilename = filename.c_str();\r
+ const char* p1 = strrchr ( pfilename, '/' );\r
+ const char* p2 = strrchr ( pfilename, '\\' );\r
+ if ( p1 || p2 )\r
+ {\r
+ if ( p2 > p1 )\r
+ p1 = p2;\r
+ out += string(pfilename,p1-pfilename) + CSEP;\r
+ pfilename = p1 + 1;\r
+ }\r
+ out += prefix + pfilename;\r
+ return out;\r
+}\r
+\r
\r
MingwModuleHandler::MingwModuleHandler ( ModuleType moduletype )\r
{\r
return dependencies;\r
}\r
\r
-/*string\r
-MingwModuleHandler::GetAllDependencies ( const Module& module ) const\r
-{\r
- string dependencies = GetImportMacro ( module );\r
- string s = GetModuleDependencies ( module );\r
- if ( s.length () > 0 )\r
- {\r
- dependencies += " ";\r
- dependencies += s;\r
- }\r
- return dependencies;\r
-}*/\r
-\r
string\r
MingwModuleHandler::GetSourceFilenames ( const Module& module,\r
- bool includeGeneratedFiles ) const\r
+ bool includeGeneratedFiles ) const\r
{\r
size_t i;\r
\r
false );\r
}\r
\r
-string\r
-MingwModuleHandler::GetObjectFilename ( const string& sourceFilename )\r
+static string\r
+GetObjectFilename ( const Module& module, const string& sourceFilename )\r
{\r
string newExtension;\r
string extension = GetExtension ( sourceFilename );\r
newExtension = ".stubs.o";\r
else\r
newExtension = ".o";\r
- return FixupTargetFilename ( ReplaceExtension ( sourceFilename, newExtension ) );\r
+ return FixupTargetFilename (\r
+ ReplaceExtension (\r
+ PrefixFilename(sourceFilename,module.prefix),\r
+ newExtension ) );\r
}\r
\r
void\r
{\r
if ( objectFilenames.size () > 0 )\r
objectFilenames += " ";\r
- objectFilenames += PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( files[i]->name ) );\r
+ objectFilenames += PassThruCacheDirectory (\r
+ GetObjectFilename ( module, files[i]->name ) );\r
}\r
return objectFilenames;\r
}\r
\r
void\r
MingwModuleHandler::GenerateMacros (\r
+ const Module& module,\r
const char* assignmentOperation,\r
const IfableData& data,\r
const vector<CompilerFlag*>* compilerFlags,\r
"%s := %s $(%s)\n",\r
objs_macro.c_str(),\r
PassThruCacheDirectory (\r
- MingwModuleHandler::GetObjectFilename ( file.name ) ).c_str (),\r
+ GetObjectFilename ( module, file.name ) ).c_str (),\r
objs_macro.c_str() );\r
}\r
}\r
"%s%s",\r
( i%10 == 9 ? "\\\n\t" : " " ),\r
PassThruCacheDirectory (\r
- MingwModuleHandler::GetObjectFilename ( file.name ) ).c_str () );\r
+ GetObjectFilename ( module, file.name ) ).c_str () );\r
}\r
}\r
fprintf ( fMakefile, "\n" );\r
rIf.property.c_str(),\r
rIf.value.c_str() );\r
GenerateMacros (\r
+ module,\r
"+=",\r
rIf.data,\r
NULL,\r
const string& linkdeps_macro ) const\r
{\r
GenerateMacros (\r
+ module,\r
"=",\r
module.non_if_data,\r
&module.compilerFlags,\r
string deps = sourceFilename;\r
if ( module.pch && use_pch )\r
deps += " " + module.pch->header + ".gch";\r
- string objectFilename = PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename ) );\r
+ string objectFilename = PassThruCacheDirectory (\r
+ GetObjectFilename ( module, sourceFilename ) );\r
fprintf ( fMakefile,\r
"%s: %s\n",\r
objectFilename.c_str (),\r
const string& cc,\r
const string& cflagsMacro ) const\r
{\r
- string objectFilename = PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename ) );\r
+ string objectFilename = PassThruCacheDirectory (\r
+ GetObjectFilename ( module, sourceFilename ) );\r
fprintf ( fMakefile,\r
"%s: %s\n",\r
objectFilename.c_str (),\r
const string& sourceFilename,\r
const string& nasmflagsMacro ) const\r
{\r
- string objectFilename = PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename ) );\r
+ string objectFilename = PassThruCacheDirectory (\r
+ GetObjectFilename ( module, sourceFilename ) );\r
fprintf ( fMakefile,\r
"%s: %s\n",\r
objectFilename.c_str (),\r
const string& sourceFilename,\r
const string& windresflagsMacro ) const\r
{\r
- string objectFilename = PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename ) );\r
+ string objectFilename = PassThruCacheDirectory ( \r
+ GetObjectFilename ( module, sourceFilename ) );\r
string rciFilename = ReplaceExtension ( sourceFilename,\r
".rci" );\r
string resFilename = ReplaceExtension ( sourceFilename,\r
const string& windresflagsMacro,\r
string_list& clean_files ) const\r
{\r
- CLEAN_FILE ( GetObjectFilename(sourceFilename) );\r
+ CLEAN_FILE ( GetObjectFilename(module,sourceFilename) );\r
string extension = GetExtension ( sourceFilename );\r
if ( extension == ".c" || extension == ".C" )\r
{\r
fprintf ( fMakefile, "\n" );\r
}\r
\r
-void\r
-MingwModuleHandler::GetCleanTargets (\r
- string_list& out,\r
- const IfableData& data ) const\r
-{\r
- size_t i;\r
-\r
- const vector<File*>& files = data.files;\r
- for ( i = 0; i < files.size(); i++ )\r
- out.push_back ( PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( files[i]->name ) ) );\r
-\r
- const vector<If*>& ifs = data.ifs;\r
- for ( i = 0; i < ifs.size(); i++ )\r
- GetCleanTargets ( out, ifs[i]->data );\r
-}\r
-\r
string\r
MingwModuleHandler::GenerateArchiveTarget ( const Module& module,\r
const string& ar,\r
void\r
MingwModuleHandler::GenerateMacrosAndTargets (\r
const Module& module,\r
- const string& cc,\r
- const string& cppc,\r
- const string& ar,\r
const string* cflags,\r
const string* nasmflags,\r
string_list& clean_files ) const\r
{\r
+ string cc = ( module.host ? "${host_gcc}" : "${gcc}" );\r
+ string cppc = ( module.host ? "${host_gpp}" : "${gpp}" );\r
+ string ar = ( module.host ? "${host_ar}" : "${ar}" );\r
+\r
string cflagsMacro = ssprintf ("%s_CFLAGS", module.name.c_str ());\r
string nasmflagsMacro = ssprintf ("%s_NASMFLAGS", module.name.c_str ());\r
string windresflagsMacro = ssprintf ("%s_RCFLAGS", module.name.c_str ());\r
}\r
}\r
\r
-void\r
-MingwModuleHandler::GenerateMacrosAndTargetsHost (\r
- const Module& module,\r
- string_list& clean_files ) const\r
-{\r
- GenerateMacrosAndTargets (\r
- module,\r
- "${host_gcc}",\r
- "${host_gpp}",\r
- "${host_ar}",\r
- NULL,\r
- NULL,\r
- clean_files );\r
-}\r
-\r
-void\r
-MingwModuleHandler::GenerateMacrosAndTargetsTarget (\r
- const Module& module,\r
- string_list& clean_files ) const\r
-{\r
- GenerateMacrosAndTargetsTarget (\r
- module,\r
- NULL,\r
- NULL,\r
- clean_files );\r
-}\r
-\r
-void\r
-MingwModuleHandler::GenerateMacrosAndTargetsTarget (\r
- const Module& module,\r
- const string* cflags,\r
- const string* nasmflags,\r
- string_list& clean_files ) const\r
-{\r
- GenerateMacrosAndTargets (\r
- module,\r
- "${gcc}",\r
- "${gpp}",\r
- "${ar}",\r
- cflags,\r
- nasmflags,\r
- clean_files );\r
-}\r
-\r
string\r
MingwModuleHandler::GetInvocationDependencies ( const Module& module ) const\r
{\r
string linkDepsMacro = GetLinkingDependenciesMacro ( module );\r
string libsMacro = GetLibsMacro ( module );\r
\r
- GenerateMacrosAndTargetsHost ( module, clean_files );\r
+ GenerateMacrosAndTargets (\r
+ module,\r
+ NULL,\r
+ NULL,\r
+ clean_files );\r
\r
string linker;\r
if ( IsCPlusPlusModule ( module ) )\r
module.entrypoint.c_str (),\r
module.baseaddress.c_str () );\r
\r
- GenerateMacrosAndTargetsTarget ( module, clean_files );\r
+ GenerateMacrosAndTargets ( module, NULL, NULL, clean_files );\r
\r
GenerateImportLibraryTargetIfNeeded ( module, clean_files );\r
\r
void\r
MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ( const Module& module, string_list& clean_files )\r
{\r
- GenerateMacrosAndTargetsTarget ( module, clean_files );\r
+ GenerateMacrosAndTargets ( module, NULL, NULL, clean_files );\r
}\r
\r
\r
void\r
MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget ( const Module& module, string_list& clean_files )\r
{\r
- GenerateMacrosAndTargetsTarget ( module, clean_files );\r
+ GenerateMacrosAndTargets ( module, NULL, NULL, clean_files );\r
}\r
\r
\r
\r
if ( module.non_if_data.files.size () > 0 )\r
{\r
- GenerateMacrosAndTargetsTarget ( module, clean_files );\r
+ GenerateMacrosAndTargets ( module, NULL, NULL, clean_files );\r
\r
fprintf ( fMakefile, "%s: %s %s\n",\r
target.c_str (),\r
if ( module.non_if_data.files.size () > 0 )\r
{\r
string cflags ( "-D__NTDRIVER__" );\r
- GenerateMacrosAndTargetsTarget ( module,\r
- &cflags,\r
- NULL,\r
- clean_files);\r
+ GenerateMacrosAndTargets ( module,\r
+ &cflags,\r
+ NULL,\r
+ clean_files );\r
\r
fprintf ( fMakefile, "%s: %s %s\n",\r
target.c_str (),\r
\r
if ( module.non_if_data.files.size () > 0 )\r
{\r
- GenerateMacrosAndTargetsTarget ( module, clean_files );\r
+ GenerateMacrosAndTargets ( module, NULL, NULL, clean_files );\r
\r
fprintf ( fMakefile, "%s: %s %s\n",\r
target.c_str (),\r
if ( module.non_if_data.files.size () > 0 )\r
{\r
string cflags ( "-D__NTAPP__" );\r
- GenerateMacrosAndTargetsTarget ( module,\r
- &cflags,\r
- NULL,\r
- clean_files );\r
+ GenerateMacrosAndTargets ( module,\r
+ &cflags,\r
+ NULL,\r
+ clean_files );\r
\r
fprintf ( fMakefile, "%s: %s %s\n",\r
target.c_str (),\r
\r
if ( module.non_if_data.files.size () > 0 )\r
{\r
- GenerateMacrosAndTargetsTarget ( module, clean_files );\r
+ GenerateMacrosAndTargets ( module, NULL, NULL, clean_files );\r
\r
fprintf ( fMakefile, "%s: %s %s\n",\r
target.c_str (),\r
linkDepsMacro.c_str () );\r
\r
string linker;\r
- if ( IsCPlusPlusModule ( module ) )\r
+ if ( module.cplusplus )\r
linker = "${gpp}";\r
else\r
linker = "${gcc}";\r
\r
if ( module.non_if_data.files.size () > 0 )\r
{\r
- GenerateMacrosAndTargetsTarget ( module, clean_files );\r
+ GenerateMacrosAndTargets ( module, NULL, NULL, clean_files );\r
\r
fprintf ( fMakefile, "%s: %s %s\n",\r
target.c_str (),\r
linkDepsMacro.c_str () );\r
\r
string linker;\r
- if ( IsCPlusPlusModule ( module ) )\r
+ if ( module.cplusplus )\r
linker = "${gpp}";\r
else\r
linker = "${gcc}";\r
\r
if ( module.non_if_data.files.size () > 0 )\r
{\r
- GenerateMacrosAndTargetsTarget ( module, clean_files );\r
+ GenerateMacrosAndTargets ( module, NULL, NULL, clean_files );\r
\r
fprintf ( fMakefile, "%s: %s %s\n",\r
target.c_str (),\r
linkDepsMacro.c_str () );\r
\r
string linker;\r
- if ( IsCPlusPlusModule ( module ) )\r
+ if ( module.cplusplus )\r
linker = "${gpp}";\r
else\r
linker = "${gcc}";\r
string linkDepsMacro = GetLinkingDependenciesMacro ( module );\r
string libsMacro = GetLibsMacro ( module );\r
\r
- GenerateMacrosAndTargetsTarget ( module, clean_files );\r
+ GenerateMacrosAndTargets ( module, NULL, NULL, clean_files );\r
\r
fprintf ( fMakefile, "%s: %s %s\n",\r
target.c_str (),\r
string objectsMacro = GetObjectsMacro ( module );\r
\r
string* nasmflags = new string ( "-f bin" );\r
- GenerateMacrosAndTargetsTarget ( module,\r
- NULL,\r
- nasmflags,\r
- clean_files );\r
+ GenerateMacrosAndTargets ( module,\r
+ NULL,\r
+ nasmflags,\r
+ clean_files );\r
\r
fprintf ( fMakefile, ".PHONY: %s\n\n",\r
module.name.c_str ());\r
ReplaceExtension ( const std::string& filename,\r
const std::string& newExtension );\r
\r
+extern std::string\r
+PrefixFilename (\r
+ const std::string& filename,\r
+ const std::string& prefix );\r
\r
class MingwModuleHandler\r
{\r
static void SetUsePch ( bool use_pch );\r
static MingwModuleHandler* LookupHandler ( const std::string& location,\r
ModuleType moduletype_ );\r
+ virtual HostType DefaultHost() = 0;\r
virtual void Process ( const Module& module, string_list& clean_files ) = 0;\r
bool IncludeDirectoryTarget ( const std::string& directory ) const;\r
void GenerateDirectoryTargets () const;\r
- static std::string GetObjectFilename ( const std::string& sourceFilename );\r
void GenerateCleanTarget ( const Module& module,\r
const string_list& clean_files ) const;\r
protected:\r
std::string GetSourceFilenamesWithoutGeneratedFiles ( const Module& module ) const;\r
\r
std::string GetObjectFilenames ( const Module& module ) const;\r
- void GenerateMacrosAndTargetsHost ( const Module& module,\r
- string_list& clean_files ) const;\r
- void GenerateMacrosAndTargetsTarget ( const Module& module,\r
- string_list& clean_files ) const;\r
- void GenerateMacrosAndTargetsTarget ( const Module& module,\r
- const std::string* cflags,\r
- const std::string* nasmflags,\r
- string_list& clean_files ) const;\r
std::string GetInvocationDependencies ( const Module& module ) const;\r
void GenerateInvocations ( const Module& module ) const;\r
\r
const std::string& objectsMacro,\r
const std::string& libsMacro,\r
string_list& clean_files ) const;\r
+ void GenerateMacrosAndTargets ( const Module& module,\r
+ const std::string* clags,\r
+ const std::string* nasmflags,\r
+ string_list& clean_files ) const;\r
void GenerateImportLibraryTargetIfNeeded ( const Module& module, string_list& clean_files ) const;\r
std::string GetDefinitionDependencies ( const Module& module ) const;\r
std::string GetLinkingDependencies ( const Module& module ) const;\r
const std::string& macro,\r
const IfableData& data,\r
const std::vector<CompilerFlag*>* compilerFlags ) const;\r
- void GenerateMacros ( const char* op,\r
+ void GenerateMacros (\r
+ const Module& module,\r
+ const char* op,\r
const IfableData& data,\r
const std::vector<CompilerFlag*>* compilerFlags,\r
const std::vector<LinkerFlag*>* linkerFlags,\r
const std::string& nasmflagsMacro,\r
const std::string& windresflagsMacro,\r
string_list& clean_files ) const;\r
- void GetCleanTargets ( string_list& out,\r
- const IfableData& data ) const;\r
std::string GenerateArchiveTarget ( const Module& module,\r
const std::string& ar,\r
const std::string& objs_macro ) const;\r
- void GenerateMacrosAndTargets ( const Module& module,\r
- const std::string& cc,\r
- const std::string& cppc,\r
- const std::string& ar,\r
- const std::string* clags,\r
- const std::string* nasmflags,\r
- string_list& clean_files ) const;\r
std::string GetSpecObjectDependencies ( const std::string& filename ) const;\r
std::string GetDefaultDependencies ( const Module& module ) const;\r
};\r
{\r
public:\r
MingwBuildToolModuleHandler ();\r
+ virtual HostType DefaultHost() { return HostTrue; }\r
virtual void Process ( const Module& module, string_list& clean_files );\r
private:\r
void GenerateBuildToolModuleTarget ( const Module& module, string_list& clean_files );\r
{\r
public:\r
MingwKernelModuleHandler ();\r
+ virtual HostType DefaultHost() { return HostFalse; }\r
virtual void Process ( const Module& module, string_list& clean_files );\r
private:\r
void GenerateKernelModuleTarget ( const Module& module, string_list& clean_files );\r
{\r
public:\r
MingwStaticLibraryModuleHandler ();\r
+ virtual HostType DefaultHost() { return HostFalse; }\r
virtual void Process ( const Module& module, string_list& clean_files );\r
private:\r
void GenerateStaticLibraryModuleTarget ( const Module& module, string_list& clean_files );\r
{\r
public:\r
MingwObjectLibraryModuleHandler ();\r
+ virtual HostType DefaultHost() { return HostFalse; }\r
virtual void Process ( const Module& module, string_list& clean_files );\r
private:\r
void GenerateObjectLibraryModuleTarget ( const Module& module, string_list& clean_files );\r
{\r
public:\r
MingwKernelModeDLLModuleHandler ();\r
+ virtual HostType DefaultHost() { return HostFalse; }\r
virtual void Process ( const Module& module, string_list& clean_files );\r
private:\r
void GenerateKernelModeDLLModuleTarget ( const Module& module, string_list& clean_files );\r
{\r
public:\r
MingwKernelModeDriverModuleHandler ();\r
+ virtual HostType DefaultHost() { return HostFalse; }\r
virtual void Process ( const Module& module, string_list& clean_files );\r
private:\r
void GenerateKernelModeDriverModuleTarget ( const Module& module, string_list& clean_files );\r
{\r
public:\r
MingwNativeDLLModuleHandler ();\r
+ virtual HostType DefaultHost() { return HostFalse; }\r
virtual void Process ( const Module& module, string_list& clean_files );\r
private:\r
void GenerateNativeDLLModuleTarget ( const Module& module, string_list& clean_files );\r
{\r
public:\r
MingwNativeCUIModuleHandler ();\r
+ virtual HostType DefaultHost() { return HostFalse; }\r
virtual void Process ( const Module& module, string_list& clean_files );\r
private:\r
void GenerateNativeCUIModuleTarget ( const Module& module, string_list& clean_files );\r
{\r
public:\r
MingwWin32DLLModuleHandler ();\r
+ virtual HostType DefaultHost() { return HostFalse; }\r
virtual void Process ( const Module& module, string_list& clean_files );\r
private:\r
void GenerateExtractWineDLLResourcesTarget ( const Module& module, string_list& clean_files );\r
{\r
public:\r
MingwWin32CUIModuleHandler ();\r
+ virtual HostType DefaultHost() { return HostFalse; }\r
virtual void Process ( const Module& module, string_list& clean_files );\r
private:\r
void GenerateWin32CUIModuleTarget ( const Module& module, string_list& clean_files );\r
{\r
public:\r
MingwWin32GUIModuleHandler ();\r
+ virtual HostType DefaultHost() { return HostFalse; }\r
virtual void Process ( const Module& module, string_list& clean_files );\r
private:\r
void GenerateWin32GUIModuleTarget ( const Module& module, string_list& clean_files );\r
{\r
public:\r
MingwBootLoaderModuleHandler ();\r
+ virtual HostType DefaultHost() { return HostFalse; }\r
virtual void Process ( const Module& module, string_list& clean_files );\r
private:\r
void GenerateBootLoaderModuleTarget ( const Module& module, string_list& clean_files );\r
{\r
public:\r
MingwBootSectorModuleHandler ();\r
+ virtual HostType DefaultHost() { return HostFalse; }\r
virtual void Process ( const Module& module, string_list& clean_files );\r
private:\r
void GenerateBootSectorModuleTarget ( const Module& module, string_list& clean_files );\r
{\r
public:\r
MingwIsoModuleHandler ();\r
+ virtual HostType DefaultHost() { return HostFalse; }\r
virtual void Process ( const Module& module, string_list& clean_files );\r
private:\r
void GenerateIsoModuleTarget ( const Module& module, string_list& clean_files );\r