1#!/usr/bin/python 2 3# Copyright (C) Vladimir Prus 2006. 4# Distributed under the Boost Software License, Version 1.0. (See 5# accompanying file LICENSE_1_0.txt or copy at 6# http://www.boost.org/LICENSE_1_0.txt) 7 8import BoostBuild 9 10t = BoostBuild.Tester(use_test_config=False) 11 12t.write("a.cpp", "int main() {}\n") 13t.write("jamroot.jam", "exe a : a.cpp sub1//sub1 sub2//sub2 sub3//sub3 ;") 14t.write("sub1/jamfile.jam", """\ 15lib sub1 : sub1.cpp sub1_2 ../sub2//sub2 ; 16lib sub1_2 : sub1_2.cpp ; 17""") 18 19t.write("sub1/sub1.cpp", """\ 20#ifdef _WIN32 21__declspec(dllexport) 22#endif 23void sub1() {} 24""") 25 26t.write("sub1/sub1_2.cpp", """\ 27#ifdef _WIN32 28__declspec(dllexport) 29#endif 30void sub1() {} 31""") 32 33t.write("sub2/jamfile.jam", "lib sub2 : sub2.cpp ;") 34t.write("sub2/sub2.cpp", """\ 35#ifdef _WIN32 36__declspec(dllexport) 37#endif 38void sub2() {} 39""") 40 41t.write("sub3/jamroot.jam", "lib sub3 : sub3.cpp ;") 42t.write("sub3/sub3.cpp", """\ 43#ifdef _WIN32 44__declspec(dllexport) 45#endif 46void sub3() {} 47""") 48 49# 'clean' should not remove files under separate jamroot.jam. 50t.run_build_system() 51t.run_build_system(["--clean"]) 52t.expect_removal("bin/$toolset/debug*/a.obj") 53t.expect_removal("sub1/bin/$toolset/debug*/sub1.obj") 54t.expect_removal("sub1/bin/$toolset/debug*/sub1_2.obj") 55t.expect_removal("sub2/bin/$toolset/debug*/sub2.obj") 56t.expect_nothing("sub3/bin/$toolset/debug*/sub3.obj") 57 58# 'clean-all' removes everything it can reach. 59t.run_build_system() 60t.run_build_system(["--clean-all"]) 61t.expect_removal("bin/$toolset/debug*/a.obj") 62t.expect_removal("sub1/bin/$toolset/debug*/sub1.obj") 63t.expect_removal("sub1/bin/$toolset/debug*/sub1_2.obj") 64t.expect_removal("sub2/bin/$toolset/debug*/sub2.obj") 65t.expect_nothing("sub3/bin/$toolset/debug*/sub3.obj") 66 67# 'clean' together with project target removes only under that project. 68t.run_build_system() 69t.run_build_system(["sub1", "--clean"]) 70t.expect_nothing("bin/$toolset/debug*/a.obj") 71t.expect_removal("sub1/bin/$toolset/debug*/sub1.obj") 72t.expect_removal("sub1/bin/$toolset/debug*/sub1_2.obj") 73t.expect_nothing("sub2/bin/$toolset/debug*/sub2.obj") 74t.expect_nothing("sub3/bin/$toolset/debug*/sub3.obj") 75 76# 'clean-all' removes everything. 77t.run_build_system() 78t.run_build_system(["sub1", "--clean-all"]) 79t.expect_nothing("bin/$toolset/debug*/a.obj") 80t.expect_removal("sub1/bin/$toolset/debug*/sub1.obj") 81t.expect_removal("sub1/bin/$toolset/debug*/sub1_2.obj") 82t.expect_removal("sub2/bin/$toolset/debug*/sub2.obj") 83t.expect_nothing("sub3/bin/$toolset/debug*/sub3.obj") 84 85# If main target is explicitly named, we should not remove files from other 86# targets. 87t.run_build_system() 88t.run_build_system(["sub1//sub1", "--clean"]) 89t.expect_removal("sub1/bin/$toolset/debug*/sub1.obj") 90t.expect_nothing("sub1/bin/$toolset/debug*/sub1_2.obj") 91t.expect_nothing("sub2/bin/$toolset/debug*/sub2.obj") 92t.expect_nothing("sub3/bin/$toolset/debug*/sub3.obj") 93 94# Regression test: sources of the 'cast' rule were mistakenly deleted. 95t.rm(".") 96t.write("jamroot.jam", """\ 97import cast ; 98cast a cpp : a.h ; 99""") 100t.write("a.h", "") 101t.run_build_system(["--clean"]) 102t.expect_nothing("a.h") 103 104t.cleanup() 105