From: stevenknight Date: Fri, 12 Aug 2005 11:58:49 +0000 (+0000) Subject: Add Framework support for Mac OS X. (Greg Noel) Document it. (Gary Oberbrunner) X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f0327c1f900f3c00cb5c7ad76a4e21611cb4fbac;p=scons.git Add Framework support for Mac OS X. (Greg Noel) Document it. (Gary Oberbrunner) git-svn-id: http://scons.tigris.org/svn/scons/trunk@1322 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/doc/man/scons.1 b/doc/man/scons.1 index 76fc7059..6e690a24 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -5711,11 +5711,66 @@ The default list is: A function that converts a file name into a File instance relative to the target being built. +.IP FRAMEWORKPATH +On Mac OS X with gcc, +a list containing the paths to search for frameworks. +Used by the compiler to find framework-style includes like +#include . +Used by the linker to find user-specified frameworks when linking (see +$FRAMEWORKS). +For example: +.ES + env.AppendUnique(FRAMEWORKPATH='#myframeworkdir') +.EE +.IP +will add +.ES + ... -Fmyframeworkdir +.EE +.IP +to the compiler and linker command lines. + +.IP _FRAMEWORKPATH +On Mac OS X with gcc, an automatically-generated construction variable +containing the linker command-line options corresponding to FRAMEWORKPATH. + +.IP FRAMEWORKPATHPREFIX +On Mac OS X with gcc, the prefix to be used for the FRAMEWORKPATH entries. +(see $FRAMEWORKPATH). +The default value is +.BR -F . + +.IP FRAMEWORKPREFIX +On Mac OS X with gcc, +the prefix to be used for linking in frameworks +(see $FRAMEWORKS). +The default value is +.BR -framework . + +.IP FRAMEWORKS +On Mac OS X with gcc, a list of the framework names to be linked into a +program or shared library or bundle. +The default value is the empty list. +For example: +.ES + env.AppendUnique(FRAMEWORKS=Split('System Cocoa SystemConfiguration')) +.EE + +.IP _FRAMEWORKS +On Mac OS X with gcc, +an automatically-generated construction variable +containing the linker command-line options +for linking with FRAMEWORKS. + .IP FRAMEWORKSFLAGS -On Mac OS X, -frameworks options to be added at +On Mac OS X with gcc, +general user-supplied frameworks options to be added at the end of a command line building a loadable module. +(This has been largely superceded by +the $FRAMEWORKPATH, $FRAMEWORKPATHPREFIX, +$FRAMWORKPREFIX and $FRAMEWORKS variables +described above.) .IP GS The Ghostscript program used to convert PostScript to PDF files. diff --git a/src/CHANGES.txt b/src/CHANGES.txt index cbc0a725..9ef394cb 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -311,6 +311,10 @@ RELEASE 0.97 - XXX - Add a --raw argument to the sconsign script, so it can print a raw representation of each entry's NodeInfo dictionary. + From Chen Lee: + + - Handle Visual Studio project and solution files in Unicode. + From Wayne Lee: - Avoid "maximum recursion limit" errors when removing $(-$) pairs @@ -368,6 +372,14 @@ RELEASE 0.97 - XXX value directory; avoiding slowing substitution logic when there's no '$' in the string. + From Greg Noel: + + - Add construction variables to support frameworks on Mac OS X: + $FRAMEWORKS, $FRAMEWORKPREFIX, $FRAMEWORKPATH, $FRAMEWORKPATHPREFIX. + + - Re-order link lines so the -o option always comes right after the + command name. + From Gary Oberbrunner: - Add an Environment.Dump() method to print the contents of a @@ -418,6 +430,8 @@ RELEASE 0.97 - XXX - Add support for Intel C++ beta 9.0 (both 32 and 64 bit versions). + - Document the new $FRAMEWORK* variables for Mac OS X. + From Chris Pawling: - Have the linkloc tool use $MSVS_VERSION to select the Microsoft diff --git a/src/RELEASE.txt b/src/RELEASE.txt index 5b95aa78..d55c7a44 100644 --- a/src/RELEASE.txt +++ b/src/RELEASE.txt @@ -137,6 +137,13 @@ RELEASE 0.97 - XXX converting signature information from .sconsign files written by SCons versions prior to 0.96 has been removed. + -- ORDER OF -o FLAGS ON CERTAIN LINK COMMAND LINES HAS CHANGED + + The -o flag that specifies an output file has been moved on + certain linker command lines to place it consistently after + the link command itself. This will cause recompilation + of target files created by these changed lines. + -- CACHED Configure() RESULTS ARE STORED IN A DIFFERENT FILE The Configure() subsystem now stores its cached results in a diff --git a/src/engine/SCons/Tool/applelink.py b/src/engine/SCons/Tool/applelink.py index 87c92d42..a65a4aff 100644 --- a/src/engine/SCons/Tool/applelink.py +++ b/src/engine/SCons/Tool/applelink.py @@ -42,16 +42,20 @@ def generate(env): Environment.""" gnulink.generate(env) + env['FRAMEWORKPATHPREFIX'] = '-F' + env['_FRAMEWORKPATH'] = '${_concat(FRAMEWORKPATHPREFIX, FRAMEWORKPATH, "", __env__)}' + env['_FRAMEWORKS'] = '${_concat("-framework ", FRAMEWORKS, "", __env__)}' + env['LINKCOM'] = env['LINKCOM'] + ' $_FRAMEWORKPATH $_FRAMEWORKS' env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -dynamiclib') + env['SHLINKCOM'] = env['SHLINKCOM'] + ' $_FRAMEWORKPATH $_FRAMEWORKS' # override the default for loadable modules, which are different # on OS X than dynamic shared libs. echoing what XCode does for # pre/suffixes: env['LDMODULEPREFIX'] = '' env['LDMODULESUFFIX'] = '' - env['LDMODULE'] = '$SHLINK' env['LDMODULEFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -bundle') - env['LDMODULECOM'] = '$LDMODULE $LDMODULEFLAGS -o ${TARGET} $SOURCES $_LIBDIRFLAGS $_LIBFLAGS $FRAMEWORKSFLAGS' + env['LDMODULECOM'] = '$LDMODULE -o ${TARGET} $LDMODULEFLAGS $SOURCES $_LIBDIRFLAGS $_LIBFLAGS $_FRAMEWORKPATH $_FRAMEWORKS $FRAMEWORKSFLAGS' diff --git a/src/engine/SCons/Tool/applelink.xml b/src/engine/SCons/Tool/applelink.xml index d839be0d..13eea311 100644 --- a/src/engine/SCons/Tool/applelink.xml +++ b/src/engine/SCons/Tool/applelink.xml @@ -1,11 +1,87 @@ - - + +"> -On Mac OS X, -frameworks options to be added at +On Mac OS X with gcc, +general user-supplied frameworks options to be added at the end of a command line building a loadable module. +(This has been largely superceded by +the &cv-FRAMEWORKPATH;, &cv-FRAMEWORKPATHPREFIX;, +&cv-FRAMEWORKPREFIX; and &cv-FRAMEWORKS; variables +described above.) + + +On Mac OS X with gcc, a list of the framework names to be linked into a +program or shared library or bundle. +The default value is the empty list. +For example: + + + env.AppendUnique(FRAMEWORKS=Split('System Cocoa SystemConfiguration')) + + + + + + + +On Mac OS X with gcc, +the prefix to be used for linking in frameworks +(see &cv-FRAMEWORKS;). +The default value is +. + + + + + +On Mac OS X with gcc, +an automatically-generated construction variable +containing the linker command-line options +for linking with FRAMEWORKS. + + + + + +On Mac OS X with gcc, +a list containing the paths to search for frameworks. +Used by the compiler to find framework-style includes like +#include <Fmwk/Header.h>. +Used by the linker to find user-specified frameworks when linking (see +&cv-FRAMEWORKS;). +For example: + + + env.AppendUnique(FRAMEWORKPATH='#myframeworkdir') + + +will add + + + ... -Fmyframeworkdir + + +to the compiler and linker command lines. + + + + +On Mac OS X with gcc, the prefix to be used for the FRAMEWORKPATH entries. +(see &cv-FRAMEWORKPATH;). +The default value is +. + + + + + +On Mac OS X with gcc, an automatically-generated construction variable +containing the linker command-line options corresponding to +&cv-FRAMEWORKPATH;. + + diff --git a/src/engine/SCons/Tool/c++.py b/src/engine/SCons/Tool/c++.py index 90b01ae8..a44fa6de 100644 --- a/src/engine/SCons/Tool/c++.py +++ b/src/engine/SCons/Tool/c++.py @@ -70,10 +70,10 @@ def generate(env): env['CXX'] = 'c++' env['CXXFLAGS'] = SCons.Util.CLVar('$CCFLAGS') - env['CXXCOM'] = '$CXX $CXXFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES' + env['CXXCOM'] = '$CXX -o $TARGET -c $CXXFLAGS $_CCCOMCOM $SOURCES' env['SHCXX'] = '$CXX' env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS') - env['SHCXXCOM'] = '$SHCXX $SHCXXFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES' + env['SHCXXCOM'] = '$SHCXX -o $TARGET -c $SHCXXFLAGS $_CCCOMCOM $SOURCES' env['CPPDEFPREFIX'] = '-D' env['CPPDEFSUFFIX'] = '' diff --git a/src/engine/SCons/Tool/cc.py b/src/engine/SCons/Tool/cc.py index 8fb9e26f..c4114b73 100644 --- a/src/engine/SCons/Tool/cc.py +++ b/src/engine/SCons/Tool/cc.py @@ -52,12 +52,21 @@ def generate(env): static_obj.add_emitter(suffix, SCons.Defaults.StaticObjectEmitter) shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter) + env['_CCCOMCOM'] = '$CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS' + # It's a hack to test for darwin here, but the alternative of creating + # an applecc.py to contain this seems overkill. Maybe someday the Apple + # platform will require more setup and this logic will be moved. + env['FRAMEWORKS'] = SCons.Util.CLVar('') + env['FRAMEWORKPATH'] = SCons.Util.CLVar('') + if env['PLATFORM'] == 'darwin': + env['_CCCOMCOM'] = env['_CCCOMCOM'] + ' $_FRAMEWORKPATH' + env['CC'] = 'cc' env['CCFLAGS'] = SCons.Util.CLVar('') - env['CCCOM'] = '$CC $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES' + env['CCCOM'] = '$CC -o $TARGET -c $CCFLAGS $_CCCOMCOM $SOURCES' env['SHCC'] = '$CC' env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS') - env['SHCCCOM'] = '$SHCC $SHCCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES' + env['SHCCCOM'] = '$SHCC -o $TARGET -c $SHCCFLAGS $_CCCOMCOM $SOURCES' env['CPPDEFPREFIX'] = '-D' env['CPPDEFSUFFIX'] = '' diff --git a/src/engine/SCons/Tool/gnulink.py b/src/engine/SCons/Tool/gnulink.py index 6276fbe3..dbd0c54c 100644 --- a/src/engine/SCons/Tool/gnulink.py +++ b/src/engine/SCons/Tool/gnulink.py @@ -45,13 +45,11 @@ def generate(env): if env['PLATFORM'] == 'hpux': env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -shared -fPIC') - elif env['PLATFORM'] == 'darwin': - env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -dynamiclib') # __RPATH is set to $_RPATH in the platform specification if that # platform supports it. env.Append(LINKFLAGS=['$__RPATH']) - env['RPATHPREFIX'] = '-Wl,--rpath=' + env['RPATHPREFIX'] = '-Wl,-rpath=' env['RPATHSUFFIX'] = '' env['_RPATH'] = '${_concat(RPATHPREFIX, RPATH, RPATHSUFFIX, __env__)}' diff --git a/src/engine/SCons/Tool/link.py b/src/engine/SCons/Tool/link.py index 51886345..b9fb71d7 100644 --- a/src/engine/SCons/Tool/link.py +++ b/src/engine/SCons/Tool/link.py @@ -51,14 +51,14 @@ def generate(env): env['SHLINK'] = '$LINK' env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -shared') - env['SHLINKCOM'] = '$SHLINK $SHLINKFLAGS -o $TARGET $SOURCES $_LIBDIRFLAGS $_LIBFLAGS' + env['SHLINKCOM'] = '$SHLINK -o $TARGET $SHLINKFLAGS $SOURCES $_LIBDIRFLAGS $_LIBFLAGS' # don't set up the emitter, cause AppendUnique will generate a list # starting with None :-( #env['SHLIBEMITTER']= None env['SMARTLINK'] = smart_link env['LINK'] = "$SMARTLINK" env['LINKFLAGS'] = SCons.Util.CLVar('') - env['LINKCOM'] = '$LINK $LINKFLAGS -o $TARGET $SOURCES $_LIBDIRFLAGS $_LIBFLAGS' + env['LINKCOM'] = '$LINK -o $TARGET $LINKFLAGS $SOURCES $_LIBDIRFLAGS $_LIBFLAGS' env['LIBDIRPREFIX']='-L' env['LIBDIRSUFFIX']='' env['_LIBFLAGS']='${_stripixes(LIBLINKPREFIX, LIBS, LIBLINKSUFFIX, LIBPREFIX, LIBSUFFIX, __env__)}' diff --git a/test/ToolSurrogate.py b/test/ToolSurrogate.py index fa13b578..527e3d33 100644 --- a/test/ToolSurrogate.py +++ b/test/ToolSurrogate.py @@ -87,7 +87,7 @@ env.Program('foo.c') test.write('foo.c', "foo.c posix\n") test.run(arguments = '. platform=posix', stdout = test.wrap_stdout("""\ -cc -c -o foo.obj foo.c +cc -o foo.obj -c foo.c cc -o foo.exe foo.obj """)) diff --git a/test/gnutools.py b/test/gnutools.py index d5173ee2..82c83ef6 100644 --- a/test/gnutools.py +++ b/test/gnutools.py @@ -128,16 +128,16 @@ def testObject(test, obj, command, flags): if sys.platform == 'cygwin': fpic = '' else: - fpic = '-fPIC ' + fpic = ' -fPIC' test.fail_test(not testObject(test, 'cfile1.o', 'gcc', '-c') or not testObject(test, 'cfile2.o', 'gcc', '-c') or not testObject(test, 'cppfile1.o', 'g++', '-c') or not testObject(test, 'cppfile2.o', 'g++', '-c') or - not testObject(test, 'cfile1.os', 'gcc', fpic + '-c') or - not testObject(test, 'cfile2.os', 'gcc', fpic + '-c') or - not testObject(test, 'cppfile1.os', 'g++', fpic + '-c') or - not testObject(test, 'cppfile2.os', 'g++', fpic + '-c') or + not testObject(test, 'cfile1.os', 'gcc', '-c' + fpic) or + not testObject(test, 'cfile2.os', 'gcc', '-c' + fpic) or + not testObject(test, 'cppfile1.os', 'g++', '-c' + fpic) or + not testObject(test, 'cppfile2.os', 'g++', '-c' + fpic) or not testObject(test, 'c-only' + _exe, 'gcc', '') or not testObject(test, 'cpp-only' + _exe, 'g++', '') or not testObject(test, 'c-and-cpp' + _exe, 'g++', '') or