[m-rev.] for prelim review: "Recursive make considered harmful" support

Peter Ross pro at missioncriticalit.com
Wed Nov 9 09:09:10 AEDT 2005


Hi,

Rather than doing all the documentation for the new option, I thought I
would get some preliminary feedback for this diff.

For me I need to document the --generate-dependency-file flag and
MMAKE_USE_DS environment in the users guide.

Also do I need to add anywhere documentation about how to use these two
flags to do a build of source files spread over many directories?

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

Estimated hours taken: 4
Branches: main, release

Implement support for writing Mmakefile in the style of
"Recursive make considered harmful".

This consists of two parts, getting mmake to ignore the .d files in the
current directory.  The second part is adding support to the compiler to
write out just the .d file.

scripts/mmake.in:
	If the environment variable MMAKE_USE_DS is set to no then don't
	include the ds in the temporary Mmakefile.

compiler/mercury_compile.m:
	Add support for the --generate-dependency-file flag which just
	writes out the .d file for a module and then stops.

compiler/options.m:
	Add the generate_dependency_file option.

compiler/mercury_compile.m:
compiler/add_type.m:
compiler/handle_options.m:
	Make sure that generate_dependency_file implies that we don't
	need to build/link anything.
	


Index: scripts/mmake.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mmake.in,v
retrieving revision 1.46
diff -u -r1.46 mmake.in
--- scripts/mmake.in	11 Aug 2005 10:40:48 -0000	1.46
+++ scripts/mmake.in	8 Nov 2005 21:58:50 -0000
@@ -341,6 +341,11 @@
 	deps=
 fi
 
+use_ds=${MMAKE_USE_DS=yes}
+if [ "$use_ds" = "no" ] ; then
+	ds=
+fi
+
 if $verbose; then
 	echo MMAKE=$MMAKE
 	echo export MMAKE
Index: compiler/add_type.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/add_type.m,v
retrieving revision 1.8
diff -u -r1.8 add_type.m
--- compiler/add_type.m	28 Oct 2005 02:09:57 -0000	1.8
+++ compiler/add_type.m	8 Nov 2005 21:58:51 -0000
@@ -461,13 +461,14 @@
     io_lookup_bool_option(generate_source_file_mapping, GenSrcFileMapping,
         !IO),
     io_lookup_bool_option(generate_dependencies, GenDepends, !IO),
+    io_lookup_bool_option(generate_dependency_file, GenDependFile, !IO),
     io_lookup_bool_option(convert_to_mercury, ConvertToMercury, !IO),
     io_lookup_bool_option(typecheck_only, TypeCheckOnly, !IO),
     io_lookup_bool_option(errorcheck_only, ErrorCheckOnly, !IO),
     io_lookup_bool_option(output_grade_string, OutputGradeString, !IO),
     bool__or_list([MakeShortInterface, MakeInterface,
         MakePrivateInterface, MakeTransOptInterface,
-        GenSrcFileMapping, GenDepends, ConvertToMercury,
+        GenSrcFileMapping, GenDepends, GenDependFile, ConvertToMercury,
         TypeCheckOnly, ErrorCheckOnly, OutputGradeString],
         NotGeneratingCode).
 
Index: compiler/handle_options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.242
diff -u -r1.242 handle_options.m
--- compiler/handle_options.m	28 Oct 2005 02:10:07 -0000	1.242
+++ compiler/handle_options.m	8 Nov 2005 21:58:51 -0000
@@ -104,6 +104,8 @@
         Errors = [],
         globals__io_lookup_bool_option(generate_dependencies,
             GenerateDependencies, !IO),
+        globals__io_lookup_bool_option(generate_dependency_file,
+            GenerateDependencyFile, !IO),
         globals__io_lookup_bool_option(make_interface, MakeInterface, !IO),
         globals__io_lookup_bool_option(make_private_interface,
             MakePrivateInterface, !IO),
@@ -123,8 +125,8 @@
         GenerateIL = (if Target = il then yes else no),
         globals__io_lookup_bool_option(compile_only, CompileOnly, !IO),
         globals__io_lookup_bool_option(aditi_only, AditiOnly, !IO),
