OSX/scons: huge change, now you can set a user-config.py just with the desired variab...
authorJens Verwiebe <info@jensverwiebe.de>
Wed, 6 Nov 2013 20:59:04 +0000 (20:59 +0000)
committerJens Verwiebe <info@jensverwiebe.de>
Wed, 6 Nov 2013 20:59:04 +0000 (20:59 +0000)
SConstruct
build_files/scons/config/darwin-config.py
build_files/scons/tools/btools.py

index 4ef56db46d40915737d56dc028d51b63e78d6e5c..3ffd3f42b32c7762c3129a0e4b145817c4d88911 100644 (file)
@@ -285,17 +285,99 @@ if 'cudakernels' in B.targets:
     env['WITH_BF_CYCLES_CUDA_BINARIES'] = True
     env['WITH_BF_PYTHON'] = False
 
-# Extended OSX_SDK and 3D_CONNEXION_CLIENT_LIBRARY and JAckOSX detection for OSX
+
+#############################################################################
+###################    Automatic configuration for OSX     ##################
+#############################################################################
+
 if env['OURPLATFORM']=='darwin':
+
+    import commands
+    
+    cmd = 'uname -p'
+    MAC_PROC=commands.getoutput(cmd)
+    cmd = 'sw_vers -productVersion'
+    MAC_CUR_VER=cmd_res=commands.getoutput(cmd)
+    cmd = 'xcodebuild -version'
+    cmd_xcode=commands.getoutput(cmd)
+    env['XCODE_CUR_VER']=cmd_xcode[6:][:3] # truncate output to major.minor version
+    cmd = 'xcodebuild -showsdks'
+    cmd_sdk=commands.getoutput(cmd)
+    env['MACOSX_SDK_CHECK']=cmd_sdk
+    cmd = 'xcode-select --print-path'
+    XCODE_SELECT_PATH=commands.getoutput(cmd)
+    if XCODE_SELECT_PATH.endswith("/Contents/Developer"):
+        XCODE_BUNDLE=XCODE_SELECT_PATH[:-19]
+    else:
+        XCODE_BUNDLE=XCODE_SELECT_PATH
+
     print B.bc.OKGREEN + "Detected Xcode version: -- " + B.bc.ENDC + env['XCODE_CUR_VER'] + " --"
     print "Available " + env['MACOSX_SDK_CHECK']
