From 59ebd9b690dd123a5178591d0dccd8ee2b97b0e9 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 28 Mar 2008 02:22:11 +0000 Subject: [PATCH] Enable building of the unit tests in the scons recipe. --- SConstruct | 19 +++++++++++++++---- src/Makefile.am | 2 -- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/SConstruct b/SConstruct index e77a56b256f..7cf8d8971f5 100644 --- a/SConstruct +++ b/SConstruct @@ -111,6 +111,9 @@ if "all" in targets or "wesnoth" in targets: print "Needed Python lib for game and didn't find it; exiting!" Exit(1) +boost_test_dyn_link = conf.CheckCXXHeader('boost/test/unit_test.hpp') +boost_auto_test = conf.CheckCXXHeader('boost/test/unit_test.hpp') + env = conf.Finish() # @@ -189,6 +192,14 @@ if 'CXXFLAGS' in os.environ: if 'LDFLAGS' in os.environ: env.Append(LINKFLAGS = os.environ['LDFLAGS']) +test_env = env.Clone() +if boost_test_dyn_link: + env["CXXFLAGS"].append("-DBOOST_TEST_DYN_LINK") + if boost_auto_test: + test_env["CXXFLAGS"].append("-DWESNOTH_BOOST_AUTO_TEST_MAIN") + else: + test_env["CXXFLAGS"].append("-DWESNOTH_BOOST_TEST_MAIN") + cc_version = env["CCVERSION"] if env["CC"] == "gcc": (major, minor, rev) = map(int, cc_version.split(".")) @@ -446,11 +457,12 @@ exploder = env.Program("exploder", exploder_sources, LIBPATH = [".", "/lib", "/usr/lib"]) # FIXME: test build presently fails at link time. +test_env = env.Clone() test_sources = [ "src/tests/main.cpp", "src/tests/test_util.cpp", ] -env.Program("test", test_sources, +test_env.Program("test", test_sources, CPPPATH = commonpath + ['/usr/include'], LIBS = ['wesnoth_core', 'wesnoth_sdl', 'wesnothd'] + commonlibs + ['boost_unit_test_framework'], LIBPATH = [".", "/lib", "/usr/lib"]) @@ -735,9 +747,8 @@ env.Precious(sanity_check) # # To do: # -# 1. Building the unit-test binaries. -# 2. Documentation formatting and man-page installation -# 3. Translations handling other than installation (pot-update). +# 1. Documentation formatting and man-page installation +# 2. Translations handling other than installation (pot-update). # Local variables: # mode: python diff --git a/src/Makefile.am b/src/Makefile.am index 18518ae50e6..1f76d66522a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -479,12 +479,10 @@ if PREFSDIR CXXFLAGS += -DPREFERENCES_DIR=\"$(prefsdir)\" endif -# *** Not yet covered by scons recipe if BOOST_TEST_DYN_LINK CXXFLAGS += -DBOOST_TEST_DYN_LINK endif -# *** Not yet covered by scons recipe if BOOST_AUTO_TEST CXXFLAGS += -DWESNOTH_BOOST_AUTO_TEST_MAIN else