[m-rev.] for review: quieten `mmc --make module.realclean'

Simon Taylor staylr at gmail.com
Tue May 1 13:05:20 AEST 2007


Estimated hours taken: 0.5
Branches: main

compiler/make.util.m:
compiler/make.*.m:
	When building a `.clean' or `.realclean' target, only report
	individual files being removed when `--very-verbose' is set,
	not `--verbose-make'.
	
	Still report each file when cleaning up the target files after
	an interrupted build.

Index: make.module_dep_file.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.module_dep_file.m,v
retrieving revision 1.28
diff -u -u -r1.28 make.module_dep_file.m
--- make.module_dep_file.m	1 Dec 2006 15:04:05 -0000	1.28
+++ make.module_dep_file.m	1 May 2007 02:49:59 -0000
@@ -641,7 +641,7 @@
     list.foldl2(
         (pred(SubModuleName::in, !.Info::in, !:Info::out, !.IO::di, !:IO::uo)
                 is det :-
-            make_remove_target_file(SubModuleName,
+            make_remove_target_file(verbose_make, SubModuleName,
                 module_target_unqualified_short_interface, !Info, !IO)
         ), SubModuleNames, !Info, !IO).
 
@@ -652,8 +652,8 @@
     list.foldl2(
         (pred(SubModuleName::in, !.Info::in, !:Info::out, !.IO::di, !:IO::uo)
                 is det :-
-            make_remove_file(SubModuleName, make_module_dep_file_extension,
-                !Info, !IO)
+            make_remove_file(verbose_make, SubModuleName,
+                make_module_dep_file_extension, !Info, !IO)
         ), SubModuleNames, !Info, !IO).
 
 :- pred maybe_write_importing_module(module_name::in, maybe(module_name)::in,
Index: make.module_target.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.module_target.m,v
retrieving revision 1.52
diff -u -u -r1.52 make.module_target.m
--- make.module_target.m	8 Jan 2007 03:03:10 -0000	1.52
+++ make.module_target.m	1 May 2007 02:51:02 -0000
@@ -341,9 +341,10 @@
     Cleanup =
         (pred(!.MakeInfo::in, !:MakeInfo::out, !.IO::di, !:IO::uo) is det :-
             % XXX Remove `.int.tmp' files.
-            list.foldl2(make_remove_target_file, TouchedTargetFiles,
+            list.foldl2(make_remove_target_file(verbose_make),
+                TouchedTargetFiles, !MakeInfo, !IO),
+            list.foldl2(make_remove_file(verbose_make), TouchedFiles,
                 !MakeInfo, !IO),
-            list.foldl2(make_remove_file, TouchedFiles, !MakeInfo, !IO),
             (
                 MaybeArgFileName = yes(ArgFileName2),
                 io.remove_file(ArgFileName2, _, !IO)
Index: make.program_target.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.program_target.m,v
retrieving revision 1.68
diff -u -u -r1.68 make.program_target.m
--- make.program_target.m	18 Apr 2007 06:27:58 -0000	1.68
+++ make.program_target.m	1 May 2007 02:54:04 -0000
@@ -45,6 +45,7 @@
 :- import_module libs.handle_options.
 :- import_module libs.process_util.
 :- import_module parse_tree.prog_foreign.
+:- import_module parse_tree.prog_out.
 :- import_module transform_hlds.
 :- import_module transform_hlds.mmc_analysis.
 
@@ -526,14 +527,14 @@
 
 linked_target_cleanup(MainModuleName, FileType, OutputFileName,
         CompilationTarget, !Info, !IO) :-
-    make_remove_file(OutputFileName, !Info, !IO),
+    make_remove_file(verbose_make, OutputFileName, !Info, !IO),
     (
         FileType = executable,
         ( CompilationTarget = target_c
         ; CompilationTarget = target_asm
         )
     ->
-        remove_init_files(MainModuleName, !Info, !IO)
+        remove_init_files(verbose_make, MainModuleName, !Info, !IO)
     ;
         true
     ).
@@ -570,7 +571,7 @@
         TargetType = misc_target_clean,
         Succeeded = yes,
         list.foldl2(make_module_clean, AllModules, !Info, !IO),
-        remove_init_files(MainModuleName, !Info, !IO)
+        remove_init_files(very_verbose, MainModuleName, !Info, !IO)
     ;
         TargetType = misc_target_realclean,
         Succeeded = yes,
@@ -1378,6 +1379,18 @@
     make_info::in, make_info::out, io::di, io::uo) is det.
 
 make_grade_clean(ModuleName, AllModules, !Info, !IO) :-
+    verbose_msg(
+        (pred(!.IO::di, !:IO::uo) is det :-
+            io.write_string("Cleaning up grade-dependent files for `",
+                !IO),
+            write_sym_name(ModuleName, !IO),
+            io.write_string("'in grade ", !IO),
+            globals.io_get_globals(Globals, !IO),
+            grade_directory_component(Globals, Grade),
+            io.write_string(Grade, !IO),
+            io.write_string(".\n", !IO)
+        ), !IO),
+
     make_main_module_realclean(ModuleName, !Info, !IO),
     list.foldl2(make_module_clean, AllModules, !Info, !IO).
 
