[m-rev.] for review: fix mmc --make .module_dep bug

Peter Wang wangp at students.csse.unimelb.edu.au
Mon Nov 27 12:16:03 AEDT 2006


Estimated hours taken: 1.5
Branches: main

compiler/make.module_dep_file.m:
	Don't search for `module_dep' files in other directories for a module
	whose source file resides in the current directory.  This fixes a bug
	where `mmc --make' would think it had built some files that it hadn't,
	because there were installed modules in its search path with the same
	name.


Index: compiler/make.module_dep_file.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make.module_dep_file.m,v
retrieving revision 1.25
diff -u -r1.25 make.module_dep_file.m
--- compiler/make.module_dep_file.m	15 Oct 2006 23:26:44 -0000	1.25
+++ compiler/make.module_dep_file.m	11 Nov 2006 06:41:54 -0000
@@ -134,14 +134,18 @@
             ; compare((>), DepFileTimestamp, SourceFileTimestamp)
             )
         ->
-            read_module_dependencies(RebuildDeps, ModuleName, !Info, !IO)
+            % Since the source file was found in this directory, don't
+            % use module_dep files which might be for installed copies
+            % of the module.
+            read_module_dependencies_no_search(RebuildDeps, ModuleName,
+                !Info, !IO)
         ;
             make_module_dependencies(ModuleName, !Info, !IO)
         )
     ;
         MaybeSourceFileTimestamp = error(_),
         MaybeDepFileTimestamp = ok(DepFileTimestamp),
-        read_module_dependencies(RebuildDeps, ModuleName, !Info, !IO),
+        read_module_dependencies_search(RebuildDeps, ModuleName, !Info, !IO),
 
         %
         % Check for the case where the module name doesn't match
@@ -293,14 +297,27 @@
         io.set_exit_status(1, !IO)
     ).
 
-:- pred read_module_dependencies(bool::in, module_name::in,
+:- pred read_module_dependencies_search(bool::in, module_name::in,
+    make_info::in, make_info::out, io::di, io::uo) is det.
+
+read_module_dependencies_search(RebuildDeps, ModuleName, !Info, !IO) :-
+    globals.io_lookup_accumulating_option(search_directories, SearchDirs, !IO),
+    read_module_dependencies_2(RebuildDeps, SearchDirs, ModuleName,
+        !Info, !IO).
+
+:- pred read_module_dependencies_no_search(bool::in, module_name::in,
     make_info::in, make_info::out, io::di, io::uo) is det.
 
-read_module_dependencies(RebuildDeps, ModuleName, !Info, !IO) :-
+read_module_dependencies_no_search(RebuildDeps, ModuleName, !Info, !IO) :-
+    read_module_dependencies_2(RebuildDeps, [dir.this_directory], ModuleName,
+        !Info, !IO).
+
+:- pred read_module_dependencies_2(bool::in, list(dir_name)::in,
+    module_name::in, make_info::in, make_info::out, io::di, io::uo) is det.
+
+read_module_dependencies_2(RebuildDeps, SearchDirs, ModuleName, !Info, !IO) :-
     module_name_to_search_file_name(ModuleName, make_module_dep_file_extension,
         ModuleDepFile, !IO),
-    globals.io_lookup_accumulating_option(search_directories, SearchDirs,
-        !IO),
     io.input_stream(OldInputStream, !IO),
     search_for_file_returning_dir(SearchDirs, ModuleDepFile, SearchResult,
         !IO),
@@ -425,7 +442,7 @@
             % the top-level module in the source file).
             %
             SubRebuildDeps = no,
-            list.foldl2(read_module_dependencies(SubRebuildDeps),
+            list.foldl2(read_module_dependencies_2(SubRebuildDeps, SearchDirs),
                 NestedChildren, !Info, !IO),
             (
                 list.member(NestedChild, NestedChildren),
--------------------------------------------------------------------------
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