[m-rev.] for review: improve handling of non-installed standard library

Simon Taylor stayl at cs.mu.OZ.AU
Sat Apr 20 00:58:48 AEST 2002


On 18-Apr-2002, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> On 17-Apr-2002, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> > 
> > Estimated hours taken: 6
> > Branches: main
> > 
> > Allow alternative locations for the standard library files 
> > to be specified using options to the various Mercury scripts
> > rather than environment variables.  This change is necessary
> > to allow the compiler to be compiled using `mmc --make', because
> > `mmc --make' does not support the environment variables.

With the changes below I'll commit this now.

Simon

Index: compiler/compile_target_code.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.4
diff -u -u -r1.4 compile_target_code.m
--- compiler/compile_target_code.m	20 Mar 2002 12:36:00 -0000	1.4
+++ compiler/compile_target_code.m	19 Apr 2002 12:26:04 -0000
@@ -673,6 +673,7 @@
 	globals__io_get_globals(Globals),
 	{ compute_grade(Globals, Grade) },
 
+	standard_library_directory_option(StdLibOpt),
 	globals__io_lookup_string_option(object_file_extension, Obj),
 	{ string__append("_init", Obj, InitObj) },
 	module_name_to_file_name(ModuleName, "_init.c", yes, InitCFileName),
@@ -695,11 +696,16 @@
 	globals__io_lookup_accumulating_option(init_files, InitFileNamesList),
 	{ join_string_list(InitFileNamesList, "", "", " ", InitFileNames) },
 
+	globals__io_lookup_accumulating_option(trace_init_files,
+		TraceInitFileNamesList),
+	{ join_string_list(TraceInitFileNamesList, "--trace-init-file ",
+		"", " ", TraceInitFileNames) },
+
 	{ TmpInitCFileName = InitCFileName ++ ".tmp" },
 	{ MkInitCmd = string__append_list(
-		["c2init --grade ", Grade, " ", TraceOpt, LinkFlags,
-		" --init-c-file ", TmpInitCFileName, " ",
-		InitFileDirs, " ", InitFileNames, " ", CFileNames]) },
+		["c2init --grade ", Grade, " ", TraceOpt, StdLibOpt, LinkFlags,
+		" --init-c-file ", TmpInitCFileName, " ", InitFileDirs, " ",
+		TraceInitFileNames, " ", InitFileNames, " ", CFileNames]) },
 	invoke_shell_command(ErrorStream, verbose, MkInitCmd, MkInitOK0),
 	maybe_report_stats(Stats),
 	( { MkInitOK0 = yes } ->
@@ -797,6 +803,7 @@
 		;
 			Target_Debug_Opt = ""
 		},
+		standard_library_directory_option(StdLibOpt),
 		{ join_string_list(ObjectsList, "", "", " ", Objects) },
 		globals__io_lookup_accumulating_option(link_flags,
 				LinkFlagsList),
@@ -812,7 +819,7 @@
 				LinkLibraries) },
 		{ string__append_list(
 			["ml --grade ", Grade, " ", SharedLibOpt,
-			Target_Debug_Opt, TraceOpt, LinkFlags,
+			Target_Debug_Opt, TraceOpt, StdLibOpt, LinkFlags,
 			" -o ", OutputFileName, " ", Objects, " ", 
 			LinkLibraryDirectories, " ", LinkLibraries],
 			LinkCmd) },
@@ -841,6 +848,25 @@
 	{ string__append_list(MakeLibCmdList, MakeLibCmd) },
 	invoke_system_command(ErrorStream, verbose_commands,
 		MakeLibCmd, MakeLibCmdOK).
+
+%-----------------------------------------------------------------------------%
+
+:- pred standard_library_directory_option(string, io__state, io__state).
+:- mode standard_library_directory_option(out, di, uo) is det.
+
+standard_library_directory_option(Opt) -->
+	globals__io_lookup_maybe_string_option(
+		mercury_standard_library_directory, MaybeStdLibDir),
+	{
+		MaybeStdLibDir = yes(StdLibDir),
+		Opt = "--mercury-standard-library-directory "
+				++ StdLibDir ++ " "
+	;
+		MaybeStdLibDir = no,
+		Opt = "--no-mercury-standard-library-directory "
+	}.
+
+%-----------------------------------------------------------------------------%
 
 	% join_string_list(Strings, Prefix, Suffix, Serarator, Result)
 	%