-    if not 'Mac OS X 10.6' in env['MACOSX_SDK_CHECK']:
-        print  B.bc.OKGREEN + "Building with user-defined OS X SDK ( Xcode 4.4 or newer )"
-    elif not 'Mac OS X 10.5' in env['MACOSX_SDK_CHECK']:
-        print  B.bc.OKGREEN + "Auto-setting available MacOSX SDK -> " + B.bc.ENDC + "MacOSX10.6.sdk"
+
+    if env['MACOSX_SDK'] == '': # no set sdk, choosing best one found
+        if 'OS X 10.9' in env['MACOSX_SDK_CHECK']:
+            env['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
+            env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.9.sdk'
+        elif 'OS X 10.8' in env['MACOSX_SDK_CHECK']:
+            env['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
+            env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.8.sdk'
+        elif 'OS X 10.7' in env['MACOSX_SDK_CHECK']:
+            env['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
+            env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.7.sdk'
+        elif 'OS X 10.6' in env['MACOSX_SDK_CHECK']:
+            env['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
+            env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.6.sdk'
+        elif 'OS X 10.5' in env['MACOSX_SDK_CHECK']:
+            env['MACOSX_DEPLOYMENT_TARGET'] = '10.5'
+            env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.5.sdk'
+    else:
+        env['MACOSX_SDK']='/Developer/SDKs/MacOSX' + env['MACOSX_SDK'] + '.sdk'
+
+    if env['XCODE_CUR_VER'] >= '4.3':  ## since version 4.3, XCode and developer dir are bundled ##
+         env['MACOSX_SDK'] = XCODE_BUNDLE + '/Contents/Developer/Platforms/MacOSX.platform' +  env['MACOSX_SDK']
+    print B.bc.OKGREEN + "Using OSX SDK :" + B.bc.ENDC + env['MACOSX_SDK']
+               
+    if not env['WITH_OSX_STATICPYTHON'] == 1:
+        # python 3.3 uses Python-framework additionally installed in /Library/Frameworks
+        env['BF_PYTHON'] = '/Library/Frameworks/Python.framework/Versions/'
+        env['BF_PYTHON_INC'] = env['BF_PYTHON'] + env['BF_PYTHON_VERSION'] + '/include/python' + env['BF_PYTHON_VERSION'] + 'm'
+        env['BF_PYTHON_BINARY'] = env['BF_PYTHON'] + env['BF_PYTHON_VERSION'] + '/bin/python' + env['BF_PYTHON_VERSION']
+        env['BF_PYTHON_LIB'] = ''
+        env['BF_PYTHON_LIBPATH'] = env['BF_PYTHON'] + env['BF_PYTHON_VERSION'] + '/lib/python' + env['BF_PYTHON_VERSION'] + '/config-' + env['BF_PYTHON_VERSION'] +'m'
+
+    #Ray trace optimization
+    if env['WITH_BF_RAYOPTIMIZATION'] == 1:
+        if env['MACOSX_ARCHITECTURE'] == 'x86_64' or env['MACOSX_ARCHITECTURE'] == 'i386':
+            env['WITH_BF_RAYOPTIMIZATION'] = 1
+        else:
+            env['WITH_BF_RAYOPTIMIZATION'] = 0
+        if env['MACOSX_ARCHITECTURE'] == 'i386':
+            env['BF_RAYOPTIMIZATION_SSE_FLAGS'] = env['BF_RAYOPTIMIZATION_SSE_FLAGS']+['-msse']
+        elif env['MACOSX_ARCHITECTURE'] == 'x86_64':
+            env['BF_RAYOPTIMIZATION_SSE_FLAGS'] = env['BF_RAYOPTIMIZATION_SSE_FLAGS']+['-msse','-msse2']
+
+    if env['MACOSX_ARCHITECTURE'] == 'x86_64' or env['MACOSX_ARCHITECTURE'] == 'ppc64':
+        ARCH_FLAGS = ['-m64']
     else:
-        print B.bc.OKGREEN + "Found recommended sdk :" + B.bc.ENDC + " using MacOSX10.5.sdk"
+        ARCH_FLAGS = ['-m32']
                
+       env['CPPFLAGS'] = list(ARCH_FLAGS)
+
+    SDK_FLAGS=['-isysroot',  env['MACOSX_SDK'],'-mmacosx-version-min='+ env['MACOSX_DEPLOYMENT_TARGET'],'-arch',env['MACOSX_ARCHITECTURE']] # always used
+    env['PLATFORM_LINKFLAGS'] = ['-mmacosx-version-min='+ env['MACOSX_DEPLOYMENT_TARGET'],'-isysroot', env['MACOSX_SDK'],'-arch',env['MACOSX_ARCHITECTURE']]+env['PLATFORM_LINKFLAGS']
+    env['CCFLAGS']=SDK_FLAGS+env['CCFLAGS']
+    env['CXXFLAGS']=SDK_FLAGS+env['CXXFLAGS']
+       
+    #Intel Macs are CoreDuo and Up
+    if env['MACOSX_ARCHITECTURE'] == 'i386' or env['MACOSX_ARCHITECTURE'] == 'x86_64':
+        env['REL_CCFLAGS'] = env['REL_CCFLAGS']+['-ftree-vectorize','-msse','-msse2','-msse3']
+    else:
+        env['CCFLAGS'] =  env['CCFLAGS']+['-fno-strict-aliasing']
+
+    # Intel 64bit Macs are Core2Duo and up
+    if env['MACOSX_ARCHITECTURE'] == 'x86_64':
+        env['REL_CCFLAGS'] = env['REL_CCFLAGS']+['-mssse3']
+
     if env['XCODE_CUR_VER'] >= '5' and not (env['CXX'][:-2].endswith('4.6') or env['CXX'][:-2].endswith('4.8')):
         env['CCFLAGS'].append('-ftemplate-depth=1024') # only valid for clang bundled with xcode 5
 
@@ -320,17 +402,40 @@ if env['OURPLATFORM']=='darwin':
         else:
             env.Append(LINKFLAGS=['-F/Library/Frameworks','-Xlinker','-weak_framework','-Xlinker','Jackmp'])
 
+    if env['WITH_BF_QUICKTIME'] == 1:
+        env['PLATFORM_LINKFLAGS'] = env['PLATFORM_LINKFLAGS']+['-framework','QTKit']
+
+    if not env['WITH_OSX_STATICPYTHON'] == 1:
+        env['PLATFORM_LINKFLAGS'] = env['PLATFORM_LINKFLAGS']+['-framework','Python']
+
+    #Defaults openMP to true if compiler handles it ( only gcc 4.6.1 and newer )
+    # if your compiler does not have accurate suffix you may have to enable it by hand !
+    if env['CC'][:-2].endswith('4.6') or env['CC'][:-2].endswith('4.8'):
+        env['WITH_BF_OPENMP'] = 1  # multithreading for fluids, cloth, sculpt and smoke
+    else:
+        env['WITH_BF_OPENMP'] = 0
+               
+       env['PLATFORM_LINKFLAGS'] = env['PLATFORM_LINKFLAGS']+ARCH_FLAGS
+
     if env['WITH_BF_CYCLES_OSL'] == 1:
         OSX_OSL_LIBPATH = Dir(env.subst(env['BF_OSL_LIBPATH'])).abspath
         # we need 2 variants of passing the oslexec with the force_load option, string and list type atm
         if env['CC'][:-2].endswith('4.8'):
-                   env.Append(LINKFLAGS=['-L'+OSX_OSL_LIBPATH,'-loslcomp','-loslexec','-loslquery'])
+            env.Append(LINKFLAGS=['-L'+OSX_OSL_LIBPATH,'-loslcomp','-loslexec','-loslquery'])
         else:
             env.Append(LINKFLAGS=['-L'+OSX_OSL_LIBPATH,'-loslcomp','-force_load '+ OSX_OSL_LIBPATH +'/liboslexec.a','-loslquery'])
         env.Append(BF_PROGRAM_LINKFLAGS=['-Xlinker','-force_load','-Xlinker',OSX_OSL_LIBPATH +'/liboslexec.a'])
 
     # Trying to get rid of eventually clashes, we export some explicite as local symbols
     env.Append(LINKFLAGS=['-Xlinker','-unexported_symbols_list','-Xlinker','./source/creator/osx_locals.map'])
+    
+    #for < 10.7.sdk, SystemStubs needs to be linked
+    if  env['MACOSX_SDK'].endswith("10.6.sdk") or  env['MACOSX_SDK'].endswith("10.5.sdk"):
+        env['LLIBS'].append('SystemStubs')
+
+#############################################################################
+###################  End Automatic configuration for OSX   ##################
+#############################################################################
 
 if env['WITH_BF_OPENMP'] == 1:
         if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
index 84665548d9687f795444a54f078a94d8d15efd13..2d658fcb7564cec1f7c50aa2dc2cfc95a8f5cf63 100644 (file)
@@ -1,55 +1,12 @@
-#
-# Note : if you want to alter this file
-# copy it as a whole in the upper folder
-# as user-config.py
-# dont create a new file with only some
-# vars changed.
-
 import commands
 
-# IMPORTANT NOTE : OFFICIAL BUILDS SHOULD BE DONE WITH SDKs
-USE_SDK=True
-
 #############################################################################
-###################     Cocoa & architecture settings      ##################
+###################     Compiler & architecture settings      ##################
 #############################################################################
 
 MACOSX_ARCHITECTURE = 'x86_64' # valid archs: ppc, i386, ppc64, x86_64
-
-
-cmd = 'uname -p'
-MAC_PROC=commands.getoutput(cmd)
-cmd = 'sw_vers -productVersion'
-MAC_CUR_VER=cmd_res=commands.getoutput(cmd)
-cmd = 'xcodebuild -version'
-cmd_xcode=commands.getoutput(cmd)
-XCODE_CUR_VER=cmd_xcode[6:][:3] # truncate output to major.minor version
-cmd = 'xcodebuild -showsdks'
-cmd_sdk=commands.getoutput(cmd)
-MACOSX_SDK_CHECK=cmd_sdk
-cmd = 'xcode-select --print-path'
-XCODE_SELECT_PATH=commands.getoutput(cmd)
-if XCODE_SELECT_PATH.endswith("/Contents/Developer"):
-       XCODE_BUNDLE=XCODE_SELECT_PATH[:-19]
-else:
-       XCODE_BUNDLE=XCODE_SELECT_PATH
-
-
-# Default target OSX settings per architecture
-# Can be customized
-
-if 'Mac OS X 10.5' in MACOSX_SDK_CHECK:
-       # OSX 10.5/6 with Xcode 3.x
-       MACOSX_DEPLOYMENT_TARGET = '10.5'
-       MACOSX_SDK='/Developer/SDKs/MacOSX10.5.sdk'
-elif 'Mac OS X 10.6' in MACOSX_SDK_CHECK:
-       # OSX 10.6/7 with Xcode 4.x
-       MACOSX_DEPLOYMENT_TARGET = '10.6'
-       MACOSX_SDK='/Developer/SDKs/MacOSX10.6.sdk'
-else:
-       # OSX 10.7/8/9 with Xcode 4.4 and higher (no 10.6sdk! )
-       MACOSX_DEPLOYMENT_TARGET = '10.6'
-       MACOSX_SDK='/Developer/SDKs/MacOSX10.8.sdk'
+MACOSX_SDK='' # set an sdk name like '10.7' or leave empty for automatic choosing highest available
+MACOSX_DEPLOYMENT_TARGET = '10.6'
 
 # gcc always defaults to the system standard compiler linked by a shim or symlink
 CC = 'gcc'
@@ -57,20 +14,10 @@ CXX = 'g++'
 LCGDIR = '#../lib/darwin-9.x.universal'
 LIBDIR = '${LCGDIR}'
 
-if XCODE_CUR_VER >= '4.3':  ## since version 4.3, XCode and developer dir are bundled ##
-       MACOSX_SDK = XCODE_BUNDLE + '/Contents/Developer/Platforms/MacOSX.platform' + MACOSX_SDK
-
 #############################################################################
 ###################          Dependency settings           ##################
 #############################################################################
 
-#Defaults openMP to true if compiler handles it ( only gcc 4.6.1 and newer )
-# if your compiler does not have accurate suffix you may have to enable it by hand !
-if CC[:-2].endswith('4.6') or CC[:-2].endswith('4.8'):
-    WITH_BF_OPENMP = True  # multithreading for fluids, cloth, sculpt and smoke
-else:
-    WITH_BF_OPENMP = False
-
 # enable ffmpeg  support
 WITH_BF_FFMPEG = True
 BF_FFMPEG = LIBDIR + '/ffmpeg'
@@ -82,23 +29,13 @@ BF_FFMPEG_LIB = 'avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore
 BF_PYTHON_VERSION = '3.3'
 WITH_OSX_STATICPYTHON = True
 
-if WITH_OSX_STATICPYTHON:
-    # python 3.3 uses precompiled libraries in bf svn /lib by default
-
-    BF_PYTHON = LIBDIR + '/python'
-    BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}m'
-    # BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}'
-    BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION}m'
-    BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib/python${BF_PYTHON_VERSION}'
-    # BF_PYTHON_LINKFLAGS = ['-u', '_PyMac_Error', '-framework', 'System']
-else:
-    # python 3.2 uses Python-framework additionally installed in /Library/Frameworks
-
-    BF_PYTHON = '/Library/Frameworks/Python.framework/Versions/'
-    BF_PYTHON_INC = '${BF_PYTHON}${BF_PYTHON_VERSION}/include/python${BF_PYTHON_VERSION}m'
-    BF_PYTHON_BINARY = '${BF_PYTHON}${BF_PYTHON_VERSION}/bin/python${BF_PYTHON_VERSION}'
-    #BF_PYTHON_LIB = ''
-    BF_PYTHON_LIBPATH = '${BF_PYTHON}${BF_PYTHON_VERSION}/lib/python${BF_PYTHON_VERSION}/config-${BF_PYTHON_VERSION}m'
+# python 3.3 uses precompiled libraries in bf svn /lib by default
+BF_PYTHON = LIBDIR + '/python'
+BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}m'
+# BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}'
+BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION}m'
+BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib/python${BF_PYTHON_VERSION}'
+# BF_PYTHON_LINKFLAGS = ['-u', '_PyMac_Error', '-framework', 'System']
 
 WITH_BF_OPENAL = True
 BF_OPENAL = LIBDIR + '/openal'
