[m-rev.] diff: search directory where .m file is located when --generate-dependency-file

Peter Ross pro at missioncriticalit.com
Tue Nov 15 18:34:25 AEDT 2005


Hi,


===================================================================


Estimated hours taken: 0.5
Branches: main

--generate-dependency-file can be called on a file located in another
directory, so search that directory as well as the current directory when
determining the dependencies of that file.

compiler/modules.m:
	Replace the search path with the directory the file is located in,
	call generate_dependencies and then restore the search path.

Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.361
diff -u -r1.361 modules.m
--- compiler/modules.m	14 Nov 2005 20:05:39 -0000	1.361
+++ compiler/modules.m	15 Nov 2005 07:26:39 -0000
@@ -3985,19 +3985,23 @@
 
 generate_module_dependencies(ModuleName, !IO) :-
     map__init(DepsMap0),
-    generate_dependencies(output_all_dependencies, ModuleName, DepsMap0, !IO).
+    generate_dependencies(output_all_dependencies,
+        dir__this_directory, ModuleName, DepsMap0, !IO).
 
 generate_file_dependencies(FileName, !IO) :-
     build_deps_map(FileName, ModuleName, DepsMap, !IO),
-    generate_dependencies(output_all_dependencies, ModuleName, DepsMap, !IO).
+    generate_dependencies(output_all_dependencies,
+        dir__dirname(FileName), ModuleName, DepsMap, !IO).
 
 generate_module_dependency_file(ModuleName, !IO) :-
     map__init(DepsMap0),
-    generate_dependencies(output_d_file_only, ModuleName, DepsMap0, !IO).
+    generate_dependencies(output_d_file_only,
+        dir__this_directory, ModuleName, DepsMap0, !IO).
 
 generate_file_dependency_file(FileName, !IO) :-
     build_deps_map(FileName, ModuleName, DepsMap, !IO),
-    generate_dependencies(output_d_file_only, ModuleName, DepsMap, !IO).
+    generate_dependencies(output_d_file_only,
+        dir__dirname(FileName), ModuleName, DepsMap, !IO).
 
 :- pred build_deps_map(file_name::in, module_name::out, deps_map::out,
     io::di, io::uo) is det.
@@ -4021,6 +4025,21 @@
     .
 
 :- pred generate_dependencies(generate_dependencies_mode::in,
+    dir_name::in, module_name::in, deps_map::in,
+    io::di, io::uo) is det.
+
+generate_dependencies(Mode, DirName, ModuleName, DepsMap, !IO) :-
+        % Set the search path to be given directory.
+    globals__io_lookup_accumulating_option(search_directories, SearchDirs, !IO),
+    globals__io_set_option(search_directories, accumulating([DirName]), !IO),
+
+    generate_dependencies(Mode, ModuleName, DepsMap, !IO),
+
+        % Restore the search path.
+    globals__io_set_option(search_directories, accumulating(SearchDirs), !IO).
+
+
+:- pred generate_dependencies(generate_dependencies_mode::in,
     module_name::in, deps_map::in,
     io::di, io::uo) is det.
 
@@ -4347,7 +4366,7 @@
 generate_deps_map([Module | Modules], !DepsMap, !IO) :-
         % Look up the module's dependencies, and determine whether
         % it has been processed yet.
-    lookup_dependencies(Module, no, Done, !DepsMap, ModuleImports, !IO),
+    lookup_dependencies(Module, yes, Done, !DepsMap, ModuleImports, !IO),
         % If the module hadn't been processed yet, then add its
         % imports, parents, and public children to the list of
         % dependencies we need to generate, and mark it as


-- 
Software Engineer                                (Work)   +32 2 757 10 15
Mission Critical                                 (Mobile) +32 485 482 559
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list