diff --git a/reactos/Makefile b/reactos/Makefile index 68543c44a12..0a874e89eeb 100644 --- a/reactos/Makefile +++ b/reactos/Makefile @@ -1,37 +1,52 @@ -host_gcc = gcc -host_gpp = g++ -host_ld = ld -host_ar = ar -host_objcopy = objcopy +# Default to half-verbose mode +ifeq ($(VERBOSE),no) + Q = @ + HALFVERBOSEECHO = @: +else +ifeq ($(VERBOSE),yes) + Q = + HALFVERBOSEECHO = @: +else + Q = @ + HALFVERBOSEECHO = @echo +endif +endif + + +host_gcc = $(Q)gcc +host_gpp = $(Q)g++ +host_ld = $(Q)ld +host_ar = $(Q)ar +host_objcopy = $(Q)objcopy ifeq ($(HOST),mingw32-linux) EXEPREFIX = ./ EXEPOSTFIX = SEP = / - nmkdir = mkdir -p - gcc = mingw32-gcc - gpp = mingw32-g++ - ld = mingw32-ld - ar = mingw32-ar - objcopy = mingw32-objcopy - dlltool = mingw32-dlltool - windres = mingw32-windres + nmkdir = $(Q)mkdir -p + gcc = $(Q)mingw32-gcc + gpp = $(Q)mingw32-g++ + ld = $(Q)mingw32-ld + ar = $(Q)mingw32-ar + objcopy = $(Q)mingw32-objcopy + dlltool = $(Q)mingw32-dlltool + windres = $(Q)mingw32-windres rm = rm -f - cp = cp + cp = $(Q)cp NUL = /dev/null else # mingw32-windows EXEPREFIX = EXEPOSTFIX = .exe SEP = \$(EMPTY_VAR) - nmkdir = mkdir - gcc = gcc - gpp = g++ - ld = ld - ar = ar - objcopy = objcopy - dlltool = dlltool - windres = windres + nmkdir = $(Q)mkdir + gcc = $(Q)gcc + gpp = $(Q)g++ + ld = $(Q)ld + ar = $(Q)ar + objcopy = $(Q)objcopy + dlltool = $(Q)dlltool + windres = $(Q)windres rm = del /f /q - cp = copy /y + cp = $(Q)copy /y NUL = NUL endif @@ -62,7 +77,8 @@ PREAUTO := \ Makefile.auto: $(RMKDIR_TARGET) $(BUILDNO_TARGET) $(NCI_SERVICE_FILES) $(WMC_TARGET) $(WRC_TARGET) \ $(RSYM_TARGET) $(CDMAKE_TARGET) $(RBUILD_TARGET) $(PREAUTO) $(XMLBUILDFILES) - tools$(SEP)rbuild$(SEP)rbuild$(EXEPOSTFIX) mingw + $(HALFVERBOSEECHO) [RBUILD] makefile.auto + $(Q)tools$(SEP)rbuild$(SEP)rbuild$(EXEPOSTFIX) mingw include$(SEP)reactos$(SEP)bugcodes.h ntoskrnl$(SEP)bugcodes.rc: $(WMC_TARGET) ntoskrnl$(SEP)ntoskrnl.mc diff --git a/reactos/tools/Makefile b/reactos/tools/Makefile index 1e0d2eff1bf..db169853b03 100644 --- a/reactos/tools/Makefile +++ b/reactos/tools/Makefile @@ -14,9 +14,11 @@ RMKDIR_HOST_CFLAGS = -g -Werror -Wall RMKDIR_HOST_LFLAGS = -g $(RMKDIR_TARGET): $(RMKDIR_OBJECTS) + $(HALFVERBOSEECHO) [LD] $@ ${host_gcc} $(RMKDIR_OBJECTS) $(RMKDIR_HOST_LFLAGS) -o $(RMKDIR_TARGET) $(RMKDIR_OBJECTS): %.o : %.c + $(HALFVERBOSEECHO) [CC] $< ${host_gcc} $(RMKDIR_HOST_CFLAGS) -c $< -o $@ .PHONY: rmkdir_clean @@ -41,9 +43,11 @@ RSYM_HOST_CFLAGS = -g -Werror -Wall RSYM_HOST_LFLAGS = -g $(RSYM_TARGET): $(RSYM_OBJECTS) + $(HALFVERBOSEECHO) [LD] $@ ${host_gcc} $(RSYM_OBJECTS) $(RSYM_HOST_LFLAGS) -o $(RSYM_TARGET) $(RSYM_OBJECTS): %.o : %.c + $(HALFVERBOSEECHO) [CC] $< ${host_gcc} $(RSYM_HOST_CFLAGS) -c $< -o $@ .PHONY: rsym_clean diff --git a/reactos/tools/buildno/makefile b/reactos/tools/buildno/makefile index a7136accdd9..33aebff4316 100644 --- a/reactos/tools/buildno/makefile +++ b/reactos/tools/buildno/makefile @@ -17,9 +17,11 @@ BUILDNO_HOST_CFLAGS = -Iinclude/reactos -g -Werror -Wall BUILDNO_HOST_LFLAGS = -g $(BUILDNO_TARGET): $(BUILDNO_OBJECTS) + $(HALFVERBOSEECHO) [LD] $@ ${host_gpp} $(BUILDNO_OBJECTS) $(BUILDNO_HOST_CFLAGS) -o $(BUILDNO_TARGET) $(BUILDNO_OBJECTS): %.o : %.cpp include$(SEP)reactos$(SEP)version.h + $(HALFVERBOSEECHO) [CC] $< ${host_gpp} $(BUILDNO_HOST_CFLAGS) -c $< -o $@ .PHONY: buildno_clean diff --git a/reactos/tools/cdmake/makefile b/reactos/tools/cdmake/makefile index 57c4fef9203..36a0151ef35 100644 --- a/reactos/tools/cdmake/makefile +++ b/reactos/tools/cdmake/makefile @@ -15,9 +15,11 @@ CDMAKE_HOST_CFLAGS = -Iinclude -g -Werror -Wall CDMAKE_HOST_LFLAGS = -g $(CDMAKE_TARGET): $(CDMAKE_OBJECTS) + $(HALFVERBOSEECHO) [LD] $@ ${host_gcc} $(CDMAKE_OBJECTS) $(CDMAKE_HOST_CFLAGS) -o $(CDMAKE_TARGET) $(CDMAKE_OBJECTS): %.o : %.c + $(HALFVERBOSEECHO) [CC] $< ${host_gcc} $(CDMAKE_CFLAGS) -c $< -o $@ .PHONY: cdmake_clean diff --git a/reactos/tools/nci/makefile b/reactos/tools/nci/makefile index 92a2c25cd02..3eaa91ad2e2 100644 --- a/reactos/tools/nci/makefile +++ b/reactos/tools/nci/makefile @@ -14,9 +14,11 @@ NCI_HOST_CFLAGS = -Iinclude -g -Werror -Wall NCI_HOST_LFLAGS = -g $(NCI_TARGET): $(NCI_OBJECTS) + $(HALFVERBOSEECHO) [LD] $@ ${host_gcc} $(NCI_OBJECTS) $(NCI_HOST_CFLAGS) -o $(NCI_TARGET) $(NCI_OBJECTS): %.o : %.c + $(HALFVERBOSEECHO) [CC] $< ${host_gcc} $(NCI_HOST_CFLAGS) -c $< -o $@ .PHONY: nci_clean @@ -45,7 +47,8 @@ NCI_SERVICE_FILES = \ $(WIN32K_USER_STUBS) $(NCI_SERVICE_FILES): $(NCI_TARGET) - @$(EXEPREFIX)$(NCI_TARGET) \ + $(HALFVERBOSEECHO) [NCI] $@ + $(Q)$(EXEPREFIX)$(NCI_TARGET) \ $(KERNEL_SVC_DB) \ $(WIN32K_SVC_DB) \ $(KERNEL_SERVICE_TABLE) \ diff --git a/reactos/tools/rbuild/backend/mingw/mingw.cpp b/reactos/tools/rbuild/backend/mingw/mingw.cpp index 27d024561c1..9780ebeb327 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.cpp +++ b/reactos/tools/rbuild/backend/mingw/mingw.cpp @@ -165,13 +165,13 @@ MingwBackend::GenerateProjectLFLAGS () const void MingwBackend::GenerateGlobalVariables () const { - fprintf ( fMakefile, "mkdir = tools" SSEP "rmkdir" EXEPOSTFIX "\n" ); - fprintf ( fMakefile, "winebuild = tools" SSEP "winebuild" SSEP "winebuild" EXEPOSTFIX "\n" ); - fprintf ( fMakefile, "bin2res = tools" SSEP "bin2res" SSEP "bin2res" EXEPOSTFIX "\n" ); - fprintf ( fMakefile, "cabman = tools" SSEP "cabman" SSEP "cabman" EXEPOSTFIX "\n" ); - fprintf ( fMakefile, "cdmake = tools" SSEP "cdmake" SSEP "cdmake" EXEPOSTFIX "\n" ); - fprintf ( fMakefile, "rsym = tools" SSEP "rsym" EXEPOSTFIX "\n" ); - fprintf ( fMakefile, "wrc = tools" SSEP "wrc" SSEP "wrc" EXEPOSTFIX "\n" ); + fprintf ( fMakefile, "mkdir = $(Q)tools" SSEP "rmkdir" EXEPOSTFIX "\n" ); + fprintf ( fMakefile, "winebuild = $(Q)tools" SSEP "winebuild" SSEP "winebuild" EXEPOSTFIX "\n" ); + fprintf ( fMakefile, "bin2res = $(Q)tools" SSEP "bin2res" SSEP "bin2res" EXEPOSTFIX "\n" ); + fprintf ( fMakefile, "cabman = $(Q)tools" SSEP "cabman" SSEP "cabman" EXEPOSTFIX "\n" ); + fprintf ( fMakefile, "cdmake = $(Q)tools" SSEP "cdmake" SSEP "cdmake" EXEPOSTFIX "\n" ); + fprintf ( fMakefile, "rsym = $(Q)tools" SSEP "rsym" EXEPOSTFIX "\n" ); + fprintf ( fMakefile, "wrc = $(Q)tools" SSEP "wrc" SSEP "wrc" EXEPOSTFIX "\n" ); fprintf ( fMakefile, "\n" ); GenerateGlobalCFlagsAndProperties ( "=", @@ -201,11 +201,14 @@ void MingwBackend::GenerateAllTarget () const { fprintf ( fMakefile, "all:" ); + int wrap_count = 0; for ( size_t i = 0; i < ProjectNode.modules.size (); i++ ) { Module& module = *ProjectNode.modules[i]; if ( IncludeInAllTarget ( module ) ) { + if ( wrap_count++ == 5 ) + fprintf ( fMakefile, " \\\n\t\t" ), wrap_count = 0; fprintf ( fMakefile, " %s", FixupTargetFilename ( module.GetPath () ).c_str () ); @@ -316,7 +319,9 @@ MingwBackend::ProcessModule ( Module& module ) const MingwModuleHandler* h = MingwModuleHandler::LookupHandler ( module.node.location, module.type ); - h->Process ( module ); + MingwModuleHandler::string_list clean_files; + h->Process ( module, clean_files ); + h->GenerateCleanTarget ( module, clean_files ); h->GenerateDirectoryTargets (); } diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp index 62f289117a4..9ad932739ec 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp @@ -12,6 +12,8 @@ using std::set; typedef set set_string; +#define CLEAN_FILE(f) clean_files.push_back ( f ); /*if ( module.name == "crt" ) printf ( "%s(%i): clean: %s\n", __FILE__, __LINE__, f.c_str() )*/ + map* MingwModuleHandler::handler_map = NULL; set_string @@ -134,21 +136,6 @@ MingwModuleHandler::GetImportLibraryDependency ( const Module& importedModule ) return PassThruCacheDirectory ( FixupTargetFilename ( importedModule.GetDependencyPath () ) ); } -string -MingwModuleHandler::GetImportLibraryDependencies ( const Module& module ) const -{ - string dependencies ( "" ); - for ( size_t i = 0; i < module.libraries.size (); i++ ) - { - if ( dependencies.size () > 0 ) - dependencies += " "; - const Module* importedModule = module.project.LocateModule ( module.libraries[i]->name ); - assert ( importedModule != NULL ); - dependencies += GetImportLibraryDependency ( *importedModule ); - } - return dependencies; -} - string MingwModuleHandler::GetModuleDependencies ( const Module& module ) const { @@ -172,10 +159,10 @@ MingwModuleHandler::GetModuleDependencies ( const Module& module ) const return dependencies; } -string +/*string MingwModuleHandler::GetAllDependencies ( const Module& module ) const { - string dependencies = GetImportLibraryDependencies ( module ); + string dependencies = GetImportMacro ( module ); string s = GetModuleDependencies ( module ); if ( s.length () > 0 ) { @@ -183,7 +170,7 @@ MingwModuleHandler::GetAllDependencies ( const Module& module ) const dependencies += s; } return dependencies; -} +}*/ string MingwModuleHandler::GetSourceFilenames ( const Module& module, @@ -241,6 +228,25 @@ MingwModuleHandler::GetObjectFilename ( const string& sourceFilename ) return FixupTargetFilename ( ReplaceExtension ( sourceFilename, newExtension ) ); } +void +MingwModuleHandler::GenerateCleanTarget ( + const Module& module, + const string_list& clean_files ) const +{ + if ( 0 == clean_files.size() ) + return; + fprintf ( fMakefile, ".PHONY: %s_clean\n", module.name.c_str() ); + fprintf ( fMakefile, "%s_clean:\n\t-@$(rm)", module.name.c_str() ); + for ( size_t i = 0; i < clean_files.size(); i++ ) + { + if ( 9==((i+1)%10) ) + fprintf ( fMakefile, " 2>$(NUL)\n\t-@$(rm)" ); + fprintf ( fMakefile, " %s", clean_files[i].c_str() ); + } + fprintf ( fMakefile, " 2>$(NUL)\n" ); + fprintf ( fMakefile, "clean: %s_clean\n\n", module.name.c_str() ); +} + string MingwModuleHandler::GetObjectFilenames ( const Module& module ) const { @@ -272,32 +278,38 @@ MingwModuleHandler::GenerateDirectoryTargets () const if ( directory_set.size () == 0 ) return; - set_string::iterator i; + set_string::iterator it; + size_t wrap_count = 0; fprintf ( fMakefile, "directories::" ); - for ( i = directory_set.begin (); - i != directory_set.end (); - i++ ) + for ( it = directory_set.begin (); + it != directory_set.end (); + it++ ) { - if ( IncludeDirectoryTarget ( *i ) ) + if ( IncludeDirectoryTarget ( *it ) ) { + if ( wrap_count++ == 5 ) + fprintf ( fMakefile, " \\\n\t\t" ), wrap_count = 0; fprintf ( fMakefile, " %s", - i->c_str () ); + it->c_str () ); } } fprintf ( fMakefile, "\n\n" ); + wrap_count = 0; - for ( i = directory_set.begin (); - i != directory_set.end (); - i++ ) + for ( it = directory_set.begin (); + it != directory_set.end (); + it++ ) { - if ( IncludeDirectoryTarget ( *i ) ) + if ( IncludeDirectoryTarget ( *it ) ) { + if ( wrap_count++ == 5 ) + fprintf ( fMakefile, " \\\n\t\t" ), wrap_count = 0; fprintf ( fMakefile, "%s ", - i->c_str () ); + it->c_str () ); } } @@ -408,6 +420,23 @@ MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector& libraries ) const +{ + string dependencies ( "" ); + int wrap_count = 0; + for ( size_t i = 0; i < libraries.size (); i++ ) + { + if ( wrap_count++ == 5 ) + dependencies += " \\\n\t\t", wrap_count = 0; + else if ( dependencies.size () > 0 ) + dependencies += " "; + dependencies += GetImportLibraryDependency ( *libraries[i]->imported_module ); + } + return dependencies; +} + string MingwModuleHandler::GenerateLinkerParameters ( const Module& module ) const { @@ -470,6 +499,7 @@ MingwModuleHandler::GenerateMacros ( const vector& files, const vector& includes, const vector& defines, + const vector& libraries, const vector* compilerFlags, const vector* linkerFlags, const vector& ifs, @@ -477,7 +507,9 @@ MingwModuleHandler::GenerateMacros ( const string& nasmflags_macro, const string& windresflags_macro, const string& linkerflags_macro, - const string& objs_macro) const + const string& objs_macro, + const string& libs_macro, + const string& linkdeps_macro ) const { size_t i; @@ -508,7 +540,21 @@ MingwModuleHandler::GenerateMacros ( linkerParameters.c_str() ); } } - + + if ( libraries.size () > 0 ) + { + string deps = GenerateImportLibraryDependenciesFromVector ( libraries ); + if ( deps.size () > 0 ) + { + fprintf ( + fMakefile, + "%s %s %s\n", + libs_macro.c_str(), + assignmentOperation, + deps.c_str() ); + } + } + if ( files.size () > 0 ) { for ( i = 0; i < files.size (); i++ ) @@ -544,7 +590,11 @@ MingwModuleHandler::GenerateMacros ( for ( i = 0; i < ifs.size(); i++ ) { If& rIf = *ifs[i]; - if ( rIf.defines.size() || rIf.includes.size() || rIf.files.size() || rIf.ifs.size() ) + if ( rIf.defines.size() + || rIf.includes.size() + || rIf.libraries.size() + || rIf.files.size() + || rIf.ifs.size() ) { fprintf ( fMakefile, @@ -556,6 +606,7 @@ MingwModuleHandler::GenerateMacros ( rIf.files, rIf.includes, rIf.defines, + rIf.libraries, NULL, NULL, rIf.ifs, @@ -563,7 +614,9 @@ MingwModuleHandler::GenerateMacros ( nasmflags_macro, windresflags_macro, linkerflags_macro, - objs_macro ); + objs_macro, + libs_macro, + linkdeps_macro ); fprintf ( fMakefile, "endif\n\n" ); @@ -578,13 +631,16 @@ MingwModuleHandler::GenerateMacros ( const string& nasmflags_macro, const string& windresflags_macro, const string& linkerflags_macro, - const string& objs_macro) const + const string& objs_macro, + const string& libs_macro, + const string& linkdeps_macro ) const { GenerateMacros ( "=", module.files, module.includes, module.defines, + module.libraries, &module.compilerFlags, &module.linkerFlags, module.ifs, @@ -592,23 +648,56 @@ MingwModuleHandler::GenerateMacros ( nasmflags_macro, windresflags_macro, linkerflags_macro, - objs_macro ); - fprintf ( fMakefile, "\n" ); + objs_macro, + libs_macro, + linkdeps_macro ); + + if ( module.importLibrary ) + { + string s; + for ( size_t i = 0; i < module.files.size (); i++ ) + { + File& file = *module.files[i]; + string extension = GetExtension ( file.name ); + if ( extension == ".spec" || extension == ".SPEC" ) + { + if ( s.length () > 0 ) + s += " "; + s += GetSpecObjectDependencies ( file.name ); + } + } + if ( s.length () > 0 ) + { + fprintf ( + fMakefile, + "%s += %s\n", + linkdeps_macro.c_str(), + s.c_str() ); + } + } fprintf ( fMakefile, - "%s += $(PROJECT_CFLAGS)\n\n", + "%s += $(PROJECT_CFLAGS)\n", cflags_macro.c_str () ); fprintf ( fMakefile, - "%s += $(PROJECT_RCFLAGS)\n\n", + "%s += $(PROJECT_RCFLAGS)\n", windresflags_macro.c_str () ); fprintf ( fMakefile, - "%s_LFLAGS += $(PROJECT_LFLAGS)\n\n", + "%s_LFLAGS += $(PROJECT_LFLAGS)\n", module.name.c_str () ); + + fprintf ( + fMakefile, + "%s += $(%s)", + linkdeps_macro.c_str (), + libs_macro.c_str () ); + + fprintf ( fMakefile, "\n" ); } void @@ -622,6 +711,7 @@ MingwModuleHandler::GenerateGccCommand ( const Module& module, "%s: %s\n", objectFilename.c_str (), sourceFilename.c_str () ); + fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [CC] $<\n" ); fprintf ( fMakefile, "\t%s -c %s -o %s %s\n", cc.c_str (), @@ -641,6 +731,7 @@ MingwModuleHandler::GenerateGccAssemblerCommand ( const Module& module, "%s: %s\n", objectFilename.c_str (), sourceFilename.c_str () ); + fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [GAS] $<\n" ); fprintf ( fMakefile, "\t%s -x assembler-with-cpp -c %s -o %s -D__ASM__ %s\n", cc.c_str (), @@ -659,9 +750,10 @@ MingwModuleHandler::GenerateNasmCommand ( const Module& module, "%s: %s\n", objectFilename.c_str (), sourceFilename.c_str () ); + fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [NASM] $<\n" ); fprintf ( fMakefile, "\t%s -f win32 %s -o %s %s\n", - "nasm", + "$(Q)nasm", sourceFilename.c_str (), objectFilename.c_str (), nasmflagsMacro.c_str () ); @@ -673,14 +765,15 @@ MingwModuleHandler::GenerateWindresCommand ( const Module& module, const string& windresflagsMacro ) const { string objectFilename = PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename ) ); - string rciFilename = ReplaceExtension ( sourceFilename, - ".rci" ); - string resFilename = ReplaceExtension ( sourceFilename, - ".res" ); + string rciFilename = ReplaceExtension ( sourceFilename, + ".rci" ); + string resFilename = ReplaceExtension ( sourceFilename, + ".res" ); fprintf ( fMakefile, "%s: %s\n", objectFilename.c_str (), sourceFilename.c_str () ); + fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [WRC] $@\n" ); fprintf ( fMakefile, "\t${gcc} -xc -E -DRC_INVOKED ${%s} %s > %s\n", windresflagsMacro.c_str (), @@ -692,52 +785,66 @@ MingwModuleHandler::GenerateWindresCommand ( const Module& module, rciFilename.c_str (), resFilename.c_str () ); fprintf ( fMakefile, - "\t${rm} %s\n", + "\t-@${rm} %s\n", rciFilename.c_str () ); fprintf ( fMakefile, "\t${windres} %s -o %s\n", resFilename.c_str (), objectFilename.c_str () ); fprintf ( fMakefile, - "\t${rm} %s\n", + "\t-@${rm} %s\n", resFilename.c_str () ); } void -MingwModuleHandler::GenerateWinebuildCommands ( const Module& module, - const string& sourceFilename ) const +MingwModuleHandler::GenerateWinebuildCommands ( + const Module& module, + const string& sourceFilename, + string_list& clean_files ) const { string basename = GetBasename ( sourceFilename ); - fprintf ( fMakefile, - "%s.spec.def: %s\n", - basename.c_str (), - sourceFilename.c_str () ); - fprintf ( fMakefile, - "\t%s --def=%s -o %s.spec.def\n", - "${winebuild}", - sourceFilename.c_str (), - basename.c_str () ); + + string def_file = basename + ".spec.def"; + CLEAN_FILE ( def_file ); + + string stub_file = basename + ".stubs.c"; + CLEAN_FILE ( stub_file ); fprintf ( fMakefile, - "%s.stubs.c: %s\n", - basename.c_str (), + "%s: %s\n", + def_file.c_str (), sourceFilename.c_str () ); + fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [WINEBLD] $@\n" ); fprintf ( fMakefile, - "\t%s --pedll=%s -o %s.stubs.c\n", + "\t%s --def=%s -o %s\n", "${winebuild}", sourceFilename.c_str (), - basename.c_str () ); + def_file.c_str () ); + + fprintf ( fMakefile, + "%s: %s\n", + stub_file.c_str (), + sourceFilename.c_str () ); + fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [WINEBLD] $@\n" ); + fprintf ( fMakefile, + "\t%s --pedll=%s -o %s\n", + "${winebuild}", + sourceFilename.c_str (), + stub_file.c_str () ); } void -MingwModuleHandler::GenerateCommands ( const Module& module, - const string& sourceFilename, - const string& cc, - const string& cppc, - const string& cflagsMacro, - const string& nasmflagsMacro, - const string& windresflagsMacro ) const +MingwModuleHandler::GenerateCommands ( + const Module& module, + const string& sourceFilename, + const string& cc, + const string& cppc, + const string& cflagsMacro, + const string& nasmflagsMacro, + const string& windresflagsMacro, + string_list& clean_files ) const { + CLEAN_FILE ( GetObjectFilename(sourceFilename) ); string extension = GetExtension ( sourceFilename ); if ( extension == ".c" || extension == ".C" ) { @@ -782,7 +889,8 @@ MingwModuleHandler::GenerateCommands ( const Module& module, else if ( extension == ".spec" || extension == ".SPEC" ) { GenerateWinebuildCommands ( module, - sourceFilename ); + sourceFilename, + clean_files ); GenerateGccCommand ( module, GetActualSourceFilename ( sourceFilename ), cc, @@ -798,20 +906,27 @@ MingwModuleHandler::GenerateCommands ( const Module& module, } void -MingwModuleHandler::GenerateLinkerCommand ( const Module& module, - const string& linker, - const string& linkerParameters, - const string& objectFilenames ) const +MingwModuleHandler::GenerateLinkerCommand ( + const Module& module, + const string& linker, + const string& linkerParameters, + const string& objectsMacro, + const string& libsMacro, + string_list& clean_files ) const { + fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [LD] $@\n" ); string targetName ( module.GetTargetName () ); string target ( FixupTargetFilename ( module.GetPath () ) ); - string importLibraryDependencies = GetImportLibraryDependencies ( module ); if ( module.importLibrary != NULL ) { static string ros_junk ( "$(ROS_TEMPORARY)" ); string base_tmp = ros_junk + module.name + ".base.tmp"; + CLEAN_FILE ( base_tmp ); string junk_tmp = ros_junk + module.name + ".junk.tmp"; + CLEAN_FILE ( junk_tmp ); string temp_exp = ros_junk + module.name + ".temp.exp"; + CLEAN_FILE ( temp_exp ); + string def_file = module.GetBasePath () + SSEP + module.importLibrary->definition; fprintf ( fMakefile, "\t%s %s -Wl,--base-file,%s -o %s %s %s %s\n", @@ -819,12 +934,12 @@ MingwModuleHandler::GenerateLinkerCommand ( const Module& module, linkerParameters.c_str (), base_tmp.c_str (), junk_tmp.c_str (), - objectFilenames.c_str (), - importLibraryDependencies.c_str (), + objectsMacro.c_str (), + libsMacro.c_str (), GetLinkerMacro ( module ).c_str () ); fprintf ( fMakefile, - "\t${rm} %s\n", + "\t-@${rm} %s\n", junk_tmp.c_str () ); string killAt = module.mangledSymbols ? "" : "--kill-at"; @@ -832,26 +947,26 @@ MingwModuleHandler::GenerateLinkerCommand ( const Module& module, "\t${dlltool} --dllname %s --base-file %s --def %s --output-exp %s %s\n", targetName.c_str (), base_tmp.c_str (), - ( module.GetBasePath () + SSEP + module.importLibrary->definition ).c_str (), + def_file.c_str (), temp_exp.c_str (), killAt.c_str () ); fprintf ( fMakefile, - "\t${rm} %s\n", + "\t-@${rm} %s\n", base_tmp.c_str () ); fprintf ( fMakefile, - "\t%s %s %s -o %s %s %s %s\n\n", + "\t%s %s %s -o %s %s %s %s\n", linker.c_str (), linkerParameters.c_str (), temp_exp.c_str (), target.c_str (), - objectFilenames.c_str (), - importLibraryDependencies.c_str (), + objectsMacro.c_str (), + libsMacro.c_str (), GetLinkerMacro ( module ).c_str () ); fprintf ( fMakefile, - "\t${rm} %s\n\n", + "\t-@${rm} %s\n", temp_exp.c_str () ); } else @@ -861,26 +976,29 @@ MingwModuleHandler::GenerateLinkerCommand ( const Module& module, linker.c_str (), linkerParameters.c_str (), target.c_str (), - objectFilenames.c_str (), - importLibraryDependencies.c_str (), + objectsMacro.c_str (), + libsMacro.c_str (), GetLinkerMacro ( module ).c_str () ); } + fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [RSYM] $@\n" ); fprintf ( fMakefile, - "\t${rsym} %s %s\n\n", - target.c_str (), - target.c_str () ); + "\t${rsym} %s %s\n\n", + target.c_str (), + target.c_str () ); } void -MingwModuleHandler::GenerateObjectFileTargets ( const Module& module, - const vector& files, - const vector& ifs, - const string& cc, - const string& cppc, - const string& cflagsMacro, - const string& nasmflagsMacro, - const string& windresflagsMacro ) const +MingwModuleHandler::GenerateObjectFileTargets ( + const Module& module, + const vector& files, + const vector& ifs, + const string& cc, + const string& cppc, + const string& cflagsMacro, + const string& nasmflagsMacro, + const string& windresflagsMacro, + string_list& clean_files ) const { size_t i; @@ -893,7 +1011,8 @@ MingwModuleHandler::GenerateObjectFileTargets ( const Module& module, cppc, cflagsMacro, nasmflagsMacro, - windresflagsMacro ); + windresflagsMacro, + clean_files ); fprintf ( fMakefile, "\n" ); } @@ -907,17 +1026,20 @@ MingwModuleHandler::GenerateObjectFileTargets ( const Module& module, cppc, cflagsMacro, nasmflagsMacro, - windresflagsMacro ); + windresflagsMacro, + clean_files ); } } void -MingwModuleHandler::GenerateObjectFileTargets ( const Module& module, - const string& cc, - const string& cppc, - const string& cflagsMacro, - const string& nasmflagsMacro, - const string& windresflagsMacro ) const +MingwModuleHandler::GenerateObjectFileTargets ( + const Module& module, + const string& cc, + const string& cppc, + const string& cflagsMacro, + const string& nasmflagsMacro, + const string& windresflagsMacro, + string_list& clean_files ) const { GenerateObjectFileTargets ( module, module.files, @@ -926,12 +1048,13 @@ MingwModuleHandler::GenerateObjectFileTargets ( const Module& module, cppc, cflagsMacro, nasmflagsMacro, - windresflagsMacro ); + windresflagsMacro, + clean_files ); fprintf ( fMakefile, "\n" ); } void -MingwModuleHandler::GetCleanTargets ( vector& out, +MingwModuleHandler::GetCleanTargets ( string_list& out, const vector& files, const vector& ifs ) const { @@ -956,6 +1079,8 @@ MingwModuleHandler::GenerateArchiveTarget ( const Module& module, archiveFilename.c_str (), objs_macro.c_str ()); + fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [AR] $@\n" ); + fprintf ( fMakefile, "\t%s -rc %s %s\n\n", ar.c_str (), @@ -979,13 +1104,25 @@ MingwModuleHandler::GetObjectsMacro ( const Module& module ) const module.name.c_str () ); } +string +MingwModuleHandler::GetLinkingDependenciesMacro ( const Module& module ) const +{ + return ssprintf ( "$(%s_LINKDEPS)", module.name.c_str () ); +} + +string +MingwModuleHandler::GetLibsMacro ( const Module& module ) const +{ + return ssprintf ( "$(%s_LIBS)", module.name.c_str () ); +} + string MingwModuleHandler::GetLinkerMacro ( const Module& module ) const { return ssprintf ( "$(%s_LFLAGS)", module.name.c_str () ); } - + void MingwModuleHandler::GenerateMacrosAndTargets ( const Module& module, @@ -993,20 +1130,25 @@ MingwModuleHandler::GenerateMacrosAndTargets ( const string& cppc, const string& ar, const string* cflags, - const string* nasmflags ) const + const string* nasmflags, + string_list& clean_files ) const { 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 ()); string linkerFlagsMacro = ssprintf ("%s_LFLAGS", module.name.c_str ()); string objectsMacro = ssprintf ("%s_OBJS", module.name.c_str ()); + string libsMacro = ssprintf("%s_LIBS", module.name.c_str ()); + string linkDepsMacro = ssprintf ("%s_LINKDEPS", module.name.c_str ()); GenerateMacros ( module, cflagsMacro, nasmflagsMacro, windresflagsMacro, linkerFlagsMacro, - objectsMacro ); + objectsMacro, + libsMacro, + linkDepsMacro ); if ( cflags != NULL ) { @@ -1042,55 +1184,59 @@ MingwModuleHandler::GenerateMacrosAndTargets ( cppc, cflagsMacro, nasmflagsMacro, - windresflagsMacro ); + windresflagsMacro, + clean_files ); - vector clean_files; - clean_files.push_back ( FixupTargetFilename(module.GetPath()) ); - clean_files.push_back ( ar_target ); - GetCleanTargets ( clean_files, module.files, module.ifs ); - - fprintf ( fMakefile, ".PHONY: %s_clean\n", module.name.c_str() ); - fprintf ( fMakefile, "%s_clean:\n\t-@$(rm)", module.name.c_str() ); - for ( size_t i = 0; i < clean_files.size(); i++ ) + CLEAN_FILE ( ar_target ); + string tgt = FixupTargetFilename(module.GetPath()); + if ( tgt != ar_target ) { - if ( 9==(i%10) ) - fprintf ( fMakefile, " 2>$(NUL)\n\t-@$(rm)" ); - fprintf ( fMakefile, " %s", clean_files[i].c_str() ); + CLEAN_FILE ( tgt ); } - fprintf ( fMakefile, " 2>$(NUL)\n" ); - fprintf ( fMakefile, "clean: %s_clean\n\n", module.name.c_str() ); } void -MingwModuleHandler::GenerateMacrosAndTargetsHost ( const Module& module ) const +MingwModuleHandler::GenerateMacrosAndTargetsHost ( + const Module& module, + string_list& clean_files ) const { - GenerateMacrosAndTargets ( module, - "${host_gcc}", - "${host_gpp}", - "${host_ar}", - NULL, - NULL ); + GenerateMacrosAndTargets ( + module, + "${host_gcc}", + "${host_gpp}", + "${host_ar}", + NULL, + NULL, + clean_files ); } void -MingwModuleHandler::GenerateMacrosAndTargetsTarget ( const Module& module ) const +MingwModuleHandler::GenerateMacrosAndTargetsTarget ( + const Module& module, + string_list& clean_files ) const { - GenerateMacrosAndTargetsTarget ( module, - NULL, - NULL ); + GenerateMacrosAndTargetsTarget ( + module, + NULL, + NULL, + clean_files ); } void -MingwModuleHandler::GenerateMacrosAndTargetsTarget ( const Module& module, - const string* cflags, - const string* nasmflags ) const +MingwModuleHandler::GenerateMacrosAndTargetsTarget ( + const Module& module, + const string* cflags, + const string* nasmflags, + string_list& clean_files ) const { - GenerateMacrosAndTargets ( module, - "${gcc}", - "${gpp}", - "${ar}", - cflags, - nasmflags ); + GenerateMacrosAndTargets ( + module, + "${gcc}", + "${gpp}", + "${ar}", + cflags, + nasmflags, + clean_files ); } string @@ -1138,6 +1284,7 @@ MingwModuleHandler::GenerateInvocations ( const Module& module ) const "%s: %s\n", invoke.GetTargets ().c_str (), FixupTargetFilename ( invoke.invokeModule->GetPath () ).c_str () ); + fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [INVOKE] $<\n" ); fprintf ( fMakefile, "\t%s %s\n\n", FixupTargetFilename ( invoke.invokeModule->GetPath () ).c_str (), @@ -1218,21 +1365,28 @@ MingwModuleHandler::GeneratePreconditionDependencies ( const Module& module ) co } void -MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ( const Module& module ) const +MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ( + const Module& module, + string_list& clean_files ) const { if ( module.importLibrary != NULL ) { + string library_target = FixupTargetFilename( module.GetDependencyPath () ).c_str (); + CLEAN_FILE ( library_target ); + string definitionDependencies = GetDefinitionDependencies ( module ); fprintf ( fMakefile, "%s: %s\n", - FixupTargetFilename( module.GetDependencyPath () ).c_str (), + library_target.c_str (), definitionDependencies.c_str () ); + fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [DLLTOOL] $@\n" ); + string killAt = module.mangledSymbols ? "" : "--kill-at"; fprintf ( fMakefile, "\t${dlltool} --dllname %s --def %s --output-lib %s %s\n\n", module.GetTargetName ().c_str (), ( module.GetBasePath () + SSEP + module.importLibrary->definition ).c_str (), - FixupTargetFilename ( module.GetDependencyPath () ).c_str (), + library_target.c_str (), killAt.c_str () ); } } @@ -1265,7 +1419,7 @@ MingwModuleHandler::GetDefinitionDependencies ( const Module& module ) const return dependencies; } -string +/*string MingwModuleHandler::GetLinkingDependencies ( const Module& module ) const { string dependencies = GetImportLibraryDependencies ( module ); @@ -1276,7 +1430,7 @@ MingwModuleHandler::GetLinkingDependencies ( const Module& module ) const dependencies += s; } return dependencies; -} +}*/ bool MingwModuleHandler::IsCPlusPlusModule ( const Module& module ) const @@ -1299,21 +1453,22 @@ MingwBuildToolModuleHandler::MingwBuildToolModuleHandler() } void -MingwBuildToolModuleHandler::Process ( const Module& module ) +MingwBuildToolModuleHandler::Process ( const Module& module, string_list& clean_files ) { GeneratePreconditionDependencies ( module ); - GenerateBuildToolModuleTarget ( module ); + GenerateBuildToolModuleTarget ( module, clean_files ); GenerateInvocations ( module ); } void -MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ( const Module& module ) +MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ( const Module& module, string_list& clean_files ) { string target ( FixupTargetFilename ( module.GetPath () ) ); string objectsMacro = GetObjectsMacro ( module ); - string importLibraryDependencies = GetImportLibraryDependencies ( module ); + string linkDepsMacro = GetLinkingDependenciesMacro ( module ); + string libsMacro = GetLibsMacro ( module ); - GenerateMacrosAndTargetsHost ( module ); + GenerateMacrosAndTargetsHost ( module, clean_files ); string linker; if ( IsCPlusPlusModule ( module ) ) @@ -1324,14 +1479,15 @@ MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ( const Module& modul fprintf ( fMakefile, "%s: %s %s\n", target.c_str (), objectsMacro.c_str (), - importLibraryDependencies.c_str () ); + linkDepsMacro.c_str () ); + fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [LD] $@\n" ); fprintf ( fMakefile, "\t%s %s -o %s %s %s\n\n", linker.c_str (), GetLinkerMacro ( module ).c_str (), target.c_str (), objectsMacro.c_str (), - importLibraryDependencies.c_str () ); + libsMacro.c_str () ); } @@ -1343,38 +1499,43 @@ MingwKernelModuleHandler::MingwKernelModuleHandler () } void -MingwKernelModuleHandler::Process ( const Module& module ) +MingwKernelModuleHandler::Process ( const Module& module, string_list& clean_files ) { GeneratePreconditionDependencies ( module ); - GenerateKernelModuleTarget ( module ); + GenerateKernelModuleTarget ( module, clean_files ); GenerateInvocations ( module ); } void -MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module ) +MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module, string_list& clean_files ) { static string ros_junk ( "$(ROS_TEMPORARY)" ); - string targetName ( module.GetTargetName () ); - string target ( FixupTargetFilename (module.GetPath ()) ); + string targetName ( module.GetTargetName () ); // i.e. "ntoskrnl.exe" + string target ( FixupTargetFilename (module.GetPath ()) ); // i.e. "$(ROS_INT).\ntoskrnl\ntoskrnl.exe" string workingDirectory = GetWorkingDirectory (); string objectsMacro = GetObjectsMacro ( module ); - string importLibraryDependencies = GetImportLibraryDependencies ( module ); + string linkDepsMacro = GetLinkingDependenciesMacro ( module ); + string libsMacro = GetLibsMacro ( module ); string base_tmp = ros_junk + module.name + ".base.tmp"; + CLEAN_FILE ( base_tmp ); string junk_tmp = ros_junk + module.name + ".junk.tmp"; + CLEAN_FILE ( junk_tmp ); string temp_exp = ros_junk + module.name + ".temp.exp"; + CLEAN_FILE ( temp_exp ); string gccOptions = ssprintf ("-Wl,-T,%s" SSEP "ntoskrnl.lnk -Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll", module.GetBasePath ().c_str (), module.entrypoint.c_str (), module.baseaddress.c_str () ); - GenerateMacrosAndTargetsTarget ( module ); + GenerateMacrosAndTargetsTarget ( module, clean_files ); - GenerateImportLibraryTargetIfNeeded ( module ); + GenerateImportLibraryTargetIfNeeded ( module, clean_files ); fprintf ( fMakefile, "%s: %s %s\n", target.c_str (), objectsMacro.c_str (), - importLibraryDependencies.c_str () ); + linkDepsMacro.c_str () ); + fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [LD] $@\n" ); fprintf ( fMakefile, "\t${gcc} %s %s -Wl,--base-file,%s -o %s %s %s\n", GetLinkerMacro ( module ).c_str (), @@ -1382,9 +1543,9 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module ) base_tmp.c_str (), junk_tmp.c_str (), objectsMacro.c_str (), - importLibraryDependencies.c_str () ); + linkDepsMacro.c_str () ); fprintf ( fMakefile, - "\t${rm} %s\n", + "\t-@${rm} %s\n", junk_tmp.c_str () ); string killAt = module.mangledSymbols ? "" : "--kill-at"; fprintf ( fMakefile, @@ -1394,7 +1555,7 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module ) temp_exp.c_str (), killAt.c_str () ); fprintf ( fMakefile, - "\t${rm} %s\n", + "\t-@${rm} %s\n", base_tmp.c_str () ); fprintf ( fMakefile, "\t${gcc} %s %s -Wl,%s -o %s %s %s\n", @@ -1403,10 +1564,11 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module ) temp_exp.c_str (), target.c_str (), objectsMacro.c_str (), - importLibraryDependencies.c_str () ); + linkDepsMacro.c_str () ); fprintf ( fMakefile, - "\t${rm} %s\n", + "\t-@${rm} %s\n", temp_exp.c_str () ); + fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [RSYM] $@\n" ); fprintf ( fMakefile, "\t${rsym} %s %s\n\n", target.c_str (), @@ -1422,17 +1584,17 @@ MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler () } void -MingwStaticLibraryModuleHandler::Process ( const Module& module ) +MingwStaticLibraryModuleHandler::Process ( const Module& module, string_list& clean_files ) { GeneratePreconditionDependencies ( module ); - GenerateStaticLibraryModuleTarget ( module ); + GenerateStaticLibraryModuleTarget ( module, clean_files ); GenerateInvocations ( module ); } void -MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ( const Module& module ) +MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ( const Module& module, string_list& clean_files ) { - GenerateMacrosAndTargetsTarget ( module ); + GenerateMacrosAndTargetsTarget ( module, clean_files ); } @@ -1444,17 +1606,17 @@ MingwObjectLibraryModuleHandler::MingwObjectLibraryModuleHandler () } void -MingwObjectLibraryModuleHandler::Process ( const Module& module ) +MingwObjectLibraryModuleHandler::Process ( const Module& module, string_list& clean_files ) { GeneratePreconditionDependencies ( module ); - GenerateObjectLibraryModuleTarget ( module ); + GenerateObjectLibraryModuleTarget ( module, clean_files ); GenerateInvocations ( module ); } void -MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget ( const Module& module ) +MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget ( const Module& module, string_list& clean_files ) { - GenerateMacrosAndTargetsTarget ( module ); + GenerateMacrosAndTargetsTarget ( module, clean_files ); } @@ -1466,32 +1628,33 @@ MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler () } void -MingwKernelModeDLLModuleHandler::Process ( const Module& module ) +MingwKernelModeDLLModuleHandler::Process ( const Module& module, string_list& clean_files ) { GeneratePreconditionDependencies ( module ); - GenerateKernelModeDLLModuleTarget ( module ); + GenerateKernelModeDLLModuleTarget ( module, clean_files ); GenerateInvocations ( module ); } void -MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ( const Module& module ) +MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ( const Module& module, string_list& clean_files ) { static string ros_junk ( "$(ROS_TEMPORARY)" ); string target ( FixupTargetFilename ( module.GetPath () ) ); string workingDirectory = GetWorkingDirectory ( ); string objectsMacro = GetObjectsMacro ( module ); - string importLibraryDependencies = GetImportLibraryDependencies ( module ); + string linkDepsMacro = GetLinkingDependenciesMacro ( module ); + string libsMacro = GetLibsMacro ( module ); - GenerateImportLibraryTargetIfNeeded ( module ); + GenerateImportLibraryTargetIfNeeded ( module, clean_files ); if ( module.files.size () > 0 ) { - GenerateMacrosAndTargetsTarget ( module ); + GenerateMacrosAndTargetsTarget ( module, clean_files ); fprintf ( fMakefile, "%s: %s %s\n", target.c_str (), objectsMacro.c_str (), - importLibraryDependencies.c_str () ); + linkDepsMacro.c_str () ); string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll", module.entrypoint.c_str (), @@ -1499,7 +1662,9 @@ MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ( const Modul GenerateLinkerCommand ( module, "${gcc}", linkerParameters, - objectsMacro ); + objectsMacro, + libsMacro, + clean_files ); } else { @@ -1519,37 +1684,40 @@ MingwKernelModeDriverModuleHandler::MingwKernelModeDriverModuleHandler () } void -MingwKernelModeDriverModuleHandler::Process ( const Module& module ) +MingwKernelModeDriverModuleHandler::Process ( const Module& module, string_list& clean_files ) { GeneratePreconditionDependencies ( module ); - GenerateKernelModeDriverModuleTarget ( module ); + GenerateKernelModeDriverModuleTarget ( module, clean_files ); GenerateInvocations ( module ); } void -MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ( const Module& module ) +MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ( + const Module& module, + string_list& clean_files ) { static string ros_junk ( "$(ROS_TEMPORARY)" ); string target ( PassThruCacheDirectory( FixupTargetFilename ( module.GetPath () ) ) ); string workingDirectory = GetWorkingDirectory (); string objectsMacro = GetObjectsMacro ( module ); - string importLibraryDependencies = GetImportLibraryDependencies ( module ); + string linkDepsMacro = GetLinkingDependenciesMacro ( module ); + string libsMacro = GetLibsMacro ( module ); - GenerateImportLibraryTargetIfNeeded ( module ); + GenerateImportLibraryTargetIfNeeded ( module, clean_files ); if ( module.files.size () > 0 ) { - string* cflags = new string ( "-D__NTDRIVER__" ); + string cflags ( "-D__NTDRIVER__" ); GenerateMacrosAndTargetsTarget ( module, - cflags, - NULL ); - delete cflags; + &cflags, + NULL, + clean_files); fprintf ( fMakefile, "%s: %s %s\n", target.c_str (), objectsMacro.c_str (), - importLibraryDependencies.c_str () ); + linkDepsMacro.c_str () ); string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll", module.entrypoint.c_str (), @@ -1557,7 +1725,9 @@ MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ( const GenerateLinkerCommand ( module, "${gcc}", linkerParameters, - objectsMacro ); + objectsMacro, + libsMacro, + clean_files ); } else { @@ -1577,32 +1747,33 @@ MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler () } void -MingwNativeDLLModuleHandler::Process ( const Module& module ) +MingwNativeDLLModuleHandler::Process ( const Module& module, string_list& clean_files ) { GeneratePreconditionDependencies ( module ); - GenerateNativeDLLModuleTarget ( module ); + GenerateNativeDLLModuleTarget ( module, clean_files ); GenerateInvocations ( module ); } void -MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ( const Module& module ) +MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ( const Module& module, string_list& clean_files ) { static string ros_junk ( "$(ROS_TEMPORARY)" ); string target ( FixupTargetFilename ( module.GetPath () ) ); string workingDirectory = GetWorkingDirectory ( ); string objectsMacro = GetObjectsMacro ( module ); - string importLibraryDependencies = GetImportLibraryDependencies ( module ); + string linkDepsMacro = GetLinkingDependenciesMacro ( module ); + string libsMacro = GetLibsMacro ( module ); - GenerateImportLibraryTargetIfNeeded ( module ); + GenerateImportLibraryTargetIfNeeded ( module, clean_files ); if ( module.files.size () > 0 ) { - GenerateMacrosAndTargetsTarget ( module ); + GenerateMacrosAndTargetsTarget ( module, clean_files ); fprintf ( fMakefile, "%s: %s %s\n", target.c_str (), objectsMacro.c_str (), - importLibraryDependencies.c_str () ); + linkDepsMacro.c_str () ); string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll", module.entrypoint.c_str (), @@ -1610,7 +1781,9 @@ MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ( const Module& modul GenerateLinkerCommand ( module, "${gcc}", linkerParameters, - objectsMacro ); + objectsMacro, + libsMacro, + clean_files ); } else { @@ -1630,36 +1803,37 @@ MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler () } void -MingwNativeCUIModuleHandler::Process ( const Module& module ) +MingwNativeCUIModuleHandler::Process ( const Module& module, string_list& clean_files ) { GeneratePreconditionDependencies ( module ); - GenerateNativeCUIModuleTarget ( module ); + GenerateNativeCUIModuleTarget ( module, clean_files ); GenerateInvocations ( module ); } void -MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ( const Module& module ) +MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ( const Module& module, string_list& clean_files ) { static string ros_junk ( "$(ROS_TEMPORARY)" ); string target ( FixupTargetFilename ( module.GetPath () ) ); string workingDirectory = GetWorkingDirectory ( ); string objectsMacro = GetObjectsMacro ( module ); - string importLibraryDependencies = GetImportLibraryDependencies ( module ); + string linkDepsMacro = GetLinkingDependenciesMacro ( module ); + string libsMacro = GetLibsMacro ( module ); - GenerateImportLibraryTargetIfNeeded ( module ); + GenerateImportLibraryTargetIfNeeded ( module, clean_files ); if ( module.files.size () > 0 ) { - string* cflags = new string ( "-D__NTAPP__" ); + string cflags ( "-D__NTAPP__" ); GenerateMacrosAndTargetsTarget ( module, - cflags, - NULL ); - delete cflags; + &cflags, + NULL, + clean_files ); fprintf ( fMakefile, "%s: %s %s\n", target.c_str (), objectsMacro.c_str (), - importLibraryDependencies.c_str () ); + linkDepsMacro.c_str () ); string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib", module.entrypoint.c_str (), @@ -1667,7 +1841,9 @@ MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ( const Module& modul GenerateLinkerCommand ( module, "${gcc}", linkerParameters, - objectsMacro ); + objectsMacro, + libsMacro, + clean_files ); } else { @@ -1687,16 +1863,16 @@ MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler () } void -MingwWin32DLLModuleHandler::Process ( const Module& module ) +MingwWin32DLLModuleHandler::Process ( const Module& module, string_list& clean_files ) { - GenerateExtractWineDLLResourcesTarget ( module ); + GenerateExtractWineDLLResourcesTarget ( module, clean_files ); GeneratePreconditionDependencies ( module ); - GenerateWin32DLLModuleTarget ( module ); + GenerateWin32DLLModuleTarget ( module, clean_files ); GenerateInvocations ( module ); } void -MingwWin32DLLModuleHandler::GenerateExtractWineDLLResourcesTarget ( const Module& module ) +MingwWin32DLLModuleHandler::GenerateExtractWineDLLResourcesTarget ( const Module& module, string_list& clean_files ) { fprintf ( fMakefile, ".PHONY: %s_extractresources\n\n", module.name.c_str () ); @@ -1709,7 +1885,8 @@ MingwWin32DLLModuleHandler::GenerateExtractWineDLLResourcesTarget ( const Module if ( extension == ".rc" || extension == ".RC" ) { string resource = FixupTargetFilename ( file.name ); - fprintf ( fMakefile, "\t@echo ${bin2res} -f -x %s\n", + fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [BIN2RES] $<\n" ); + fprintf ( fMakefile, "\t@:echo ${bin2res} -f -x %s\n", resource.c_str () ); } } @@ -1717,23 +1894,25 @@ MingwWin32DLLModuleHandler::GenerateExtractWineDLLResourcesTarget ( const Module } void -MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ( const Module& module ) +MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ( const Module& module, string_list& clean_files ) { static string ros_junk ( "$(ROS_TEMPORARY)" ); string target ( FixupTargetFilename ( module.GetPath () ) ); string workingDirectory = GetWorkingDirectory ( ); string objectsMacro = GetObjectsMacro ( module ); - string linkingDependencies = GetLinkingDependencies ( module ); + string linkDepsMacro = GetLinkingDependenciesMacro ( module ); + string libsMacro = GetLibsMacro ( module ); + + GenerateImportLibraryTargetIfNeeded ( module, clean_files ); - GenerateImportLibraryTargetIfNeeded ( module ); if ( module.files.size () > 0 ) { - GenerateMacrosAndTargetsTarget ( module ); - + GenerateMacrosAndTargetsTarget ( module, clean_files ); + fprintf ( fMakefile, "%s: %s %s\n", target.c_str (), objectsMacro.c_str (), - linkingDependencies.c_str () ); + linkDepsMacro.c_str () ); string linker; if ( IsCPlusPlusModule ( module ) ) @@ -1747,7 +1926,9 @@ MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ( const Module& module GenerateLinkerCommand ( module, linker, linkerParameters, - objectsMacro ); + objectsMacro, + libsMacro, + clean_files ); } else { @@ -1767,32 +1948,33 @@ MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler () } void -MingwWin32CUIModuleHandler::Process ( const Module& module ) +MingwWin32CUIModuleHandler::Process ( const Module& module, string_list& clean_files ) { GeneratePreconditionDependencies ( module ); - GenerateWin32CUIModuleTarget ( module ); + GenerateWin32CUIModuleTarget ( module, clean_files ); GenerateInvocations ( module ); } void -MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ( const Module& module ) +MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ( const Module& module, string_list& clean_files ) { static string ros_junk ( "$(ROS_TEMPORARY)" ); string target ( FixupTargetFilename ( module.GetPath () ) ); string workingDirectory = GetWorkingDirectory ( ); string objectsMacro = GetObjectsMacro ( module ); - string importLibraryDependencies = GetImportLibraryDependencies ( module ); + string linkDepsMacro = GetLinkingDependenciesMacro ( module ); + string libsMacro = GetLibsMacro ( module ); - GenerateImportLibraryTargetIfNeeded ( module ); + GenerateImportLibraryTargetIfNeeded ( module, clean_files ); if ( module.files.size () > 0 ) { - GenerateMacrosAndTargetsTarget ( module ); + GenerateMacrosAndTargetsTarget ( module, clean_files ); fprintf ( fMakefile, "%s: %s %s\n", target.c_str (), objectsMacro.c_str (), - importLibraryDependencies.c_str () ); + linkDepsMacro.c_str () ); string linker; if ( IsCPlusPlusModule ( module ) ) @@ -1806,7 +1988,9 @@ MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ( const Module& module GenerateLinkerCommand ( module, linker, linkerParameters, - objectsMacro ); + objectsMacro, + libsMacro, + clean_files ); } else { @@ -1826,32 +2010,33 @@ MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler () } void -MingwWin32GUIModuleHandler::Process ( const Module& module ) +MingwWin32GUIModuleHandler::Process ( const Module& module, string_list& clean_files ) { GeneratePreconditionDependencies ( module ); - GenerateWin32GUIModuleTarget ( module ); + GenerateWin32GUIModuleTarget ( module, clean_files ); GenerateInvocations ( module ); } void -MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ( const Module& module ) +MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ( const Module& module, string_list& clean_files ) { static string ros_junk ( "$(ROS_TEMPORARY)" ); string target ( FixupTargetFilename ( module.GetPath () ) ); string workingDirectory = GetWorkingDirectory ( ); string objectsMacro = GetObjectsMacro ( module ); - string importLibraryDependencies = GetImportLibraryDependencies ( module ); + string linkDepsMacro = GetLinkingDependenciesMacro ( module ); + string libsMacro = GetLibsMacro ( module ); - GenerateImportLibraryTargetIfNeeded ( module ); + GenerateImportLibraryTargetIfNeeded ( module, clean_files ); if ( module.files.size () > 0 ) { - GenerateMacrosAndTargetsTarget ( module ); + GenerateMacrosAndTargetsTarget ( module, clean_files ); fprintf ( fMakefile, "%s: %s %s\n", target.c_str (), objectsMacro.c_str (), - importLibraryDependencies.c_str () ); + linkDepsMacro.c_str () ); string linker; if ( IsCPlusPlusModule ( module ) ) @@ -1865,7 +2050,9 @@ MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ( const Module& module GenerateLinkerCommand ( module, linker, linkerParameters, - objectsMacro ); + objectsMacro, + libsMacro, + clean_files ); } else { @@ -1885,43 +2072,49 @@ MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler () } void -MingwBootLoaderModuleHandler::Process ( const Module& module ) +MingwBootLoaderModuleHandler::Process ( const Module& module, string_list& clean_files ) { GeneratePreconditionDependencies ( module ); - GenerateBootLoaderModuleTarget ( module ); + GenerateBootLoaderModuleTarget ( module, clean_files ); GenerateInvocations ( module ); } void -MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ( const Module& module ) +MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ( + const Module& module, + string_list& clean_files ) { static string ros_junk ( "$(ROS_TEMPORARY)" ); string targetName ( module.GetTargetName () ); string target ( FixupTargetFilename ( module.GetPath () ) ); string workingDirectory = GetWorkingDirectory (); string junk_tmp = ros_junk + module.name + ".junk.tmp"; + CLEAN_FILE ( junk_tmp ); string objectsMacro = GetObjectsMacro ( module ); - string importLibraryDependencies = GetImportLibraryDependencies ( module ); + string linkDepsMacro = GetLinkingDependenciesMacro ( module ); + string libsMacro = GetLibsMacro ( module ); - GenerateMacrosAndTargetsTarget ( module ); + GenerateMacrosAndTargetsTarget ( module, clean_files ); fprintf ( fMakefile, "%s: %s %s\n", target.c_str (), objectsMacro.c_str (), - importLibraryDependencies.c_str () ); + linkDepsMacro.c_str () ); + + fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [LD] $@\n" ); fprintf ( fMakefile, "\t${ld} %s -N -Ttext=0x8000 -o %s %s %s\n", GetLinkerMacro ( module ).c_str (), junk_tmp.c_str (), objectsMacro.c_str (), - importLibraryDependencies.c_str () ); + linkDepsMacro.c_str () ); fprintf ( fMakefile, "\t${objcopy} -O binary %s %s\n", junk_tmp.c_str (), target.c_str () ); fprintf ( fMakefile, - "\t${rm} %s\n", + "\t-@${rm} %s\n", junk_tmp.c_str () ); } @@ -1934,22 +2127,23 @@ MingwBootSectorModuleHandler::MingwBootSectorModuleHandler () } void -MingwBootSectorModuleHandler::Process ( const Module& module ) +MingwBootSectorModuleHandler::Process ( const Module& module, string_list& clean_files ) { GeneratePreconditionDependencies ( module ); - GenerateBootSectorModuleTarget ( module ); + GenerateBootSectorModuleTarget ( module, clean_files ); GenerateInvocations ( module ); } void -MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget ( const Module& module ) +MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget ( const Module& module, string_list& clean_files ) { string objectsMacro = GetObjectsMacro ( module ); string* nasmflags = new string ( "-f bin" ); GenerateMacrosAndTargetsTarget ( module, NULL, - nasmflags); + nasmflags, + clean_files ); fprintf ( fMakefile, ".PHONY: %s\n\n", module.name.c_str ()); @@ -1968,10 +2162,10 @@ MingwIsoModuleHandler::MingwIsoModuleHandler () } void -MingwIsoModuleHandler::Process ( const Module& module ) +MingwIsoModuleHandler::Process ( const Module& module, string_list& clean_files ) { GeneratePreconditionDependencies ( module ); - GenerateIsoModuleTarget ( module ); + GenerateIsoModuleTarget ( module, clean_files ); GenerateInvocations ( module ); } @@ -2101,7 +2295,7 @@ MingwIsoModuleHandler::GetCdFiles ( const string bootcdDirectory, } void -MingwIsoModuleHandler::GenerateIsoModuleTarget ( const Module& module ) +MingwIsoModuleHandler::GenerateIsoModuleTarget ( const Module& module, string_list& clean_files ) { string bootcdDirectory = "cd"; string isoboot = FixupTargetFilename ( "boot/freeldr/bootsect/isoboot.o" ); @@ -2123,6 +2317,7 @@ MingwIsoModuleHandler::GenerateIsoModuleTarget ( const Module& module ) isoboot.c_str (), cdDirectories.c_str (), cdFiles.c_str () ); + fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [CABMAN] $<\n" ); fprintf ( fMakefile, "\t${cabman} -C %s -L %s -I\n", reactosDff.c_str (), @@ -2133,12 +2328,13 @@ MingwIsoModuleHandler::GenerateIsoModuleTarget ( const Module& module ) reactosInf.c_str (), bootcdReactos.c_str () ); fprintf ( fMakefile, - "\t- ${rm} %s\n", + "\t-@${rm} %s\n", reactosInf.c_str () ); OutputBootstrapfileCopyCommands ( bootcdDirectory, module ); OutputCdfileCopyCommands ( bootcdDirectory, module ); + fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [CDMAKE] $@\n" ); fprintf ( fMakefile, "\t${cdmake} -v -m -b %s %s REACTOS ReactOS.iso\n", isoboot.c_str (), diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.h b/reactos/tools/rbuild/backend/mingw/modulehandler.h index c1eb8e51eca..3bdb2e9ddce 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.h +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.h @@ -11,6 +11,8 @@ ReplaceExtension ( const std::string& filename, class MingwModuleHandler { public: + typedef std::vector string_list; + static std::map* handler_map; static int ref; @@ -20,10 +22,12 @@ public: static void SetMakefile ( FILE* f ); static MingwModuleHandler* LookupHandler ( const std::string& location, ModuleType moduletype_ ); - virtual void Process ( const Module& module ) = 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: const std::string &PassThruCacheDirectory ( const std::string &f ) const; std::string GetWorkingDirectory () const; @@ -32,7 +36,6 @@ protected: std::string GetModuleArchiveFilename ( const Module& module ) const; bool IsGeneratedFile ( const File& file ) const; std::string GetImportLibraryDependency ( const Module& importedModule ) const; - std::string GetImportLibraryDependencies ( const Module& module ) const; std::string GetModuleDependencies ( const Module& module ) const; std::string GetAllDependencies ( const Module& module ) const; std::string GetSourceFilenames ( const Module& module, @@ -41,11 +44,14 @@ protected: std::string GetSourceFilenamesWithoutGeneratedFiles ( const Module& module ) const; std::string GetObjectFilenames ( const Module& module ) const; - void GenerateMacrosAndTargetsHost ( const Module& module ) const; - void GenerateMacrosAndTargetsTarget ( 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 ) const; + const std::string* nasmflags, + string_list& clean_files ) const; std::string GetInvocationDependencies ( const Module& module ) const; void GenerateInvocations ( const Module& module ) const; @@ -53,12 +59,16 @@ protected: void GeneratePreconditionDependencies ( const Module& module ) const; std::string GetCFlagsMacro ( const Module& module ) const; std::string GetObjectsMacro ( const Module& module ) const; + std::string GetLinkingDependenciesMacro ( const Module& module ) const; + std::string GetLibsMacro ( const Module& module ) const; std::string GetLinkerMacro ( const Module& module ) const; void GenerateLinkerCommand ( const Module& module, const std::string& linker, const std::string& linkerParameters, - const std::string& objectFilenames ) const; - void GenerateImportLibraryTargetIfNeeded ( const Module& module ) const; + const std::string& objectsMacro, + const std::string& libsMacro, + 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; bool IsCPlusPlusModule ( const Module& module ) const; @@ -72,6 +82,7 @@ private: std::string GenerateGccIncludeParametersFromVector ( const std::vector& includes ) const; std::string GenerateCompilerParametersFromVector ( const std::vector& compilerFlags ) const; std::string GenerateLinkerParametersFromVector ( const std::vector& linkerFlags ) const; + std::string GenerateImportLibraryDependenciesFromVector ( const std::vector& libraries ) const; std::string GenerateLinkerParameters ( const Module& module ) const; void GenerateMacro ( const char* assignmentOperation, const std::string& macro, @@ -82,6 +93,7 @@ private: const std::vector& files, const std::vector& includes, const std::vector& defines, + const std::vector& libraries, const std::vector* compilerFlags, const std::vector* linkerFlags, const std::vector& ifs, @@ -89,13 +101,17 @@ private: const std::string& nasmflags_macro, const std::string& windresflags_macro, const std::string& linkerflags_macro, - const std::string& objs_macro) const; + const std::string& objs_macro, + const std::string& libs_macro, + const std::string& linkdeps_macro ) const; void GenerateMacros ( const Module& module, const std::string& cflags_macro, const std::string& nasmflags_macro, const std::string& windresflags_macro, const std::string& linkerflags_macro, - const std::string& objs_macro) const; + const std::string& objs_macro, + const std::string& libs_macro, + const std::string& linkDepsMacro ) const; std::string GenerateGccIncludeParameters ( const Module& module ) const; std::string GenerateGccParameters ( const Module& module ) const; std::string GenerateNasmParameters ( const Module& module ) const; @@ -114,14 +130,16 @@ private: const std::string& sourceFilename, const std::string& windresflagsMacro ) const; void GenerateWinebuildCommands ( const Module& module, - const std::string& sourceFilename ) const; + const std::string& sourceFilename, + string_list& clean_files ) const; void GenerateCommands ( const Module& module, const std::string& sourceFilename, const std::string& cc, const std::string& cppc, const std::string& cflagsMacro, const std::string& nasmflagsMacro, - const std::string& windresflagsMacro ) const; + const std::string& windresflagsMacro, + string_list& clean_files ) const; void GenerateObjectFileTargets ( const Module& module, const std::vector& files, const std::vector& ifs, @@ -129,14 +147,16 @@ private: const std::string& cppc, const std::string& cflagsMacro, const std::string& nasmflagsMacro, - const std::string& windresflagsMacro ) const; + const std::string& windresflagsMacro, + string_list& clean_files ) const; void GenerateObjectFileTargets ( const Module& module, const std::string& cc, const std::string& cppc, const std::string& cflagsMacro, const std::string& nasmflagsMacro, - const std::string& windresflagsMacro ) const; - void GetCleanTargets ( std::vector& out, + const std::string& windresflagsMacro, + string_list& clean_files ) const; + void GetCleanTargets ( string_list& out, const std::vector& files, const std::vector& ifs ) const; std::string GenerateArchiveTarget ( const Module& module, @@ -147,7 +167,8 @@ private: const std::string& cppc, const std::string& ar, const std::string* clags, - const std::string* nasmflags ) const; + const std::string* nasmflags, + string_list& clean_files ) const; std::string GetSpecObjectDependencies ( const std::string& filename ) const; std::string GetDefaultDependencies ( const Module& module ) const; }; @@ -157,9 +178,9 @@ class MingwBuildToolModuleHandler : public MingwModuleHandler { public: MingwBuildToolModuleHandler (); - virtual void Process ( const Module& module ); + virtual void Process ( const Module& module, string_list& clean_files ); private: - void GenerateBuildToolModuleTarget ( const Module& module ); + void GenerateBuildToolModuleTarget ( const Module& module, string_list& clean_files ); }; @@ -167,9 +188,9 @@ class MingwKernelModuleHandler : public MingwModuleHandler { public: MingwKernelModuleHandler (); - virtual void Process ( const Module& module ); + virtual void Process ( const Module& module, string_list& clean_files ); private: - void GenerateKernelModuleTarget ( const Module& module ); + void GenerateKernelModuleTarget ( const Module& module, string_list& clean_files ); }; @@ -177,9 +198,9 @@ class MingwStaticLibraryModuleHandler : public MingwModuleHandler { public: MingwStaticLibraryModuleHandler (); - virtual void Process ( const Module& module ); + virtual void Process ( const Module& module, string_list& clean_files ); private: - void GenerateStaticLibraryModuleTarget ( const Module& module ); + void GenerateStaticLibraryModuleTarget ( const Module& module, string_list& clean_files ); }; @@ -187,9 +208,9 @@ class MingwObjectLibraryModuleHandler : public MingwModuleHandler { public: MingwObjectLibraryModuleHandler (); - virtual void Process ( const Module& module ); + virtual void Process ( const Module& module, string_list& clean_files ); private: - void GenerateObjectLibraryModuleTarget ( const Module& module ); + void GenerateObjectLibraryModuleTarget ( const Module& module, string_list& clean_files ); }; @@ -197,9 +218,9 @@ class MingwKernelModeDLLModuleHandler : public MingwModuleHandler { public: MingwKernelModeDLLModuleHandler (); - virtual void Process ( const Module& module ); + virtual void Process ( const Module& module, string_list& clean_files ); private: - void GenerateKernelModeDLLModuleTarget ( const Module& module ); + void GenerateKernelModeDLLModuleTarget ( const Module& module, string_list& clean_files ); }; @@ -207,9 +228,9 @@ class MingwKernelModeDriverModuleHandler : public MingwModuleHandler { public: MingwKernelModeDriverModuleHandler (); - virtual void Process ( const Module& module ); + virtual void Process ( const Module& module, string_list& clean_files ); private: - void GenerateKernelModeDriverModuleTarget ( const Module& module ); + void GenerateKernelModeDriverModuleTarget ( const Module& module, string_list& clean_files ); }; @@ -217,9 +238,9 @@ class MingwNativeDLLModuleHandler : public MingwModuleHandler { public: MingwNativeDLLModuleHandler (); - virtual void Process ( const Module& module ); + virtual void Process ( const Module& module, string_list& clean_files ); private: - void GenerateNativeDLLModuleTarget ( const Module& module ); + void GenerateNativeDLLModuleTarget ( const Module& module, string_list& clean_files ); }; @@ -227,9 +248,9 @@ class MingwNativeCUIModuleHandler : public MingwModuleHandler { public: MingwNativeCUIModuleHandler (); - virtual void Process ( const Module& module ); + virtual void Process ( const Module& module, string_list& clean_files ); private: - void GenerateNativeCUIModuleTarget ( const Module& module ); + void GenerateNativeCUIModuleTarget ( const Module& module, string_list& clean_files ); }; @@ -237,10 +258,10 @@ class MingwWin32DLLModuleHandler : public MingwModuleHandler { public: MingwWin32DLLModuleHandler (); - virtual void Process ( const Module& module ); + virtual void Process ( const Module& module, string_list& clean_files ); private: - void GenerateExtractWineDLLResourcesTarget ( const Module& module ); - void GenerateWin32DLLModuleTarget ( const Module& module ); + void GenerateExtractWineDLLResourcesTarget ( const Module& module, string_list& clean_files ); + void GenerateWin32DLLModuleTarget ( const Module& module, string_list& clean_files ); }; @@ -248,9 +269,9 @@ class MingwWin32CUIModuleHandler : public MingwModuleHandler { public: MingwWin32CUIModuleHandler (); - virtual void Process ( const Module& module ); + virtual void Process ( const Module& module, string_list& clean_files ); private: - void GenerateWin32CUIModuleTarget ( const Module& module ); + void GenerateWin32CUIModuleTarget ( const Module& module, string_list& clean_files ); }; @@ -258,9 +279,9 @@ class MingwWin32GUIModuleHandler : public MingwModuleHandler { public: MingwWin32GUIModuleHandler (); - virtual void Process ( const Module& module ); + virtual void Process ( const Module& module, string_list& clean_files ); private: - void GenerateWin32GUIModuleTarget ( const Module& module ); + void GenerateWin32GUIModuleTarget ( const Module& module, string_list& clean_files ); }; @@ -268,9 +289,9 @@ class MingwBootLoaderModuleHandler : public MingwModuleHandler { public: MingwBootLoaderModuleHandler (); - virtual void Process ( const Module& module ); + virtual void Process ( const Module& module, string_list& clean_files ); private: - void GenerateBootLoaderModuleTarget ( const Module& module ); + void GenerateBootLoaderModuleTarget ( const Module& module, string_list& clean_files ); }; @@ -278,9 +299,9 @@ class MingwBootSectorModuleHandler : public MingwModuleHandler { public: MingwBootSectorModuleHandler (); - virtual void Process ( const Module& module ); + virtual void Process ( const Module& module, string_list& clean_files ); private: - void GenerateBootSectorModuleTarget ( const Module& module ); + void GenerateBootSectorModuleTarget ( const Module& module, string_list& clean_files ); }; @@ -288,9 +309,9 @@ class MingwIsoModuleHandler : public MingwModuleHandler { public: MingwIsoModuleHandler (); - virtual void Process ( const Module& module ); + virtual void Process ( const Module& module, string_list& clean_files ); private: - void GenerateIsoModuleTarget ( const Module& module ); + void GenerateIsoModuleTarget ( const Module& module, string_list& clean_files ); std::string GetBootstrapCdDirectories ( const std::string bootcdDirectory, const Module& module ) const; std::string GetNonModuleCdDirectories ( const std::string bootcdDirectory, diff --git a/reactos/tools/rbuild/makefile b/reactos/tools/rbuild/makefile index 67f56e9a88d..0dad9ca3216 100644 --- a/reactos/tools/rbuild/makefile +++ b/reactos/tools/rbuild/makefile @@ -85,24 +85,30 @@ RBUILD_HOST_CXXFLAGS = -g -I$(RBUILD_BASE) -Werror -Wall RBUILD_HOST_LFLAGS = -g $(RBUILD_TARGET): $(RBUILD_OBJECTS) + $(HALFVERBOSEECHO) [LD] $@ ${host_gpp} $(RBUILD_OBJECTS) $(RBUILD_HOST_LFLAGS) -o $(RBUILD_TARGET) $(RBUILD_COMMON_OBJECTS): %.o: %.cpp + $(HALFVERBOSEECHO) [CC] $< ${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@ $(RBUILD_SPECIAL_OBJECTS): %.o: %.cpp + $(HALFVERBOSEECHO) [CC] $< ${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@ $(RBUILD_TEST_TARGET): $(RBUILD_TEST_OBJECTS) + $(HALFVERBOSEECHO) [LD] $@ ${host_gpp} $(RBUILD_TEST_OBJECTS) $(RBUILD_HOST_LFLAGS) -o $(RBUILD_TEST_TARGET) $(RBUILD_TEST_SPECIAL_OBJECTS): %.o: %.cpp + $(HALFVERBOSEECHO) [CC] $< ${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@ .PHONY: rbuild_test rbuild_test: $(RBUILD_TEST_TARGET) - $(RBUILD_TEST_TARGET) + $(HALFVERBOSEECHO) [TEST] $@ + $(Q)$(RBUILD_TEST_TARGET) .PHONY: rbuild_clean rbuild_clean: diff --git a/reactos/tools/rbuild/module.cpp b/reactos/tools/rbuild/module.cpp index 1ee50a5cc1f..c9e3504ce89 100644 --- a/reactos/tools/rbuild/module.cpp +++ b/reactos/tools/rbuild/module.cpp @@ -174,10 +174,10 @@ Module::ProcessXMLSubElement ( const XMLElement& e, } else if ( e.name == "library" && e.value.size () ) { - if ( pIf ) + /*if ( pIf ) throw InvalidBuildFileException ( e.location, - " is not a valid sub-element of " ); + " is not a valid sub-element of " );*/ libraries.push_back ( new Library ( e, *this, e.value ) ); subs_invalid = true; } @@ -528,13 +528,20 @@ Library::Library ( const XMLElement& _node, const string& _name ) : node(_node), module(_module), - name(_name) + name(_name), + imported_module(_module.project.LocateModule(_name)) { if ( module.name == name ) throw InvalidBuildFileException ( node.location, "module '%s' cannot link against itself", name.c_str() ); + if ( !imported_module ) + throw InvalidBuildFileException ( + node.location, + "module '%s' trying to import non-existant module '%s'", + module.name.c_str(), + name.c_str() ); } void diff --git a/reactos/tools/rbuild/rbuild.h b/reactos/tools/rbuild/rbuild.h index ee08699be06..0f9d8a25d50 100644 --- a/reactos/tools/rbuild/rbuild.h +++ b/reactos/tools/rbuild/rbuild.h @@ -231,6 +231,7 @@ public: const XMLElement& node; const Module& module; std::string name; + const Module* imported_module; Library ( const XMLElement& _node, const Module& _module, @@ -317,6 +318,7 @@ public: std::vector defines; std::vector properties; std::vector ifs; + std::vector libraries; If ( const XMLElement& node_, const Project& project_, diff --git a/reactos/tools/unicode/makefile b/reactos/tools/unicode/makefile index af4b5159d71..0d40bd7a5c9 100644 --- a/reactos/tools/unicode/makefile +++ b/reactos/tools/unicode/makefile @@ -84,9 +84,11 @@ UNICODE_HOST_CFLAGS = \ -I$(UNICODE_BASE) -Iinclude/wine -Iw32api/include $(UNICODE_TARGET): $(UNICODE_OBJECTS) + $(HALFVERBOSEECHO) [AR] $@ ${host_ar} -rc $(UNICODE_TARGET) $(UNICODE_OBJECTS) $(UNICODE_OBJECTS): %.o : %.c + $(HALFVERBOSEECHO) [CC] $< ${host_gcc} $(UNICODE_HOST_CFLAGS) -c $< -o $@ .PHONY: unicode_clean diff --git a/reactos/tools/wmc/makefile b/reactos/tools/wmc/makefile index 9407229a526..e51f945c608 100644 --- a/reactos/tools/wmc/makefile +++ b/reactos/tools/wmc/makefile @@ -21,9 +21,11 @@ WMC_HOST_CXXFLAGS = -I$(WMC_BASE) -g -Werror -Wall WMC_HOST_LFLAGS = -g $(WMC_TARGET): $(WMC_OBJECTS) + $(HALFVERBOSEECHO) [LD] $@ ${host_gcc} $(WMC_OBJECTS) $(WMC_HOST_LFLAGS) -o $(WMC_TARGET) $(WMC_OBJECTS): %.o : %.c + $(HALFVERBOSEECHO) [CC] $< ${host_gcc} $(WMC_HOST_CXXFLAGS) -c $< -o $@ .PHONY: wmc_clean diff --git a/reactos/tools/wpp/Makefile b/reactos/tools/wpp/Makefile index 60cdb598585..dce245f4cbc 100644 --- a/reactos/tools/wpp/Makefile +++ b/reactos/tools/wpp/Makefile @@ -15,9 +15,11 @@ WPP_OBJECTS = \ WPP_HOST_CFLAGS = -D__USE_W32API -I$(WPP_BASE) -Iinclude -Iinclude/wine -g $(WPP_TARGET): $(WPP_OBJECTS) + $(HALFVERBOSEECHO) [AR] $@ ${host_ar} -rc $(WPP_TARGET) $(WPP_OBJECTS) $(WPP_OBJECTS): %.o : %.c + $(HALFVERBOSEECHO) [CC] $< ${host_gcc} $(WPP_HOST_CFLAGS) -c $< -o $@ .PHONY: wpp_clean diff --git a/reactos/tools/wrc/makefile b/reactos/tools/wrc/makefile index 333bef9f0fa..204a9402d21 100644 --- a/reactos/tools/wrc/makefile +++ b/reactos/tools/wrc/makefile @@ -28,9 +28,11 @@ WRC_HOST_CFLAGS = -I$(WRC_BASE) -g -Werror -Wall \ WRC_HOST_LFLAGS = -g $(WRC_TARGET): $(WRC_OBJECTS) $(UNICODE_TARGET) $(WPP_TARGET) + $(HALFVERBOSEECHO) [LD] $@ ${host_gcc} $(WRC_OBJECTS) $(UNICODE_TARGET) $(WPP_TARGET) $(WRC_HOST_LFLAGS) -o $(WRC_TARGET) $(WRC_OBJECTS): %.o : %.c + $(HALFVERBOSEECHO) [CC] $< ${host_gcc} $(WRC_HOST_CFLAGS) -c $< -o $@ .PHONY: wrc_clean