Commits

Anonymous committed 1038f68

Add Framework support for Mac OS X. (Greg Noel) Document it. (Gary Oberbrunner)

  • Participants
  • Parent commits 14b3d06

Comments (0)

Files changed (11)

 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 <Fmwk/Header.h>.
+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.
   - 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
     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
 
   - 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
               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

src/engine/SCons/Tool/applelink.py

     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'
 
 
 

src/engine/SCons/Tool/applelink.xml

-<!-- __COPYRIGHT__ -->
-<cvar name="FRAMEWORKSFLAGS">
+<!-- Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation -->
+<cvar name="FRAMEWORKSFLAGS">">
 <summary>
-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.)
 </summary>
 </cvar>
 
+<cvar name="FRAMEWORKS">
+<summary>
+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:
 
+<example>
+ env.AppendUnique(FRAMEWORKS=Split('System Cocoa SystemConfiguration'))
+</example>
+
+</summary>
+</cvar>
+
+<cvar name="FRAMEWORKPREFIX">
+<summary>
+On Mac OS X with gcc,
+the prefix to be used for linking in frameworks
+(see &cv-FRAMEWORKS;).
+The default value is
+<option>-framework</option>.
+</summary>
+</cvar>
+
+<cvar name="_FRAMEWORKS">
+<summary>
+On Mac OS X with gcc,
+an automatically-generated construction variable
+containing the linker command-line options
+for linking with FRAMEWORKS.
+</summary>
+</cvar>
+
+<cvar name="FRAMEWORKPATH">
+<summary>
+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 &lt;Fmwk/Header.h&gt;.
+Used by the linker to find user-specified frameworks when linking (see
+&cv-FRAMEWORKS;).
+For example:
+
+<example>
+ env.AppendUnique(FRAMEWORKPATH='#myframeworkdir')
+</example>
+
+will add
+
+<example>
+  ... -Fmyframeworkdir
+</example>
+
+to the compiler and linker command lines.
+</summary>
+</cvar>
+
+<cvar name="FRAMEWORKPATHPREFIX">
+<summary>
+On Mac OS X with gcc, the prefix to be used for the FRAMEWORKPATH entries.
+(see &cv-FRAMEWORKPATH;).
+The default value is
+<option>-F</option>.
+</summary>
+</cvar>
+
+<cvar name="_FRAMEWORKPATH">
+<summary>
+On Mac OS X with gcc, an automatically-generated construction variable
+containing the linker command-line options corresponding to
+&cv-FRAMEWORKPATH;.
+</summary>
+</cvar>

src/engine/SCons/Tool/c++.py

         
     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']  = ''

src/engine/SCons/Tool/cc.py

         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']  = ''

src/engine/SCons/Tool/gnulink.py

 
     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__)}'
     

src/engine/SCons/Tool/link.py

     
     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__)}'

test/ToolSurrogate.py

 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
 """))
 
 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