Skip to content

Commit be6df87

Browse files
committed
exporting pkgconfig file
1 parent c4dfd40 commit be6df87

File tree

8 files changed

+131
-5
lines changed

8 files changed

+131
-5
lines changed

conanfile.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
python_requires,
44
tools,
55
)
6+
import os
67
import re
78

89

@@ -28,9 +29,19 @@ class EnumFlagsConan(b2.B2.Mixin, ConanFile):
2829
url = "https://github.com/grisumbras/enum-flags"
2930
homepage = url
3031

31-
exports_sources = "jamroot.jam", "build.jam", "*.hpp", "*.cpp", "LICENSE*",
32+
exports_sources = (
33+
"jamroot.jam",
34+
"*build.jam",
35+
"exports/*.jam",
36+
"*.hpp",
37+
"*.cpp",
38+
"LICENSE*",
39+
)
3240
no_copy_source = True
3341
build_requires = "boost_build/[>=1.68]@bincrafters/stable"
3442

3543
def package_info(self):
3644
self.info.header_only()
45+
46+
pkgconfig_dir = os.path.join(self.package_folder, "lib", "pkgconfig")
47+
self.env_info.PKG_CONFIG_PATH.append(pkgconfig_dir)

exports/build.jam

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import install-path ;
2+
import make ;
3+
import print ;
4+
5+
6+
prefix = [ install-path.prefix enum-flags ] ;
7+
execprefix = [ install-path.exec-prefix $(prefix) ] ;
8+
libdir = [ install-path.libdir $(execprefix) ] ;
9+
includedir = [ install-path.includedir $(prefix) ] ;
10+
11+
12+
make enum-flags.pc : : @write-pc ;
13+
install install-pc : enum-flags.pc : <location>$(libdir)/pkgconfig ;
14+
15+
16+
alias install : install-pc ;
17+
explicit install install-pc ;
18+
19+
20+
rule write-pc ( target : sources * : properties * ) {
21+
write $(target)
22+
: "Name: enum-flags"
23+
"Description: Bit-flags for C++ scoped enums"
24+
"Version: $(VERSION)"
25+
"Cflags: -I$(includedir)"
26+
""
27+
;
28+
}
29+
30+
31+
local rule write ( target : content * ) {
32+
print.output $(target) ;
33+
print.text $(content) ;
34+
}

exports/install-path.jam

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import modules ;
2+
import option ;
3+
import property ;
4+
5+
6+
rule prefix ( package-name : requirements * ) {
7+
local prefix
8+
= [ option.get prefix
9+
: [ property.select <install-default-prefix> : $(requirements) ]
10+
] ;
11+
prefix = $(prefix:G=) ;
12+
requirements
13+
= [ property.change $(requirements) : <install-default-prefix> ] ;
14+
15+
if ! $(prefix) {
16+
if [ modules.peek : NT ] {
17+
prefix = C:\\$(package-name) ;
18+
} else if [ modules.peek : UNIX ] {
19+
prefix = /usr/local ;
20+
}
21+
}
22+
return $(prefix) ;
23+
}
24+
25+
26+
rule exec-prefix ( prefix ) {
27+
return [ option.get execprefix : $(prefix) ] ;
28+
}
29+
30+
31+
rule libdir ( execprefix ) {
32+
return [ option.get libdir : $(execprefix)/lib ] ;
33+
}
34+
35+
36+
rule includedir ( prefix ) {
37+
return [ option.get includedir : $(prefix)/include ] ;
38+
}

jamroot.jam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ explicit headers ;
2020

2121
package.install-data license : enum-flags : LICENSE ;
2222

23-
alias install : headers license ;
23+
alias install : headers license exports//install ;
2424
explicit install headers license ;

test/build.jam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import testing ;
22

33

4-
project
4+
project enum-flags-test
55
: requirements <warnings>all
66
<warnings-as-errors>on
77
: default-build <variant>release

test/conanfile.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,28 @@
22
ConanFile,
33
python_requires,
44
)
5+
import os
56

67

78
b2 = python_requires("b2-helper/0.2.0@grisumbras/testing")
89

910

10-
class EnumFlagsTestConan(b2.B2.Mixin, ConanFile):
11+
class EnumFlagsTestConan(ConanFile):
1112
settings = "os", "compiler", "build_type", "arch", "cppstd",
1213
build_requires = (
1314
"boost_build/[>=1.68]@bincrafters/stable",
1415
"boost_core/[>1.60]@bincrafters/stable",
1516
)
17+
generators = "b2"
1618

1719
def test(self):
18-
pass
20+
builder = b2.B2(self)
21+
builder.build_folder = os.path.join(self.build_folder, "base")
22+
builder.configure()
23+
builder.build()
24+
25+
builder = b2.B2(self)
26+
builder.source_folder = os.path.join(self.source_folder, "pkgconfig")
27+
builder.build_folder = os.path.join(self.build_folder, "pkgconfig")
28+
builder.configure()
29+
builder.build()

test/pkgconfig/jamroot.jam

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import errors ;
2+
import os ;
3+
import string ;
4+
5+
project enum-flags-test ;
6+
7+
exe app : main.cpp pkgconfig-enum-flags ;
8+
9+
10+
local rule pkgconfig ( package ) {
11+
local pkgconfig = [ os.environ PKG_CONFIG ] ;
12+
pkgconfig ?= pkg-config ;
13+
14+
local result
15+
= [ SHELL "$(pkgconfig) $(package) --cflags --libs"
16+
: exit-status strip-eol
17+
] ;
18+
if 0 != $(result[2]) {
19+
errors.error Could not find package '$(package)' with pkg-config
20+
"($(pkgconfig)):" $(result[1])! ;
21+
}
22+
23+
results = [ string.words $(result[1]) ] ;
24+
return <cxxflags>$(results) ;
25+
}
26+
27+
alias pkgconfig-enum-flags
28+
: usage-requirements [ pkgconfig enum-flags ]
29+
;

test/pkgconfig/main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#include <flags/flags.hpp>
2+
3+
int main() { return 0; }

0 commit comments

Comments
 (0)