Various fixes to scons for linux:
authorBastien Montagne <montagne29@wanadoo.fr>
Wed, 29 May 2013 18:55:02 +0000 (18:55 +0000)
committerBastien Montagne <montagne29@wanadoo.fr>
Wed, 29 May 2013 18:55:02 +0000 (18:55 +0000)
* Better handling of "multiarch" python stuff (libs also need two different paths).
* Fix Opencollada default paths.

Hopefully this won't break anything...

build_files/scons/config/Modules/FindPython.py
build_files/scons/config/linux-config.py
build_files/scons/tools/btools.py

index 01215753cf77d5733af2ce8b2333d484a47c8214..03e15349da5caee132b34dbeeb1e671360f74214 100644 (file)
@@ -7,6 +7,8 @@ def FindPython():
     abi_flags = "m"  # Most common for linux distros
     version = "3.3"
 
+    _arch = "x86_64-linux-gnu"
+
     # Determine ABI flags used on this system
     include = os.path.join(python, "include")
     for cur_flags in all_abi_flags:
@@ -16,10 +18,8 @@ def FindPython():
             break
 
     # Find config.h. In some distros, such as ubuntu 12.10 they are not in standard include dir.
-    incconf64 = os.path.join(include, "x86_64-linux-gnu", "python" + version + cur_flags, "pyconfig.h")
-    if os.path.exists(incconf64):
-        incconf = os.path.join(include, "x86_64-linux-gnu", "python" + version + cur_flags)
-    else:
+    incconf = os.path.join(include, _arch, "python" + version + cur_flags)
+    if not os.path.exists(os.path.join(incconf, "pyconfig.h")):
         incconf = ''
 
     # Determine whether python is in /usr/lib or /usr/lib64
@@ -33,8 +33,19 @@ def FindPython():
         # roll back to default value
         libpath = "${BF_PYTHON}/lib"
 
-    return {'PYTHON': python,
+    libpath_arch = libpath
+    _libpath_arch = os.path.join(python, "lib", _arch)  # No lib64 stuff with recent deb-like distro afaik...
+    _libs = ["libpython" + version + abi_flags + ext for ext in (".so", ".a")]
+    for l in _libs:
+        print os.path.join(libpath, l), os.path.exists(os.path.join(libpath, l))
+        print os.path.join(_libpath_arch, l), os.path.exists(os.path.join(_libpath_arch, l))
+        if not os.path.exists(os.path.join(libpath, l)) and os.path.exists(os.path.join(_libpath_arch, l)):
+            libpath_arch = os.path.join(libpath, _arch)
+            break
+
+    return {"PYTHON": python,
             "VERSION": version,
-            'LIBPATH': libpath,
-            'ABI_FLAGS': abi_flags,
-            'CONFIG': incconf}
+            "LIBPATH": libpath,
+            "LIBPATH_ARCH": libpath_arch,
+            "ABI_FLAGS": abi_flags,
+            "CONFIG": incconf}
index 2aec75edb0853e398101871789a75ebdfdecdee1..418d2ef41b8e5643bfc0271937c523f8befc2b7b 100644 (file)
@@ -5,6 +5,7 @@ py = FindPython()
 BF_PYTHON_ABI_FLAGS = py['ABI_FLAGS']
 BF_PYTHON = py['PYTHON']
 BF_PYTHON_LIBPATH = py['LIBPATH']
+BF_PYTHON_LIBPATH_ARCH = py['LIBPATH_ARCH']
 BF_PYTHON_CONFIG = py['CONFIG']
 BF_PYTHON_VERSION = py['VERSION']
 WITH_BF_STATICPYTHON = False
@@ -12,7 +13,7 @@ BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}${BF_PYTHON_ABI_
 BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}'
 BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION}${BF_PYTHON_ABI_FLAGS}'  # BF_PYTHON+'/lib/python'+BF_PYTHON_VERSION+'/config/libpython'+BF_PYTHON_VERSION+'.a'
 BF_PYTHON_LINKFLAGS = ['-Xlinker', '-export-dynamic']