-        bool__or_list([GenerateDependencies, MakeInterface,
-            MakePrivateInterface, MakeShortInterface,
+        bool__or_list([GenerateDependencies, GenerateDependencyFile,
+            MakeInterface, MakePrivateInterface, MakeShortInterface,
             MakeOptimizationInt, MakeTransOptInt,
             ConvertToMercury, TypecheckOnly,
             ErrorcheckOnly, TargetCodeOnly,
@@ -711,6 +713,8 @@
         % for which smart recompilation will not work.
         %
         option_implies(generate_dependencies, smart_recompilation, bool(no),
+            !Globals),
+        option_implies(generate_dependency_file, smart_recompilation, bool(no),
             !Globals),
         option_implies(convert_to_mercury, smart_recompilation, bool(no),
             !Globals),
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.358
diff -u -r1.358 mercury_compile.m
--- compiler/mercury_compile.m	28 Oct 2005 14:00:33 -0000	1.358
+++ compiler/mercury_compile.m	8 Nov 2005 21:58:52 -0000
@@ -534,7 +534,8 @@
     globals__get_target(Globals, asm),
     % even if --target asm is specified,
     % it can be overridden by other options:
-    OptionList = [convert_to_mercury, generate_dependencies, make_interface,
+    OptionList = [convert_to_mercury, generate_dependencies,
+        generate_dependency_file, make_interface,
         make_short_interface, make_private_interface,
         make_optimization_interface, make_transitive_opt_interface,
         typecheck_only, errorcheck_only],
@@ -1415,7 +1416,6 @@
 
 mercury_compile(Module, NestedSubModules, FindTimestampFiles,
         FactTableObjFiles, !DumpInfo, !IO) :-
-    module_imports_get_module_name(Module, ModuleName),
     % If we are only typechecking or error checking, then we should not
     % modify any files, this includes writing to .d files.
     globals__io_lookup_bool_option(typecheck_only, TypeCheckOnly, !IO),
@@ -1423,6 +1423,43 @@
     bool__or(TypeCheckOnly, ErrorCheckOnly, DontWriteDFile),
     pre_hlds_pass(Module, DontWriteDFile, HLDS1, QualInfo, MaybeTimestamps,
         UndefTypes, UndefModes, Errors1, !DumpInfo, !IO),
+
+    globals__io_lookup_bool_option(generate_dependency_file, GenDepFile, !IO),
+    ( GenDepFile = no ->
+        mercury_compile_2(Module, NestedSubModules, FindTimestampFiles,
+            HLDS1, QualInfo, MaybeTimestamps,
+            UndefTypes, UndefModes, Errors1,
+            TypeCheckOnly, ErrorCheckOnly,
+            FactTableObjFiles, !DumpInfo, !IO)
+    ;
+        FactTableObjFiles = [],
+        ( Errors1 = yes ->
+            % If the number of errors is > 0, make sure that the compiler
+            % exits with a non-zero exit status.
+            io__get_exit_status(ExitStatus, !IO),
+            ( ExitStatus = 0 ->
+                io__set_exit_status(1, !IO)
+            ;
+                true
+            )
+        ;
+            true
+        )
+    ).
+
+:- pred mercury_compile_2(module_imports::in, list(module_name)::in,
+    find_timestamp_file_names::in(find_timestamp_file_names),
+    module_info::in,
+    make_hlds_qual_info::in, maybe(module_timestamps)::in,
+    bool::in, bool::in, bool::in,
+    bool::in, bool::in,
+    list(string)::out, dump_info::in, dump_info::out, io::di, io::uo) is det.
+
+mercury_compile_2(Module, NestedSubModules, FindTimestampFiles,
+        HLDS1, QualInfo, MaybeTimestamps, UndefTypes, UndefModes, Errors1,
+        TypeCheckOnly, ErrorCheckOnly,
+        FactTableObjFiles, !DumpInfo, !IO) :-
+    module_imports_get_module_name(Module, ModuleName),
     frontend_pass(QualInfo, UndefTypes, UndefModes, Errors1, Errors2,
         HLDS1, HLDS20, !DumpInfo, !IO),
     (
@@ -1437,6 +1474,7 @@
             MakeOptInt, !IO),
         globals__io_lookup_bool_option(make_transitive_opt_interface,
             MakeTransOptInt, !IO),
+
         ( TypeCheckOnly = yes ->
             FactTableObjFiles = []
         ; ErrorCheckOnly = yes ->
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.474
diff -u -r1.474 options.m
--- compiler/options.m	7 Nov 2005 05:42:07 -0000	1.474
+++ compiler/options.m	8 Nov 2005 21:58:53 -0000
@@ -144,6 +144,7 @@
     ;       make_optimization_interface
     ;       make_transitive_opt_interface
     ;       generate_source_file_mapping
+    ;       generate_dependency_file
     ;       generate_dependencies
     ;       generate_module_order
     ;       convert_to_mercury
@@ -871,6 +872,7 @@
 option_defaults_2(output_option, [
     % Output Options (mutually exclusive)
     generate_source_file_mapping        -   bool(no),
+    generate_dependency_file            -   bool(no),
     generate_dependencies               -   bool(no),
     generate_module_order               -   bool(no),
     make_short_interface                -   bool(no),
@@ -1565,6 +1567,7 @@
 % output options (mutually exclusive)
 long_option("generate-source-file-mapping",
                     generate_source_file_mapping).
+long_option("generate-dependency-file", generate_dependency_file).
 long_option("generate-dependencies",    generate_dependencies).
 long_option("generate-module-order",    generate_module_order).
 long_option("make-short-interface", make_short_interface).


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