Skip to content

Commit eb40d1a

Browse files
committed
vcpkg module
1 parent 501f72a commit eb40d1a

4 files changed

Lines changed: 450 additions & 2 deletions

File tree

doc/src/tasks.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,3 +726,7 @@ managers. Currently the supported ones are:
726726

727727
* Conan (`conan`): currently supports the
728728
link:https://docs.conan.io/en/latest/reference/generators/b2.html[`b2 generator`].
729+
730+
:leveloffset: +1
731+
include::../../src/tools/vcpkg.jam[tag=doc]
732+
:leveloffset: -1

src/build/ac.jam

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,17 @@ class ac-library : basic-target
199199
else
200200
{
201201
local use-environment ;
202+
local vcpkg-ps ;
202203
if ! $(self.library-name) && ! $(self.include-path) && ! $(self.library-path)
203204
{
204205
use-environment = true ;
206+
local vcpkg-proj = [ project.target vcpkg : allow-missing ] ;
207+
if $(vcpkg-proj)
208+
{
209+
vcpkg-ps = [ targets.generate-from-reference
210+
/vcpkg//prefix : $(vcpkg-proj) : $(property-set) ] ;
211+
}
212+
205213
}
206214
local libnames = $(self.library-name) ;
207215
if ! $(libnames) && $(use-environment)
@@ -213,12 +221,20 @@ class ac-library : basic-target
213221
libnames ?= $(self.default-names) ;
214222

215223
local include-path = $(self.include-path) ;
224+
if ! $(include-path) && $(vcpkg-ps)
225+
{
226+
include-path = [ $(vcpkg-ps).get <include> ] ;
227+
}
216228
if ! $(include-path) && $(use-environment)
217229
{
218230
include-path = [ os.environ $(name:U)_INCLUDE ] ;
219231
}
220232

221233
local library-path = $(self.library-path) ;
234+
if ! $(library-path) && $(vcpkg-ps)
235+
{
236+
library-path = [ $(vcpkg-ps).get <search> ] ;
237+
}
222238
if ! $(library-path) && $(use-environment)
223239
{
224240
library-path = [ os.environ $(name:U)_LIBRARY_PATH ] ;

src/tools/external.jam

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ targets inside projects it created. This allows seamless integration with
3838
package managers, if certain care is taken. In particular, it has become a
3939
convention to call the sole target in a header-only library project `libs`.
4040

41+
The module interoperates with <<bbv2.tasks.packagemanagers.vcpkg,`vcpkg`>>
42+
module. If configuration for some build request does not set include or library
43+
directories, but there is a fitting vcpkg configuration, the module will
44+
attempt to use it.
45+
4146
[[bbv2.tools.external.configure]]
4247
== Rule `configure`
4348

@@ -401,9 +406,17 @@ class external-library : ac-library
401406
proj = $(proj:B) ;
402407

403408
local use-environment ;
409+
local vcpkg-ps ;
410+
local used-vcpkg ;
404411
if ! $(self.library-name) && ! $(self.include-path)
405412
{
406413
use-environment = true ;
414+
local vcpkg-proj = [ project.target vcpkg : allow-missing ] ;
415+
if $(vcpkg-proj)
416+
{
417+
vcpkg-ps = [ targets.generate-from-reference
418+
/vcpkg//prefix : $(vcpkg-proj) : $(property-set) ] ;
419+
}
407420
}
408421

409422
local libnames = $(self.library-name) ;
@@ -415,21 +428,41 @@ class external-library : ac-library
415428
libnames ?= $(self.default-names) ;
416429

417430
local include-path = $(self.include-path) ;
431+
if ! $(include-path) && $(vcpkg-ps)
432+
{
433+
include-path = [ $(vcpkg-ps).get <include> ] ;
434+
used-vcpkg = true ;
435+
}
418436
if ! $(include-path) && $(use-environment)
419437
{
420438
include-path = [ os.environ $(proj:U)_$(name:U)_INCLUDE ] ;
421439
include-path ?= [ os.environ $(name:U)_INCLUDE ] ;
422440
}
423441

424442
local library-path = $(self.library-path) ;
443+
if ! $(library-path) && $(vcpkg-ps)
444+
{
445+
library-path = [ $(vcpkg-ps).get <search> ] ;
446+
used-vcpkg = true ;
447+
}
425448
if ! $(library-path) && $(use-environment)
426449
{
427450
library-path = [ os.environ $(proj:U)_$(name:U)_LIBRARY_PATH ] ;
428451
library-path ?= [ os.environ $(name:U)_LIBRARY_PATH ] ;
429452
}
430453

431-
local relevant = [
432-
configure.get-relevant-features [ $(self.requirements).raw ] ] ;
454+
local relevant = [ $(self.requirements).raw ] ;
455+
if $(used-vcpkg)
456+
{
457+
local vcpkg-proj = [ project.target vcpkg ] ;
458+
local vcpkg-main = [ $(vcpkg-proj).main-target prefix ] ;
459+
local vcpkg-alt = [
460+
$(vcpkg-main).select-alternatives $(property-set) ] ;
461+
local vcpkg-condition = [ $(vcpkg-alt).requirements ] ;
462+
relevant += [ $(vcpkg-condition).raw ] ;
463+
}
464+
465+
relevant = [ configure.get-relevant-features $(relevant) ] ;
433466
relevant = $(relevant:G) ;
434467
relevant = [ sequence.unique [ SORT $(relevant) ] ] ;
435468
relevant = [ property.select $(relevant) : [ $(property-set).raw ] ] ;

0 commit comments

Comments
 (0)