Skip to content

Commit

Permalink
Update to work with new Bazel
Browse files Browse the repository at this point in the history
  • Loading branch information
fulldecent committed Aug 13, 2024
1 parent dfcebc9 commit 4f60273
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 95 deletions.
4 changes: 0 additions & 4 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,5 @@ startup --host_jvm_args=-XX:-UseParallelGC
# build --local_resources=400,2,1.0
build --worker_max_instances=auto

# Setting to false will cause Bazel to use local JDK. This can cause the
# build to fail if it is not version 9.
build --distinct_host_configuration=true

# Configure tests - increase timeout, print everything and timeout warnings
test --verbose_failures --test_output=all --test_verbose_timeout_warnings
23 changes: 23 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module(
name = "openlocationcode",
version = "1.0",
)

bazel_dep(name = "googletest", version = "1.15.2")
bazel_dep(name = "rules_proto", version = "6.0.2") # Deprecated (moved), TODO find new URL
bazel_dep(name = "rules_java", version = "7.8.0")
bazel_dep(name = "bazel_skylib", version = "1.6.1")
bazel_dep(name = "rules_python", version = "0.33.2")

# External dependency archives
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "io_bazel_rules_closure",
sha256 = "9498e57368efb82b985db1ed426a767cbf1ba0398fd7aed632fc3908654e1b1e",
strip_prefix = "rules_closure-0.12.0",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_closure/archive/0.12.0.tar.gz",
"https://github.com/bazelbuild/rules_closure/archive/0.12.0.tar.gz",
],
)
56 changes: 0 additions & 56 deletions WORKSPACE

This file was deleted.

25 changes: 16 additions & 9 deletions c/BUILD
Original file line number Diff line number Diff line change
@@ -1,37 +1,43 @@
# Rule to build the library.
cc_library(
name = "openlocationcode",
srcs = [
"src/olc.c",
],
copts = ["-std=c99"],
copts = [
"-std=c99",
"-Wall",
"-Wextra",
"-O2",
],
hdrs = [
"src/olc.h",
"src/olc_private.h",
],
visibility = ["//visibility:public"],
includes = ["src"],
visibility = ["//visibility:private"],
)

# Rule to build and run the unit tests.
cc_test(
name = "openlocationcode_test",
size = "small",
srcs = ["openlocationcode_test.cc"],
copts = [
"-pthread",
"-Iexternal/gtest/include",
"-I@googletest//:include",
],
linkopts = ["-pthread"],
linkstatic = False,
data = [
"//test_data",
],
linkopts = ["-pthread"],
deps = [
":openlocationcode",
"@gtest//:main",
"@googletest//:gtest_main",
],
testonly = True,
visibility = ["//visibility:private"],
)

# Rule to build and run the example.
cc_binary(
name = "openlocationcode_example",
srcs = [
Expand All @@ -40,4 +46,5 @@ cc_binary(
deps = [
":openlocationcode",
],
)
visibility = ["//visibility:private"],
)
24 changes: 17 additions & 7 deletions cpp/BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Library to handle open location codes
cc_library(
name = "openlocationcode",
srcs = [
Expand All @@ -7,14 +8,19 @@ cc_library(
"codearea.h",
"openlocationcode.h",
],
copts = ["-pthread"],
copts = [
"-pthread",
"-Wall",
"-Wextra",
"-O2",
],
linkopts = ["-pthread"],
visibility = ["//visibility:public"],
deps = [
":codearea",
],
)

# Code area library, used by open location codes
cc_library(
name = "codearea",
srcs = [
Expand All @@ -23,27 +29,31 @@ cc_library(
hdrs = [
"codearea.h",
],
visibility = ["//visibility:private"],
visibility = ["//visibility:private"], # Keep private unless needed elsewhere
)

# Unit test for open location codes
cc_test(
name = "openlocationcode_test",
size = "small",
srcs = ["openlocationcode_test.cc"],
copts = [
"-pthread",
"-Iexternal/gtest/include",
"-I@googletest//:include",
],
linkopts = ["-pthread"],
linkstatic = False,
data = [
"//test_data",
],
linkopts = ["-pthread"],
deps = [
":openlocationcode",
"@gtest//:main",
"@googletest//:gtest_main",
],
testonly = True,
)

# Example binary for open location codes
cc_binary(
name = "openlocationcode_example",
srcs = [
Expand All @@ -52,4 +62,4 @@ cc_binary(
deps = [
":openlocationcode",
],
)
)
14 changes: 0 additions & 14 deletions cpp/gtest.BUILD

This file was deleted.

9 changes: 9 additions & 0 deletions java/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ java_library(
srcs = [
"src/main/java/com/google/openlocationcode/OpenLocationCode.java",
],
visibility = ["//visibility:private"],
)

java_test(
Expand All @@ -15,6 +16,7 @@ java_test(
deps = [
":openlocationcode",
],
visibility = ["//visibility:private"],
)

java_test(
Expand All @@ -31,6 +33,7 @@ java_test(
deps = [
":openlocationcode",
],
visibility = ["//visibility:private"],
)

java_test(
Expand All @@ -47,6 +50,7 @@ java_test(
deps = [
":openlocationcode",
],
visibility = ["//visibility:private"],
)

java_test(
Expand All @@ -63,6 +67,7 @@ java_test(
deps = [
":openlocationcode",
],
visibility = ["//visibility:private"],
)

java_test(
Expand All @@ -79,6 +84,7 @@ java_test(
deps = [
":openlocationcode",
],
visibility = ["//visibility:private"],
)

java_test(
Expand All @@ -92,6 +98,7 @@ java_test(
deps = [
":openlocationcode",
],
visibility = ["//visibility:private"],
)

java_test(
Expand All @@ -105,6 +112,7 @@ java_test(
deps = [
":openlocationcode",
],
visibility = ["//visibility:private"],
)

java_test(
Expand All @@ -118,4 +126,5 @@ java_test(
deps = [
":openlocationcode",
],
visibility = ["//visibility:private"],
)
7 changes: 5 additions & 2 deletions js/closure/BUILD
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# Load the necessary Closure rules
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library", "closure_js_test")

# Define the Closure library for Open Location Code
closure_js_library(
name = "openlocationcode_lib",
srcs = ["openlocationcode.js"],
convention = "GOOGLE",
)

# Define the Closure test for Open Location Code
closure_js_test(
name = "openlocationcode_test",
timeout = "short",
srcs = ["openlocationcode_test.js"],
data = [
"//test_data",
"//test_data:test_data", # Reference the filegroup for test data
],
entry_points = ["goog:openlocationcode_test"],
deps = [
Expand All @@ -22,4 +25,4 @@ closure_js_test(
"@io_bazel_rules_closure//closure/library/testing:asynctestcase",
"@io_bazel_rules_closure//closure/library/testing:testsuite",
],
)
)
5 changes: 2 additions & 3 deletions python/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package(default_visibility = ["//visibility:public"])

py_library(
name = "openlocationcode",
srcs = ["openlocationcode/openlocationcode.py"],
Expand All @@ -12,4 +10,5 @@ py_test(
srcs = ["openlocationcode_test.py"],
data = ["//test_data:test_data"],
deps = [":openlocationcode"],
)
visibility = ["//visibility:private"]
)

0 comments on commit 4f60273

Please sign in to comment.