implicit_dependency.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/usr/bin/python
  2. # Copyright (C) Vladimir Prus 2006.
  3. # Distributed under the Boost Software License, Version 1.0. (See
  4. # accompanying file LICENSE.txt or copy at
  5. # https://www.bfgroup.xyz/b2/LICENSE.txt)
  6. # Test the <implicit-dependency> is respected even if the target referred to is
  7. # not built itself, but only referred to by <implicit-dependency>.
  8. import BoostBuild
  9. t = BoostBuild.Tester(use_test_config=False)
  10. t.write("jamroot.jam", """
  11. make a.h : : gen-header ;
  12. explicit a.h ;
  13. exe hello : hello.cpp : <implicit-dependency>a.h ;
  14. import os ;
  15. if [ os.name ] = NT
  16. {
  17. actions gen-header
  18. {
  19. echo int i; > $(<)
  20. }
  21. }
  22. else
  23. {
  24. actions gen-header
  25. {
  26. echo "int i;" > $(<)
  27. }
  28. }
  29. """)
  30. t.write("hello.cpp", """
  31. #include "a.h"
  32. int main() { return i; }
  33. """)
  34. t.run_build_system()
  35. t.expect_addition("bin/$toolset/debug*/hello.exe")
  36. t.rm("bin")
  37. t.write("jamroot.jam", """
  38. make dir/a.h : : gen-header ;
  39. explicit dir/a.h ;
  40. exe hello : hello.cpp : <implicit-dependency>dir/a.h ;
  41. import os ;
  42. if [ os.name ] = NT
  43. {
  44. actions gen-header
  45. {
  46. echo int i; > $(<)
  47. }
  48. }
  49. else
  50. {
  51. actions gen-header
  52. {
  53. echo "int i;" > $(<)
  54. }
  55. }
  56. """)
  57. t.write("hello.cpp", """
  58. #include "dir/a.h"
  59. int main() { return i; }
  60. """)
  61. t.run_build_system()
  62. t.expect_addition("bin/$toolset/debug*/hello.exe")
  63. t.cleanup()