attilaolah / bazel-tools

Starlark Macros for Bazel
Apache License 2.0
2 stars 1 forks source link
bazel bazel-rules json

Starlark Macros for Bazel

This repo contains a collection of Starlark macros, the required genrule tools and the corresponding WORKSPACE configuration to use them.

Load the macros from defs.bzl like so:

load("@tools//:defs.bzl", "json_extract", "json_test")

The following macros are defined:

json_extract

Extract data from a JSQN file. By default, it extracts the entire file (query = "."). To extract a raw field, use it like so:

json_extract(
    name = "geometry",
    srcs = [
        "geometry.json",
    ],
    out = "geometry.wkt",
    query = ".geom",
    raw = True,
)

json_test

This is a test rule to validate the syntax of JSON files.

json_test(
    name = "json_test",
    srcs = glob(["*.json"]),
)

Disclaimer

This is not an official Google product (experimental or otherwise), it is just code that happens to be owned by Google.