mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-16 22:35:41 +00:00
Allow alternative locations for the standard library files
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. All of the Mercury scripts now accept an option `--mercury-standard-library-directory' to specify the installed library to use, or `--no-mercury-standard-library-directory' to disable the use of the installed library. The location of the alternate files to use can then be specified using ordinary options to the scripts. There is a new environment variable MERCURY_STDLIB_DIR, which has the same effect as the `--mercury-standard-library-directory' option. scripts/parse_ml_options.sh-subr.in: scripts/mgnuc.in: scripts/mmc.in: scripts/mmake.in: scripts/Mmake.vars.in: scripts/Mmake.rules: Handle MERCURY_STDLIB_DIR and `--mercury-standard-library-directory'. Remove support for the MERCURY_C_INCL_DIR, MERCURY_MOD_LIB_DIRS and MERCURY_TRACE_LIB_DIRS environment variables -- they aren't used anywhere. MERCURY_C_INCL_DIR is being removed because the assumption it makes (that all header files are installed into a single directory) will not hold for much longer because the generated header files for hl* grades are grade dependent. compiler/options.m: compiler/compile_target_code.m: Add an option `--trace-init-file', used to specify `.init' files which should only be used when tracing is enabled, such as browser/mer_browse.init. Allow `--mercury-stdlib-dir' as an abbreviation for `--mercury-standard-library-directory'. tools/lmc: Use options rather than environment variables. doc/user_guide.texi: Document MERCURY_STDLIB_DIR, MERCURY_TRACE_LIB_MODS and the `--trace-init-file' mmc option. Remove documentation for the no longer used MERCURY_C_INCL_DIR, MERCURY_MOD_LIB_DIRS, MERCURY_TRACE_LIB_DIRS and MERCURY_NC_BUILTIN environment variables.
This commit is contained in:
@@ -673,6 +673,7 @@ make_init_obj_file(ErrorStream, MustCompile, ModuleName,
|
||||
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 @@ make_init_obj_file(ErrorStream, MustCompile, ModuleName,
|
||||
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 @@ link(ErrorStream, LinkTargetType, ModuleName,
|
||||
;
|
||||
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 @@ link(ErrorStream, LinkTargetType, ModuleName,
|
||||
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) },
|
||||
@@ -842,6 +849,25 @@ create_archive(ErrorStream, LibFileName, ObjectList, MakeLibCmdOK) -->
|
||||
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)
|
||||
%
|
||||
% Appends the strings in the list `Strings' together into the
|
||||
|
||||
Reference in New Issue
Block a user