Skip to content

Commit dd93762

Browse files
committed
fix: make test-bazel-bench
1 parent 491b1fa commit dd93762

15 files changed

+137
-146
lines changed

.bazelignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
conandeps2/
2+
strange/

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
*~
22
bazel-*
33
conandeps/
4+
.vscode/
5+
a.out
46
conan.lock
57
conanbuild.json
68
conanbuildinfo.txt
79
conaninfo.txt
810
graph_info.json
9-
conan_cache/
11+
conan_cache*
12+
conanbuild.conf

.vscode/settings.json

Lines changed: 0 additions & 100 deletions
This file was deleted.

BUILD.bzl

Whitespace-only changes.

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@ This is an experimental library in Header Only format (just add `Scanner.hpp` to
88
This project tries to use both Conan and Bazel (during tests and benchmarks, not production).
99
By Conan, the files at `conandeps` are created in a compatible manner with Bazel.
1010

11+
### Working Example for Conan+Bazel+Benchmark
12+
13+
`make test-bazel-bench`
14+
15+
This will create `conandeps/` folder and initialize bazel dependencies from `setup-conandeps-bazel/`.
16+
1117
### Dependencies
1218

13-
`conan search benchmark -r conan-center`
19+
`conan search benchmark -r conancenter`
1420

15-
`conan search tl-expected -r conan-center`
21+
`conan search tl-expected -r conancenter`
1622

1723
### Conan + Bazel
1824

@@ -32,6 +38,8 @@ or install in local `conan_cache` folder:
3238
mkdir -p conan_cache && export CONAN_USER_HOME=${PWD}/conan_cache && conan install . -s compiler.libcxx=libstdc++11
3339
```
3440

41+
MAYBE: `conan profile update settings.compiler.libcxx=libstdc++11 default`
42+
TODO: TRY THIS LATER TO MAYBE AVOID PREVIOUS COMMAND...
3543

3644
At `conandeps/benchmark/BUILD`, small fix, add these into `cc_library`:
3745

WORKSPACE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ load('@bazel_tools//tools/build_defs/repo:git.bzl', 'git_repository')
1313
# conan install .
1414
# will generate 'conandeps' folder and many conaninfo local files (see .gitignore)
1515
load("@//conandeps:dependencies.bzl", "load_conan_dependencies")
16+
#w=__workspace_dir__
1617
load_conan_dependencies()

makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ all:
44
test:
55
cd tests && make
66

7+
test-bazel-bench: get_conan_packages
8+
# cd tests && ./run_bench.sh
9+
cd tests && make bazel-bench
10+
711
install:
812
# this will require sudo to copy header to /usr/local/include/scannerpp/
913
./install.sh && echo "Finished successfully"
@@ -13,3 +17,16 @@ test-install:
1317

1418
test-coverage:
1519
cd tests && make test-coverage && echo "Finished successfully"
20+
21+
get_conan_packages:
22+
# rm -rf conan_packages
23+
mkdir -p conandeps/conan_packages
24+
cp setup-conandeps-bazel/conanfile-conandeps.py conandeps/conanfile.py
25+
export CONAN_USER_HOME=${PWD}/conandeps/conan_packages && cd conandeps && conan install . -s compiler.libcxx=libstdc++11
26+
cp setup-conandeps-bazel/BUILD-conandeps-benchmark.bzl conandeps/benchmark/BUILD
27+
cp setup-conandeps-bazel/BUILD-conandeps-tl-expected.bzl conandeps/tl-expected/BUILD
28+
29+
clean_bazel_deps:
30+
rm -f conandeps/dependencies.bzl
31+
rm -rf conandeps/tl-expected
32+
rm -rf conandeps/benchmark
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
#filegroup(
3+
# name = "benchmark_binaries",
4+
# data = glob(["**"]),
5+
# visibility = ["//visibility:public"],
6+
#)
7+
8+
cc_import(
9+
name = "benchmark_precompiled",
10+
static_library = "lib/libbenchmark.a",
11+
# visibility = ["//visibility:public"],
12+
)
13+
14+
cc_import(
15+
name = "benchmark_main_precompiled",
16+
static_library = "lib/libbenchmark_main.a",
17+
#visibility = ["//visibility:public"],
18+
)
19+
20+
21+
cc_library(
22+
name = "benchmark",
23+
includes = ["include"],
24+
hdrs = glob(["include/**"]),
25+
deps = [":benchmark_precompiled"],
26+
linkopts = ["-lpthread"],
27+
visibility = ["//visibility:public"]
28+
)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
load("@rules_cc//cc:defs.bzl", "cc_import", "cc_library")
3+
4+
cc_library(
5+
name = "tl-expected",
6+
hdrs = glob(["include/**"]),
7+
includes = ["include"],
8+
visibility = ["//visibility:public"]
9+
)

conanfile.py renamed to setup-conandeps-bazel/conanfile-conandeps.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#
2+
# MOVE THIS FILE FROM setup-conandeps/ TO conandeps/ FOLDER AND RENAME IT TO conanfile.py
3+
# SCRIPT WILL DO THIS AUTOMATICALLY:
4+
# - make get_conan_packages
5+
# - make bazel-bench
6+
#
17
from conans import ConanFile
28

39
# conan with bazel (since Conan 1.37.0)
@@ -11,7 +17,7 @@
1117
# INSTRUCTIONS
1218
# ============
1319
# pip install conan
14-
# conan search tl-expected -r conan-center
20+
# conan search tl-expected -r conancenter
1521
# conan inspect tl-expected/20190710
1622
# > write local conanfile.py (this file)
1723
# conan install .

0 commit comments

Comments
 (0)