1#!/usr/local/bin/python3.8 2 3# Copyright (C) 2003. Pedro Ferreira 4# Distributed under the Boost Software License, Version 1.0. 5# (See accompanying file LICENSE_1_0.txt or copy at 6# http://www.boost.org/LICENSE_1_0.txt) 7 8import BoostBuild 9 10 11############################################################################### 12# 13# test_folder_with_dot_in_name() 14# ------------------------------ 15# 16############################################################################### 17 18def test_folder_with_dot_in_name(t): 19 """ 20 Regression test: the 'tag' feature did not work in directories that had a 21 dot in their name. 22 23 """ 24 t.write("version-1.32.0/jamroot.jam", """\ 25project test : requirements <tag>@$(__name__).tag ; 26 27rule tag ( name : type ? : property-set ) 28{ 29 # Do nothing, just make sure the rule is invoked OK. 30 ECHO The tag rule has been invoked. ; 31} 32exe a : a.cpp ; 33""") 34 t.write("version-1.32.0/a.cpp", "int main() {}\n") 35 36 t.run_build_system(subdir="version-1.32.0") 37 t.expect_addition("version-1.32.0/bin/$toolset/debug*/a.exe") 38 t.expect_output_lines("The tag rule has been invoked.") 39 40 41############################################################################### 42# 43# test_tag_property() 44# ------------------- 45# 46############################################################################### 47 48def test_tag_property(t): 49 """Basic tag property test.""" 50 51 t.write("jamroot.jam", """\ 52import virtual-target ; 53 54rule tag ( name : type ? : property-set ) 55{ 56 local tags ; 57 switch [ $(property-set).get <variant> ] 58 { 59 case debug : tags += d ; 60 case release : tags += r ; 61 } 62 switch [ $(property-set).get <link> ] 63 { 64 case shared : tags += s ; 65 case static : tags += t ; 66 } 67 if $(tags) 68 { 69 return [ virtual-target.add-prefix-and-suffix $(name)_$(tags:J="") 70 : $(type) : $(property-set) ] ; 71 } 72} 73 74# Test both fully-qualified and local name of the rule 75exe a : a.cpp : <tag>@$(__name__).tag ; 76lib b : a.cpp : <tag>@tag ; 77stage c : a ; 78""") 79 80 t.write("a.cpp", """\ 81int main() {} 82#ifdef _MSC_VER 83__declspec (dllexport) void x () {} 84#endif 85""") 86 87 file_list = ( 88 BoostBuild.List("bin/$toolset/debug*/a_ds.exe") + 89 BoostBuild.List("bin/$toolset/debug*/b_ds.dll") + 90 BoostBuild.List("c/a_ds.exe") + 91 BoostBuild.List("bin/$toolset/release*/a_rs.exe") + 92 BoostBuild.List("bin/$toolset/release*/b_rs.dll") + 93 BoostBuild.List("c/a_rs.exe") + 94 BoostBuild.List("bin/$toolset/debug*/a_dt.exe") + 95 BoostBuild.List("bin/$toolset/debug*/b_dt.lib") + 96 BoostBuild.List("c/a_dt.exe") + 97 BoostBuild.List("bin/$toolset/release*/a_rt.exe") + 98 BoostBuild.List("bin/$toolset/release*/b_rt.lib") + 99 BoostBuild.List("c/a_rt.exe")) 100 101 variants = ["debug", "release", "link=static,shared"] 102 103 t.run_build_system(variants) 104 t.expect_addition(file_list) 105 106 t.run_build_system(variants + ["clean"]) 107 t.expect_removal(file_list) 108 109 110############################################################################### 111# 112# main() 113# ------ 114# 115############################################################################### 116 117t = BoostBuild.Tester(use_test_config=False) 118 119test_tag_property(t) 120test_folder_with_dot_in_name(t) 121 122t.cleanup() 123