feature_relevant.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #!/usr/bin/python
  2. # Copyright 2018 Steven Watanabe
  3. # Distributed under the Boost Software License, Version 1.0.
  4. # (See accompanying file LICENSE.txt or copy at
  5. # https://www.bfgroup.xyz/b2/LICENSE.txt)
  6. # Tests the <relevant> feature
  7. import BoostBuild
  8. t = BoostBuild.Tester(use_test_config=False)
  9. t.write("xxx.jam", """
  10. import type ;
  11. import feature : feature ;
  12. import toolset : flags ;
  13. import generators ;
  14. type.register XXX : xxx ;
  15. type.register YYY : yyy ;
  16. feature xxxflags : : free ;
  17. generators.register-standard xxx.run : YYY : XXX ;
  18. # xxxflags is relevant because it is used by flags
  19. flags xxx.run OPTIONS : <xxxflags> ;
  20. actions run
  21. {
  22. echo okay > $(<)
  23. }
  24. """)
  25. t.write("zzz.jam", """
  26. import xxx ;
  27. import type ;
  28. import feature : feature ;
  29. import generators ;
  30. type.register ZZZ : zzz ;
  31. feature zzz.enabled : off on : propagated ;
  32. # zzz.enabled is relevant because it is used in the generator's
  33. # requirements
  34. generators.register-standard zzz.run : XXX : ZZZ : <zzz.enabled>on ;
  35. actions run
  36. {
  37. echo okay > $(<)
  38. }
  39. """)
  40. t.write("aaa.jam", """
  41. import zzz ;
  42. import type ;
  43. import feature : feature ;
  44. import generators ;
  45. import toolset : flags ;
  46. type.register AAA : aaa ;
  47. feature aaaflags : : free ;
  48. generators.register-standard aaa.run : ZZZ : AAA ;
  49. flags aaa.run OPTIONS : <aaaflags> ;
  50. actions run
  51. {
  52. echo okay > $(<)
  53. }
  54. """)
  55. t.write("Jamroot.jam", """
  56. import xxx ;
  57. import zzz ;
  58. import aaa ;
  59. import feature : feature ;
  60. # f1 is relevant, because it is composite and <xxxflags> is relevant
  61. feature f1 : n y : composite propagated ;
  62. feature.compose <f1>y : <xxxflags>-no1 ;
  63. # f2 is relevant, because it is used in a conditional
  64. feature f2 : n y : propagated ;
  65. # f3 is relevant, because it is used to choose the target alternative
  66. feature f3 : n y : propagated ;
  67. # f4 is relevant, because it is marked as such explicitly
  68. feature f4 : n y : propagated ;
  69. # f5 is relevant because of the conditional usage-requirements
  70. feature f5 : n y : propagated ;
  71. # f6 is relevant because the indirect conditional indicates so
  72. feature f6 : n y : propagated ;
  73. # f7 is relevant because the icond7 says so
  74. feature f7 : n y : propagated ;
  75. # The same as f[n], except not propagated
  76. feature g1 : n y : composite ;
  77. feature.compose <g1>y : <xxxflags>-no1 ;
  78. feature g2 : n y ;
  79. feature g3 : n y ;
  80. feature g4 : n y ;
  81. feature g5 : n y ;
  82. feature g6 : n y ;
  83. feature g7 : n y ;
  84. project : default-build
  85. <f1>y <f2>y <f3>y <f4>y <f5>y <f6>y <f7>y
  86. <g1>y <g2>y <g3>y <g4>y <g5>y <g6>y <g7>y <zzz.enabled>on ;
  87. rule icond6 ( properties * )
  88. {
  89. local result ;
  90. if <f6>y in $(properties) || <g6>y in $(properties)
  91. {
  92. result += <xxxflags>-yes6 ;
  93. }
  94. return $(result)
  95. <relevant>xxxflags:<relevant>f6
  96. <relevant>xxxflags:<relevant>g6 ;
  97. }
  98. rule icond7 ( properties * )
  99. {
  100. local result ;
  101. if <f7>y in $(properties) || <g7>y in $(properties)
  102. {
  103. result += <aaaflags>-yes7 ;
  104. }
  105. return $(result)
  106. <relevant>aaaflags:<relevant>f7
  107. <relevant>aaaflags:<relevant>g7 ;
  108. }
  109. zzz out : in.yyy
  110. : <f2>y:<xxxflags>-no2 <g2>y:<xxxflags>-no2 <relevant>f4 <relevant>g4
  111. <conditional>@icond6
  112. :
  113. : <f5>y:<aaaflags>-yes5 <g5>y:<aaaflags>-yes5 <conditional>@icond7
  114. ;
  115. alias out : : <f3>n ;
  116. alias out : : <g3>n ;
  117. # Features that are relevant for out are also relevant for check-propagate
  118. aaa check-propagate : out ;
  119. """)
  120. t.write("in.yyy", "")
  121. t.run_build_system()
  122. t.expect_addition("bin/f1-y/f2-y/f3-y/f4-y/f6-y/g1-y/g2-y/g3-y/g4-y/g6-y/out.xxx")
  123. t.expect_addition("bin/f1-y/f2-y/f3-y/f4-y/f6-y/g1-y/g2-y/g3-y/g4-y/g6-y/zzz.enabled-on/out.zzz")
  124. t.expect_addition("bin/f1-y/f2-y/f3-y/f4-y/f5-y/f6-y/f7-y/zzz.enabled-on/check-propagate.aaa")
  125. t.cleanup()