@@ -1385,6 +1398,13 @@
     make_info::in, make_info::out, io::di, io::uo) is det.
 
 make_main_module_realclean(ModuleName, !Info, !IO) :-
+    verbose_msg(
+        (pred(!.IO::di, !:IO::uo) is det :-
+            io.write_string("Removing executable and library files for `",
+                !IO),
+            write_sym_name(ModuleName, !IO),
+            io.write_string("'.\n", !IO)
+        ), !IO),
     linked_target_file_name(ModuleName, executable, ExeFileName, !IO),
     linked_target_file_name(ModuleName, static_library, LibFileName, !IO),
     linked_target_file_name(ModuleName, shared_library, SharedLibFileName,
@@ -1402,37 +1422,46 @@
     linked_target_file_name(ModuleName, java_archive, ThisDirJarFileName, !IO),
     globals.io_set_option(use_grade_subdirs, bool(UseGradeSubdirs), !IO),
 
-    list.foldl2(make_remove_file,
+    list.foldl2(make_remove_file(very_verbose),
         [ExeFileName, LibFileName, SharedLibFileName, JarFileName,
         ThisDirExeFileName, ThisDirLibFileName,
         ThisDirSharedLibFileName, ThisDirJarFileName],
         !Info, !IO),
-    make_remove_file(ModuleName, ".init", !Info, !IO),
-    remove_init_files(ModuleName, !Info, !IO).
+    make_remove_file(very_verbose, ModuleName, ".init", !Info, !IO),
+    remove_init_files(very_verbose, ModuleName, !Info, !IO).
 
-:- pred remove_init_files(module_name::in, make_info::in, make_info::out,
-    io::di, io::uo) is det.
+:- pred remove_init_files(option::in, module_name::in,
+    make_info::in, make_info::out, io::di, io::uo) is det.
 
-remove_init_files(ModuleName, !Info, !IO) :-
+remove_init_files(Verbose, ModuleName, !Info, !IO) :-
     globals.io_lookup_string_option(object_file_extension, ObjExt, !IO),
     globals.io_lookup_string_option(pic_object_file_extension, PicObjExt,
         !IO),
     globals.io_lookup_string_option(link_with_pic_object_file_extension,
         LinkWithPicObjExt, !IO),
-    list.foldl2(make_remove_file(ModuleName), ["_init.c", "_init" ++ ObjExt,
-        "_init" ++ PicObjExt, "_init" ++ LinkWithPicObjExt],
+    list.foldl2(make_remove_file(Verbose, ModuleName),
+        ["_init.c", "_init" ++ ObjExt,
+            "_init" ++ PicObjExt, "_init" ++ LinkWithPicObjExt],
         !Info, !IO).
 
 :- pred make_module_clean(module_name::in, make_info::in, make_info::out,
     io::di, io::uo) is det.
 
 make_module_clean(ModuleName, !Info, !IO) :-
-    list.foldl2(make_remove_target_file(ModuleName),
+    verbose_msg(verbose_make,
+        (pred(!.IO::di, !:IO::uo) is det :-
+            io.write_string("Cleaning up target files for module `", !IO),
+            write_sym_name(ModuleName, !IO),
+            io.write_string("'.\n", !IO)
+        ), !IO),
+
+    list.foldl2(make_remove_target_file(very_verbose, ModuleName),
         [module_target_errors, module_target_c_code,
         module_target_c_header(header_mih), module_target_il_code,
         module_target_java_code], !Info, !IO),
 
-    list.foldl2(make_remove_file(ModuleName), [".used", ".prof"], !Info, !IO),
+    list.foldl2(make_remove_file(very_verbose, ModuleName),
+        [".used", ".prof"], !Info, !IO),
 
     get_module_dependencies(ModuleName, MaybeImports, !Info, !IO),
     (
@@ -1447,25 +1476,27 @@
         (pred(FactTableFile::in, !.Info::in, !:Info::out, di, uo) is det -->
             fact_table_file_name(ModuleName, FactTableFile,
                 ".c", no, FactTableCFile),
-            make_remove_file(FactTableCFile, !Info)
+            make_remove_file(very_verbose, FactTableCFile, !Info)
         ), FactTableFiles, !Info, !IO),
 
     CCodeModule = foreign_language_module_name(ModuleName, lang_c),
-    make_remove_target_file(CCodeModule, module_target_c_code, !Info, !IO),
+    make_remove_target_file(very_verbose, CCodeModule, module_target_c_code,
+        !Info, !IO),
 
     % Remove object and assembler files.
     list.foldl2(
         (pred(PIC::in, !.Info::in, !:Info::out, !.IO::di, !:IO::uo) is det :-
-        make_remove_target_file(ModuleName, module_target_object_code(PIC),
-            !Info, !IO),
-        make_remove_target_file(ModuleName, module_target_asm_code(PIC),
+        make_remove_target_file(very_verbose, ModuleName,
+            module_target_object_code(PIC),
             !Info, !IO),
-        make_remove_target_file(ModuleName,
+        make_remove_target_file(very_verbose, ModuleName,
+            module_target_asm_code(PIC), !Info, !IO),
+        make_remove_target_file(very_verbose, ModuleName,
             module_target_foreign_object(PIC, lang_c), !Info, !IO),
         list.foldl2(
             (pred(FactTableFile::in, !.Info::in, !:Info::out,
                     !.IO::di, !:IO::uo) is det :-
-                make_remove_target_file(ModuleName,
+                make_remove_target_file(very_verbose, ModuleName,
                     module_target_fact_table_object(PIC, FactTableFile),
                     !Info, !IO)
             ), FactTableFiles, !Info, !IO)
@@ -1474,17 +1505,17 @@
 
     % Remove IL foreign code files.
     CSharpModule = foreign_language_module_name(ModuleName, lang_csharp),
-    make_remove_file(CSharpModule,
+    make_remove_file(very_verbose, CSharpModule,
         foreign_language_file_extension(lang_csharp), !Info, !IO),
-    make_remove_target_file(CSharpModule,
+    make_remove_target_file(very_verbose, CSharpModule,
         module_target_foreign_il_asm(lang_csharp), !Info, !IO),
 
     McppModule = foreign_language_module_name(ModuleName,
         lang_managed_cplusplus),
-    make_remove_file(McppModule,
+    make_remove_file(very_verbose, McppModule,
         foreign_language_file_extension(lang_managed_cplusplus),
         !Info, !IO),
-    make_remove_target_file(McppModule,
+    make_remove_target_file(very_verbose, McppModule,
         module_target_foreign_il_asm(lang_managed_cplusplus), !Info, !IO).
 
 :- pred make_module_realclean(module_name::in, make_info::in, make_info::out,
@@ -1492,7 +1523,14 @@
 
 make_module_realclean(ModuleName, !Info, !IO) :-
     make_module_clean(ModuleName, !Info, !IO),
-    list.foldl2(make_remove_target_file(ModuleName),
+
+    verbose_msg(verbose_make,
+        (pred(!.IO::di, !:IO::uo) is det :-
+            io.write_string("Cleaning up interface files for module `", !IO),
+            write_sym_name(ModuleName, !IO),
+            io.write_string("'.\n", !IO)
+        ), !IO),
+    list.foldl2(make_remove_target_file(very_verbose, ModuleName),
         [
             module_target_private_interface, 
             module_target_long_interface, 
@@ -1503,9 +1541,10 @@
             module_target_c_header(header_mh)
         ],
         !Info, !IO),
-    make_remove_file(ModuleName, make_module_dep_file_extension, !Info, !IO),
-    make_remove_file(ModuleName, ".imdg", !Info, !IO),
-    make_remove_file(ModuleName, ".request", !Info, !IO).
+    make_remove_file(very_verbose, ModuleName, make_module_dep_file_extension,
+        !Info, !IO),
+    make_remove_file(very_verbose, ModuleName, ".imdg", !Info, !IO),
+    make_remove_file(very_verbose, ModuleName, ".request", !Info, !IO).
 
 %-----------------------------------------------------------------------------%
 
Index: make.util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.util.m,v
retrieving revision 1.44
diff -u -u -r1.44 make.util.m
--- make.util.m	11 Apr 2007 04:21:59 -0000	1.44
+++ make.util.m	1 May 2007 02:53:11 -0000
@@ -180,25 +180,30 @@
 %-----------------------------------------------------------------------------%
 %
 % Remove file a file, deleting the cached timestamp
+% The removal is reported to the user if the given boolean option is set.
+% In general the option given should be `--very-verbose' when making a
+% `.clean' or `.realclean target', and `--verbose-make' when cleaning
+% after an interrupted build.
 %
 
     % Remove the target file and the corresponding timestamp file.
     %
-:- pred make_remove_target_file(target_file::in, make_info::in, make_info::out,
-    io::di, io::uo) is det.
+:- pred make_remove_target_file(option::in, target_file::in,
+    make_info::in, make_info::out, io::di, io::uo) is det.
 
     % Remove the target file and the corresponding timestamp file.
     %
-:- pred make_remove_target_file(module_name::in, module_target_type::in,
-    make_info::in, make_info::out, io::di, io::uo) is det.
+:- pred make_remove_target_file(option::in, module_name::in,
+    module_target_type::in, make_info::in, make_info::out,
+    io::di, io::uo) is det.
 
-    % make_remove_file(ModuleName, Extension, !Info).
+    % make_remove_file(VerboseOption, ModuleName, Extension, !Info).
     %
-:- pred make_remove_file(module_name::in, string::in,
+:- pred make_remove_file(option::in, module_name::in, string::in,
     make_info::in, make_info::out, io::di, io::uo) is det.
 
-:- pred make_remove_file(file_name::in, make_info::in, make_info::out,
-    io::di, io::uo) is det.
+:- pred make_remove_file(option::in, file_name::in,
+    make_info::in, make_info::out, io::di, io::uo) is det.
 
 %-----------------------------------------------------------------------------%
 
@@ -238,6 +243,11 @@
 :- pred verbose_msg(pred(io, io)::(pred(di, uo) is det),
     io::di, io::uo) is det.
 
+    % Apply the given predicate if the given boolean option is set to `yes'.
+    %
+:- pred verbose_msg(option::in, pred(io, io)::(pred(di, uo) is det),
+    io::di, io::uo) is det.
+
     % Write a debugging message relating to a given target file.
     %
 :- pred debug_file_msg(target_file::in, string::in, io::di, io::uo) is det.
@@ -277,7 +287,7 @@
     make_info::in, make_info::out, io::di, io::uo) is det.
 
     % Write a message "Made symlink/copy of <filename>" if
-    % `--verbose-message' is set.
+    % `--verbose-make' is set.
     %
 :- pred maybe_symlink_or_copy_linked_target_message(
     pair(module_name, target_type)::in, io::di, io::uo) is det.
@@ -935,25 +945,26 @@
 
 %-----------------------------------------------------------------------------%
 
-make_remove_target_file(target_file(ModuleName, FileType), !Info, !IO) :-
-    make_remove_target_file(ModuleName, FileType, !Info, !IO).
+make_remove_target_file(VerboseOption, target_file(ModuleName, FileType),
+        !Info, !IO) :-
+    make_remove_target_file(VerboseOption, ModuleName, FileType, !Info, !IO).
 
-make_remove_target_file(ModuleName, FileType, !Info, !IO) :-
+make_remove_target_file(VerboseOption, ModuleName, FileType, !Info, !IO) :-
     globals.io_get_globals(Globals, !IO),
     module_target_to_file_name(ModuleName, FileType, no, FileName, !IO),
-    make_remove_file(FileName, !Info, !IO),
+    make_remove_file(VerboseOption, FileName, !Info, !IO),
     ( TimestampExt = timestamp_extension(Globals, FileType) ->
-        make_remove_file(ModuleName, TimestampExt, !Info, !IO)
+        make_remove_file(VerboseOption, ModuleName, TimestampExt, !Info, !IO)
     ;
         true
     ).
 
-make_remove_file(ModuleName, Ext, !Info, !IO) :-
+make_remove_file(VerboseOption, ModuleName, Ext, !Info, !IO) :-
     module_name_to_file_name(ModuleName, Ext, no, FileName, !IO),
-    make_remove_file(FileName, !Info, !IO).
+    make_remove_file(VerboseOption, FileName, !Info, !IO).
 
-make_remove_file(FileName, !Info, !IO) :-
-    verbose_msg(report_remove_file(FileName), !IO),
+make_remove_file(VerboseOption, FileName, !Info, !IO) :-
+    verbose_msg(VerboseOption, report_remove_file(FileName), !IO),
     io.remove_file(FileName, _, !IO),
     !:Info = !.Info ^ file_timestamps :=
         map.delete(!.Info ^ file_timestamps, FileName).
@@ -1170,23 +1181,19 @@
 %-----------------------------------------------------------------------------%
 
 debug_msg(P, !IO) :-
-    globals.io_lookup_bool_option(debug_make, Debug, !IO),
-    (
-        Debug = yes,
-        P(!IO),
-        io.flush_output(!IO)
-    ;
-        Debug = no
-    ).
+    verbose_msg(debug_make, P, !IO).
 
 verbose_msg(P, !IO) :-
-    globals.io_lookup_bool_option(verbose_make, Verbose, !IO),
+    verbose_msg(verbose_make, P, !IO).
+
+verbose_msg(Option, P, !IO) :-
+    globals.io_lookup_bool_option(Option, OptionValue, !IO),
     (
-        Verbose = yes,
+        OptionValue = yes,
         P(!IO),
         io.flush_output(!IO)
     ;
-        Verbose = no
+        OptionValue = no
     ).
 
 debug_file_msg(TargetFile, Msg, !IO) :-
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list