ndebug.py 893 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/python
  2. # Copyright 2003 Vladimir Prus
  3. # Distributed under the Boost Software License, Version 1.0.
  4. # (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
  5. # Test that building with optimization brings NDEBUG define, and, more
  6. # importantly, that dependency targets are built with NDEBUG as well, even if
  7. # they are not directly requested.
  8. import BoostBuild
  9. t = BoostBuild.Tester(use_test_config=False)
  10. t.write("jamroot.jam", "exe hello : hello.cpp lib//lib1 ;")
  11. t.write("hello.cpp", """\
  12. #ifdef NDEBUG
  13. void foo();
  14. int main() { foo(); }
  15. #endif
  16. """)
  17. t.write("lib/jamfile.jam", "lib lib1 : lib1.cpp ;")
  18. t.write("lib/lib1.cpp", """\
  19. #ifdef NDEBUG
  20. void foo() {}
  21. #endif
  22. """)
  23. # 'release' builds should get the NDEBUG define. We use static linking to avoid
  24. # messing with imports/exports on Windows.
  25. t.run_build_system(["link=static", "release"])
  26. t.cleanup()