-BF_PYTHON_LIB_STATIC = '${BF_PYTHON}/lib/libpython${BF_PYTHON_VERSION}${BF_PYTHON_ABI_FLAGS}.a'
+BF_PYTHON_LIB_STATIC = '${BF_PYTHON_LIBPATH_ARCH}/libpython${BF_PYTHON_VERSION}${BF_PYTHON_ABI_FLAGS}.a'
 
 WITH_BF_OPENAL = True
 WITH_BF_STATICOPENAL = False
@@ -160,9 +161,9 @@ BF_COLLADA = '#source/blender/collada'
 BF_COLLADA_INC = '${BF_COLLADA}'
 BF_COLLADA_LIB = 'bf_collada'
 BF_OPENCOLLADA = '/usr'
-BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}'
+BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}/include/opencollada'
 BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre buffer ftoa'
-BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib'
+BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib/opencollada'
 BF_PCRE = ''
 BF_PCRE_LIB = 'pcre'
 BF_PCRE_LIBPATH = '/usr/lib'
index aeb4a33eea9c93f7eb2813321ad216bf52e6ed8e..b8d036d9a8413fefd253952930a5b5054d9ae2bb 100644 (file)
@@ -96,7 +96,7 @@ def print_arguments(args, bc):
 
 def validate_arguments(args, bc):
     opts_list = [
-            'WITH_BF_FREESTYLE', 'WITH_BF_PYTHON', 'WITH_BF_PYTHON_SAFETY', 'BF_PYTHON', 'BF_PYTHON_VERSION', 'BF_PYTHON_INC', 'BF_PYTHON_BINARY', 'BF_PYTHON_LIB', 'BF_PYTHON_LIBPATH', 'WITH_BF_STATICPYTHON', 'WITH_OSX_STATICPYTHON', 'BF_PYTHON_LIB_STATIC', 'BF_PYTHON_DLL', 'BF_PYTHON_ABI_FLAGS',
+            'WITH_BF_FREESTYLE', 'WITH_BF_PYTHON', 'WITH_BF_PYTHON_SAFETY', 'BF_PYTHON', 'BF_PYTHON_VERSION', 'BF_PYTHON_INC', 'BF_PYTHON_BINARY', 'BF_PYTHON_LIB', 'BF_PYTHON_LIBPATH', 'BF_PYTHON_LIBPATH_ARCH', 'WITH_BF_STATICPYTHON', 'WITH_OSX_STATICPYTHON', 'BF_PYTHON_LIB_STATIC', 'BF_PYTHON_DLL', 'BF_PYTHON_ABI_FLAGS',
             'WITH_BF_OPENAL', 'BF_OPENAL', 'BF_OPENAL_INC', 'BF_OPENAL_LIB', 'BF_OPENAL_LIBPATH', 'WITH_BF_STATICOPENAL', 'BF_OPENAL_LIB_STATIC',
             'WITH_BF_SDL', 'BF_SDL', 'BF_SDL_INC', 'BF_SDL_LIB', 'BF_SDL_LIBPATH',
             'WITH_BF_JACK', 'BF_JACK', 'BF_JACK_INC', 'BF_JACK_LIB', 'BF_JACK_LIBPATH', 'WITH_BF_JACK_DYNLOAD',
@@ -259,6 +259,7 @@ def read_opts(env, cfg, args):
         ('BF_PYTHON_INC', 'Include path for Python headers', ''),
         ('BF_PYTHON_BINARY', 'Path to the Python interpreter', ''),
         ('BF_PYTHON_LIB', 'Python library', ''),
+        ('BF_PYTHON_LIBPATH_ARCH', 'Additional Python library under some linux flavors (arch-dependent)', ''),
         ('BF_PYTHON_DLL', 'Python dll - used on Windows only', ''),
         ('BF_PYTHON_LIB_STATIC', 'Python static libraries', ''),
         ('BF_PYTHON_LIBPATH', 'Library path', ''),