[m-rev.] for review: move mmc configuration into options file

Simon Taylor stayl at cs.mu.OZ.AU
Sat Mar 1 17:32:26 AEDT 2003


On 01-Mar-2003, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 01-Mar-2003, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> > 
> > Index: Mmake.workspace
> > ===================================================================
> > RCS file: /home/mercury1/repository/mercury/Mmake.workspace,v
> > retrieving revision 1.12
> > diff -u -u -r1.12 Mmake.workspace
> > --- Mmake.workspace	13 Feb 2003 08:28:42 -0000	1.12
> > +++ Mmake.workspace	17 Feb 2003 08:35:03 -0000
> > @@ -98,6 +98,8 @@
> >  
> >  VPATH =		$(LIBRARY_DIR)
> >  
> > +MCFLAGS +=	--config-file $(SCRIPTS_DIR)/Mercury.config
> 
> That should be commented out, as you said in the log message.

The log message was wrong - the compiler has accepted and ignored
`--config-file' since November last year.
 
> > Index: Mmakefile
> > ===================================================================
> > RCS file: /home/mercury1/repository/mercury/Mmakefile,v
> > retrieving revision 1.97
> > diff -u -u -r1.97 Mmakefile
> > --- Mmakefile	6 Feb 2003 17:05:02 -0000	1.97
> > +++ Mmakefile	28 Feb 2003 13:47:19 -0000
> > @@ -609,7 +609,9 @@
> >  .PHONY : bindist
> >  bindist: WORK_IN_PROGRESS TODO
> >  	cd bindist; \
> > -		PATH="$(INSTALL_PREFIX)/bin:$$PATH" mmake binary_distribution
> > +		PATH="$(INSTALL_PREFIX)/bin:$$PATH" \
> > +		MMAKE_DIR="$(INSTALL_MMAKE_DIR)" \
> > +		mmake -v binary_distribution
> 
> That one is not mentioned in the log message.

Fixed.

> > Index: bindist/Mmakefile
> > ===================================================================
> > RCS file: /home/mercury1/repository/mercury/bindist/Mmakefile,v
> > retrieving revision 1.38
> > diff -u -u -r1.38 Mmakefile
> > --- bindist/Mmakefile	24 Jan 2003 07:17:06 -0000	1.38
> > +++ bindist/Mmakefile	28 Feb 2003 15:19:29 -0000
> > @@ -8,6 +8,9 @@
> >  # You need to have already installed the Mercury compiler.
> >  
> >  MERCURY_DIR=..
> > +# Make sure we get a version of Mmake.vars with INSTALL_PREFIX
> > +# pointing to the configured installation directory.
> > +include $(MERCURY_DIR)/scripts/Mmake.vars
> >  include $(MERCURY_DIR)/Mmake.common
> 
> I think we should just set INSTALL_PREFIX in Mmake.common,
> like we used to do (as well as setting it in Mmake.vars).

Done.

> > Index: compiler/make.util.m
> > +	% build_with_module_options(ModuleName, ExtraArgs, Builder,
> > +	%	Succeeded, Info0, Info).
> > +	%
> >  	% Perform the given closure after updating the option_table in
> >  	% the globals in the io__state to contain the module-specific
> > -	% options for the specified module.
> > +	% options for the specified module and the extra options given
> > +	% in the ExtraArgs.
> > +	% Adds `--invoked-by-mmc-make' and `--use-subdirs' to the option
> > +	% list.
> >  :- pred build_with_module_options(module_name::in,
> >  	list(string)::in, build(list(string))::in(build), bool::out,
> >  	make_info::in, make_info::out, io__state::di, io__state::uo) is det.
> >  
> > +	% build_with_module_options(ModuleName, OptionsVariables,
> > +	%	OptionArgs, ExtraArgs, Builder, Succeeded, Info0, Info).
> > +	%
> > +	% Perform the given closure after updating the option_table in
> > +	% the globals in the io__state to contain the module-specific
> > +	% options for the specified module and the extra options given
> > +	% in ExtraArgs and OptionArgs 
> > +	% Does not add `--invoked-by-mmc-make' and `--use-subdirs'
> > +	% to the option list.
> > +:- pred build_with_module_options(module_name::in, options_variables::in,
> > +	list(string)::in, list(string)::in,
> > +	build(list(string), Info)::in(build),
> > +	bool::out, Info::in, Info::out, io__state::di, io__state::uo) is det.
> 
> The documentation for these two leaves it unclear as to whether or
> not the option_table in the final io__state returned from build_*
> is the same as in the initial io__state or not.

