Skip to content

Commit 4b68dbb

Browse files
Merge pull request #3 from andreiavrammsd/bazel
Bazel
2 parents 3d7aea4 + 2e4887f commit 4b68dbb

File tree

15 files changed

+136
-4
lines changed

15 files changed

+136
-4
lines changed

.github/workflows/bazel.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: bazel
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
bazel:
8+
runs-on: ubuntu-22.04
9+
10+
steps:
11+
- uses: actions/checkout@v3
12+
- uses: bazelbuild/setup-bazelisk@v2
13+
- name: Mount bazel cache
14+
uses: actions/cache@v3
15+
with:
16+
path: "~/.cache/bazel"
17+
key: bazel
18+
19+
- run: bazel test poly_map_test --test_output=all

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.idea
2-
cmake-build-*
2+
*build*
3+
*bazel*

.vscode/settings.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"files.insertFinalNewline": true,
3+
"files.trimFinalNewlines": true,
4+
}

BUILD

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
cc_library(
2+
name = "poly_map",
3+
hdrs = ["include/msd/poly_map.hpp"],
4+
includes = ["include"],
5+
visibility = ["//visibility:public"],
6+
)
7+
8+
cc_test(
9+
name = "poly_map_test",
10+
size = "small",
11+
srcs = ["tests/poly_map_test.cpp"],
12+
copts = ["--std=c++17 -Wall -Wextra -Wpedantic -Werror"],
13+
deps = [
14+
":poly_map",
15+
"@gtest//:gtest_main",
16+
],
17+
)

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.17)
22
project(poly_map)
3-
set(PROJECT_VERSION 0.2.0)
3+
set(PROJECT_VERSION 0.3.0)
44

55
set(CMAKE_CXX_STANDARD 17)
66
set(CMAKE_CXX_STANDARD_REQUIRED YES)

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ A recursive map that can have any shape and can hold multiple types for keys and
1515
## Requirements
1616

1717
* C++17
18-
* CMake 3.17+
18+
* CMake 3.17+ or Bazel
1919

2020
## Usage
2121

WORKSPACE

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
2+
3+
http_archive(
4+
name = "gtest",
5+
url = "https://github.com/google/googletest/archive/release-1.10.0.zip",
6+
sha256 = "94c634d499558a76fa649edb13721dce6e98fb1e7018dfaeba3cd7a083945e91",
7+
build_file = "@//:gtest.BUILD",
8+
strip_prefix = "googletest-release-1.10.0",
9+
)

examples/bazel-project/.clang-format

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
BasedOnStyle: Google
2+
IndentWidth: 4
3+
Language: Cpp
4+
PointerAlignment: Right
5+
BreakBeforeBraces: Stroustrup
6+
ColumnLimit: 120

examples/bazel-project/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea
2+
*build*
3+
*bazel*

examples/bazel-project/BUILD

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cc_binary(
2+
name = "bazel-project",
3+
srcs = ["src/main.cpp"],
4+
deps = [
5+
"@poly_map//:poly_map",
6+
],
7+
copts = ["--std=c++17"],
8+
)

examples/bazel-project/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Bazel project
2+
3+
Example of using Poly map in a project with Bazel.
4+
5+
## Requirements
6+
7+
* C++17 compiler
8+
* Bazel

examples/bazel-project/WORKSPACE

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
2+
3+
http_archive(
4+
name = "poly_map",
5+
url = "https://github.com/andreiavrammsd/polymap/archive/refs/tags/v0.3.0.zip",
6+
strip_prefix = "polymap-0.3.0",
7+
)

examples/bazel-project/src/main.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <cassert>
2+
3+
#include "msd/poly_map.hpp"
4+
5+
int main()
6+
{
7+
msd::poly_map<int> map;
8+
9+
map[0][0] = 1;
10+
map[0][1] = 2;
11+
map[0][2] = 3;
12+
13+
map[1][1] = 5;
14+
map[1][2] = 6;
15+
16+
map[2][0] = 7;
17+
map[2][1] = 8;
18+
map[2][2] = 9;
19+
20+
assert(!map.contains(1, 0));
21+
assert(map.at(2, 2).get<int>() == 9);
22+
}

examples/cmake-project/.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
.idea
2-
cmake-build-*
2+
*build*

gtest.BUILD

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
cc_library(
2+
name = "gtest",
3+
srcs = [
4+
"googletest/src/gtest-all.cc",
5+
"googlemock/src/gmock-all.cc",
6+
],
7+
hdrs = glob([
8+
"**/*.h",
9+
"googletest/src/*.cc",
10+
"googlemock/src/*.cc",
11+
]),
12+
includes = [
13+
"googlemock",
14+
"googletest",
15+
"googletest/include",
16+
"googlemock/include",
17+
],
18+
linkopts = ["-pthread"],
19+
visibility = ["//visibility:public"],
20+
)
21+
22+
cc_library(
23+
name = "gtest_main",
24+
srcs = ["googlemock/src/gmock_main.cc"],
25+
linkopts = ["-pthread"],
26+
visibility = ["//visibility:public"],
27+
deps = [":gtest"],
28+
)

0 commit comments

Comments
 (0)