Skip to content

Commit

Permalink
Merge pull request #84 from mwitkow/bazel-build
Browse files Browse the repository at this point in the history
Add support for Bazel import of the project
  • Loading branch information
Helcaraxan authored Dec 23, 2019
2 parents 3ad4d6c + 04a47d1 commit 3197598
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 0 deletions.
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deps/
26 changes: 26 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@rules_proto//proto:defs.bzl", "proto_library")

proto_library(
name = "validator_proto",
srcs = ["validator.proto"],
import_prefix = "github.com/mwitkow/go-proto-validators",
deps = [
"@com_google_protobuf//:descriptor_proto",
],
visibility = ["//visibility:public"],
)

go_library(
name = "go_default_library",
srcs = [
"helper.go",
"validator.pb.go",
],
importpath = "github.com/mwitkow/go-proto-validators",
deps = [
"@com_github_gogo_protobuf//proto:go_default_library",
"@com_github_gogo_protobuf//protoc-gen-gogo/descriptor:go_default_library",
],
visibility = ["//visibility:public"],
)
51 changes: 51 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
workspace(name = "com_github_mwitkow_go_proto_validators")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

GO_VERSION="1.13.5"

http_archive(
name = "rules_proto",
sha256 = "296ffd3e7992bd83fa75151255f7c7f27d22d6e52e2fd3c3d3d10c292317fbed",
strip_prefix = "rules_proto-f6c112fa4eb2b8f934feb938a6fce41425e41587",
urls = [
"https://github.com/bazelbuild/rules_proto/archive/f6c112fa4eb2b8f934feb938a6fce41425e41587.tar.gz",
],
)

http_archive(
name = "com_google_protobuf",
strip_prefix = "protobuf-3.10.1",
url = "https://github.com/protocolbuffers/protobuf/archive/v3.10.1.zip",
)

http_archive(
name = "io_bazel_rules_go",
sha256 = "d5de13e9a994527b6dc41f39ad9ceee3214974dacb18f73a5fa2a4458ae6d3c9",
strip_prefix = "rules_go-0.20.3",
url = "https://github.com/bazelbuild/rules_go/archive/v0.20.3.tar.gz",
)

load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains")

go_rules_dependencies()

go_register_toolchains(go_version = GO_VERSION)

http_archive(
name = "bazel_gazelle",
strip_prefix = "bazel-gazelle-0.19.1",
urls = [
"https://github.com/bazelbuild/bazel-gazelle/archive/v0.19.1.tar.gz",
],
)

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")

gazelle_dependencies()

go_repository(
name = "com_github_gogo_protobuf",
importpath = "github.com/gogo/protobuf",
version = "v1.3.1",
)
16 changes: 16 additions & 0 deletions plugin/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = ["plugin.go"],
importpath = "github.com/mwitkow/go-proto-validators/plugin",
visibility = ["//visibility:public"],
deps = [
"//:go_default_library",
"@com_github_gogo_protobuf//gogoproto:go_default_library",
"@com_github_gogo_protobuf//proto:go_default_library",
"@com_github_gogo_protobuf//protoc-gen-gogo/descriptor:go_default_library",
"@com_github_gogo_protobuf//protoc-gen-gogo/generator:go_default_library",
"@com_github_gogo_protobuf//vanity:go_default_library",
],
)
19 changes: 19 additions & 0 deletions protoc-gen-govalidators/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")

go_library(
name = "go_default_library",
srcs = ["main.go"],
importpath = "github.com/mwitkow/go-proto-validators/protoc-gen-govalidators",
visibility = ["//visibility:private"],
deps = [
"//plugin:go_default_library",
"@com_github_gogo_protobuf//proto:go_default_library",
"@com_github_gogo_protobuf//protoc-gen-gogo/generator:go_default_library",
],
)

go_binary(
name = "protoc-gen-govalidators",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
)

0 comments on commit 3197598

Please sign in to comment.