[m-rev.] diff: don't pass DEFAULT_MCFLAGS twice

Simon Taylor stayl at cs.mu.OZ.AU
Fri May 3 16:52:58 AEST 2002


Estimated hours taken: 2
Branches: main

Don't pass the default options twice when `mmc --make' invokes mmc.

compiler/options.m:
	Add an option `--invoked-by-mmc-make', which is passed
	to mmc by `mmc --make' to disable reading the default
	options and generation of `.d' files.

	Remove the `--generate-mmake-module-dependencies' option.
	It's functionality is subsumed by `--invoked-by-mmc-make'.	

compiler/make.util.m:
	Pass `--invoked-by-mmc-make' to mmc.

compiler/mercury_compile.m:
compiler/handle_options.m:
	Handle `--invoked-by-mmc-make'.

	When computing the option arguments to pass to make__make_targets,
	don't include the DEFAULT_MCFLAGS.

Index: handle_options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.138
diff -u -u -r1.138 handle_options.m
--- handle_options.m	15 Apr 2002 05:04:02 -0000	1.138
+++ handle_options.m	2 May 2002 18:47:15 -0000
@@ -17,7 +17,7 @@
 :- module libs__handle_options.
 
 :- interface.
-:- import_module list, bool, std_util, io.
+:- import_module list, bool, getopt, std_util, io.
 :- import_module libs__globals, libs__options.
 
 	% handle_options(Args, MaybeError, OptionArgs, NonOptionArgs, Link).
@@ -25,6 +25,15 @@
 		list(string), bool, io__state, io__state).
 :- mode handle_options(in, out, out, out, out, di, uo) is det.
 
+	% process_options(Args, OptionArgs, NonOptionArgs, MaybeOptionTable).
+	%
+	% Process the options, but don't do any post-processing or
+	% modify the globals. This is mainly useful for separating
+	% the list of arguments into option and non-option arguments.
+:- pred process_options(list(string), list(string), list(string),
+			maybe_option_table(option)).
+:- mode process_options(in, out, out, out) is det.
+
 	% usage_error(Descr, Message)
 	%
 	% Display the description of the error location, the error message
@@ -59,17 +68,12 @@
 :- import_module libs__options, libs__globals, parse_tree__prog_io_util.
 :- import_module libs__trace_params, check_hlds__unify_proc.
 :- import_module parse_tree__prog_data, backend_libs__foreign.
-:- import_module char, dir, int, string, map, set, getopt, library.
+:- import_module char, dir, int, string, map, set, library.
 
 handle_options(Args0, MaybeError, OptionArgs, Args, Link) -->
 	% io__write_string("original arguments\n"),
 	% dump_arguments(Args0),
-	{ OptionOps = option_ops(short_option, long_option,
-		option_defaults, special_handler) },
-	% default to optimization level `-O2'
-	{ Args1 = ["-O2" | Args0] },
-	{ getopt__process_options(OptionOps, Args1,
-		OptionArgs, Args, Result) },
+	{ process_options(Args0, OptionArgs, Args, Result) },
 	% io__write_string("final arguments\n"),
 	% dump_arguments(Args),
 	postprocess_options(Result, MaybeError),
@@ -118,6 +122,14 @@
 		)
 	).
 
+process_options(Args0, OptionArgs, Args, Result) :-
+	OptionOps = option_ops(short_option, long_option,
+		option_defaults, special_handler),
+	% default to optimization level `-O2'
+	Args1 = ["-O2" | Args0],
+	getopt__process_options(OptionOps, Args1,
+		OptionArgs, Args, Result).
+
 :- pred dump_arguments(list(string), io__state, io__state).
 :- mode dump_arguments(in, di, uo) is det.
 
@@ -511,6 +523,13 @@
 	% --rebuild is just like --make but always rebuilds the files
 	% without checking timestamps.
 	option_implies(rebuild, make, bool(yes)),
+
+	% --make handles creation of the module dependencies itself,
+	% and they don't need to be recreated when compiling to C.
+	option_implies(invoked_by_mmc_make,
+		generate_mmc_make_module_dependencies, bool(no)),
+	option_implies(invoked_by_mmc_make, make, bool(no)),
+	option_implies(invoked_by_mmc_make, rebuild, bool(no)),
 
 	% --make does not handle --transitive-intermodule-optimization.
 	% --transitive-intermodule-optimization is in the process of
Index: make.util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.util.m,v
retrieving revision 1.4
diff -u -u -r1.4 make.util.m
--- make.util.m	24 Apr 2002 08:42:35 -0000	1.4
+++ make.util.m	3 May 2002 06:30:16 -0000
@@ -271,13 +271,12 @@
 		{ OptionsResult = yes(OptionArgs) }, 
 		globals__io_get_globals(Globals),
 