Fixed.
 
> > Index: compiler/options.m
> > ===================================================================
> > RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
> > retrieving revision 1.406
> > diff -u -u -r1.406 options.m
> > --- compiler/options.m	21 Feb 2003 01:54:38 -0000	1.406
> > +++ compiler/options.m	21 Feb 2003 02:57:37 -0000
> > @@ -1890,6 +1890,8 @@
> >  long_option("extra-init-command",	extra_init_command).
> >  long_option("mercury-configuration-directory",
> >  				mercury_configuration_directory_special).
> > +long_option("mercury-config-dir",
> > +				mercury_configuration_directory_special).
> >  long_option("install-prefix",		install_prefix).
> >  long_option("install-command",		install_command).
> >  long_option("library-grade",		libgrades).
> 
> The diff there doesn't match the log message.

Fixed.
 
> > Index: doc/user_guide.texi
> > ===================================================================
> > RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
> > retrieving revision 1.355
> > diff -u -u -r1.355 user_guide.texi
> > --- doc/user_guide.texi	21 Feb 2003 01:57:23 -0000	1.355
> > +++ doc/user_guide.texi	21 Feb 2003 02:57:43 -0000
> > @@ -6320,6 +6320,12 @@
> >  standard input.  By default the file @file{Mercury.options}
> >  in the current directory will be read.
> >  
> > + at item --config-file @var{file}
> > + at findex --config-file
> > +Read the Mercury compiler's configuration information from @var{file}.
> > +If the @samp{--config-file} option is not set, a default configuration
> > +will be used, unless @samp{--no-mercury-stdlib-dir} is passed to mmc.
> 
> There should be a cross-reference here to the place where the
> configuration file syntax is documented.

Done.

Simon.



Estimated hours taken: 20
Branches: main

Move the setting of configuration options from mmc.in to
an options file Mercury.config. This has a few advantages:
- reduces the duplication between mmc and mercury.bat
- reduces the chance of running out of environment space
  on crappy operating systems (although we probably exceed
  the command line length limits on those systems anyway).
- makes it easier to bootstrap changes which add new
  configuration options.

Always read the options files, even without `--make',
to avoid inconsistent behaviour.

scripts/Mercury.config.in:
	New file containing the configuration code from mmc.in.

configure.in:
	Create scripts/Mercury.config.

bindist/Mmakefile:
	Make sure Mercury.config.in goes in the binary distribution.

Mmakefile:
bindist/Mmakefile:
Mmake.common.in:
	Make sure we get the correct setting of INSTALL_PREFIX
	when building the binary distribution.

scripts/Mmakefile:
scripts/mercury_config.in:
bindist/bindist.Mmakefile.in:
	Install Mercury.config.

compiler/options.m:
doc/user_guide.texi:
	Add documentation for the `--config-file' option, which gives
	the name of the configuration file to read.

	Add an option `read-config-file-2003-03-01' which will be
	used in configure.in to test whether the compiler is up
	to date after the configuration code is removed from mmc.in
	(after this change is installed everywhere).

	Add `--mercury-config-dir' as an abbreviation for
	`--mercury-configuration-directory'.

Mmake.workspace:
	Use the configuration file in scripts/Mercury.config.

browser/Mmakefile:
compiler/Mmakefile:
scripts/Mmake.vars.in:
	Always pass ALL_MCFLAGS to mmc so that mmc will
	use the configuration file specified in the options.

compiler/handle_options.m:
	Handle the default value of `--config-file'.

compiler/mercury_compile.m:
	Read the configuration file.

diff -u compiler/make.util.m compiler/make.util.m
--- compiler/make.util.m
+++ compiler/make.util.m
@@ -56,6 +56,7 @@
 	% in the ExtraArgs.
 	% Adds `--invoked-by-mmc-make' and `--use-subdirs' to the option
 	% list.
+	% The old option table will be restored afterwards.
 :- pred build_with_module_options(module_name::in,
 	list(string)::in, build(list(string))::in(build), bool::out,
 	make_info::in, make_info::out, io__state::di, io__state::uo) is det.
@@ -69,6 +70,7 @@
 	% in ExtraArgs and OptionArgs 
 	% Does not add `--invoked-by-mmc-make' and `--use-subdirs'
 	% to the option list.
