default_build.py 2.3 KB

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