@@ -275,14 +212,8 @@ BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35']
 WITH_BF_FREESTYLE = True
 
 #Ray trace optimization
-if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'i386':
-    WITH_BF_RAYOPTIMIZATION = True
-else:
-    WITH_BF_RAYOPTIMIZATION = False
-if MACOSX_ARCHITECTURE == 'i386':
-    BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse']
-elif MACOSX_ARCHITECTURE == 'x86_64':
-    BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse','-msse2']
+WITH_BF_RAYOPTIMIZATION = True
+BF_RAYOPTIMIZATION_SSE_FLAGS = []
 
 # SpaceNavigator and related 3D mice, driver must be 3DxWare 10 Beta 4 (Mac OS X) or later !
 WITH_BF_3DMOUSE = True
@@ -293,53 +224,17 @@ WITH_BF_3DMOUSE = True
 
 BF_QUIET = '1' # suppress verbose output
 
-if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'ppc64':
-    ARCH_FLAGS = ['-m64']
-else:
-    ARCH_FLAGS = ['-m32']
-
 CFLAGS = []
 CXXFLAGS = []
 CCFLAGS = ['-pipe','-funsigned-char']
 
+PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Cocoa','-framework','Carbon','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']
 
-CPPFLAGS = list(ARCH_FLAGS)
-
-PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Cocoa','-framework','Carbon','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS
-
-if WITH_BF_QUICKTIME:
-    PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QTKit']
-
-if not WITH_OSX_STATICPYTHON:
-    PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','Python']
-
-
-#for > 10.7.sdk, SystemStubs needs to be excluded (lib doesn't exist anymore)
-if MACOSX_SDK.endswith("10.7.sdk") or MACOSX_SDK.endswith("10.8.sdk") or MACOSX_SDK.endswith("10.9.sdk"):
-    LLIBS = ['stdc++']
-else:
-    LLIBS = ['stdc++', 'SystemStubs']
-
-if USE_SDK:
-    SDK_FLAGS=['-isysroot', MACOSX_SDK,'-mmacosx-version-min='+MACOSX_DEPLOYMENT_TARGET,'-arch',MACOSX_ARCHITECTURE]
-    PLATFORM_LINKFLAGS = ['-mmacosx-version-min='+MACOSX_DEPLOYMENT_TARGET,'-Wl','-isysroot',MACOSX_SDK,'-arch',MACOSX_ARCHITECTURE]+PLATFORM_LINKFLAGS
-    CCFLAGS=SDK_FLAGS+CCFLAGS
-    CXXFLAGS=SDK_FLAGS+CXXFLAGS
-
-#Intel Macs are CoreDuo and Up
-if MACOSX_ARCHITECTURE == 'i386' or MACOSX_ARCHITECTURE == 'x86_64':
-    REL_CFLAGS = []
-    REL_CXXFLAGS = []
-    REL_CCFLAGS = ['-DNDEBUG', '-O2','-ftree-vectorize','-msse','-msse2','-msse3']
-else:
-    CCFLAGS += ['-fno-strict-aliasing']
-    REL_CFLAGS = []
-    REL_CXXFLAGS = []
-    REL_CCFLAGS = ['-DNDEBUG', '-O2']
+LLIBS = ['stdc++']
 