+	% The old option table will be restored afterwards.
 :- pred build_with_module_options(module_name::in, options_variables::in,
 	list(string)::in, list(string)::in,
 	build(list(string), Info)::in(build),
diff -u compiler/options.m compiler/options.m
--- compiler/options.m
+++ compiler/options.m
@@ -1915,6 +1915,7 @@
 long_option("bug-intermod-2002-06-13",	compiler_sufficiently_recent).
 long_option("bug-foreign_import-2002-08-06", compiler_sufficiently_recent).
 long_option("install-opt-files-2002-08-30", compiler_sufficiently_recent).
+long_option("read-config-file-2003-03-01", compiler_sufficiently_recent).
  
 %-----------------------------------------------------------------------------%
 
@@ -3937,6 +3938,7 @@
 		"\tfrom <file>.  If the `--config-file' option is not set,",
 		"\ta default configuration will be used, unless",
 		"\t`--no-mercury-stdlib-dir' is passed to mmc.",
+		"\tThe configuration file is just an options file.",
 		"-I <dir>, --search-directory <dir>",
 		"\tAppend <dir> to the list of directories to be searched for",
 		"\timported modules.",
diff -u doc/user_guide.texi doc/user_guide.texi
--- doc/user_guide.texi
+++ doc/user_guide.texi
@@ -860,12 +860,14 @@
 Note that @samp{--use-subdirs} is automatically enabled if you specify
 @samp{mmc --make}.
 
+ at cindex Options files
+ at cindex Mercury.options
 The Mmake variables above can be used by @samp{mmc --make} if they
 are set in a file called @file{Mercury.options}. The @file{Mercury.options}
 file has the same syntax as an Mmakefile, but only variable assignments and
 @samp{include} directives are allowed.  All variables in the Mercury.options
 are treated as if they are assigned using @samp{:=}. Variables may also
-be set in the environment.
+be set in the environment, overriding settings in options files.
 
 @samp{mmc --make} can be used in conjunction with Mmake. This is useful
 for projects which include source code written in languages other than
@@ -6315,16 +6317,21 @@
 @sp 1
 @item --options-file @var{file}
 @findex --options-file
+ at cindex Options files
+ at cindex Mercury.options
 Add @var{file} to the list of options files to be processed.
 If @var{file} is @samp{-}, an options file will be read from the
 standard input.  By default the file @file{Mercury.options}
 in the current directory will be read.
+See @ref{Using Mmake} for a description of the syntax of options files.
 
 @item --config-file @var{file}
 @findex --config-file
+ at cindex Options files
 Read the Mercury compiler's configuration information from @var{file}.
 If the @samp{--config-file} option is not set, a default configuration
 will be used, unless @samp{--no-mercury-stdlib-dir} is passed to mmc.
+The configuration file is just an options file (@pxref{Using Mmake}).
 
 @sp 1
 @item --options-search-directory @var{dir}
only in patch2:
--- Mmake.common.in	22 Oct 2002 14:55:14 -0000	1.68
+++ Mmake.common.in	1 Mar 2003 04:02:21 -0000
@@ -109,6 +109,12 @@
 # objects.
 SHARED_LIBS		= @SHARED_LIBS@
 
+# Set the installation prefix. This is done here as well as
+# in scripts/Mmake.vars to avoid accidentally overwriting an
+# existing installation when using an installed mmake.
+INSTALL_PREFIX		= @prefix@
+FINAL INSTALL_PREFIX	= @prefix@
+
 #-----------------------------------------------------------------------------#
 
 INSTALL_MERC_GC_LIB_DIR	= $(INSTALL_MERC_GRADELESS_LIB_DIR)
	Always read the options files, even without `--make',
	to avoid inconsistent behaviour.

compiler/make.m:
	Pass the variable settings from the configuration file
	to make__process_args.

	The options files have already been read in mercury_compile.m,
	so don't read them again here.

compiler/make.util.m:
	Add a version of build_with_module_options which doesn't
	need a make_info, for use by mercury_compile.m.

compiler/options_file.m:
	Export a predicate to read a single options file.

	Make the predicates to read options files add to an initial
	options_variables map, rather than always creating a new one.

	Allow MERCURY_STDLIB_DIR and MERCURY_CONFIG_DIR
	to be set in the options file or environment.

scripts/mmc.in:
	Set MERCURY_STDLIB_DIR and MERCURY_CONFIG_DIR in
	mercury_compile's environment.

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