[m-rev.] for review: improve support for using frameworks on Mac OS X
Julien Fischer
juliensf at csse.unimelb.edu.au
Wed Oct 6 13:21:14 AEDT 2010
For review by Ian.
Improve support for building and linking against frameworks on Mac OS X
by providing mmc command line options that allow which framework(s) to
build against to be specified directly.
compiler/options.m:
Add a new option, --framework, that causes an executable
or library to be linked against the framework specified
by the argument.
Add new option, --framework-directory, that appends a new
framework search directory to the current set of framework
search directories. (The short for of the option is -F;
the reason for using this is that if the linker emits warnings
about the framework search directories, then it will refer
to the option by that name.)
compiler/compile_target_code.m:
Pass the framework search directories to both the C compiler
and the linker. (They need to go the C compiler so that it
knows where to search for framework headers.)
Pass the list of frameworks to link against to the linker.
doc/user_guide.texi:
Document the new options.
NEWS:
Announce the addition.
Julien.
Index: NEWS
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/NEWS,v
retrieving revision 1.534
diff -u -r1.534 NEWS
--- NEWS 30 Sep 2010 16:03:15 -0000 1.534
+++ NEWS 6 Oct 2010 02:13:46 -0000
@@ -1,6 +1,9 @@
NEWS since Mercury 10.04
------------------------
+HIGHLIGHTS
+==========
+
Changes to the Mercury standard library:
* We have added semidet modes for array.foldl/4, array.foldl2/6,
@@ -13,6 +16,21 @@
to the predicates of the same name in the list module, but do the relevant
operations on keys instead of entire list elements.
+Changes to the Mercury compiler:
+
+* Support for building and linking against frameworks on Mac OS X has
+ been improved.
+
+
+DETAILED LISTING
+================
+
+Changes to the Mercury compiler:
+
+* We have added two new options, --framework and --framework-directory
+ (-F for short), in order to simplify building and linking against
+ frameworks on Mac OS X.
+
NEWS for Mercury 10.04.2
------------------------
Index: compiler/compile_target_code.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.160
diff -u -r1.160 compile_target_code.m
--- compiler/compile_target_code.m 30 Sep 2010 07:23:31 -0000 1.160
+++ compiler/compile_target_code.m 6 Oct 2010 02:13:46 -0000
@@ -437,6 +437,9 @@
C_Incl_Dirs),
InclOpt = string.append_list(list.condense(list.map(
(func(C_INCL) = ["-I", quote_arg(C_INCL), " "]), C_Incl_Dirs))),
+
+ get_framework_directories(Globals, FrameworkInclOpt),
+
globals.lookup_bool_option(Globals, highlevel_code, HighLevelCode),
(
HighLevelCode = yes,
@@ -889,7 +892,8 @@
% listed after CFLAGS.
%
string.append_list([
- SubDirInclOpt, InclOpt,
+ SubDirInclOpt, InclOpt, " ",
+ FrameworkInclOpt, " ",
OptimizeOpt, " ",
HighLevelCodeOpt,
NestedFunctionsOpt,
@@ -1885,6 +1889,9 @@
get_runtime_library_path_opts(Globals, LinkTargetType,
RpathFlagOpt, RpathSepOpt, RpathOpts),
+ % Set up any framework search paths.
+ get_framework_directories(Globals, FrameworkDirectories),
+
% Set up the install name for shared libraries.
globals.lookup_bool_option(Globals, shlib_linker_use_install_name,
UseInstallName),
@@ -1913,6 +1920,7 @@
globals.lookup_string_option(Globals, TraceFlagsOpt, TraceOpts)
),
+ get_frameworks(Globals, Frameworks),
get_link_libraries(Globals, MaybeLinkLibraries, !IO),
globals.lookup_string_option(Globals, linker_opt_separator, LinkOptSep),
(
@@ -1961,8 +1969,10 @@
LinkOptSep, " ",
LinkLibraryDirectories, " ",
RpathOpts, " ",
+ FrameworkDirectories, " ",
InstallNameOpt, " ",
DebugOpts, " ",
+ Frameworks, " ",
LDFlags, " ",
LinkLibraries, " ",
MercuryStdLibs, " ",
@@ -2400,6 +2410,34 @@
MadeSymlinkOrCopy = no
).
+:- pred get_framework_directories(globals::in, string::out) is det.
+
+get_framework_directories(Globals, FrameworkDirs) :-
+ globals.lookup_accumulating_option(Globals, framework_directories,
+ FrameworkDirs0),
+ (
+ % Short-circuit the common case.
+ FrameworkDirs0 = [],
+ FrameworkDirs = ""
+ ;
+ FrameworkDirs0 = [_ | _],
+ join_quoted_string_list(FrameworkDirs0, "-F", "", " ", FrameworkDirs)
+ ).
+
+:- pred get_frameworks(globals::in, string::out) is det.
+
+get_frameworks(Globals, FrameworkOpts) :-
+ globals.lookup_accumulating_option(Globals, frameworks, Frameworks),
+ (
+ % Short-circuit the common case.
+ Frameworks = [],
+ FrameworkOpts = ""
+ ;
+ Frameworks = [_ | _],
+ join_quoted_string_list(Frameworks, "-framework ", "", " ",
+ FrameworkOpts)
+ ).
+
:- pred same_timestamp(string::in, string::in, bool::out, io::di, io::uo)
is det.
Index: compiler/options.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.677
diff -u -r1.677 options.m
--- compiler/options.m 30 Sep 2010 07:23:31 -0000 1.677
+++ compiler/options.m 6 Oct 2010 02:13:46 -0000
@@ -868,6 +868,8 @@
; use_readline
; runtime_flags
; extra_initialization_functions
+ ; frameworks
+ ; framework_directories
% Auto-configured options.
; shared_library_extension
@@ -1721,6 +1723,8 @@
use_readline - bool(yes),
runtime_flags - accumulating([]),
extra_initialization_functions - bool(no),
+ frameworks - accumulating([]),
+ framework_directories - accumulating([]),
shared_library_extension - string(".so"),
% The `mmc' script will override the
@@ -1834,6 +1838,7 @@
short_option('e', errorcheck_only).
short_option('E', verbose_errors).
short_option('f', generate_source_file_mapping).
+short_option('F', framework_directories).
short_option('h', help).
short_option('H', highlevel_code).
short_option('i', make_interface).
@@ -2635,6 +2640,9 @@
long_option("extra-initialization-functions",
extra_initialization_functions).
long_option("extra-inits", extra_initialization_functions).
+long_option("framework", frameworks).
+long_option("framework-directory", framework_directories).
+
long_option("shared-library-extension", shared_library_extension).
long_option("library-extension", library_extension).
long_option("executable-file-extension", executable_file_extension).
@@ -5406,7 +5414,14 @@
"\ta shared library.",
"--java-archive-command <command>",
- "\tSpecify the command used to produce Java archive (JAR) files."
+ "\tSpecify the command used to produce Java archive (JAR) files.",
+
+ "--framework <framework>",
+ "\tBuild and link against the specified framework.",
+ "\t(Mac OS X only.)",
+ "-F <directory>, --framework-directory <directory>",
+ "\tAppend the specified directory to the framework search path.",
+ "\t(Mac OS X only.)"
% The --shared-library-extension,
% --library-extension, --executable-file-extension
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.612
diff -u -r1.612 user_guide.texi
--- doc/user_guide.texi 30 Sep 2010 07:23:32 -0000 1.612
+++ doc/user_guide.texi 6 Oct 2010 02:13:46 -0000
@@ -9772,6 +9772,24 @@
@findex --java-archive-command
Specify the command used to produce Java archive (JAR) files.
+ at sp 1
+ at item --framework @var{framework}
+ at findex --framework
+ at cindex Mac OS X, Using Frameworks
+Build and link against the specified framework.
+(Mac OS X only.)
+
+ at sp 1
+ at item -F @var{directory}
+ at itemx --framework-directory @var{directory}
+ at findex -F
+ at findex --framework-directory
+ at cindex Directories for libraries
+ at cindex Search path for libraries
+ at cindex Mac OS X, Using Frameworks
+Append the specified directory to the framework search path.
+(Mac OS X only.)
+
@end table
@c ----------------------------------------------------------------------------
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list