Skip to content

Commit b5bb92c

Browse files
committed
Move bullet library build code to runner.py so that it can be shared between test_the_bullet in test_core.py and test_static_link test_other.py.
1 parent a30bd53 commit b5bb92c

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

tests/runner.py

+18
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,24 @@ def btest(self, filename, expected=None, reference=None, force_c=False, referenc
673673

674674
###################################################################################################
675675

676+
# Both test_core and test_other access the Bullet library, share the access here to avoid duplication.
677+
def get_bullet_library(runner_core, use_cmake):
678+
if use_cmake:
679+
configure_commands = ['cmake', '.']
680+
configure_args = ['-DBUILD_DEMOS=OFF', '-DBUILD_EXTRAS=OFF']
681+
# Depending on whether 'configure' or 'cmake' is used to build, Bullet places output files in different directory structures.
682+
generated_libs = [os.path.join('src', 'BulletDynamics', 'libBulletDynamics.a'),
683+
os.path.join('src', 'BulletCollision', 'libBulletCollision.a'),
684+
os.path.join('src', 'LinearMath', 'libLinearMath.a')]
685+
else:
686+
configure_commands = ['sh', './configure']
687+
configure_args = ['--disable-demos','--disable-dependency-tracking']
688+
generated_libs = [os.path.join('src', '.libs', 'libBulletDynamics.a'),
689+
os.path.join('src', '.libs', 'libBulletCollision.a'),
690+
os.path.join('src', '.libs', 'libLinearMath.a')]
691+
692+
return runner_core.get_library('bullet', generated_libs, configure=configure_commands, configure_args=configure_args, cache_name_extra=configure_commands[0])
693+
676694
if __name__ == '__main__':
677695
# Sanity checks
678696
total_engines = len(JS_ENGINES)

tests/test_core.py

+4-17
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import glob, hashlib, os, re, shutil, subprocess, sys
44
import tools.shared
55
from tools.shared import *
6-
from runner import RunnerCore, path_from_root, checked_sanity, test_modes
6+
from runner import RunnerCore, path_from_root, checked_sanity, test_modes, get_bullet_library
77

88
class T(RunnerCore): # Short name, to make it more fun to use manually on the commandline
99
def is_le32(self):
@@ -9001,30 +9001,17 @@ def test_the_bullet(self): # Called thus so it runs late in the alphabetical cyc
90019001
Settings.SAFE_HEAP_LINES = ['btVoronoiSimplexSolver.h:40', 'btVoronoiSimplexSolver.h:41',
90029002
'btVoronoiSimplexSolver.h:42', 'btVoronoiSimplexSolver.h:43']
90039003

9004-
configure_commands = [['sh', './configure'], ['cmake', '.']]
9005-
configure_args = [['--disable-demos','--disable-dependency-tracking'], ['-DBUILD_DEMOS=OFF', '-DBUILD_EXTRAS=OFF']]
9006-
for c in range(0,2):
9007-
configure = configure_commands[c]
9004+
for use_cmake in [False, True]: # If false, use a configure script to configure Bullet build.
90089005
# Windows cannot run configure sh scripts.
9009-
if WINDOWS and configure[0] == 'sh':
9006+
if WINDOWS and not use_cmake:
90109007
continue
90119008

9012-
# Depending on whether 'configure' or 'cmake' is used to build, Bullet places output files in different directory structures.
9013-
if configure[0] == 'sh':
9014-
generated_libs = [os.path.join('src', '.libs', 'libBulletDynamics.a'),
9015-
os.path.join('src', '.libs', 'libBulletCollision.a'),
9016-
os.path.join('src', '.libs', 'libLinearMath.a')]
9017-
else:
9018-
generated_libs = [os.path.join('src', 'BulletDynamics', 'libBulletDynamics.a'),
9019-
os.path.join('src', 'BulletCollision', 'libBulletCollision.a'),
9020-
os.path.join('src', 'LinearMath', 'libLinearMath.a')]
9021-
90229009
def test():
90239010
self.do_run(open(path_from_root('tests', 'bullet', 'Demos', 'HelloWorld', 'HelloWorld.cpp'), 'r').read(),
90249011
[open(path_from_root('tests', 'bullet', 'output.txt'), 'r').read(), # different roundings
90259012
open(path_from_root('tests', 'bullet', 'output2.txt'), 'r').read(),
90269013
open(path_from_root('tests', 'bullet', 'output3.txt'), 'r').read()],
9027-
libraries=self.get_library('bullet', generated_libs, configure=configure, configure_args=configure_args[c], cache_name_extra=configure[0]),
9014+
libraries=get_bullet_library(self, use_cmake),
90289015
includes=[path_from_root('tests', 'bullet', 'src')])
90299016
test()
90309017

0 commit comments

Comments
 (0)