[bazel] Add go/gazelle to WORKSPACE and use c++ extension.

This adds a simple go program to test the installed go
toolchain, and a Make rule to codify the arguments to
our gazelle binary, built with extensions.

I could not figure out how to get the .json file to work
with the gazelle() Bazel rule, but this works ok for now.

Bug: skia:12541
Change-Id: I5067b15c7518951aeb69559d3871799d3b5745f4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/475716
Reviewed-by: Leandro Lovisolo <lovisolo@google.com>
This commit is contained in:
Kevin Lubick 2021-11-23 14:58:20 -05:00
parent 0260471f60
commit cc9d0cd5a9
11 changed files with 3598 additions and 1 deletions

View File

@ -1,6 +1,7 @@
# https://github.com/bazelbuild/bazel-skylib
load("@bazel_skylib//lib:selects.bzl", "selects")
load("//bazel:macros.bzl", "select_multi")
load("@bazel_gazelle//:def.bzl", "gazelle")
package(default_visibility = ["//:__subpackages__"])
@ -238,3 +239,6 @@ cc_library(
textual_hdrs = ["//tools:txts"],
deps = [":skia-core"],
)
# gazelle:prefix go.skia.org/skia
gazelle(name = "gazelle")

View File

@ -50,3 +50,37 @@ http_archive(
sha256 = "cd6730ed53a002c56ce4e2f396ba3b3be262fd7cb68339f0377a45e8227fe332",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.5.0/rules_python-0.5.0.tar.gz",
)
#######################################################################################
# Gazelle
#######################################################################################
http_archive(
name = "io_bazel_rules_go",
sha256 = "2b1641428dff9018f9e85c0384f03ec6c10660d935b750e3fa1492a281a53b0f",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.29.0/rules_go-v0.29.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.29.0/rules_go-v0.29.0.zip",
],
)
http_archive(
name = "bazel_gazelle",
sha256 = "de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("//:go_repositories.bzl", "go_repositories")
# gazelle:repository_macro go_repositories.bzl%go_repositories
go_repositories()
go_rules_dependencies()
go_register_toolchains(version = "1.17.2")
gazelle_dependencies(go_repository_default_config = "//:WORKSPACE.bazel")

8
bazel/Makefile Normal file
View File

@ -0,0 +1,8 @@
generate:
bazel build @org_skia_go_infra//bazel/gazelle:gazelle_cpp
cd .. && bazel-bin/external/org_skia_go_infra/bazel/gazelle/gazelle_cpp_/gazelle_cpp update \
--third_party_file_map="third_party/file_map_for_bazel.json" \
include src
gazelle_update_repo:
cd .. && bazel run //:gazelle -- update-repos -from_file=go.mod -to_macro=go_repositories.bzl%go_repositories

View File

@ -1,5 +1,6 @@
load("//bazel:macros.bzl", "generated_cc_atom")
load("@rules_cc//cc:defs.bzl", "cc_binary")
load("@io_bazel_rules_go//go:def.bzl", "go_binary")
cc_binary(
name = "bazel_test_exe",
@ -23,3 +24,9 @@ generated_cc_atom(
"//third_party:libpng",
],
)
go_binary(
name = "hello_world",
srcs = ["hello_world.go"],
)

View File

@ -0,0 +1,11 @@
// Copyright 2021 Google LLC
//
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package main
import "fmt"
func main() {
fmt.Println("Hello world!")
}

2
go.mod
View File

@ -49,7 +49,7 @@ require (
github.com/yosuke-furukawa/json5 v0.1.1 // indirect
go.chromium.org/gae v0.0.0-20190826183307-50a499513efa // indirect
go.chromium.org/luci v0.0.0-20201121231857-b9ab316d7198 // indirect
go.skia.org/infra v0.0.0-20211118151522-74751ee0f13f
go.skia.org/infra v0.0.0-20211123190342-9cd7cd57f7fb
go.starlark.net v0.0.0-20201118183435-e55f603d8c79 // indirect
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83
golang.org/x/exp v0.0.0-20200228211341-fcea875c7e85 // indirect

4
go.sum
View File

@ -2095,6 +2095,10 @@ go.skia.org/infra v0.0.0-20211110142552-553519b41e71 h1:MsyIiBuNicDVyMBAECY6QO6A
go.skia.org/infra v0.0.0-20211110142552-553519b41e71/go.mod h1:BX7j5CR8GabRog5/v70hZ7QERcahOEUvzkDN/oBJSEM=
go.skia.org/infra v0.0.0-20211118151522-74751ee0f13f h1:2QeDr9yTkQd/Mi9uyaXJ4FUnm7OADX6TflY++ne/8R4=
go.skia.org/infra v0.0.0-20211118151522-74751ee0f13f/go.mod h1:BX7j5CR8GabRog5/v70hZ7QERcahOEUvzkDN/oBJSEM=
go.skia.org/infra v0.0.0-20211123165136-e48bd69c8150 h1:2URXRfHoDUhYEVFfiWPllQ2j7H03s8vQaCok1Htludw=
go.skia.org/infra v0.0.0-20211123165136-e48bd69c8150/go.mod h1:BX7j5CR8GabRog5/v70hZ7QERcahOEUvzkDN/oBJSEM=
go.skia.org/infra v0.0.0-20211123190342-9cd7cd57f7fb h1:4N5YfkJxnlEyzYRwMu4UrENUibFW7y/HaWDpf3qsUNU=
go.skia.org/infra v0.0.0-20211123190342-9cd7cd57f7fb/go.mod h1:BX7j5CR8GabRog5/v70hZ7QERcahOEUvzkDN/oBJSEM=
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5/go.mod h1:nmDLcffg48OtT/PSW0Hg7FvpRQsQh5OSqIylirxKC7o=
go.starlark.net v0.0.0-20201118183435-e55f603d8c79 h1:JPjLPz44y2N9mkzh2N344kTk1Y4/V4yJAjTrXGmzv8I=
go.starlark.net v0.0.0-20201118183435-e55f603d8c79/go.mod h1:5YFcFnRptTN+41758c2bMPiqpGg4zBfYji1IQz8wNFk=

3525
go_repositories.bzl Normal file

File diff suppressed because it is too large Load Diff

View File

@ -97,6 +97,7 @@ generated_cc_atom(
hdrs = ["SkImageFilters.h"],
visibility = ["//:__subpackages__"],
deps = [
":SkRuntimeEffect_hdr",
"//include/core:SkBlendMode_hdr",
"//include/core:SkColor_hdr",
"//include/core:SkImageFilter_hdr",
@ -104,6 +105,7 @@ generated_cc_atom(
"//include/core:SkPicture_hdr",
"//include/core:SkRect_hdr",
"//include/core:SkTileMode_hdr",
"//include/core:SkTypes_hdr",
],
)

View File

@ -1306,6 +1306,7 @@ generated_cc_atom(
"//include/core:SkShader_hdr",
"//include/core:SkVertices_hdr",
"//include/private:SkTo_hdr",
"//include/private/chromium:GrSlug_hdr",
"//src/image:SkImage_Base_hdr",
"//src/shaders:SkLocalMatrixShader_hdr",
"//src/utils:SkPatchUtils_hdr",

View File

@ -95,6 +95,7 @@ generated_cc_atom(
"//include/gpu:GrRecordingContext_hdr",
"//include/private:SkShadowFlags_hdr",
"//include/private:SkTo_hdr",
"//include/private/chromium:GrSlug_hdr",
"//src/core:SkCanvasPriv_hdr",
"//src/core:SkClipStack_hdr",
"//src/core:SkDraw_hdr",