From ae55110082d28491550e54bc3d7b914a0c77fe0b Mon Sep 17 00:00:00 2001 From: Christian Nieves Date: Wed, 12 Jul 2023 22:28:24 -0500 Subject: [PATCH] meh --- BUILD | 5 ++++ cmd/beornextract/BUILD | 17 +++++++---- cmd/beornextract/main.go | 21 ++++++++++++- deps.bzl | 64 ++++++++++++++++++++++++++++++++++++++++ go.mod | 5 +++- go.sum | 2 ++ 6 files changed, 106 insertions(+), 8 deletions(-) diff --git a/BUILD b/BUILD index 6a7581a..0c6c870 100644 --- a/BUILD +++ b/BUILD @@ -18,3 +18,8 @@ gazelle( ], command = "update-repos", ) + +alias( + name = "beornextract", + actual = "//cmd/beornextract:beornextract", +) diff --git a/cmd/beornextract/BUILD b/cmd/beornextract/BUILD index 997f8c5..36b2e8f 100644 --- a/cmd/beornextract/BUILD +++ b/cmd/beornextract/BUILD @@ -1,20 +1,25 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") package( default_visibility = ["//visibility:public"], ) -alias( - name = "beornextract", - actual = "//beornextract/", -) - go_library( name = "beornextract_lib", srcs = ["main.go"], + data = [ + "//cmd/beornextract/data:Bot.Cards.json", + "//cmd/beornextract/data:Export.Cards.json", + ], importpath = "github.com/squk/lotr/cmd/beornextract", deps = [ "//cmd/beornextract/types", "@com_github_davecgh_go_spew//spew", + "@io_bazel_rules_go//go/tools/bazel:go_default_library", ], ) + +go_binary( + name = "beornextract", + embed = [":beornextract_lib"], +) diff --git a/cmd/beornextract/main.go b/cmd/beornextract/main.go index 97037e1..afbc314 100644 --- a/cmd/beornextract/main.go +++ b/cmd/beornextract/main.go @@ -4,17 +4,36 @@ import ( "encoding/json" "fmt" "io/ioutil" + "log" "os" + "path/filepath" + "github.com/bazelbuild/rules_go/go/tools/bazel" "github.com/davecgh/go-spew/spew" "github.com/squk/lotr/cmd/beornextract/types" ) func main() { fmt.Println("LOTR CARD PARSE") + f, err := bazel.Runfile(".") + if err != nil { + panic(err) + } + err = filepath.Walk(f, + func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + fmt.Println(path, info.Size()) + return nil + }) + if err != nil { + log.Println(err) + } // Open our jsonFile - jsonFile, err := os.Open("./data/Bot.Cards.json") + // jsonFile, err := os.Open("cmd/beornextract/data/Bot.Cards.json") + jsonFile, err := bazel.Runfile("cmd/beornextract/data/Bot.Cards.json") // if we os.Open returns an error then handle it if err != nil { fmt.Println(err) diff --git a/deps.bzl b/deps.bzl index 8b69518..e70f841 100644 --- a/deps.bzl +++ b/deps.bzl @@ -1,6 +1,14 @@ load("@bazel_gazelle//:deps.bzl", "go_repository") def go_dependencies(): + go_repository( + name = "com_github_bazelbuild_rules_go", + build_file_proto_mode = "disable_global", + importpath = "github.com/bazelbuild/rules_go", + sum = "h1:JzlRxsFNhlX+g4drDRPhIaU5H5LnI978wdMJ0vK4I+k=", + version = "v0.41.0", + ) + go_repository( name = "com_github_davecgh_go_spew", build_file_proto_mode = "disable_global", @@ -8,6 +16,20 @@ def go_dependencies(): sum = "h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=", version = "v1.1.1", ) + go_repository( + name = "com_github_golang_mock", + build_file_proto_mode = "disable_global", + importpath = "github.com/golang/mock", + sum = "h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=", + version = "v1.6.0", + ) + go_repository( + name = "com_github_golang_protobuf", + build_file_proto_mode = "disable_global", + importpath = "github.com/golang/protobuf", + sum = "h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=", + version = "v1.5.2", + ) go_repository( name = "com_github_mattn_go_sqlite3", @@ -16,3 +38,45 @@ def go_dependencies(): sum = "h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM=", version = "v1.14.17", ) + go_repository( + name = "org_golang_google_genproto", + build_file_proto_mode = "disable_global", + importpath = "google.golang.org/genproto", + sum = "h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY=", + version = "v0.0.0-20200526211855-cb27e3aa2013", + ) + go_repository( + name = "org_golang_google_grpc", + build_file_proto_mode = "disable_global", + importpath = "google.golang.org/grpc", + sum = "h1:fPVVDxY9w++VjTZsYvXWqEf9Rqar/e+9zYfxKK+W+YU=", + version = "v1.50.0", + ) + go_repository( + name = "org_golang_google_protobuf", + build_file_proto_mode = "disable_global", + importpath = "google.golang.org/protobuf", + sum = "h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=", + version = "v1.28.0", + ) + go_repository( + name = "org_golang_x_net", + build_file_proto_mode = "disable_global", + importpath = "golang.org/x/net", + sum = "h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0=", + version = "v0.0.0-20210405180319-a5a99cb37ef4", + ) + go_repository( + name = "org_golang_x_sys", + build_file_proto_mode = "disable_global", + importpath = "golang.org/x/sys", + sum = "h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=", + version = "v0.0.0-20210510120138-977fb7262007", + ) + go_repository( + name = "org_golang_x_text", + build_file_proto_mode = "disable_global", + importpath = "golang.org/x/text", + sum = "h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=", + version = "v0.3.3", + ) diff --git a/go.mod b/go.mod index 1519920..eb6b7bc 100644 --- a/go.mod +++ b/go.mod @@ -4,4 +4,7 @@ go 1.19 require github.com/davecgh/go-spew v1.1.1 -require github.com/mattn/go-sqlite3 v1.14.17 // indirect +require ( + github.com/bazelbuild/rules_go v0.41.0 // indirect + github.com/mattn/go-sqlite3 v1.14.17 // indirect +) diff --git a/go.sum b/go.sum index 4a2aa70..cb2bf78 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/bazelbuild/rules_go v0.41.0 h1:JzlRxsFNhlX+g4drDRPhIaU5H5LnI978wdMJ0vK4I+k= +github.com/bazelbuild/rules_go v0.41.0/go.mod h1:TMHmtfpvyfsxaqfL9WnahCsXMWDMICTw7XeK9yVb+YU= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/mattn/go-sqlite3 v1.14.17 h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM=