[c167d7b] master: OSX/scons: Introduce a new env var 'MACOSX_COMPILER' This is needed to resolve the real used compiler from the compatibility shim’S or symlinks. Also set the real CCVERSION as scons CCVERSION would only read the default one, which is not useful for OSX

Jens Verwiebe noreply at git.blender.org
Fri Dec 6 17:27:39 CET 2013


Commit: c167d7b79a9f72c4ff24ee0f650e0dfb5fcdb79c
Author: Jens Verwiebe
Date:   Fri Dec 6 17:06:37 2013 +0100
http://developer.blender.org/rBc167d7b79a9f72c4ff24ee0f650e0dfb5fcdb79c

OSX/scons: Introduce a new env var 'MACOSX_COMPILER'
This is needed to resolve the real used compiler from the compatibility shim’S or symlinks.
Also set the real CCVERSION as scons CCVERSION would only read the default one, which
is not useful for OSX

===================================================================

M	SConstruct
M	build_files/scons/tools/Blender.py
M	build_files/scons/tools/btools.py

===================================================================

diff --git a/SConstruct b/SConstruct
index d95811a..98bb61a3 100644
--- a/SConstruct
+++ b/SConstruct
@@ -296,6 +296,19 @@ env['CONFIGURELOG'] = os.path.abspath(os.path.normpath(os.path.join(env['BF_BUIL
 if env['OURPLATFORM']=='darwin':
 
     import commands
+    import subprocess
+
+    command = ["%s"%env['CC'], "--version"]
+    process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=None, shell=False)
+    line = process.communicate()[0]
+    ver = re.search(r'[0-9]+(\.[0-9]+)+', line)
+    if ver:
+        env['CCVERSION'] = ver.group(0)
+    frontend = re.search(r'gcc', line) or re.search(r'clang', line) or re.search(r'llvm-gcc', line)
+    if frontend:
+        env['MACOSX_COMPILER'] = frontend.group(0)
+
+    print B.bc.OKGREEN + "Using Compiler: " + B.bc.ENDC + env['MACOSX_COMPILER'] + '-' + env['CCVERSION']
 
     cmd = 'sw_vers -productVersion'
     MAC_CUR_VER=cmd_res=commands.getoutput(cmd)
@@ -374,7 +387,7 @@ if env['OURPLATFORM']=='darwin':
     #Intel Macs are CoreDuo and Up
     if env['MACOSX_ARCHITECTURE'] == 'i386' or env['MACOSX_ARCHITECTURE'] == 'x86_64':
         env['REL_CCFLAGS'] = env['REL_CCFLAGS']+['-msse','-msse2','-msse3']
-        if env['XCODE_CUR_VER'] >= '5':
+        if env['MACOSX_COMPILER'] != 'clang' or (env['MACOSX_COMPILER'] == 'clang' and env['CCVERSION'] >= '5.0'):
             env['REL_CCFLAGS'] = env['REL_CCFLAGS']+['-ftree-vectorize'] # clang xcode 4 does not accept flag
     else:
         env['CCFLAGS'] =  env['CCFLAGS']+['-fno-strict-aliasing']
@@ -383,7 +396,7 @@ if env['OURPLATFORM']=='darwin':
     if env['MACOSX_ARCHITECTURE'] == 'x86_64':
         env['REL_CCFLAGS'] = env['REL_CCFLAGS']+['-mssse3']
 
-    if env['XCODE_CUR_VER'] >= '5' and not env['CC'].split('/')[len(env['CC'].split('/'))-1][4:] >= '4.6.1':
+    if env['MACOSX_COMPILER'] == 'clang' and env['CCVERSION'] >= '5.0':
         env['CCFLAGS'].append('-ftemplate-depth=1024') # only valid for clang bundled with xcode 5
 
     # 3DconnexionClient.framework, optionally install
@@ -411,7 +424,7 @@ if env['OURPLATFORM']=='darwin':
     #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['WITH_BF_OPENMP'] == 1:
-        if env['CC'].split('/')[len(env['CC'].split('/'))-1].strip('llvm - gcc clang') >= '4.6.1': # strip down to version string if any
+        if env['MACOSX_COMPILER'] == 'gcc' and env['CCVERSION'] >= '4.6.1': # strip down to version string if any
             env['WITH_BF_OPENMP'] = 1  # multithreading for fluids, cloth, sculpt and smoke
             print B.bc.OKGREEN + "Using OpenMP"
         else:
@@ -421,7 +434,7 @@ if env['OURPLATFORM']=='darwin':
     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'].split('/')[len(env['CC'].split('/'))-1].strip('llvm - gcc clang') >= '4.8': # strip down to version string if any
+        if env['MACOSX_COMPILER'] == 'gcc' and env['CCVERSION'] >= '4.8': # strip down to version string if any
             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'])
diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py
index 2cb93c8..2642585 100644
--- a/build_files/scons/tools/Blender.py
+++ b/build_files/scons/tools/Blender.py
@@ -730,7 +730,7 @@ def AppIt(target=None, source=None, env=None):
     commands.getoutput(cmd)
     cmd = 'find %s/%s.app -name __MACOSX -exec rm -rf {} \;'%(installdir, binary)
     commands.getoutput(cmd)
-    if env['CC'].split('/')[len(env['CC'].split('/'))-1].strip('llvm - gcc clang') >= '4.6.1': # for correct errorhandling with gcc >= 4.6.1 we need the gcc.dylib and gomp.dylib to link, thus distribute in app-bundle
+    if env['MACOSX_COMPILER'] == 'gcc' and env['CCVERSION'] >= '4.6.1': # for correct errorhandling with gcc >= 4.6.1 we need the gcc.dylib and gomp.dylib to link, thus distribute in app-bundle
         print "Bundling libgcc and libgomp"
         instname = env['BF_CXX']
         cmd = 'ditto --arch %s %s/lib/libgcc_s.1.dylib %s/%s.app/Contents/MacOS/lib/'%(osxarch, instname, installdir, binary) # copy libgcc
diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py
index f7a5eb8..fd31218 100644
--- a/build_files/scons/tools/btools.py
+++ b/build_files/scons/tools/btools.py
@@ -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', 'XCODE_CUR_VER',
+            'LLIBS', 'PLATFORM_LINKFLAGS', 'MACOSX_ARCHITECTURE', 'MACOSX_SDK', 'XCODE_CUR_VER', 'MACOSX_COMPILER',
             'BF_CYCLES_CUDA_BINARIES_ARCH', 'BF_PROGRAM_LINKFLAGS', 'MACOSX_DEPLOYMENT_TARGET'
     ]
 
@@ -504,6 +504,7 @@ def read_opts(env, cfg, args):
         ('MACOSX_SDK', 'Set OS X SDK', ''),
         ('XCODE_CUR_VER', 'Detect XCode version', ''),
         ('MACOSX_DEPLOYMENT_TARGET', 'Detect OS X target version', ''),
+        ('MACOSX_COMPILER', 'Detect the resolved compiler', ''),
 
         (BoolVariable('BF_PROFILE', 'Add profiling information if true', False)),
         ('BF_PROFILE_CFLAGS', 'C only profiling flags', []),




More information about the Bf-blender-cvs mailing list