-		% --no-generate-mmake-module-dependencies disables
-		% generation of `.d' files.
-		{ AllOptionArgs = list__condense(
-		    [["--no-generate-mmake-module-dependencies" | OptionArgs],
-		    Info0 ^ option_args, ExtraOptions,
-		    ["--no-make", "--no-rebuild"]]) },
-	    	
+		% --invoked-by-mmc-make disables reading DEFAULT_MCFLAGS
+		% from the environment (DEFAULT_MCFLAGS is included in
+		% OptionArgs) and generation of `.d' files.
+		{ AllOptionArgs = list__condense([
+		    ["--invoked-by-mmc-make" | OptionArgs],
+		    Info0 ^ option_args, ExtraOptions]) },
 		handle_options(AllOptionArgs, OptionsError, _, _, _),
 		(
 			{ OptionsError = yes(OptionsMessage) },
Index: mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.247
diff -u -u -r1.247 mercury_compile.m
--- mercury_compile.m	19 Apr 2002 12:14:06 -0000	1.247
+++ mercury_compile.m	3 May 2002 06:41:09 -0000
@@ -126,15 +126,32 @@
 
 	% Lookup the the default options in the
 	% environment (set by the mmc script).
-	lookup_default_options(options_variables_init, MaybeMCFlags),
+	( { Args0 = ["--invoked-by-mmc-make" | _] } ->
+		{ MaybeMCFlags = yes([]) }
+	;
+		lookup_default_options(options_variables_init, MaybeMCFlags)
+	),
 	(
-	    { MaybeMCFlags = yes(MCFlags) },
-	    handle_options(MCFlags ++ Args0, MaybeError,
-	    	OptionArgs, NonOptionArgs, Link),
-	    main_2(MaybeError, OptionArgs, NonOptionArgs, Link)
+		{ MaybeMCFlags = yes(MCFlags) },
+		handle_options(MCFlags ++ Args0, MaybeError,
+	    		OptionArgs0, NonOptionArgs, Link),
+		
+		%
+		% When computing the option arguments to pass
+		% to `--make', only include the command-line
+		% arguments, not the contents of DEFAULT_MCFLAGS.
+		%
+		globals__io_lookup_bool_option(make, Make),
+		{ Make = yes ->
+			process_options(Args0, OptionArgs, _, _)
+		;
+			% OptionArgs is only used with `--make'.
+			OptionArgs = OptionArgs0
+		},
+		main_2(MaybeError, OptionArgs, NonOptionArgs, Link)
 	;
-	    { MaybeMCFlags = no },
-	    io__set_exit_status(1)
+		{ MaybeMCFlags = no },
+		io__set_exit_status(1)
 	).
 
 main(Args) -->
@@ -1237,9 +1254,8 @@
 		UndefTypes, UndefModes, FoundError) -->
 	globals__io_lookup_bool_option(statistics, Stats),
 	globals__io_lookup_bool_option(verbose, Verbose),
-	globals__io_lookup_bool_option(generate_mmake_module_dependencies,
-		WriteDFile),
-	{ DontWriteDFile = DontWriteDFile0 `or` not(WriteDFile) },
+	globals__io_lookup_bool_option(invoked_by_mmc_make, MMCMake),
+	{ DontWriteDFile = DontWriteDFile0 `or` MMCMake },
 
 	{ module_imports_get_module_name(ModuleImports0, Module) },
 
Index: options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.368
diff -u -u -r1.368 options.m
--- options.m	19 Apr 2002 14:59:24 -0000	1.368
+++ options.m	3 May 2002 06:42:36 -0000
@@ -119,7 +119,6 @@
 				% and cannot be set explicitly by the user.
 		;	generate_item_version_numbers
 		;	generate_mmc_make_module_dependencies
-		;	generate_mmake_module_dependencies
 		;	assume_gmake
 		;	trace
 		;	trace_optimized
@@ -539,6 +538,7 @@
 		;	make
 		;	keep_going
 		;	rebuild
+		;	invoked_by_mmc_make
 		;	install_prefix
 		;	install_command
 		;	libgrades
@@ -667,7 +667,6 @@
 	smart_recompilation	-	bool(no),
 	generate_item_version_numbers -	bool(no),
 	generate_mmc_make_module_dependencies - bool(no),
-	generate_mmake_module_dependencies - bool(yes),
 	assume_gmake		-	bool(yes),
 	trace			-	string("default"),
 	trace_optimized		-	bool(no),
@@ -1069,6 +1068,7 @@
 	make			-	bool(no),
 	keep_going		-	bool(no),
 	rebuild			-	bool(no),
+	invoked_by_mmc_make	-	bool(no),
 	install_prefix		-	string("/usr/local/"),
 	install_command		-	string("cp"),
 	libgrades		-	accumulating([]),
@@ -1213,8 +1213,6 @@
 					generate_mmc_make_module_dependencies).
 long_option("generate-mmc-deps",
 					generate_mmc_make_module_dependencies).
-long_option("generate-mmake-module-dependencies",
-					generate_mmake_module_dependencies).
 long_option("trace",			trace).
 long_option("trace-optimised",		trace_optimized).
 long_option("trace-optimized",		trace_optimized).
@@ -1639,6 +1637,7 @@
 long_option("make",			make).
 long_option("keep-going",		keep_going).
 long_option("rebuild",			rebuild).
+long_option("invoked-by-mmc-make",	invoked_by_mmc_make).
 long_option("install-prefix",		install_prefix).
 long_option("install-command",		install_command).
 long_option("library-grade",		libgrades).
@@ -2262,9 +2261,6 @@
 		"\twhen using Mmake. This is recommended when building a",
 		"\tlibrary for installation.",
 
-		% --generate-mmake-module-dependencies is for internal
-		% use by the compiler.
-
 % declarative debugging is not documented yet, since it is still experimental
 %		"--trace {minimum, shallow, deep, decl, rep, default}",
 		"--trace {minimum, shallow, deep, default}",
@@ -3364,6 +3360,9 @@
 options_help_build_system -->
 	io__write_string("\nBuild System Options:\n"),
 	write_tabbed_lines([
+		% `--invoked-by-mmc-make' is for internal use by the
+		% compiler. `mmc --make' passes it as the first argument
+		% when compiling a module.
 		"-m, --make",
 		"\tTreat the non-option arguments to `mmc' as files to",
 		"\tmake, rather than source files.",
--------------------------------------------------------------------------
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