Skip to content

Commit fd0f456

Browse files
authored
Merge pull request #340 from PJK/ci-updates
Update Bazel setup to Bzlmod
2 parents 907790d + 41686ee commit fd0f456

File tree

10 files changed

+88
-151
lines changed

10 files changed

+88
-151
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
build
21
*~
32
nbproject
43
.idea
@@ -8,9 +7,11 @@ cmake-build-debug
87
venv
98
**.DS_Store
109
.vscode
10+
doc/build
1111
# No top-level requirements, see doc/source
1212
requirements.txt
1313
examples/bazel/bazel-bazel
1414
examples/bazel/bazel-bin
1515
examples/bazel/bazel-out
1616
examples/bazel/bazel-testlogs
17+
**MODULE.bazel.lock

BUILD

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
genrule(
2+
name = "cbor_cmake",
3+
srcs = glob(["**"]),
4+
outs = [
5+
"libcbor.a",
6+
"cbor.h",
7+
"cbor/arrays.h",
8+
"cbor/bytestrings.h",
9+
"cbor/callbacks.h",
10+
"cbor/cbor_export.h",
11+
"cbor/common.h",
12+
"cbor/configuration.h",
13+
"cbor/data.h",
14+
"cbor/encoding.h",
15+
"cbor/floats_ctrls.h",
16+
"cbor/ints.h",
17+
"cbor/maps.h",
18+
"cbor/serialization.h",
19+
"cbor/streaming.h",
20+
"cbor/strings.h",
21+
"cbor/tags.h",
22+
],
23+
cmd = " && ".join([
24+
# Remember where output should go.
25+
"INITIAL_WD=`pwd`",
26+
"cd `dirname $(location CMakeLists.txt)`",
27+
"cmake -DCMAKE_BUILD_TYPE=Release .",
28+
"cmake --build .",
29+
# Export the .a and .h files for cbor rule, below.
30+
"cp -R src/* $$INITIAL_WD/$(RULEDIR)",
31+
"cp cbor/configuration.h $$INITIAL_WD/$(RULEDIR)/cbor",
32+
]),
33+
visibility = ["//visibility:private"],
34+
)
35+
36+
cc_import(
37+
name = "cbor",
38+
hdrs = [
39+
"cbor.h",
40+
"cbor/arrays.h",
41+
"cbor/bytestrings.h",
42+
"cbor/callbacks.h",
43+
"cbor/cbor_export.h",
44+
"cbor/common.h",
45+
"cbor/configuration.h",
46+
"cbor/data.h",
47+
"cbor/encoding.h",
48+
"cbor/floats_ctrls.h",
49+
"cbor/ints.h",
50+
"cbor/maps.h",
51+
"cbor/serialization.h",
52+
"cbor/streaming.h",
53+
"cbor/strings.h",
54+
"cbor/tags.h",
55+
],
56+
static_library = "libcbor.a",
57+
visibility = ["//visibility:public"],
58+
)

Bazel.md

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

MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module(name = "libcbor")

examples/bazel/MODULE.bazel

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module(
2+
name = "libcbor_bazel_example",
3+
version = "0.1.0",
4+
)
5+
6+
bazel_dep(name = "rules_cc", version = "0.1.1")
7+
bazel_dep(name = "googletest", version = "1.15.2")
8+
9+
bazel_dep(name = "libcbor")
10+
local_path_override(
11+
module_name = "libcbor",
12+
path = "../..",
13+
)

examples/bazel/WORKSPACE

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

examples/bazel/src/BUILD

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ load("@rules_cc//cc:defs.bzl", "cc_library")
22
load("@rules_cc//cc:defs.bzl", "cc_binary")
33

44
cc_library(
5-
name = "src",
5+
name = "hello_lib",
66
srcs = [
77
"hello.cc",
88
],
@@ -18,7 +18,7 @@ cc_library(
1818
)
1919

2020
cc_test(
21-
name = "tests",
21+
name = "hello_test",
2222
size = "small",
2323
srcs = [
2424
"hello_test.cc",
@@ -27,8 +27,8 @@ cc_test(
2727
"//visibility:private",
2828
],
2929
deps = [
30-
":src",
31-
"@gtest//:gtest_main",
30+
":hello_lib",
31+
"@googletest//:gtest_main",
3232
"@libcbor//:cbor",
3333
],
3434
)
@@ -40,7 +40,7 @@ cc_binary(
4040
"main.cc",
4141
],
4242
deps = [
43-
":src",
43+
":hello_lib",
4444
],
4545
)
4646

examples/bazel/src/hello_test.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
#include "src/hello.h"
2+
#include "cbor.h"
23

34
#include "gtest/gtest.h"
45

5-
class HelloTest : public ::testing::Test {};
6+
class CborTest : public ::testing::Test {};
67

7-
TEST_F(HelloTest, CborVersion) {
8-
EXPECT_EQ(cbor_version(), 0);
8+
TEST_F(CborTest, IntegerItem) {
9+
cbor_item_t * answer = cbor_build_uint8(42);
10+
EXPECT_EQ(cbor_get_uint8(answer), 42);
11+
cbor_decref(&answer);
12+
EXPECT_EQ(answer, nullptr);
913
}
1014

examples/bazel/third_party/libcbor.BUILD

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

oss-fuzz/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
#
1616
################################################################################
1717

18-
mkdir build
19-
cd build
18+
mkdir oss_fuzz_build
19+
cd oss_fuzz_build
2020
# We disable libcbor's default sanitizers since we'll be configuring them ourselves via CFLAGS.
2121
cmake -D CMAKE_BUILD_TYPE=Debug \
2222
-D CMAKE_INSTALL_PREFIX="$WORK" \

0 commit comments

Comments
 (0)