[m-rev.] diff: --make-xml-doc and mmc --make

Julien Fischer juliensf at csse.unimelb.edu.au
Thu Nov 23 17:07:59 AEDT 2006


Estimated hours taken: 1.5
Branches: main

Being integrating the recently add `--make-xml-doc' functionality into
mmc --make.

compiler/make.dependencies.m:
compiler/make.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
 	Add support for a .doc target that builds files containg the XML
 	representation of the local modules reachable from a specified
 	target, e.g.  `mmc --make mer_std.doc' could be used to generate
 	XML files for the standard library modules.

compiler/modules.m:
 	Delete some leftover Aditi stuff.

 	Delete an old out-of-date comment: the compiler no longer generates
 	.h files.

 	Fix the formatting of some comments.

compiler/xml_documentation.m:
 	Put the .xml files in Mercury/xmls if we are compiling if
 	--use-subdirs is enabled.

Julien.

Index: compiler/make.dependencies.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make.dependencies.m,v
retrieving revision 1.33
diff -u -r1.33 make.dependencies.m
--- compiler/make.dependencies.m	23 Nov 2006 04:03:42 -0000	1.33
+++ compiler/make.dependencies.m	23 Nov 2006 04:16:12 -0000
@@ -257,6 +257,13 @@
      get_foreign_deps(Globals, PIC).
  target_dependencies(Globals, module_target_fact_table_object(PIC, _)) =
      get_foreign_deps(Globals, PIC).
+target_dependencies(_, module_target_xml_doc) = 
+    combine_deps_list([
+        module_target_source `of` self,
+        module_target_private_interface `of` parents,
+        module_target_long_interface `of` non_intermod_direct_imports,
+        module_target_short_interface `of` non_intermod_indirect_imports
+    ]).

  :- func get_foreign_deps(globals::in, pic::in) =
      (find_module_deps(dependency_file)::out(find_module_deps)) is det.
Index: compiler/make.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make.m,v
retrieving revision 1.41
diff -u -r1.41 make.m
--- compiler/make.m	23 Nov 2006 04:03:42 -0000	1.41
+++ compiler/make.m	23 Nov 2006 04:30:04 -0000
@@ -176,7 +176,8 @@
      ;       task_make_private_interface
      ;       task_make_optimization_interface
      ;       task_make_analysis_registry
-    ;       task_compile_to_target_code.
+    ;       task_compile_to_target_code
+    ;       task_make_xml_doc.

  :- type module_target_type
      --->    module_target_source
@@ -196,7 +197,8 @@
      ;       module_target_object_code(pic)
      ;       module_target_foreign_il_asm(foreign_language)
      ;       module_target_foreign_object(pic, foreign_language)
