[m-rev.] for review: fix mer_std.init

Simon Taylor stayl at cs.mu.OZ.AU
Mon Jul 29 00:37:22 AEST 2002


Estimated hours taken: 1.5
Branches: main

Fix the code to add extra initialization functions to library/mer_std.init.

compiler/options.m:
doc/user_guide.texi:
compiler/compile_target_code.m:
	Rename the `--make-init-file-command' as `--extra-init-command'.
	This should now only generated the extra entries in the `.init'
	file, not the whole file.

scripts/Mmake.vars.in:
compiler/modules.m:
	Allow $(EXTRA_INIT_COMMAND) as the Mmake equivalent
	of `--extra-init-command'. Append the output of
	$(EXTRA_INIT_COMMAND) to the `.init' file.

library/Mmakefile:
	Set EXTRA_INIT_COMMAND rather than overriding the
	libmer_std.init rule.

Index: compiler/compile_target_code.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.16
diff -u -u -r1.16 compile_target_code.m
--- compiler/compile_target_code.m	6 Jul 2002 16:02:44 -0000	1.16
+++ compiler/compile_target_code.m	28 Jul 2002 11:05:05 -0000
@@ -639,16 +639,6 @@
 %-----------------------------------------------------------------------------%
 
 make_init_file(ErrorStream, MainModuleName, AllModules, Succeeded) -->
-    globals__io_lookup_maybe_string_option(make_init_file_command,
-		MaybeInitFileCommand),
-    (
-	{ MaybeInitFileCommand = yes(InitFileCommand0) },
-	{ InitFileCommand = substitute_user_command(InitFileCommand0,
-		MainModuleName, AllModules) },
-	invoke_shell_command(ErrorStream, verbose_commands,
-		InitFileCommand, Succeeded)
-    ;
-	{ MaybeInitFileCommand = no },
 	module_name_to_file_name(MainModuleName, ".init.tmp",
 		yes, TmpInitFileName),
 	io__open_output(TmpInitFileName, InitFileRes),
@@ -674,10 +664,25 @@
 				[]
 			)
 		    ), AllModules),
+		globals__io_lookup_maybe_string_option(extra_init_command,
+			MaybeInitFileCommand),
+		(
+			{ MaybeInitFileCommand = yes(InitFileCommand0) },
+			{ InitFileCommand = substitute_user_command(
+				InitFileCommand0, MainModuleName,
+				AllModules) },
+			invoke_shell_command(InitFileStream, verbose_commands,
+				InitFileCommand, Succeeded0)
+		;
+			{ MaybeInitFileCommand = no },
+			{ Succeeded0 = yes }
+		),
+
 		io__close_output(InitFileStream),
 		module_name_to_file_name(MainModuleName, ".init",
 			yes, InitFileName),
-		update_interface(InitFileName, Succeeded)
+		update_interface(InitFileName, Succeeded1),
+		{ Succeeded = Succeeded0 `and` Succeeded1 }
 	;
 		{ InitFileRes = error(Error) },
 		io__progname_base("mercury_compile", ProgName),
@@ -689,8 +694,7 @@
 		io__write_string(ErrorStream, io__error_message(Error)),
 		io__nl(ErrorStream),
 		{ Succeeded = no }
-	)
-    ).
+	).
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.240
diff -u -u -r1.240 modules.m
--- compiler/modules.m	23 Jul 2002 13:33:59 -0000	1.240
+++ compiler/modules.m	28 Jul 2002 09:09:11 -0000
@@ -4047,6 +4047,8 @@
 		"\techo > ", InitFileName, "\n"
 	]),
 	list__foldl(append_to_init_list(DepStream, InitFileName), Modules),
+	io__write_string(DepStream, "\t$(EXTRA_INIT_COMMAND) >> "),
+	io__write_string(DepStream, InitFileName),
 	io__write_string(DepStream, "\n"),
 
 	% The `force-module_init' dependency forces the commands for
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.377
diff -u -u -r1.377 options.m
--- compiler/options.m	22 Jul 2002 07:13:01 -0000	1.377
+++ compiler/options.m	28 Jul 2002 09:38:04 -0000
@@ -544,7 +544,7 @@
 		;	keep_going
 		;	rebuild
 		;	invoked_by_mmc_make
-		;	make_init_file_command
+		;	extra_init_command
 		;	pre_link_command
 		;	install_prefix
 		;	install_command
@@ -1086,7 +1086,7 @@
 	rebuild			-	bool(no),
 	invoked_by_mmc_make	-	bool(no),
 	pre_link_command	-	maybe_string(no),
