[m-rev.] diff: search include path for --generate-dependency-file

Peter Ross pro at missioncriticalit.com
Wed Nov 23 04:27:03 AEDT 2005


Hi,

With this patch  --generate-dependencies ignores the include search patch, but
--generate-dependency-file doesn't.                                                                                     
                                                                                                                        
What was the reason for --generate-dependencies to ignore the search path?                                              
This is the current behaviour.
                                                                                                                        
I have a suspicion that if it didn't I would be able to build multi-directory                                           
projects without all my work on --generate-dependency-file.                                                             
                                                          

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


Estimated hours taken: 0.25
Branches: main

The idea behind --generate-dependency-file was to use it in a situtation
where the source is spread over many directories but built in one
directory, for this to work then one needs to search the include path
when generating the dependency map.

compiler/modules.m:
    Search the include path for --generate-dependency-file, but not for
    --generate-dependencies, as this was the old behaviour.

Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.363
diff -u -r1.363 modules.m
--- compiler/modules.m	17 Nov 2005 15:57:24 -0000	1.363
+++ compiler/modules.m	22 Nov 2005 10:10:04 -0000
@@ -3982,24 +3982,28 @@
 %-----------------------------------------------------------------------------%
 
 generate_module_dependencies(ModuleName, !IO) :-
-    map__init(DepsMap0),
+    map__init(DepsMap),
+    SearchIncludePath = no,
     generate_dependencies(output_all_dependencies,
-        dir__this_directory, ModuleName, DepsMap0, !IO).
+        SearchIncludePath, ModuleName, DepsMap, !IO).
 
 generate_file_dependencies(FileName, !IO) :-
     build_deps_map(FileName, ModuleName, DepsMap, !IO),
+    SearchIncludePath = no,
     generate_dependencies(output_all_dependencies,
-        dir__dirname(FileName), ModuleName, DepsMap, !IO).
+        SearchIncludePath, ModuleName, DepsMap, !IO).
 
 generate_module_dependency_file(ModuleName, !IO) :-
-    map__init(DepsMap0),
+    map__init(DepsMap),
+    SearchIncludePath = yes,
     generate_dependencies(output_d_file_only,
-        dir__this_directory, ModuleName, DepsMap0, !IO).
+        SearchIncludePath, ModuleName, DepsMap, !IO).
 
 generate_file_dependency_file(FileName, !IO) :-
     build_deps_map(FileName, ModuleName, DepsMap, !IO),
+    SearchIncludePath = yes,
     generate_dependencies(output_d_file_only,
-        dir__dirname(FileName), ModuleName, DepsMap, !IO).
+        SearchIncludePath, ModuleName, DepsMap, !IO).
 
 :- pred build_deps_map(file_name::in, module_name::out, deps_map::out,
     io::di, io::uo) is det.
@@ -4022,28 +4026,13 @@
     ;       output_all_dependencies
     .
 
-:- 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,
+:- pred generate_dependencies(generate_dependencies_mode::in, bool::in,
     module_name::in, deps_map::in,
     io::di, io::uo) is det.
 
-generate_dependencies(Mode, ModuleName, DepsMap0, !IO) :-
+generate_dependencies(Mode, Search, ModuleName, DepsMap0, !IO) :-
     % First, build up a map of the dependencies.
-    generate_deps_map([ModuleName], DepsMap0, DepsMap, !IO),
+    generate_deps_map([ModuleName], Search, DepsMap0, DepsMap, !IO),
 
     %
     % Check whether we could read the main `.m' file.
@@ -4357,14 +4346,14 @@
     % (Module1 deps_rel Module2) means Module1 is imported by Module2.
 :- type deps_rel == relation(module_name).
 
-:- pred generate_deps_map(list(module_name)::in, deps_map::in, deps_map::out,
-    io::di, io::uo) is det.
+:- pred generate_deps_map(list(module_name)::in, bool::in,
+    deps_map::in, deps_map::out, io::di, io::uo) is det.
 
-generate_deps_map([], !DepsMap, !IO).
-generate_deps_map([Module | Modules], !DepsMap, !IO) :-
+generate_deps_map([], _, !DepsMap, !IO).
+generate_deps_map([Module | Modules], Search, !DepsMap, !IO) :-
         % Look up the module's dependencies, and determine whether
         % it has been processed yet.
-    lookup_dependencies(Module, yes, Done, !DepsMap, ModuleImports, !IO),
+    lookup_dependencies(Module, Search, 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
@@ -4390,7 +4379,7 @@
         Modules1 = Modules
     ),
         % Recursively process the remaining modules
-    generate_deps_map(Modules1, !DepsMap, !IO).
+    generate_deps_map(Modules1, Search, !DepsMap, !IO).
 
     % Construct a pair of dependency relations (the interface dependencies
     % and the implementation dependencies) for all the modules in the

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