[m-rev.] diff: improve mmc --make messages
Peter Wang
novalazy at gmail.com
Fri Jul 31 11:10:29 AEST 2009
Branches: main
Print common `mmc --make' messages with a single call to io.write_string, to
avoid interleaved messages when parallel make is used.
When cleaning up after receiving a signal, only print messages about the files
being removed if `--very-verbose' is set.
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.util.m:
compiler/process_util.m:
As above.
diff --git a/compiler/make.module_dep_file.m b/compiler/make.module_dep_file.m
index d5e2363..e8fc7d7 100644
--- a/compiler/make.module_dep_file.m
+++ b/compiler/make.module_dep_file.m
@@ -683,7 +683,7 @@ cleanup_short_interfaces(SubModuleNames, !Info, !IO) :-
list.foldl2(
(pred(SubModuleName::in, !.Info::in, !:Info::out, !.IO::di, !:IO::uo)
is det :-
- make_remove_target_file(verbose_make, SubModuleName,
+ make_remove_target_file(very_verbose, SubModuleName,
module_target_unqualified_short_interface, !Info, !IO)
), SubModuleNames, !Info, !IO).
diff --git a/compiler/make.module_target.m b/compiler/make.module_target.m
index 3437a2a..b9be997 100644
--- a/compiler/make.module_target.m
+++ b/compiler/make.module_target.m
@@ -366,9 +366,9 @@ build_target(CompilationTask, TargetFile, Imports, TouchedTargetFiles,
Cleanup =
(pred(!.MakeInfo::in, !:MakeInfo::out, !.IO::di, !:IO::uo) is det :-
% XXX Remove `.int.tmp' files.
- list.foldl2(make_remove_target_file(verbose_make),
+ list.foldl2(make_remove_target_file(very_verbose),
TouchedTargetFiles, !MakeInfo, !IO),
- list.foldl2(make_remove_file(verbose_make), TouchedFiles,
+ list.foldl2(make_remove_file(very_verbose), TouchedFiles,
!MakeInfo, !IO),
(
MaybeArgFileName = yes(ArgFileName2),
diff --git a/compiler/make.util.m b/compiler/make.util.m
index 5c29bee..05532e0 100644
--- a/compiler/make.util.m
+++ b/compiler/make.util.m
@@ -259,6 +259,9 @@
:- pred make_write_target_file(target_file::in, io::di, io::uo) is det.
+:- pred make_write_target_file_wrapped(string::in, target_file::in, string::in,
+ io::di, io::uo) is det.
+
% Write a message "Making <filename>" if `--verbose-make' is set.
%
:- pred maybe_make_linked_target_message(file_name::in, io::di, io::uo) is det.
@@ -1619,17 +1622,29 @@ make_write_dependency_file_list([DepFile | DepFiles], !IO) :-
make_write_dependency_file_list(DepFiles, !IO).
make_write_target_file(TargetFile, !IO) :-
+ make_write_target_file_wrapped("", TargetFile, "", !IO).
+
+make_write_target_file_wrapped(Prefix, TargetFile, Suffix, !IO) :-
TargetFile = target_file(ModuleName, FileType),
module_target_to_file_name(ModuleName, FileType, do_not_create_dirs,
FileName, !IO),
- io.write_string(FileName, !IO).
+ (
+ Prefix = "",
+ Suffix = ""
+ ->
+ io.write_string(FileName, !IO)
+ ;
+ % Try to write this with one call to avoid interleaved output when
+ % doing parallel builds.
+ io.write_string(Prefix ++ FileName ++ Suffix, !IO)
+ ).
maybe_make_linked_target_message(TargetFile, !IO) :-
verbose_msg(
(pred(!.IO::di, !:IO::uo) is det :-
- io.write_string("Making ", !IO),
- io.write_string(TargetFile, !IO),
- io.nl(!IO)
+ % Try to write this with one call to avoid interleaved output
+ % when doing parallel builds.
+ io.write_string("Making " ++ TargetFile ++ "\n", !IO)
), !IO).
maybe_make_target_message(TargetFile, !IO) :-
@@ -1640,30 +1655,26 @@ maybe_make_target_message_to_stream(OutputStream, TargetFile, !IO) :-
verbose_msg(
(pred(!.IO::di, !:IO::uo) is det :-
io.set_output_stream(OutputStream, OldOutputStream, !IO),
- io.write_string("Making ", !IO),
- make_write_target_file(TargetFile, !IO),
- io.nl(!IO),
+ make_write_target_file_wrapped("Making ", TargetFile, "\n", !IO),
io.set_output_stream(OldOutputStream, _, !IO)
), !IO).
maybe_reanalyse_modules_message(!IO) :-
- io.output_stream(OutputStream, !IO),
verbose_msg(
(pred(!.IO::di, !:IO::uo) is det :-
- io.set_output_stream(OutputStream, OldOutputStream, !IO),
- io.write_string("Reanalysing invalid/suboptimal modules\n", !IO),
- io.set_output_stream(OldOutputStream, _, !IO)
+ io.output_stream(OutputStream, !IO),
+ io.write_string(OutputStream,
+ "Reanalysing invalid/suboptimal modules\n", !IO)
), !IO).
target_file_error(TargetFile, !IO) :-
- io.write_string("** Error making `", !IO),
- make_write_target_file(TargetFile, !IO),
- io.write_string("'.\n", !IO).
+ make_write_target_file_wrapped("** Error making `", TargetFile, "'.\n",
+ !IO).
file_error(TargetFile, !IO) :-
- io.write_string("** Error making `", !IO),
- io.write_string(TargetFile, !IO),
- io.write_string("'.\n", !IO).
+ % Try to write this with one call to avoid interleaved output when doing
+ % parallel builds.
+ io.write_string("** Error making `" ++ TargetFile ++ "'.\n", !IO).
maybe_warn_up_to_date_target(Target, !Info, !IO) :-
globals.io_lookup_bool_option(warn_up_to_date, Warn, !IO),
diff --git a/compiler/process_util.m b/compiler/process_util.m
index 5cd3858..c6e88b0 100644
--- a/compiler/process_util.m
+++ b/compiler/process_util.m
@@ -129,7 +129,7 @@ build_with_check_for_interrupt(Build, Cleanup, Succeeded, !Info, !IO) :-
check_for_signal(Signalled, Signal, !IO),
( Signalled = 1 ->
Succeeded = no,
- globals.io_lookup_bool_option(verbose_make, Verbose, !IO),
+ globals.io_lookup_bool_option(very_verbose, Verbose, !IO),
(
Verbose = yes,
io.write_string("** Received signal ", !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