-    ;       module_target_fact_table_object(pic, file_name).
+    ;       module_target_fact_table_object(pic, file_name)
+    ;       module_target_xml_doc.

  :- type c_header_type
      --->    header_mh      % For `:- pragma export' declarations.
@@ -210,7 +212,8 @@
      ;       misc_target_build_all(module_target_type)
      ;       misc_target_build_analyses
      ;       misc_target_build_library
-    ;       misc_target_install_library.
+    ;       misc_target_install_library
+    ;       misc_target_build_xml_docs.

  :- type file_timestamps == map(string, maybe_error(timestamp)).

@@ -347,7 +350,7 @@
          string.length(FileName, NameLength),
          search_backwards_for_dot(FileName, NameLength - 1, DotLocn),
          string.split(FileName, DotLocn, ModuleNameStr0, Suffix),
-        solutions.solutions(classify_target_2(Globals, ModuleNameStr0, Suffix),
+        solutions(classify_target_2(Globals, ModuleNameStr0, Suffix),
              TargetFiles),
          TargetFiles = [TargetFile]
      ->
@@ -426,6 +429,11 @@
          ModuleNameStr = ModuleNameStr1,
          TargetType = misc_target(misc_target_install_library)
      ;
+        Suffix = ".doc"
+    ->
+        ModuleNameStr = ModuleNameStr0,
+        TargetType = misc_target(misc_target_build_xml_docs)
+    ;
          fail
      ),
      file_name_to_module_name(ModuleNameStr, ModuleName).
Index: compiler/make.module_target.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make.module_target.m,v
retrieving revision 1.49
diff -u -r1.49 make.module_target.m
--- compiler/make.module_target.m	23 Nov 2006 04:03:42 -0000	1.49
+++ compiler/make.module_target.m	23 Nov 2006 04:19:00 -0000
@@ -503,6 +503,7 @@
  forkable_module_compilation_task_type(task_make_optimization_interface) = yes.
  forkable_module_compilation_task_type(task_make_analysis_registry) = yes.
  forkable_module_compilation_task_type(task_compile_to_target_code) = yes.
+forkable_module_compilation_task_type(task_make_xml_doc) = yes.

  %-----------------------------------------------------------------------------%

@@ -713,6 +714,8 @@
      foreign_code_to_object_code(PIC, Lang) - get_pic_flags(PIC).
  compilation_task(_, module_target_fact_table_object(PIC, FactTable)) =
      fact_table_code_to_object_code(PIC, FactTable) - get_pic_flags(PIC).
+compilation_task(_, module_target_xml_doc) = 
+    process_module(task_make_xml_doc) - ["--make-xml-doc"].

  :- func get_pic_flags(pic) = list(string).

@@ -855,6 +858,7 @@
          ; Task = task_make_private_interface
          ; Task = task_make_optimization_interface
          ; Task = task_make_analysis_registry
+        ; Task = task_make_xml_doc
          ),
          ForeignCodeFiles = [],
          TouchedTargetFiles = make_target_file_list(TargetModuleNames, FileType)
Index: compiler/make.program_target.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make.program_target.m,v
retrieving revision 1.59
diff -u -r1.59 make.program_target.m
--- compiler/make.program_target.m	23 Nov 2006 04:08:54 -0000	1.59
+++ compiler/make.program_target.m	23 Nov 2006 05:00:47 -0000
@@ -626,6 +626,20 @@
              LibSucceeded = no,
              Succeeded = no
          )
+    ;
+        TargetType = misc_target_build_xml_docs,
+        get_target_modules(module_target_xml_doc, AllModules,
+            TargetModules, !Info, !IO),
+        globals.io_lookup_bool_option(keep_going, KeepGoing, !IO),
+        ( Succeeded0 = no, KeepGoing = no ->
+            Succeeded = no
+        ;
+            foldl2_maybe_stop_at_error(KeepGoing,
+                make_module_target,
+                make_dependency_list(TargetModules, module_target_xml_doc),
+                Succeeded1, !Info, !IO),
+            Succeeded = Succeeded0 `and` Succeeded1
+        )
      ).

  :- pred build_analysis_files(module_name::in, list(module_name)::in,
@@ -730,7 +744,7 @@
  modules_needing_reanalysis(_, [], [], [], !IO).
  modules_needing_reanalysis(ReanalyseSuboptimal, [Module | Modules],
          InvalidModules, SuboptimalModules, !IO) :-
-    analysis.read_module_overall_status(mmc, module_name_to_module_id(Module),
+    read_module_overall_status(mmc, module_name_to_module_id(Module),
          MaybeModuleStatus, !IO),
      (
          MaybeModuleStatus = yes(ModuleStatus),
Index: compiler/make.util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make.util.m,v
retrieving revision 1.39
diff -u -r1.39 make.util.m
--- compiler/make.util.m	23 Nov 2006 04:03:43 -0000	1.39
+++ compiler/make.util.m	23 Nov 2006 04:21:09 -0000
@@ -824,6 +824,7 @@
  target_extension(_, module_target_asm_code(pic)) = yes(".pic_s").
  target_extension(Globals, module_target_object_code(PIC)) = yes(Ext) :-
      maybe_pic_object_file_extension(Globals, PIC, Ext).
+target_extension(_, module_target_xml_doc) = yes(".xml").

      % These all need to be handled as special cases.
  target_extension(_, module_target_foreign_object(_, _)) = no.
@@ -956,6 +957,7 @@
  search_for_file_type(module_target_foreign_object(_, _)) = no.
  search_for_file_type(module_target_foreign_il_asm(_)) = no.
  search_for_file_type(module_target_fact_table_object(_, _)) = no.
+search_for_file_type(module_target_xml_doc) = no.

  target_is_grade_or_arch_dependent(Target) :-
      is_target_grade_or_arch_dependent(Target) = yes.
@@ -971,6 +973,7 @@
          ; Target = module_target_short_interface
          ; Target = module_target_unqualified_short_interface
          ; Target = module_target_c_header(header_mh)
+        ; Target = module_target_xml_doc
          ),
          IsDependent = no
      ;
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.410
diff -u -r1.410 modules.m
--- compiler/modules.m	21 Nov 2006 05:39:10 -0000	1.410
+++ compiler/modules.m	23 Nov 2006 05:56:22 -0000
@@ -878,13 +878,11 @@
          (
              UseSubdirs = no
          ;
-            %
-            % If we're searching for (rather than writing)
-            % a `.mih' file, use the plain file name.
-            % This is so that searches for files in installed
-            % libraries will work.  `--c-include-directory' is
-            % set so that searches for files in the current
-            % directory will work.
+            % If we're searching for (rather than writing) a `.mih' file,
+            % use the plain file name.  This is so that searches for files
+            % in installed libraries will work.  `--c-include-directory' is
+            % set so that searches for files in the current directory will
+            % work.
              %
              Search = yes,
              ( Ext = ".mih"
@@ -895,21 +893,20 @@
          FileName = BaseName
      ;
          %
-        % the source files, the final executables,
-        % library files (including .init files)
-        % output files intended for use by the user,
-        % and phony Mmake targets names go in the current directory
+        % The source files, the final executables, library files (including
+        % .init files) output files intended for use by the user, and phony
+        % Mmake targets names go in the current directory
          %
          \+ (
              UseGradeSubdirs = yes,
              file_is_arch_or_grade_dependent(Globals, Ext)
          ),
          (
-            % executable files
+            % Executable files.
              ( Ext = ""
              ; Ext = ".exe"
              ; Ext = ".dll"
-            % library files
+            % Library files.
              ; Ext = ".a"
              ; Ext = ".$A"
              ; Ext = ".so"
@@ -934,24 +931,12 @@
                      % be in the same directory as the
                      % `.mh' files.
              ; Ext = ".mh.tmp"
