jamroot.jam 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #|
  2. Copyright 2019 Dmitry Arkhipov
  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. |#
  7. using pkg-config : : : <libdir>packages ;
  8. using pkg-config : debug : : <libdir>packages <path>debug-packages ;
  9. import common ;
  10. import pkg-config ;
  11. import property-set ;
  12. import testing ;
  13. import version ;
  14. project : requirements <variant>debug:<pkg-config>debug ;
  15. pkg-config.import debugged ;
  16. pkg-config.import foobar : requirements <version>>=0.3 ;
  17. pkg-config.import mangled : requirements <conditional>@mangle-name ;
  18. versioned =
  19. [ pkg-config.import versioned
  20. : usage-requirements <conditional>@versioned-api
  21. ] ;
  22. with-var =
  23. [ pkg-config.import with-var
  24. : usage-requirements <conditional>@var-to-define
  25. ] ;
  26. # test if a package is found at all
  27. run test1.cpp foobar ;
  28. # test if conditional requirement is applied
  29. run test2.cpp mangled
  30. : target-name test2-1
  31. : requirements <threading>single
  32. : args SINGLE
  33. ;
  34. run test2.cpp mangled
  35. : target-name test2-2
  36. : requirements <threading>multi
  37. : args MULTI
  38. ;
  39. # test if pkg-config configuration is properly inferred from property set
  40. run test3.cpp debugged
  41. : target-name test3-1
  42. : requirements <variant>release
  43. : args RELEASE
  44. ;
  45. run test3.cpp debugged
  46. : target-name test3-2
  47. : requirements <variant>debug
  48. : args DEBUG
  49. ;
  50. # test use of version method of pkg-config targets
  51. run test4.cpp versioned ;
  52. # test use of variable method of pkg-config targets
  53. run test5.cpp with-var ;
  54. rule mangle-name ( props * ) {
  55. import feature ;
  56. local name =
  57. [ common.format-name
  58. <base> <threading>
  59. : mangled
  60. : ""
  61. : [ property-set.create $(props) ]
  62. ] ;
  63. return <name>$(name) ;
  64. }
  65. rule versioned-api ( props * ) {
  66. local ps = [ property-set.create $(props) ] ;
  67. local version = [ $(versioned).version $(ps) ] ;
  68. if [ version.version-less $(version) : 2 ]
  69. {
  70. return <define>VERSIONED_API=1 ;
  71. }
  72. else
  73. {
  74. return <define>VERSIONED_API=2 ;
  75. }
  76. }
  77. rule var-to-define ( props * ) {
  78. local ps = [ property-set.create $(props) ] ;
  79. local qwerty = [ $(with-var).variable qwerty : $(ps) ] ;
  80. return <define>QWERTY=\\\"$(qwerty)\\\" ;
  81. }