Index: tools/lmc
===================================================================
RCS file: /home/mercury1/repository/mercury/tools/lmc,v
retrieving revision 1.4
diff -u -u -r1.4 lmc
--- tools/lmc	26 Oct 2001 07:59:36 -0000	1.4
+++ tools/lmc	19 Apr 2002 14:21:37 -0000
@@ -28,8 +28,6 @@
 
 MERCURY_COMPILER=$WORKSPACE/compiler/mercury_compile
 export MERCURY_COMPILER
-MERCURY_INT_DIR=$WORKSPACE/library
-export MERCURY_INT_DIR
 
 if test ! -d $WORKSPACE
 then
@@ -49,18 +47,8 @@
 	echo "$WORKSPACE/boehm_gc does not have a gc library"
 fi
 
-MERCURY_LIBS="$WORKSPACE/trace/libmer_trace.a $WORKSPACE/browser/libmer_browser.a $WORKSPACE/library/libmer_std.a $WORKSPACE/runtime/libmer_rt.a $gclib -lm"
-export MERCURY_LIBS
-MERCURY_ALL_C_INCL_DIRS="-I$WORKSPACE/library -I$WORKSPACE/runtime -I$WORKSPACE/trace -I$WORKSPACE/boehm_gc -I$WORKSPACE/boehm_gc/include"
-export MERCURY_ALL_C_INCL_DIRS
-MMAKE_DIR=$WORKSPACE/scripts
-export MMAKE_DIR
-MERCURY_TRACE_LIB_MODS="$WORKSPACE/browser/mer_browser.init"
-export MERCURY_TRACE_LIB_MODS
-MERCURY_MOD_LIB_MODS="$WORKSPACE/library/mer_std.init $WORKSPACE/runtime/mer_rt.init"
-export MERCURY_MOD_LIB_MODS
-PATH="$WORKSPACE/scripts:$WORKSPACE/util:$PATH"
-export PATH
+LIB_FLAGS="--link-object $WORKSPACE/trace/libmer_trace.a --link-object $WORKSPACE/browser/libmer_browser.a --link-object $WORKSPACE/library/libmer_std.a --link-object $WORKSPACE/runtime/libmer_rt.a --link-object $gclib -lm"
+INIT_FLAGS="--trace-init-file $WORKSPACE/browser/mer_browse.init --init-file $WORKSPACE/library/mer_std.init --init-file $WORKSPACE/runtime/mer_rt.init"
 
 if test "$MMC_CDEBUG" != ""
 then
@@ -69,7 +57,7 @@
 	CDEBUG_FLAGS=""
 fi
 
-DIR_FLAGS="--cflags -I$WORKSPACE/trace --cflags -I$WORKSPACE/library --cflags -I$WORKSPACE/runtime --cflags -I$WORKSPACE/boehm_gc --cflags -I$WORKSPACE/boehm_gc/include -I$WORKSPACE/library"
+C_FLAGS="--c-include-directory $WORKSPACE/trace --c-include-directory $WORKSPACE/library --c-include-directory $WORKSPACE/runtime --c-include-directory $WORKSPACE/boehm_gc --c-include-directory $WORKSPACE/boehm_gc/include"
 
 if test "$MMC_UNDER_GDB" != ""
 then
@@ -77,4 +65,6 @@
 	export MERCURY_COMPILER
 fi
 
-mmc $CDEBUG_FLAGS $DIR_FLAGS "$@"
+PATH="$WORKSPACE/scripts:$WORKSPACE/util:$PATH"
+export PATH
+mmc --no-mercury-stdlib-dir -I $WORKSPACE/library $CDEBUG_FLAGS $C_FLAGS $INIT_FLAGS $LIB_FLAGS "$@"
--------------------------------------------------------------------------
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