param.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/usr/bin/python
  2. # Copyright 2018 Steven Watanabe
  3. # Distributed under the Boost Software License, Version 1.0.
  4. # (See accompanying file LICENSE.txt or copy at
  5. # https://www.bfgroup.xyz/b2/LICENSE.txt)
  6. import BoostBuild
  7. t = BoostBuild.Tester(pass_toolset=0)
  8. t.write("Jamroot.jam", """\
  9. import param ;
  10. import assert ;
  11. import errors : try catch ;
  12. rule test1 ( )
  13. {
  14. param.handle-named-params ;
  15. }
  16. test1 ;
  17. rule test2 ( sources * )
  18. {
  19. param.handle-named-params sources ;
  20. return $(sources) ;
  21. }
  22. assert.result : test2 ;
  23. assert.result test1.cpp test2.cpp : test2 test1.cpp test2.cpp ;
  24. assert.result test1.cpp test2.cpp : test2 sources test1.cpp test2.cpp ;
  25. rule test3 ( sources * : requirements * )
  26. {
  27. param.handle-named-params sources requirements ;
  28. return $(sources) -- $(requirements) ;
  29. }
  30. assert.result -- : test3 ;
  31. assert.result -- <link>shared : test3 : <link>shared ;
  32. assert.result test1.cpp -- <link>shared : test3 test1.cpp : <link>shared ;
  33. assert.result test1.cpp -- <link>shared
  34. : test3 test1.cpp : requirements <link>shared ;
  35. assert.result test1.cpp -- <link>shared
  36. : test3 sources test1.cpp : requirements <link>shared ;
  37. assert.result test1.cpp -- <link>shared
  38. : test3 requirements <link>shared : sources test1.cpp ;
  39. assert.result -- : test3 sources ;
  40. assert.result -- : test3 requirements ;
  41. assert.result -- <link>shared : test3 requirements <link>shared ;
  42. try ;
  43. {
  44. test3 sources test1.cpp : sources test2.cpp ;
  45. }
  46. catch Parameter 'sources' passed more than once. ;
  47. try ;
  48. {
  49. test3 sources test1.cpp : <link>shared ;
  50. }
  51. catch "Positional arguments must appear first." ;
  52. EXIT : 0 ;
  53. """)
  54. t.run_build_system()
  55. t.cleanup()