[m-rev.] diff: add support for using libraries to mmc
Simon Taylor
stayl at cs.mu.OZ.AU
Sat Nov 10 05:20:23 AEDT 2001
Estimated hours taken: 1.5
Branches: main
Add support for using libraries installed by
`mmake liblibrary.install' directly from mmc.
This is needed for `mmc --make'.
compiler/options.m:
Add options:
* `--mercury-library-directory'
Adds `--search-directory', `--c-include-directory',
`--init-file-directory' and `--link-library-directory'
options for the specified Mercury installation directory.
* `--mercury-library'
Link with the specified library (passing it's
`.init' file to c2init).
* `--init-file-directory'
Directories to search for `.init' files.
* `--init-file'
Add a `.init' file to pass to c2init.
* `--fullarch'
Determined by configure.
compiler/handle_options.m:
Handle the grade dependent library search directories.
compiler/mercury_compile.m:
Pass the accumulated `--init-file' and `--init-file-directory'
options to c2init.
doc/user_guide.texi:
Documentation for the new options.
Index: compiler/handle_options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.120
diff -u -u -r1.120 handle_options.m
--- compiler/handle_options.m 8 Nov 2001 12:53:10 -0000 1.120
+++ compiler/handle_options.m 8 Nov 2001 15:31:55 -0000
@@ -47,7 +47,7 @@
:- import_module options, globals, prog_io_util, trace_params, unify_proc.
:- import_module prog_data, foreign.
-:- import_module char, int, string, map, set, getopt, library.
+:- import_module char, dir, int, string, map, set, getopt, library.
handle_options(MaybeError, Args, Link) -->
io__command_line_arguments(Args0),
@@ -721,6 +721,27 @@
[]
),
+ %
+ % Handle library search directories. These couldn't be handled
+ % by options.m because they are grade dependent.
+ %
+ globals__io_lookup_accumulating_option(mercury_library_directories,
+ MercuryLibDirs),
+ globals__io_lookup_string_option(fullarch, FullArch),
+ globals__io_get_globals(Globals),
+ { compute_grade(Globals, GradeString) },
+ { ExtraLinkLibDirs = list__map(
+ (func(MercuryLibDir) =
+ dir__make_path_name(MercuryLibDir,
+ dir__make_path_name("lib",
+ dir__make_path_name(GradeString,
+ FullArch)))
+ ), MercuryLibDirs) },
+ globals__io_lookup_accumulating_option(link_library_directories,
+ LinkLibDirs),
+ globals__io_set_option(link_library_directories,
+ accumulating(LinkLibDirs ++ ExtraLinkLibDirs)),
+
% If --use-search-directories-for-intermod is true, append the
% search directories to the list of directories to search for
% .opt files.
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.223
diff -u -u -r1.223 mercury_compile.m
--- compiler/mercury_compile.m 6 Nov 2001 15:20:54 -0000 1.223
+++ compiler/mercury_compile.m 9 Nov 2001 14:57:43 -0000
@@ -3777,9 +3777,21 @@
;
TraceOpt = ""
},
- join_module_list(Modules, ".c", ["-o ", InitCFileName], MkInitCmd0),
- { string__append_list(["c2init ", TraceOpt | MkInitCmd0],
- MkInitCmd) },
+
+ globals__io_lookup_accumulating_option(init_file_directories,
+ InitFileDirsList),
+ { join_string_list(InitFileDirsList, "-I ", "",
+ " ", InitFileDirs) },
+
+ globals__io_lookup_accumulating_option(init_files,
+ InitFileNamesList),
+ { join_string_list(InitFileNamesList, "", "",
+ " ", InitFileNames) },
+
+ join_module_list(Modules, ".c", [], CFileNames),
+ { MkInitCmd = string__append_list(
+ ["c2init ", TraceOpt, " -o ", InitCFileName, " ",
+ InitFileDirs, " ", InitFileNames, " " | CFileNames]) },
invoke_shell_command(MkInitCmd, MkInitOK),
maybe_report_stats(Stats),
( { MkInitOK = no } ->
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.340
diff -u -u -r1.340 options.m
--- compiler/options.m 3 Nov 2001 16:09:12 -0000 1.340
+++ compiler/options.m 9 Nov 2001 18:13:22 -0000
@@ -466,6 +466,12 @@
; link_library_directories
; link_libraries
; link_objects
+ ; mercury_library_directories
+ ; mercury_library_directory_special
+ ; mercury_libraries
+ ; mercury_library_special
+ ; init_file_directories
+ ; init_files
% Miscellaneous Options
; make
; keep_going
@@ -479,11 +485,14 @@
% "Auxiliary output options"
% section
; aditi_user
- ; help.
+ ; help
+ ; fullarch
+ .
:- implementation.
:- import_module string, bool, int, map, std_util, assoc_list, require, list.
+:- import_module dir.
:- import_module handle_options.
:- type option_category
@@ -911,7 +920,14 @@
link_flags - accumulating([]),
link_library_directories - accumulating([]),
link_libraries - accumulating([]),
- link_objects - accumulating([])
+ link_objects - accumulating([]),
+ mercury_library_directory_special -
+ string_special,
+ mercury_library_directories - accumulating([]),
+ mercury_library_special - string_special,
+ mercury_libraries - accumulating([]),
+ init_file_directories - accumulating([]),
+ init_files - accumulating([])
]).
option_defaults_2(miscellaneous_option, [
% Miscellaneous Options
@@ -926,7 +942,8 @@
use_subdirs - bool(no),
aditi - bool(no),
aditi_user - string(""),
- help - bool(no)
+ help - bool(no),
+ fullarch - string("")
]).
% please keep this in alphabetic order
@@ -1405,6 +1422,10 @@
long_option("library-directory", link_library_directories).
long_option("library", link_libraries).
long_option("link-object", link_objects).
+long_option("mercury-library", mercury_library_special).
+long_option("mercury-library-directory", mercury_library_directory_special).
+long_option("init-file-directory", init_file_directories).
+long_option("init-file", init_files).
% misc options
long_option("help", help).
@@ -1419,6 +1440,7 @@
long_option("use-subdirs", use_subdirs).
long_option("aditi", aditi).
long_option("aditi-user", aditi_user).
+long_option("fullarch", fullarch).
%-----------------------------------------------------------------------------%
@@ -1529,6 +1551,35 @@
N = N0
),
set_opt_level(N, OptionTable0, OptionTable).
+special_handler(mercury_library_directory_special, string(Dir),
+ OptionTable0, ok(OptionTable)) :-
+ % The link_library_directories for Mercury libraries are grade
+ % dependent, so they need to be handled in handle_options.m
+ % when we know the grade.
+ OptionTable =
+ list__foldl(append_to_accumulating_option, [
+ search_directories - dir__make_path_name(Dir, "ints"),
+ c_include_directory - dir__make_path_name(Dir, "inc"),
+ init_file_directories - dir__make_path_name(Dir, "modules"),
+ mercury_library_directories - Dir
+ ], OptionTable0).
+special_handler(mercury_library_special, string(Lib),
+ OptionTable0, ok(OptionTable)) :-
+ OptionTable =
+ list__foldl(append_to_accumulating_option, [
+ link_libraries - Lib,
+ mercury_libraries - Lib,
+ init_files - (Lib ++ ".init")
+ ], OptionTable0).
+
+:- func append_to_accumulating_option(pair(option, string),
+ option_table) = option_table.
+
+append_to_accumulating_option(Option - Value, OptionTable0) =
+ OptionTable0 ^ elem(Option) :=
+ accumulating(
+ getopt__lookup_accumulating_option(OptionTable0, Option)
+ ++ [Value]).
:- pred set_opt_level(int, option_table, option_table).
:- mode set_opt_level(in, in, out) is det.
@@ -2934,7 +2985,21 @@
"-l <library>, --library <library>",
"\tLink with the specified library.",
"--link-object <object-file>",
- "\tLink with the specified object file."
+ "\tLink with the specified object file.",
+ "--mercury-library-directory <directory>",
+ "\tAppend <directory> to the list of directories to",
+ "\tbe searched for Mercury libraries. This will add",
+ "\t`--search-directory', `--library-directory',",
+ "\t`--init-file-directory' and `--c-include-directory'",
+ "\toptions as needed.",
+ "--mercury-library <library>",
+ "\tLink with the specified Mercury library.",
+ "--init-file-directory <directory>",
+ "\tAppend <directory> to the list of directories to",
+ "\tbe searched for `.init' files by c2init.",
+ "--init-file <init-file>",
+ "\tAppend <init-file> to the list of `.init' files to",
+ "\tbe passed to c2init."
]).
:- pred options_help_misc(io__state::di, io__state::uo) is det.
@@ -2983,6 +3048,9 @@
"\tDefaults to the value of the `USER' environment",
"\tvariable. If `$USER' is not set, `--aditi-user'",
"\tdefaults to the string ""guest""."
+
+ % The `--fullarch' option is reserved for
+ % use by the mmc script.
]).
:- pred write_tabbed_lines(list(string), io__state, io__state).
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.275
diff -u -u -r1.275 user_guide.texi
--- doc/user_guide.texi 31 Oct 2001 17:53:26 -0000 1.275
+++ doc/user_guide.texi 9 Nov 2001 18:13:21 -0000
@@ -5594,7 +5594,8 @@
@findex --library-directory
@cindex Directories for libraries
@cindex Search path for libraries
-Append @var{dir} to the list of directories in which to search for libraries.
+Append @var{directory} to the list of directories in which
+to search for libraries.
@item -l @var{library}
@itemx --library @var{library}
@@ -5607,6 +5608,31 @@
@findex --link-object
@cindex Object files, linking with
Link with the specified object file.
+
+ at item --mercury-library-directory @var{directory}
+ at findex --mercury-library-directory
+ at cindex Directories for libraries
+ at cindex Search path for libraries
+Append @var{directory} to the list of directories to
+be searched for Mercury libraries. This will add
+ at samp{--search-directory}, @samp{--library-directory},
+ at samp{--init-file-directory} and @samp{--c-include-directory}
+options as needed.
+
+ at item --mercury-library @var{library}
+ at findex --mercury-library
+ at cindex Libraries, linking with
+Link with the specified Mercury library.
+
+ at item --init-file-directory @var{directory}
+ at findex --init-file-directory
+Append @var{directory} to the list of directories to
+be searched for @samp{.init} files by @samp{c2init}.
+
+ at item --init-file @var{file}
+ at findex --init-file
+Append @var{file} to the list of @samp{.init} files
+to be passed to @samp{c2init}.
@end table
--------------------------------------------------------------------------
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