-	make_init_file_command	-	maybe_string(no),
+	extra_init_command	-	maybe_string(no),
 	install_prefix		-	string("/usr/local/"),
 	install_command		-	string("cp"),
 	libgrades		-	accumulating([]),
@@ -1665,7 +1665,7 @@
 long_option("rebuild",			rebuild).
 long_option("invoked-by-mmc-make",	invoked_by_mmc_make).
 long_option("pre-link-command",		pre_link_command).
-long_option("make-init-file-command",	make_init_file_command).
+long_option("extra-init-command",	extra_init_command).
 long_option("install-prefix",		install_prefix).
 long_option("install-command",		install_command).
 long_option("library-grade",		libgrades).
@@ -3433,11 +3433,10 @@
 		"\treplaced with the list of modules making up the library.",
 		"\tOccurrences of `@@' and `%%' will be replaced with `@'",
 		"\tand `%' respectively.",
-		"--make-init-file-command <command>",
-		"\tSpecify an alternative command to produce the `.init' file",
-		"\tfor a library. Occurrences of `@' and `%' in the command",
+		"--extra-init-command <command>",
+		"\tSpecify a command to produce extra entries in the `.init'",
+		"\tfile for a library. Occurrences of `@' and `%' in the command",
 		"\tare substituted as for the `--pre-link-command' option.",
-		"\tBy default, `mmc --make' creates the `.init' file itself.",
 		"--install-prefix <dir>",
 		"\tThe directory under which to install Mercury libraries.",
 		"--install-command <command>",
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.314
diff -u -u -r1.314 user_guide.texi
--- doc/user_guide.texi	12 Jun 2002 14:26:55 -0000	1.314
+++ doc/user_guide.texi	28 Jul 2002 09:38:12 -0000
@@ -5634,12 +5634,11 @@
 Occurrences of @samp{@@@@} and @samp{%%} will be replaced
 with @samp{@@} and @samp{%} respectively.
 
- at item --make-init-file-command @var{command}
- at findex --make-init-file-command
-Specify an alternative command to produce the @file{.init} file
+ at item --extra-init-command @var{command}
+ at findex --extra-init-command
+Specify a command to produce extra entries in the @file{.init} file
 for a library. Occurrences of @samp{@@} and @samp{%} in the command
 are substituted as for the @samp{--pre-link-command} option.
-By default, @samp{mmc --make} creates the @samp{.init} file itself.
 
 @item -k
 @itemx --keep-going
Index: library/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/library/Mmakefile,v
retrieving revision 1.94
diff -u -u -r1.94 Mmakefile
--- library/Mmakefile	23 Jul 2002 08:26:21 -0000	1.94
+++ library/Mmakefile	28 Jul 2002 11:03:37 -0000
@@ -246,23 +246,19 @@
 
 ifeq ($(MMAKE_USE_MMC_MAKE),no)
 
-$(STD_LIB_NAME).init: $(deps_subdir)$(STD_LIB_NAME).dep
+EXTRA_INIT_COMMAND = \
 	for file in $($(STD_LIB_NAME).ms); do \
 		grep '^INIT ' $$file; \
-		echo "INIT mercury__`basename $$file .m`__init"; \
-	done > $(STD_LIB_NAME).init
-
+		true; \
+	done
 
 else
 
-# The command below is invoked as "command >& module.err". The braces
-# stop the output meant for the `.init' file being redirected to the
-# `.err' file.
-MCFLAGS += --make-init-file-command \
-		"{ for module in %; do \
+MCFLAGS += --extra-init-command \
+		"for module in %; do \
 			grep '^INIT ' $$$${module}.m; \
-			echo INIT mercury__$$$${module}__init; \
-		done > @.init; }"
+			true; \
+		done"
 endif
 
 endif	# GRADE != il
Index: scripts/Mmake.vars.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmake.vars.in,v
retrieving revision 1.75
diff -u -u -r1.75 Mmake.vars.in
--- scripts/Mmake.vars.in	15 Jul 2002 07:03:53 -0000	1.75
+++ scripts/Mmake.vars.in	28 Jul 2002 09:09:35 -0000
@@ -281,6 +281,7 @@
 C2INITARGS	=
 EXTRA_C2INITARGS =
 LIB_C2INITARGS	= $(patsubst %,%.init,$(ALL_EXTRA_LIBRARIES))
+EXTRA_INIT_COMMAND =
 
 # c2init and ml take the same arguments.
 C2INIT_AND_MLFLAGS = $(MLFLAGS) $(C2INITFLAGS) \
--------------------------------------------------------------------------
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