1#!/usr/bin/python 2 3# Copyright 2003 Dave Abrahams 4# Copyright 2002, 2003 Vladimir Prus 5# Distributed under the Boost Software License, Version 1.0. 6# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 7 8# Test that default build clause actually has any effect. 9 10import BoostBuild 11 12t = BoostBuild.Tester(use_test_config=False) 13 14t.write("jamroot.jam", "") 15t.write("jamfile.jam", "exe a : a.cpp : : debug release ;") 16t.write("a.cpp", "int main() {}\n") 17 18t.run_build_system() 19t.expect_addition("bin/$toolset/debug*/a.exe") 20t.expect_addition("bin/$toolset/release*/a.exe") 21 22# Check that explictly-specified build variant suppresses default-build. 23t.rm("bin") 24t.run_build_system(["release"]) 25t.expect_addition(BoostBuild.List("bin/$toolset/release*/") * "a.exe a.obj") 26t.ignore_addition('bin/*/a.rsp') 27t.expect_nothing_more() 28 29# Now check that we can specify explicit build request and default-build will be 30# combined with it. 31t.run_build_system(["optimization=space"]) 32t.expect_addition("bin/$toolset/debug/optimization-space*/a.exe") 33t.expect_addition("bin/$toolset/release/optimization-space*/a.exe") 34 35# Test that default-build must be identical in all alternatives. Error case. 36t.write("jamfile.jam", """\ 37exe a : a.cpp : : debug ; 38exe a : b.cpp : : ; 39""") 40t.run_build_system(["-n", "--no-error-backtrace"], status=1) 41t.fail_test(t.stdout().find("default build must be identical in all alternatives") == -1) 42 43# Test that default-build must be identical in all alternatives. No Error case, 44# empty default build. 45t.write("jamfile.jam", """\ 46exe a : a.cpp : <variant>debug ; 47exe a : b.cpp : <variant>release ; 48""") 49t.run_build_system(["-n", "--no-error-backtrace"], status=0) 50 51# Now try a harder example: default build which contains <define> should cause 52# <define> to be present when "b" is compiled. This happens only if 53# "build-project b" is placed first. 54t.write("jamfile.jam", """\ 55project : default-build <define>FOO ; 56build-project a ; 57build-project b ; 58""") 59 60t.write("a/jamfile.jam", "exe a : a.cpp ../b//b ;") 61t.write("a/a.cpp", """\ 62#ifdef _WIN32 63__declspec(dllimport) 64#endif 65void foo(); 66int main() { foo(); } 67""") 68 69t.write("b/jamfile.jam", "lib b : b.cpp ;") 70t.write("b/b.cpp", """\ 71#ifdef FOO 72#ifdef _WIN32 73__declspec(dllexport) 74#endif 75void foo() {} 76#endif 77""") 78 79t.run_build_system() 80 81t.cleanup() 82