inherit_toolset.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. import BoostBuild
  6. import string
  7. t = BoostBuild.Tester(pass_toolset=0)
  8. t.write("a.cpp", "\n")
  9. t.write("yfc1.jam", """\
  10. import feature ;
  11. import generators ;
  12. feature.extend toolset : yfc1 ;
  13. rule init ( ) { }
  14. generators.register-standard yfc1.compile : CPP : OBJ : <toolset>yfc1 ;
  15. generators.register-standard yfc1.link : OBJ : EXE : <toolset>yfc1 ;
  16. actions compile { yfc1-compile }
  17. actions link { yfc1-link }
  18. """)
  19. t.write(
  20. 'yfc1.py',
  21. """
  22. from b2.build import feature, generators
  23. from b2.manager import get_manager
  24. MANAGER = get_manager()
  25. ENGINE = MANAGER.engine()
  26. feature.extend('toolset', ['yfc1'])
  27. generators.register_standard('yfc1.compile', ['CPP'], ['OBJ'], ['<toolset>yfc1'])
  28. generators.register_standard('yfc1.link', ['OBJ'], ['EXE'], ['<toolset>yfc1'])
  29. ENGINE.register_action(
  30. 'yfc1.compile',
  31. 'yfc1-compile'
  32. )
  33. ENGINE.register_action(
  34. 'yfc1.link',
  35. 'yfc1-link'
  36. )
  37. def init(*args):
  38. pass
  39. """
  40. )
  41. t.write("yfc2.jam", """\
  42. import feature ;
  43. import toolset ;
  44. feature.extend toolset : yfc2 ;
  45. toolset.inherit yfc2 : yfc1 ;
  46. rule init ( ) { }
  47. actions link { yfc2-link }
  48. """)
  49. t.write(
  50. 'yfc2.py',
  51. """
  52. from b2.build import feature, toolset
  53. from b2.manager import get_manager
  54. MANAGER = get_manager()
  55. ENGINE = MANAGER.engine()
  56. feature.extend('toolset', ['yfc2'])
  57. toolset.inherit('yfc2', 'yfc1')
  58. ENGINE.register_action('yfc2.link', 'yfc2-link')
  59. def init(*args):
  60. pass
  61. """
  62. )
  63. t.write("jamfile.jam", "exe a : a.cpp ;")
  64. t.write("jamroot.jam", "using yfc1 ;")
  65. t.run_build_system(["-n", "-d2", "yfc1"])
  66. t.fail_test(t.stdout().find("yfc1-link") == -1)
  67. # Make sure we do not have to explicitly 'use' yfc1.
  68. t.write("jamroot.jam", "using yfc2 ;")
  69. t.run_build_system(["-n", "-d2", "yfc2"])
  70. t.fail_test(t.stdout().find("yfc2-link") == -1)
  71. t.cleanup()