Skip to content

Commit d73ccd8

Browse files
fulldecentdrinckes
andauthored
Update to work with new Bazel (#599)
Co-authored-by: Doug Rinckes <[email protected]>
1 parent 394ecef commit d73ccd8

File tree

9 files changed

+72
-95
lines changed

9 files changed

+72
-95
lines changed

.bazelrc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,5 @@ startup --host_jvm_args=-XX:-UseParallelGC
55
# build --local_resources=400,2,1.0
66
build --worker_max_instances=auto
77

8-
# Setting to false will cause Bazel to use local JDK. This can cause the
9-
# build to fail if it is not version 9.
10-
build --distinct_host_configuration=true
11-
128
# Configure tests - increase timeout, print everything and timeout warnings
139
test --verbose_failures --test_output=all --test_verbose_timeout_warnings

MODULE.bazel

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module(
2+
name = "openlocationcode",
3+
version = "1.0",
4+
)
5+
6+
bazel_dep(name = "googletest", version = "1.15.2")
7+
bazel_dep(name = "rules_proto", version = "6.0.2") # Deprecated (moved), TODO find new URL
8+
bazel_dep(name = "rules_java", version = "7.8.0")
9+
bazel_dep(name = "bazel_skylib", version = "1.6.1")
10+
bazel_dep(name = "rules_python", version = "0.33.2")
11+
12+
# External dependency archives
13+
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
14+
15+
http_archive(
16+
name = "io_bazel_rules_closure",
17+
sha256 = "9498e57368efb82b985db1ed426a767cbf1ba0398fd7aed632fc3908654e1b1e",
18+
strip_prefix = "rules_closure-0.12.0",
19+
urls = [
20+
"https://mirror.bazel.build/github.com/bazelbuild/rules_closure/archive/0.12.0.tar.gz",
21+
"https://github.com/bazelbuild/rules_closure/archive/0.12.0.tar.gz",
22+
],
23+
)

WORKSPACE

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

c/BUILD

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,43 @@
1-
# Rule to build the library.
21
cc_library(
32
name = "openlocationcode",
43
srcs = [
54
"src/olc.c",
65
],
7-
copts = ["-std=c99"],
6+
copts = [
7+
"-std=c99",
8+
"-Wall",
9+
"-Wextra",
10+
"-O2",
11+
],
812
hdrs = [
913
"src/olc.h",
1014
"src/olc_private.h",
1115
],
12-
visibility = ["//visibility:public"],
16+
includes = ["src"],
17+
visibility = ["//visibility:private"],
1318
)
1419

15-
# Rule to build and run the unit tests.
1620
cc_test(
1721
name = "openlocationcode_test",
1822
size = "small",
1923
srcs = ["openlocationcode_test.cc"],
2024
copts = [
2125
"-pthread",
22-
"-Iexternal/gtest/include",
26+
"-I@googletest//:include",
2327
],
28+
linkopts = ["-pthread"],
29+
linkstatic = False,
2430
data = [
2531
"//test_data",
2632
],
27-
linkopts = ["-pthread"],
2833
deps = [
2934
":openlocationcode",
30-
"@gtest//:main",
35+
"@googletest//:gtest_main",
3136
],
37+
testonly = True,
38+
visibility = ["//visibility:private"],
3239
)
3340

34-
# Rule to build and run the example.
3541
cc_binary(
3642
name = "openlocationcode_example",
3743
srcs = [
@@ -40,4 +46,5 @@ cc_binary(
4046
deps = [
4147
":openlocationcode",
4248
],
43-
)
49+
visibility = ["//visibility:private"],
50+
)

cpp/BUILD

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Library to handle open location codes
12
cc_library(
23
name = "openlocationcode",
34
srcs = [
@@ -7,14 +8,19 @@ cc_library(
78
"codearea.h",
89
"openlocationcode.h",
910
],
10-
copts = ["-pthread"],
11+
copts = [
12+
"-pthread",
13+
"-Wall",
14+
"-Wextra",
15+
"-O2",
16+
],
1117
linkopts = ["-pthread"],
12-
visibility = ["//visibility:public"],
1318
deps = [
1419
":codearea",
1520
],
1621
)
1722

23+
# Code area library, used by open location codes
1824
cc_library(
1925
name = "codearea",
2026
srcs = [
@@ -23,27 +29,31 @@ cc_library(
2329
hdrs = [
2430
"codearea.h",
2531
],
26-
visibility = ["//visibility:private"],
32+
visibility = ["//visibility:private"], # Keep private unless needed elsewhere
2733
)
2834

35+
# Unit test for open location codes
2936
cc_test(
3037
name = "openlocationcode_test",
3138
size = "small",
3239
srcs = ["openlocationcode_test.cc"],
3340
copts = [
3441
"-pthread",
35-
"-Iexternal/gtest/include",
42+
"-I@googletest//:include",
3643
],
44+
linkopts = ["-pthread"],
45+
linkstatic = False,
3746
data = [
3847
"//test_data",
3948
],
40-
linkopts = ["-pthread"],
4149
deps = [
4250
":openlocationcode",
43-
"@gtest//:main",
51+
"@googletest//:gtest_main",
4452
],
53+
testonly = True,
4554
)
4655

56+
# Example binary for open location codes
4757
cc_binary(
4858
name = "openlocationcode_example",
4959
srcs = [
@@ -52,4 +62,4 @@ cc_binary(
5262
deps = [
5363
":openlocationcode",
5464
],
55-
)
65+
)

cpp/gtest.BUILD

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

java/BUILD

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ java_library(
33
srcs = [
44
"src/main/java/com/google/openlocationcode/OpenLocationCode.java",
55
],
6+
visibility = ["//visibility:private"],
67
)
78

89
java_test(
@@ -15,6 +16,7 @@ java_test(
1516
deps = [
1617
":openlocationcode",
1718
],
19+
visibility = ["//visibility:private"],
1820
)
1921

2022
java_test(
@@ -31,6 +33,7 @@ java_test(
3133
deps = [
3234
":openlocationcode",
3335
],
36+
visibility = ["//visibility:private"],
3437
)
3538

3639
java_test(
@@ -47,6 +50,7 @@ java_test(
4750
deps = [
4851
":openlocationcode",
4952
],
53+
visibility = ["//visibility:private"],
5054
)
5155

5256
java_test(
@@ -63,6 +67,7 @@ java_test(
6367
deps = [
6468
":openlocationcode",
6569
],
70+
visibility = ["//visibility:private"],
6671
)
6772

6873
java_test(
@@ -79,6 +84,7 @@ java_test(
7984
deps = [
8085
":openlocationcode",
8186
],
87+
visibility = ["//visibility:private"],
8288
)
8389

8490
java_test(
@@ -92,6 +98,7 @@ java_test(
9298
deps = [
9399
":openlocationcode",
94100
],
101+
visibility = ["//visibility:private"],
95102
)
96103

97104
java_test(
@@ -105,6 +112,7 @@ java_test(
105112
deps = [
106113
":openlocationcode",
107114
],
115+
visibility = ["//visibility:private"],
108116
)
109117

110118
java_test(
@@ -118,4 +126,5 @@ java_test(
118126
deps = [
119127
":openlocationcode",
120128
],
129+
visibility = ["//visibility:private"],
121130
)

js/closure/BUILD

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1+
# Load the necessary Closure rules
12
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library", "closure_js_test")
23

4+
# Define the Closure library for Open Location Code
35
closure_js_library(
46
name = "openlocationcode_lib",
57
srcs = ["openlocationcode.js"],
68
convention = "GOOGLE",
79
)
810

11+
# Define the Closure test for Open Location Code
912
closure_js_test(
1013
name = "openlocationcode_test",
1114
timeout = "short",
1215
srcs = ["openlocationcode_test.js"],
1316
data = [
14-
"//test_data",
17+
"//test_data:test_data", # Reference the filegroup for test data
1518
],
1619
entry_points = ["goog:openlocationcode_test"],
1720
deps = [
@@ -22,4 +25,4 @@ closure_js_test(
2225
"@io_bazel_rules_closure//closure/library/testing:asynctestcase",
2326
"@io_bazel_rules_closure//closure/library/testing:testsuite",
2427
],
25-
)
28+
)

python/BUILD

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
package(default_visibility = ["//visibility:public"])
2-
31
py_library(
42
name = "openlocationcode",
53
srcs = ["openlocationcode/openlocationcode.py"],
@@ -12,4 +10,5 @@ py_test(
1210
srcs = ["openlocationcode_test.py"],
1311
data = ["//test_data:test_data"],
1412
deps = [":openlocationcode"],
15-
)
13+
visibility = ["//visibility:private"]
14+
)

0 commit comments

Comments
 (0)