-# Intel 64bit Macs are Core2Duo and up
-if MACOSX_ARCHITECTURE == 'x86_64':
-    REL_CCFLAGS += ['-mssse3']
+REL_CFLAGS = []
+REL_CXXFLAGS = []
+REL_CCFLAGS = ['-DNDEBUG', '-O2']
 
 CC_WARN = ['-Wall']
 C_WARN = ['-Wno-char-subscripts', '-Wpointer-arith', '-Wcast-align', '-Wdeclaration-after-statement', '-Wno-unknown-pragmas', '-Wstrict-prototypes']
index 65cbcf4e1ec1e1fe16da537033995f4761b28b97..c542435fb471094e1cfbdc3194d670340b30e7ba 100644 (file)
@@ -179,7 +179,7 @@ def validate_arguments(args, bc):
             'BF_PROFILE_CFLAGS', 'BF_PROFILE_CCFLAGS', 'BF_PROFILE_CXXFLAGS', 'BF_PROFILE_LINKFLAGS',
             'BF_DEBUG_CFLAGS', 'BF_DEBUG_CCFLAGS', 'BF_DEBUG_CXXFLAGS',
             'C_WARN', 'CC_WARN', 'CXX_WARN',
-            'LLIBS', 'PLATFORM_LINKFLAGS','MACOSX_ARCHITECTURE', 'MACOSX_SDK_CHECK', 'XCODE_CUR_VER',
+            'LLIBS', 'PLATFORM_LINKFLAGS', 'MACOSX_ARCHITECTURE', 'MACOSX_SDK', 'MACOSX_SDK_CHECK', 'XCODE_CUR_VER',
             'BF_CYCLES_CUDA_BINARIES_ARCH', 'BF_PROGRAM_LINKFLAGS', 'MACOSX_DEPLOYMENT_TARGET'
     ]
 
@@ -501,6 +501,7 @@ def read_opts(env, cfg, args):
         ('LLIBS', 'Platform libs', []),
         ('PLATFORM_LINKFLAGS', 'Platform linkflags', []),
         ('MACOSX_ARCHITECTURE', 'python_arch.zip select', ''),
+        ('MACOSX_SDK', 'Set OS X SDK', ''),
         ('MACOSX_SDK_CHECK', 'Detect available OS X SDK`s', ''),
         ('XCODE_CUR_VER', 'Detect XCode version', ''),
         ('MACOSX_DEPLOYMENT_TARGET', 'Detect OS X target version', ''),