load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")

# If you run `go build` a header "libgojsonnet.h" will be autogenerated in
# this directory. Then it can be picked up by Gazelle and added to `srcs` here.
# When building with Bazel the file gets created elsewhere in Bazel's
# sandbox tree, so when using Bazel exclusively it won't cause any trouble.
# However, sooner or later someone is going to run Gazelle after using `go build`
# and then the file may slip in, so it's better to just exclude it explicitly,
# with the directive below:
# gazelle:exclude ./libgojsonnet.h

go_library(
    name = "go_default_library",
    srcs = [
        "c-bindings.go",
        "handles.go",
        "internal.h",
        "libjsonnet.cpp",
    ],
    cdeps = [
        "@cpp_jsonnet//include:libjsonnet",
    ],
    cgo = True,
    copts = ["-Wall -Icpp-jsonnet/include"],  # keep
    cxxopts = ["-std=c++11"],
    importpath = "github.com/google/go-jsonnet/c-bindings",
    visibility = ["//visibility:private"],
    deps = [
        "//:go_default_library",
        "//ast:go_default_library",
        "//formatter:go_default_library",
    ],
)

go_binary(
    name = "c-bindings",
    embed = [":go_default_library"],
    visibility = ["//visibility:public"],
)
