[m-rev.] for post-commit review: don't bump .hrl file timestamps

Peter Wang novalazy at gmail.com
Fri Aug 31 11:05:08 AEST 2007


Estimated hours taken: 6
Branches: main

compiler/elds_to_erlang.m:
	Don't bump the timestamp of an Erlang header file (.hrl) if its
	content doesn't change.  It was causing unnecessary rebuilds of .beam
	files.

compiler/make.module_target.m:
	List foo.hrl as file touched by the process of compiling foo.m.

compiler/make.dependencies.m:
compiler/make.util.m:
	List .hrl files as having .erl_date files as their timestamp files.

	Mark the module_target_erlang_header target as grade-dependent,
	to be consistent with file_is_arch_or_grade_dependent_2(".hrl").

	Make the output of --debug-make more readable and useful by printing
	out dependency file lists over multiple lines, and writing out
	timestamps.

compiler/modules.m:
	Put .hrl.tmp files in the same directory as .hrl files.


Index: compiler/elds_to_erlang.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/elds_to_erlang.m,v
retrieving revision 1.29
diff -u -r1.29 elds_to_erlang.m
--- compiler/elds_to_erlang.m	24 Aug 2007 02:53:24 -0000	1.29
+++ compiler/elds_to_erlang.m	28 Aug 2007 05:29:15 -0000
@@ -76,8 +76,11 @@
     module_name_to_file_name(Name, ".hrl", yes, HeaderFileName, !IO),
     output_to_file(SourceFileName, output_erl_file(ModuleInfo, ELDS,
         SourceFileName), !IO),
-    output_to_file(HeaderFileName, output_hrl_file(Name, ELDS,
-        SourceFileName), !IO).
+    % Avoid updating the timestamp on the `.hrl' file if it hasn't changed.
+    TmpHeaderFileName = HeaderFileName ++ ".tmp",
+    output_to_file(TmpHeaderFileName, output_hrl_file(Name, ELDS,
+        SourceFileName), !IO),
+    update_interface(HeaderFileName, !IO).
 
 :- pred output_erl_file(module_info::in, elds::in, string::in,
     io::di, io::uo) is det.
Index: compiler/make.dependencies.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make.dependencies.m,v
retrieving revision 1.41
diff -u -r1.41 make.dependencies.m
--- compiler/make.dependencies.m	23 Aug 2007 04:03:03 -0000	1.41
+++ compiler/make.dependencies.m	28 Aug 2007 05:29:15 -0000
@@ -1056,7 +1056,7 @@
             compare((>), DepTimestamp, Timestamp)
         ->
             debug_newer_dependencies(TargetFileName, MaybeTimestamp,
-                DepFiles, WriteDepFile, DepTimestamps, !IO),
+                DepFiles, DepTimestamps, !IO),
             DepsResult = deps_out_of_date
         ;
             DepsResult = deps_up_to_date
@@ -1064,26 +1064,26 @@
     ).
 
 :- pred debug_newer_dependencies(string::in, maybe_error(timestamp)::in,
-    list(T)::in, pred(T, io, io)::(pred(in, di, uo) is det),
-    list(maybe_error(timestamp))::in, io::di, io::uo) is det.
+    list(T)::in, list(maybe_error(timestamp))::in, io::di, io::uo) is det.
 
 debug_newer_dependencies(TargetFileName, MaybeTimestamp,
-        DepFiles, WriteDepFile, DepTimestamps, !IO) :-
+        DepFiles, DepTimestamps, !IO) :-
     debug_msg(debug_newer_dependencies_2(TargetFileName, MaybeTimestamp,
-        DepFiles, WriteDepFile, DepTimestamps), !IO).
+        DepFiles, DepTimestamps), !IO).
 
 :- pred debug_newer_dependencies_2(string::in, maybe_error(timestamp)::in,
-    list(T)::in, pred(T, io, io)::(pred(in, di, uo) is det),
-    list(maybe_error(timestamp))::in, io::di, io::uo) is det.
+    list(T)::in, list(maybe_error(timestamp))::in, io::di, io::uo) is det.
 
 debug_newer_dependencies_2(TargetFileName, MaybeTimestamp,
-        DepFiles, WriteDepFile, DepTimestamps, !IO) :-
+        DepFiles, DepTimestamps, !IO) :-
     io.write_string(TargetFileName, !IO),
-    io.write_string(": newer dependencies: ", !IO),
+    io.write_string(" [", !IO),
+    io.write(MaybeTimestamp, !IO),
+    io.write_string("]: newer dependencies:\n", !IO),
     assoc_list.from_corresponding_lists(DepFiles, DepTimestamps,
         DepTimestampAL),
     solutions(
-        (pred(DepFile::out) is nondet :-
+        (pred({DepFile, MaybeDepTimestamp}::out) is nondet :-
             list.member(DepFile - MaybeDepTimestamp, DepTimestampAL),
             (
                 MaybeDepTimestamp = error(_)
@@ -1093,8 +1093,20 @@
                 compare((>), DepTimestamp, Timestamp)
             )
         ), NewerDeps),
-    io.write_list(NewerDeps, ",\n\t", WriteDepFile, !IO),
-    io.nl(!IO).
+    write_dependency_file_and_timestamp_list(NewerDeps, !IO).
+
+:- pred write_dependency_file_and_timestamp_list(
+    list({T, maybe_error(timestamp)})::in, io::di, io::uo) is det.
+
+write_dependency_file_and_timestamp_list([], !IO).
+write_dependency_file_and_timestamp_list([Head | Tail], !IO) :-
+    Head = {DepFile, MaybeTimestamp},
+    io.write_char('\t', !IO),
+    io.write(DepFile, !IO),
+    io.write_char(' ', !IO),
+    io.write(MaybeTimestamp, !IO),
+    io.nl(!IO),
+    write_dependency_file_and_timestamp_list(Tail, !IO).
 
 dependency_status(dep_file(FileName, _) @ Dep, Status, !Info, !IO) :-
     (
Index: compiler/make.module_target.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make.module_target.m,v
retrieving revision 1.57
diff -u -r1.57 make.module_target.m
--- compiler/make.module_target.m	14 Jul 2007 02:32:44 -0000	1.57
+++ compiler/make.module_target.m	28 Aug 2007 05:29:15 -0000
@@ -163,9 +163,7 @@
                    (pred(!.IO::di, !:IO::uo) is det :-
                         write_target_file(TargetFile, !IO),
                         io.write_string(": dependencies:\n", !IO),
-                        io.write_list(DepFiles, ", ", write_dependency_file,
-                            !IO),
-                        io.nl(!IO)
+                        write_dependency_file_list(DepFiles, !IO)
                 ), !IO),
 
                 globals.io_lookup_bool_option(keep_going, KeepGoing, !IO),
@@ -845,10 +843,15 @@
         ;
             ( CompilationTarget = target_il
             ; CompilationTarget = target_java
-            ; CompilationTarget = target_erlang
             ),
             HeaderTargets0 = []
         ;
+            CompilationTarget = target_erlang,
+            % When compiling to Erlang we always generate a header file.
+            HeaderModuleNames = SourceFileModuleNames,
+            HeaderTargets0 = make_target_file_list(HeaderModuleNames,
+                module_target_erlang_header)
+        ;
             CompilationTarget = target_x86_64,
             sorry(this_file, "NYI mmc --make and target x86_64")
         ),
@@ -856,13 +859,16 @@
         (
             ( CompilationTarget = target_c
             ; CompilationTarget = target_asm
-            )
-        ->
+            ),
             Names = SourceFileModuleNames,
             HeaderTargets =
                 make_target_file_list(Names, module_target_c_header(header_mh))
                 ++ HeaderTargets0
         ;
+            ( CompilationTarget = target_il
+            ; CompilationTarget = target_java
+            ; CompilationTarget = target_erlang
+            ),
             HeaderTargets = HeaderTargets0
         ),
 
Index: compiler/make.util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make.util.m,v
retrieving revision 1.50
diff -u -r1.50 make.util.m
--- compiler/make.util.m	27 Aug 2007 06:36:33 -0000	1.50
+++ compiler/make.util.m	28 Aug 2007 05:29:15 -0000
@@ -255,6 +255,9 @@
 
 :- pred write_dependency_file(dependency_file::in, io::di, io::uo) is det.
 
+:- pred write_dependency_file_list(list(dependency_file)::in, io::di, io::uo)
+    is det.
+
 :- pred write_target_file(target_file::in, io::di, io::uo) is det.
 
     % Write a message "Making <filename>" if `--verbose-make' is set.