-            ; Ext = ".h"    % `.h' files are being replaced with
-                    % `.mh' files (for the
-                    % `:- pragma export'  declarations),
-                    % and `.mih' files (for the high-level
-                    % C backend's function declarations).
-                    % We still generate the `.h' files
-                    % for bootstrapping (the trace
-                    % directory refers to std_util.h
-                    % and io.h).
-            ; Ext = ".h.tmp"
              ; Ext = ".err"
              ; Ext = ".ugly"
              ; Ext = ".hlds_dump"
              ; Ext = ".mlds_dump"
              ; Ext = ".dependency_graph"
              ; Ext = ".order"
-            ; Ext = ".rla"
-            ; Ext = ".rl_dump"
              % Mmake targets
              ; Ext = ".clean"
              ; Ext = ".realclean"
@@ -972,7 +957,8 @@
              ; Ext = ".trans_opts"
              )
          ;
-            % output files intended for use by the user
+            % Output files intended for use by the user.
+            %
              ( string.prefix(Ext, ".c_dump")
              ; string.prefix(Ext, ".mih_dump")
              )
@@ -981,7 +967,7 @@
          FileName = BaseName
      ;
          %
-        % we need to handle a few cases specially
+        % We need to handle a few cases specially.
          %
          (
              ( Ext = ".dir/*.o"
@@ -1027,8 +1013,7 @@
          ->
              SubDirName = "deps"
          ;
-            % the usual case: `*.foo' files go in the `foos'
-            % subdirectory
+            % The usual case: `*.foo' files go in the `foos' subdirectory.
              string.append(".", ExtName, Ext)
          ->
              string.append(ExtName, "s", SubDirName)
@@ -1139,12 +1124,11 @@
      (
          UseGradeSubdirs = yes,
          file_is_arch_or_grade_dependent(Globals, Ext),
-
          %
-        % If we're searching for (rather than writing) the file,
-        % just search in Mercury/<ext>s. This is so that searches
-        % for files in installed libraries work.
-        % `--intermod-directories' is set so this will work.
+        % If we're searching for (rather than writing) the file, just search
+        % in Mercury/<ext>s. This is so that searches for files in installed
+        % libraries work.  `--intermod-directories' is set so this will
+        % work.
          %
          \+ (
              Search = yes,
@@ -1158,11 +1142,11 @@
      ->
          grade_directory_component(Globals, Grade),

-        % The extra "Mercury" is needed so we can use
-        % `--intermod-directory Mercury/<grade>/<fullarch>' and
-        % `--c-include Mercury/<grade>/<fullarch>' to find
-        % the local `.opt' and `.mih' files without messing
-        % up the search for the files for installed libraries.
+        % The extra "Mercury" is needed so we can use `--intermod-directory
+        % Mercury/<grade>/<fullarch>' and `--c-include
+        % Mercury/<grade>/<fullarch>' to find the local `.opt' and `.mih'
+        % files without messing up the search for the files for installed
+        % libraries.
          DirName = "Mercury"/Grade/FullArch/"Mercury"/SubDirName
      ;
          DirName = "Mercury"/SubDirName
Index: compiler/xml_documentation.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/xml_documentation.m,v
retrieving revision 1.8
diff -u -r1.8 xml_documentation.m
--- compiler/xml_documentation.m	14 Nov 2006 04:02:40 -0000	1.8
+++ compiler/xml_documentation.m	23 Nov 2006 05:40:25 -0000
@@ -90,7 +90,7 @@

  xml_documentation(ModuleInfo, !IO) :-
      module_info_get_name(ModuleInfo, ModuleName),
-    module_name_to_file_name(ModuleName, ".xml", no, FileName, !IO),
+    module_name_to_file_name(ModuleName, ".xml", yes, FileName, !IO),

      lookup_module_source_file(ModuleName, SrcFileName, !IO),
      io.open_input(SrcFileName, SrcResult, !IO),
@@ -136,8 +136,7 @@
          svmap.set(LineNumber, line_type(Line), !C),
          build_comments(S, comments(!.C), comments(!:C), !IO)
      ;
-        LineResult = eof,
-        true
+        LineResult = eof
      ;
          LineResult = error(E),
              % XXX we should recover more gracefully from this error.

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