conditionals.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/python
  2. # Copyright 2003 Dave Abrahams
  3. # Copyright 2002, 2003, 2004 Vladimir Prus
  4. # Distributed under the Boost Software License, Version 1.0.
  5. # (See accompanying file LICENSE.txt or copy at
  6. # https://www.bfgroup.xyz/b2/LICENSE.txt)
  7. # Test conditional properties.
  8. import BoostBuild
  9. t = BoostBuild.Tester(use_test_config=False)
  10. # Arrange a project which will build only if 'a.cpp' is compiled with "STATIC"
  11. # define.
  12. t.write("a.cpp", """\
  13. #ifdef STATIC
  14. int main() {}
  15. #endif
  16. """)
  17. # Test conditionals in target requirements.
  18. t.write("jamroot.jam", "exe a : a.cpp : <link>static:<define>STATIC ;")
  19. t.run_build_system(["link=static"])
  20. t.expect_addition("bin/$toolset/debug/link-static*/a.exe")
  21. t.rm("bin")
  22. # Test conditionals in project requirements.
  23. t.write("jamroot.jam", """
  24. project : requirements <link>static:<define>STATIC ;
  25. exe a : a.cpp ;
  26. """)
  27. t.run_build_system(["link=static"])
  28. t.expect_addition("bin/$toolset/debug/link-static*/a.exe")
  29. t.rm("bin")
  30. # Regression test for a bug found by Ali Azarbayejani. Conditionals inside
  31. # usage requirement were not being evaluated.
  32. t.write("jamroot.jam", """
  33. lib l : l.cpp : : : <link>static:<define>STATIC ;
  34. exe a : a.cpp l ;
  35. """)
  36. t.write("l.cpp", "int i;")
  37. t.run_build_system(["link=static"])
  38. t.expect_addition("bin/$toolset/debug/link-static*/a.exe")
  39. t.cleanup()