1#| 2Copyright 2019 Dmitry Arkhipov 3Distributed under the Boost Software License, Version 1.0. (See 4accompanying file LICENSE_1_0.txt or copy at 5http://www.boost.org/LICENSE_1_0.txt) 6|# 7 8 9using pkg-config : : : <libdir>packages ; 10using pkg-config : debug : : <libdir>packages <path>debug-packages ; 11 12import common ; 13import pkg-config ; 14import property-set ; 15import testing ; 16import version ; 17 18 19project : requirements <variant>debug:<pkg-config>debug ; 20 21 22pkg-config.import debugged ; 23pkg-config.import foobar : requirements <version>>=0.3 ; 24pkg-config.import mangled : requirements <conditional>@mangle-name ; 25 26versioned = 27 [ pkg-config.import versioned 28 : usage-requirements <conditional>@versioned-api 29 ] ; 30 31with-var = 32 [ pkg-config.import with-var 33 : usage-requirements <conditional>@var-to-define 34 ] ; 35 36 37# test if a package is found at all 38run test1.cpp foobar ; 39 40# test if conditional requirement is applied 41run test2.cpp mangled 42 : target-name test2-1 43 : requirements <threading>single 44 : args SINGLE 45 ; 46 47run test2.cpp mangled 48 : target-name test2-2 49 : requirements <threading>multi 50 : args MULTI 51 ; 52 53# test if pkg-config configuration is properly inferred from property set 54run test3.cpp debugged 55 : target-name test3-1 56 : requirements <variant>release 57 : args RELEASE 58 ; 59 60run test3.cpp debugged 61 : target-name test3-2 62 : requirements <variant>debug 63 : args DEBUG 64 ; 65 66# test use of version method of pkg-config targets 67run test4.cpp versioned ; 68 69# test use of variable method of pkg-config targets 70run test5.cpp with-var ; 71 72 73rule mangle-name ( props * ) { 74 import feature ; 75 local name = 76 [ common.format-name 77 <base> <threading> 78 : mangled 79 : "" 80 : [ property-set.create $(props) ] 81 ] ; 82 return <name>$(name) ; 83} 84 85 86rule versioned-api ( props * ) { 87 local ps = [ property-set.create $(props) ] ; 88 local version = [ $(versioned).version $(ps) ] ; 89 if [ version.version-less $(version) : 2 ] 90 { 91 return <define>VERSIONED_API=1 ; 92 } 93 else 94 { 95 return <define>VERSIONED_API=2 ; 96 } 97} 98 99 100rule var-to-define ( props * ) { 101 local ps = [ property-set.create $(props) ] ; 102 local qwerty = [ $(with-var).variable qwerty : $(ps) ] ; 103 return <define>QWERTY=\\\"$(qwerty)\\\" ; 104} 105