@@ -1297,6 +1300,10 @@
     % can be modified in the process of analysing _another_ module.
     % The timestamp is only updated after actually analysing the module that
     % the `.analysis' file corresponds to.
+    %
+    % Header files share a timestamp file with their corresponding target code
+    % files.
+    %
 timestamp_extension(_, module_target_errors) = ".err_date".
 timestamp_extension(_, module_target_private_interface) = ".date0".
 timestamp_extension(_, module_target_long_interface) = ".date".
@@ -1313,6 +1320,8 @@
 timestamp_extension(_, module_target_il_code) = ".il_date".
 timestamp_extension(_, module_target_java_code) = ".java_date".
 timestamp_extension(_, module_target_erlang_code) = ".erl_date".
+timestamp_extension(Globals, module_target_erlang_header) =
+    timestamp_extension(Globals, module_target_erlang_code).
 timestamp_extension(_, module_target_asm_code(non_pic)) = ".s_date".
 timestamp_extension(_, module_target_asm_code(pic)) = ".pic_s_date".
 
@@ -1361,7 +1370,6 @@
         ; Target = module_target_short_interface
         ; Target = module_target_unqualified_short_interface
         ; Target = module_target_c_header(header_mh)
-        ; Target = module_target_erlang_header
         ; Target = module_target_xml_doc
         ),
         IsDependent = no
@@ -1375,6 +1383,7 @@
         ; Target = module_target_java_code
         ; Target = module_target_erlang_code
         ; Target = module_target_erlang_beam_code
+        ; Target = module_target_erlang_header
         ; Target = module_target_asm_code(_)
         ; Target = module_target_object_code(_)
         ; Target = module_target_foreign_object(_, _)
@@ -1416,6 +1425,13 @@
 write_dependency_file(dep_file(FileName, _), !IO) :-
     io.write_string(FileName, !IO).
 
+write_dependency_file_list([], !IO).
+write_dependency_file_list([DepFile | DepFiles], !IO) :-
+    io.write_string("\t", !IO),
+    write_dependency_file(DepFile, !IO),
+    io.nl(!IO),
+    write_dependency_file_list(DepFiles, !IO).
+
 write_target_file(TargetFile, !IO) :-
     TargetFile = target_file(ModuleName, FileType),
     module_target_to_file_name(ModuleName, FileType, no, FileName, !IO),
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.437
diff -u -r1.437 modules.m
--- compiler/modules.m	20 Aug 2007 03:36:02 -0000	1.437
+++ compiler/modules.m	28 Aug 2007 05:29:15 -0000
@@ -943,6 +943,7 @@
             ( Ext = ".mih"
             ; Ext = ".mih.tmp"
             ; Ext = ".hrl"
+            ; Ext = ".hrl.tmp"
             )
         )
     ->

--------------------------------------------------------------------------
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