From e141845bfb3e12a9213c8682d5b2589ce5305f70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Sat, 13 Jan 2018 15:16:11 +0100 Subject: [PATCH] SCons: Allow unbundling bullet on Linux (only 2.87+) --- SConstruct | 1 + modules/bullet/SCsub | 21 +++++++++------------ modules/enet/SCsub | 4 ++-- platform/server/detect.py | 10 ++++++++++ platform/x11/detect.py | 10 ++++++++++ 5 files changed, 32 insertions(+), 14 deletions(-) diff --git a/SConstruct b/SConstruct index 9fced81f9cf..7e82e582d03 100644 --- a/SConstruct +++ b/SConstruct @@ -171,6 +171,7 @@ opts.Add(BoolVariable('dev', "If yes, alias for verbose=yes warnings=all", False opts.Add(EnumVariable('macports_clang', "Build using clang from MacPorts", 'no', ('no', '5.0', 'devel'))) # Thirdparty libraries +opts.Add(BoolVariable('builtin_bullet', "Use the builtin bullet library", True)) opts.Add(BoolVariable('builtin_enet', "Use the builtin enet library", True)) opts.Add(BoolVariable('builtin_freetype', "Use the builtin freetype library", True)) opts.Add(BoolVariable('builtin_libogg', "Use the builtin libogg library", True)) diff --git a/modules/bullet/SCsub b/modules/bullet/SCsub index 6b1c38a2655..d8d0b930a54 100644 --- a/modules/bullet/SCsub +++ b/modules/bullet/SCsub @@ -3,14 +3,15 @@ Import('env') Import('env_modules') -# build only version 2 -# Bullet 2.87 - env_bullet = env_modules.Clone() -thirdparty_dir = "#thirdparty/bullet/" +# Thirdparty source files -bullet2_src = [ +if env['builtin_bullet']: + # Build only version 2 for now (as of 2.87) + thirdparty_dir = "#thirdparty/bullet/" + + bullet2_src = [ # BulletCollision "BulletCollision/BroadphaseCollision/btAxisSweep3.cpp" , "BulletCollision/BroadphaseCollision/btBroadphaseProxy.cpp" @@ -181,14 +182,10 @@ bullet2_src = [ , "LinearMath/btVector3.cpp" ] -bullet_sources = [thirdparty_dir + file for file in bullet2_src] + thirdparty_sources = [thirdparty_dir + file for file in bullet2_src] -# include headers -env_bullet.Append(CPPPATH=[thirdparty_dir]) - -env_bullet.add_source_files(env.modules_sources, bullet_sources) + env_bullet.add_source_files(env.modules_sources, thirdparty_sources) + env_bullet.Append(CPPPATH=[thirdparty_dir]) # Godot source files env_bullet.add_source_files(env.modules_sources, "*.cpp") - -Export('env') diff --git a/modules/enet/SCsub b/modules/enet/SCsub index 4790c5099f2..7caeafa1d6d 100644 --- a/modules/enet/SCsub +++ b/modules/enet/SCsub @@ -3,10 +3,10 @@ Import('env') Import('env_modules') -# Thirdparty source files - env_enet = env_modules.Clone() +# Thirdparty source files + if env['builtin_enet']: thirdparty_dir = "#thirdparty/enet/" thirdparty_sources = [ diff --git a/platform/server/detect.py b/platform/server/detect.py index 72c9c770e3d..bc90a38e245 100644 --- a/platform/server/detect.py +++ b/platform/server/detect.py @@ -86,6 +86,16 @@ def configure(env): if not env['builtin_libpng']: env.ParseConfig('pkg-config libpng --cflags --libs') + if not env['builtin_bullet']: + # We need at least version 2.87 + import subprocess + bullet_version = subprocess.check_output(['pkg-config', 'bullet', '--modversion']).strip() + if bullet_version < "2.87": + # Abort as system bullet was requested but too old + print("Bullet: System version {0} does not match minimal requirements ({1}). Aborting.".format(bullet_version, "2.87")) + sys.exit(255) + env.ParseConfig('pkg-config bullet --cflags --libs') + if not env['builtin_enet']: env.ParseConfig('pkg-config libenet --cflags --libs') diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 478b42f9f71..1c6bada815a 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -172,6 +172,16 @@ def configure(env): if not env['builtin_libpng']: env.ParseConfig('pkg-config libpng --cflags --libs') + if not env['builtin_bullet']: + # We need at least version 2.87 + import subprocess + bullet_version = subprocess.check_output(['pkg-config', 'bullet', '--modversion']).strip() + if bullet_version < "2.87": + # Abort as system bullet was requested but too old + print("Bullet: System version {0} does not match minimal requirements ({1}). Aborting.".format(bullet_version, "2.87")) + sys.exit(255) + env.ParseConfig('pkg-config bullet --cflags --libs') + if not env['builtin_enet']: env.ParseConfig('pkg-config libenet --cflags --libs')