From d49953e8d01e5f1bb4f2e84e3d82f303360be277 Mon Sep 17 00:00:00 2001 From: Benjamin Elder Date: Tue, 12 Feb 2019 13:11:11 -0800 Subject: [PATCH 1/5] add buildozer to deps --- Godeps/Godeps.json | 3 ++- hack/godep-save.sh | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index c32fdcc6d13..d479b419e0d 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -4,6 +4,7 @@ "GodepVersion": "v80-k8s-r1", "Packages": [ "github.com/bazelbuild/bazel-gazelle/cmd/gazelle", + "github.com/bazelbuild/buildtools/buildozer", "github.com/cespare/prettybench", "github.com/client9/misspell/cmd/misspell", "github.com/cloudflare/cfssl/cmd/cfssl", @@ -4239,4 +4240,4 @@ "Rev": "db5cfe13f5cc80a4990d98e2e1b0707a4d1a5394" } ] -} +} \ No newline at end of file diff --git a/hack/godep-save.sh b/hack/godep-save.sh index 093cb411fa8..452b102dd75 100755 --- a/hack/godep-save.sh +++ b/hack/godep-save.sh @@ -56,6 +56,7 @@ fi # won't pick them up. REQUIRED_BINS=( "github.com/bazelbuild/bazel-gazelle/cmd/gazelle" + "github.com/bazelbuild/buildtools/buildozer" "github.com/cespare/prettybench" "github.com/client9/misspell/cmd/misspell" "github.com/cloudflare/cfssl/cmd/cfssl" From e070d9fd6714b82315f3b66e424150f44890ef2a Mon Sep 17 00:00:00 2001 From: Benjamin Elder Date: Tue, 12 Feb 2019 15:16:34 -0800 Subject: [PATCH 2/5] vendor buildozer --- Godeps/Godeps.json | 37 +- Godeps/LICENSES | 147 ++ vendor/BUILD | 7 + .../bazelbuild/buildtools/api_proto/BUILD | 24 + .../buildtools/api_proto/api.gen.pb.go | 315 +++ .../bazelbuild/buildtools/api_proto/api.proto | 42 + .../bazelbuild/buildtools/build_proto/BUILD | 24 + .../buildtools/build_proto/build.gen.pb.go | 2092 +++++++++++++++++ .../bazelbuild/buildtools/buildozer/BUILD | 33 + .../bazelbuild/buildtools/buildozer/README.md | 266 +++ .../bazelbuild/buildtools/buildozer/main.go | 87 + .../bazelbuild/buildtools/edit/BUILD | 37 + .../bazelbuild/buildtools/edit/buildozer.go | 976 ++++++++ .../bazelbuild/buildtools/edit/edit.go | 823 +++++++ .../bazelbuild/buildtools/edit/fix.go | 569 +++++ .../bazelbuild/buildtools/edit/types.go | 59 + .../bazelbuild/buildtools/file/BUILD | 23 + .../bazelbuild/buildtools/file/file.go | 48 + .../bazelbuild/buildtools/lang/BUILD | 24 + .../buildtools/lang/build-language.pb | Bin 0 -> 30512 bytes .../bazelbuild/buildtools/lang/tables.gen.go | 245 ++ .../bazelbuild/buildtools/wspace/BUILD | 24 + .../bazelbuild/buildtools/wspace/workspace.go | 114 + 23 files changed, 6015 insertions(+), 1 deletion(-) create mode 100644 vendor/github.com/bazelbuild/buildtools/api_proto/BUILD create mode 100755 vendor/github.com/bazelbuild/buildtools/api_proto/api.gen.pb.go create mode 100644 vendor/github.com/bazelbuild/buildtools/api_proto/api.proto create mode 100644 vendor/github.com/bazelbuild/buildtools/build_proto/BUILD create mode 100755 vendor/github.com/bazelbuild/buildtools/build_proto/build.gen.pb.go create mode 100644 vendor/github.com/bazelbuild/buildtools/buildozer/BUILD create mode 100644 vendor/github.com/bazelbuild/buildtools/buildozer/README.md create mode 100644 vendor/github.com/bazelbuild/buildtools/buildozer/main.go create mode 100644 vendor/github.com/bazelbuild/buildtools/edit/BUILD create mode 100644 vendor/github.com/bazelbuild/buildtools/edit/buildozer.go create mode 100644 vendor/github.com/bazelbuild/buildtools/edit/edit.go create mode 100644 vendor/github.com/bazelbuild/buildtools/edit/fix.go create mode 100644 vendor/github.com/bazelbuild/buildtools/edit/types.go create mode 100644 vendor/github.com/bazelbuild/buildtools/file/BUILD create mode 100644 vendor/github.com/bazelbuild/buildtools/file/file.go create mode 100644 vendor/github.com/bazelbuild/buildtools/lang/BUILD create mode 100644 vendor/github.com/bazelbuild/buildtools/lang/build-language.pb create mode 100755 vendor/github.com/bazelbuild/buildtools/lang/tables.gen.go create mode 100644 vendor/github.com/bazelbuild/buildtools/wspace/BUILD create mode 100644 vendor/github.com/bazelbuild/buildtools/wspace/workspace.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index d479b419e0d..c1e1a7bacc7 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -472,16 +472,51 @@ "Comment": "0.15.0", "Rev": "c728ce9f663e2bff26361ba5978ec5c9e6816a3c" }, + { + "ImportPath": "github.com/bazelbuild/buildtools/api_proto", + "Comment": "0.6.0-60-g1a9c38e0df9397", + "Rev": "1a9c38e0df9397d033a1ca535596de5a7c1cf18f" + }, { "ImportPath": "github.com/bazelbuild/buildtools/build", "Comment": "0.6.0-60-g1a9c38e0df9397", "Rev": "1a9c38e0df9397d033a1ca535596de5a7c1cf18f" }, + { + "ImportPath": "github.com/bazelbuild/buildtools/build_proto", + "Comment": "0.6.0-60-g1a9c38e0df9397", + "Rev": "1a9c38e0df9397d033a1ca535596de5a7c1cf18f" + }, + { + "ImportPath": "github.com/bazelbuild/buildtools/buildozer", + "Comment": "0.6.0-60-g1a9c38e0df9397", + "Rev": "1a9c38e0df9397d033a1ca535596de5a7c1cf18f" + }, + { + "ImportPath": "github.com/bazelbuild/buildtools/edit", + "Comment": "0.6.0-60-g1a9c38e0df9397", + "Rev": "1a9c38e0df9397d033a1ca535596de5a7c1cf18f" + }, + { + "ImportPath": "github.com/bazelbuild/buildtools/file", + "Comment": "0.6.0-60-g1a9c38e0df9397", + "Rev": "1a9c38e0df9397d033a1ca535596de5a7c1cf18f" + }, + { + "ImportPath": "github.com/bazelbuild/buildtools/lang", + "Comment": "0.6.0-60-g1a9c38e0df9397", + "Rev": "1a9c38e0df9397d033a1ca535596de5a7c1cf18f" + }, { "ImportPath": "github.com/bazelbuild/buildtools/tables", "Comment": "0.6.0-60-g1a9c38e0df9397", "Rev": "1a9c38e0df9397d033a1ca535596de5a7c1cf18f" }, + { + "ImportPath": "github.com/bazelbuild/buildtools/wspace", + "Comment": "0.6.0-60-g1a9c38e0df9397", + "Rev": "1a9c38e0df9397d033a1ca535596de5a7c1cf18f" + }, { "ImportPath": "github.com/beorn7/perks/quantile", "Rev": "3ac7bf7a47d159a033b107610db8a1b6575507a4" @@ -4240,4 +4275,4 @@ "Rev": "db5cfe13f5cc80a4990d98e2e1b0707a4d1a5394" } ] -} \ No newline at end of file +} diff --git a/Godeps/LICENSES b/Godeps/LICENSES index a44c1afe3f6..84e91c3d7b3 100644 --- a/Godeps/LICENSES +++ b/Godeps/LICENSES @@ -14961,6 +14961,27 @@ THE SOFTWARE. ================================================================================ +================================================================================ += vendor/github.com/bazelbuild/buildtools/api_proto licensed under: = + +Copyright 2016 Google Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + += vendor/github.com/bazelbuild/buildtools/LICENSE adb52eb384caedba181cd51fbcdf4b99 +================================================================================ + + ================================================================================ = vendor/github.com/bazelbuild/buildtools/build licensed under: = @@ -14982,6 +15003,111 @@ limitations under the License. ================================================================================ +================================================================================ += vendor/github.com/bazelbuild/buildtools/buildozer licensed under: = + +Copyright 2016 Google Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + += vendor/github.com/bazelbuild/buildtools/LICENSE adb52eb384caedba181cd51fbcdf4b99 +================================================================================ + + +================================================================================ += vendor/github.com/bazelbuild/buildtools/build_proto licensed under: = + +Copyright 2016 Google Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + += vendor/github.com/bazelbuild/buildtools/LICENSE adb52eb384caedba181cd51fbcdf4b99 +================================================================================ + + +================================================================================ += vendor/github.com/bazelbuild/buildtools/edit licensed under: = + +Copyright 2016 Google Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + += vendor/github.com/bazelbuild/buildtools/LICENSE adb52eb384caedba181cd51fbcdf4b99 +================================================================================ + + +================================================================================ += vendor/github.com/bazelbuild/buildtools/file licensed under: = + +Copyright 2016 Google Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + += vendor/github.com/bazelbuild/buildtools/LICENSE adb52eb384caedba181cd51fbcdf4b99 +================================================================================ + + +================================================================================ += vendor/github.com/bazelbuild/buildtools/lang licensed under: = + +Copyright 2016 Google Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + += vendor/github.com/bazelbuild/buildtools/LICENSE adb52eb384caedba181cd51fbcdf4b99 +================================================================================ + + ================================================================================ = vendor/github.com/bazelbuild/buildtools/tables licensed under: = @@ -15003,6 +15129,27 @@ limitations under the License. ================================================================================ +================================================================================ += vendor/github.com/bazelbuild/buildtools/wspace licensed under: = + +Copyright 2016 Google Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + += vendor/github.com/bazelbuild/buildtools/LICENSE adb52eb384caedba181cd51fbcdf4b99 +================================================================================ + + ================================================================================ = vendor/github.com/beorn7/perks/quantile licensed under: = diff --git a/vendor/BUILD b/vendor/BUILD index 1cc078453dc..d49a06d26fe 100644 --- a/vendor/BUILD +++ b/vendor/BUILD @@ -65,8 +65,15 @@ filegroup( "//vendor/github.com/bazelbuild/bazel-gazelle/internal/version:all-srcs", "//vendor/github.com/bazelbuild/bazel-gazelle/internal/walk:all-srcs", "//vendor/github.com/bazelbuild/bazel-gazelle/internal/wspace:all-srcs", + "//vendor/github.com/bazelbuild/buildtools/api_proto:all-srcs", "//vendor/github.com/bazelbuild/buildtools/build:all-srcs", + "//vendor/github.com/bazelbuild/buildtools/build_proto:all-srcs", + "//vendor/github.com/bazelbuild/buildtools/buildozer:all-srcs", + "//vendor/github.com/bazelbuild/buildtools/edit:all-srcs", + "//vendor/github.com/bazelbuild/buildtools/file:all-srcs", + "//vendor/github.com/bazelbuild/buildtools/lang:all-srcs", "//vendor/github.com/bazelbuild/buildtools/tables:all-srcs", + "//vendor/github.com/bazelbuild/buildtools/wspace:all-srcs", "//vendor/github.com/beorn7/perks/quantile:all-srcs", "//vendor/github.com/blang/semver:all-srcs", "//vendor/github.com/cespare/prettybench:all-srcs", diff --git a/vendor/github.com/bazelbuild/buildtools/api_proto/BUILD b/vendor/github.com/bazelbuild/buildtools/api_proto/BUILD new file mode 100644 index 00000000000..18005665fa7 --- /dev/null +++ b/vendor/github.com/bazelbuild/buildtools/api_proto/BUILD @@ -0,0 +1,24 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["api.gen.pb.go"], + importmap = "k8s.io/kubernetes/vendor/github.com/bazelbuild/buildtools/api_proto", + importpath = "github.com/bazelbuild/buildtools/api_proto", + visibility = ["//visibility:public"], + deps = ["//vendor/github.com/golang/protobuf/proto:go_default_library"], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/vendor/github.com/bazelbuild/buildtools/api_proto/api.gen.pb.go b/vendor/github.com/bazelbuild/buildtools/api_proto/api.gen.pb.go new file mode 100755 index 00000000000..d060daca5a7 --- /dev/null +++ b/vendor/github.com/bazelbuild/buildtools/api_proto/api.gen.pb.go @@ -0,0 +1,315 @@ +// Code generated by protoc-gen-go. +// source: api_proto/api.proto +// DO NOT EDIT! + +/* +Package devtools_buildozer is a generated protocol buffer package. + +It is generated from these files: + api_proto/api.proto + +It has these top-level messages: + Output + RepeatedString +*/ +package devtools_buildozer + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package + +type Output_Record_Field_ERROR int32 + +const ( + Output_Record_Field_UNKNOWN Output_Record_Field_ERROR = 0 + Output_Record_Field_MISSING Output_Record_Field_ERROR = 1 +) + +var Output_Record_Field_ERROR_name = map[int32]string{ + 0: "UNKNOWN", + 1: "MISSING", +} +var Output_Record_Field_ERROR_value = map[string]int32{ + "UNKNOWN": 0, + "MISSING": 1, +} + +func (x Output_Record_Field_ERROR) String() string { + return proto.EnumName(Output_Record_Field_ERROR_name, int32(x)) +} +func (Output_Record_Field_ERROR) EnumDescriptor() ([]byte, []int) { + return fileDescriptor0, []int{0, 0, 0, 0} +} + +type Output struct { + Records []*Output_Record `protobuf:"bytes,1,rep,name=records" json:"records,omitempty"` +} + +func (m *Output) Reset() { *m = Output{} } +func (m *Output) String() string { return proto.CompactTextString(m) } +func (*Output) ProtoMessage() {} +func (*Output) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } + +func (m *Output) GetRecords() []*Output_Record { + if m != nil { + return m.Records + } + return nil +} + +type Output_Record struct { + Fields []*Output_Record_Field `protobuf:"bytes,1,rep,name=fields" json:"fields,omitempty"` +} + +func (m *Output_Record) Reset() { *m = Output_Record{} } +func (m *Output_Record) String() string { return proto.CompactTextString(m) } +func (*Output_Record) ProtoMessage() {} +func (*Output_Record) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0, 0} } + +func (m *Output_Record) GetFields() []*Output_Record_Field { + if m != nil { + return m.Fields + } + return nil +} + +type Output_Record_Field struct { + // Types that are valid to be assigned to Value: + // *Output_Record_Field_Text + // *Output_Record_Field_Number + // *Output_Record_Field_Error + // *Output_Record_Field_List + Value isOutput_Record_Field_Value `protobuf_oneof:"value"` + // Used internally by Buildozer to decide whether a field should be quoted + // when printing. This does not affect the contents of 'value'. + QuoteWhenPrinting bool `protobuf:"varint,7,opt,name=quote_when_printing,json=quoteWhenPrinting" json:"quote_when_printing,omitempty"` +} + +func (m *Output_Record_Field) Reset() { *m = Output_Record_Field{} } +func (m *Output_Record_Field) String() string { return proto.CompactTextString(m) } +func (*Output_Record_Field) ProtoMessage() {} +func (*Output_Record_Field) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0, 0, 0} } + +type isOutput_Record_Field_Value interface { + isOutput_Record_Field_Value() +} + +type Output_Record_Field_Text struct { + Text string `protobuf:"bytes,1,opt,name=text,oneof"` +} +type Output_Record_Field_Number struct { + Number int32 `protobuf:"varint,2,opt,name=number,oneof"` +} +type Output_Record_Field_Error struct { + Error Output_Record_Field_ERROR `protobuf:"varint,3,opt,name=error,enum=devtools.buildozer.Output_Record_Field_ERROR,oneof"` +} +type Output_Record_Field_List struct { + List *RepeatedString `protobuf:"bytes,5,opt,name=list,oneof"` +} + +func (*Output_Record_Field_Text) isOutput_Record_Field_Value() {} +func (*Output_Record_Field_Number) isOutput_Record_Field_Value() {} +func (*Output_Record_Field_Error) isOutput_Record_Field_Value() {} +func (*Output_Record_Field_List) isOutput_Record_Field_Value() {} + +func (m *Output_Record_Field) GetValue() isOutput_Record_Field_Value { + if m != nil { + return m.Value + } + return nil +} + +func (m *Output_Record_Field) GetText() string { + if x, ok := m.GetValue().(*Output_Record_Field_Text); ok { + return x.Text + } + return "" +} + +func (m *Output_Record_Field) GetNumber() int32 { + if x, ok := m.GetValue().(*Output_Record_Field_Number); ok { + return x.Number + } + return 0 +} + +func (m *Output_Record_Field) GetError() Output_Record_Field_ERROR { + if x, ok := m.GetValue().(*Output_Record_Field_Error); ok { + return x.Error + } + return Output_Record_Field_UNKNOWN +} + +func (m *Output_Record_Field) GetList() *RepeatedString { + if x, ok := m.GetValue().(*Output_Record_Field_List); ok { + return x.List + } + return nil +} + +func (m *Output_Record_Field) GetQuoteWhenPrinting() bool { + if m != nil { + return m.QuoteWhenPrinting + } + return false +} + +// XXX_OneofFuncs is for the internal use of the proto package. +func (*Output_Record_Field) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { + return _Output_Record_Field_OneofMarshaler, _Output_Record_Field_OneofUnmarshaler, _Output_Record_Field_OneofSizer, []interface{}{ + (*Output_Record_Field_Text)(nil), + (*Output_Record_Field_Number)(nil), + (*Output_Record_Field_Error)(nil), + (*Output_Record_Field_List)(nil), + } +} + +func _Output_Record_Field_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { + m := msg.(*Output_Record_Field) + // value + switch x := m.Value.(type) { + case *Output_Record_Field_Text: + b.EncodeVarint(1<<3 | proto.WireBytes) + b.EncodeStringBytes(x.Text) + case *Output_Record_Field_Number: + b.EncodeVarint(2<<3 | proto.WireVarint) + b.EncodeVarint(uint64(x.Number)) + case *Output_Record_Field_Error: + b.EncodeVarint(3<<3 | proto.WireVarint) + b.EncodeVarint(uint64(x.Error)) + case *Output_Record_Field_List: + b.EncodeVarint(5<<3 | proto.WireBytes) + if err := b.EncodeMessage(x.List); err != nil { + return err + } + case nil: + default: + return fmt.Errorf("Output_Record_Field.Value has unexpected type %T", x) + } + return nil +} + +func _Output_Record_Field_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { + m := msg.(*Output_Record_Field) + switch tag { + case 1: // value.text + if wire != proto.WireBytes { + return true, proto.ErrInternalBadWireType + } + x, err := b.DecodeStringBytes() + m.Value = &Output_Record_Field_Text{x} + return true, err + case 2: // value.number + if wire != proto.WireVarint { + return true, proto.ErrInternalBadWireType + } + x, err := b.DecodeVarint() + m.Value = &Output_Record_Field_Number{int32(x)} + return true, err + case 3: // value.error + if wire != proto.WireVarint { + return true, proto.ErrInternalBadWireType + } + x, err := b.DecodeVarint() + m.Value = &Output_Record_Field_Error{Output_Record_Field_ERROR(x)} + return true, err + case 5: // value.list + if wire != proto.WireBytes { + return true, proto.ErrInternalBadWireType + } + msg := new(RepeatedString) + err := b.DecodeMessage(msg) + m.Value = &Output_Record_Field_List{msg} + return true, err + default: + return false, nil + } +} + +func _Output_Record_Field_OneofSizer(msg proto.Message) (n int) { + m := msg.(*Output_Record_Field) + // value + switch x := m.Value.(type) { + case *Output_Record_Field_Text: + n += proto.SizeVarint(1<<3 | proto.WireBytes) + n += proto.SizeVarint(uint64(len(x.Text))) + n += len(x.Text) + case *Output_Record_Field_Number: + n += proto.SizeVarint(2<<3 | proto.WireVarint) + n += proto.SizeVarint(uint64(x.Number)) + case *Output_Record_Field_Error: + n += proto.SizeVarint(3<<3 | proto.WireVarint) + n += proto.SizeVarint(uint64(x.Error)) + case *Output_Record_Field_List: + s := proto.Size(x.List) + n += proto.SizeVarint(5<<3 | proto.WireBytes) + n += proto.SizeVarint(uint64(s)) + n += s + case nil: + default: + panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) + } + return n +} + +type RepeatedString struct { + Strings []string `protobuf:"bytes,1,rep,name=strings" json:"strings,omitempty"` +} + +func (m *RepeatedString) Reset() { *m = RepeatedString{} } +func (m *RepeatedString) String() string { return proto.CompactTextString(m) } +func (*RepeatedString) ProtoMessage() {} +func (*RepeatedString) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } + +func (m *RepeatedString) GetStrings() []string { + if m != nil { + return m.Strings + } + return nil +} + +func init() { + proto.RegisterType((*Output)(nil), "devtools.buildozer.Output") + proto.RegisterType((*Output_Record)(nil), "devtools.buildozer.Output.Record") + proto.RegisterType((*Output_Record_Field)(nil), "devtools.buildozer.Output.Record.Field") + proto.RegisterType((*RepeatedString)(nil), "devtools.buildozer.RepeatedString") + proto.RegisterEnum("devtools.buildozer.Output_Record_Field_ERROR", Output_Record_Field_ERROR_name, Output_Record_Field_ERROR_value) +} + +func init() { proto.RegisterFile("api_proto/api.proto", fileDescriptor0) } + +var fileDescriptor0 = []byte{ + // 336 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0xc1, 0x4a, 0xf3, 0x40, + 0x14, 0x85, 0x33, 0x6d, 0x93, 0xfc, 0xbd, 0x85, 0xd2, 0x7f, 0xea, 0x62, 0xe8, 0x2a, 0xcd, 0xc6, + 0x20, 0x38, 0x42, 0xdd, 0x08, 0x2e, 0x04, 0xa1, 0xda, 0x22, 0xa6, 0x32, 0x45, 0xba, 0x2c, 0xa9, + 0x19, 0xdb, 0x81, 0x98, 0x89, 0x93, 0x49, 0x15, 0x9f, 0xc3, 0x87, 0xf0, 0xb1, 0x7c, 0x14, 0xc9, + 0x24, 0x15, 0x44, 0x41, 0x77, 0xf7, 0xdc, 0x7b, 0xbe, 0x73, 0x42, 0x06, 0xfa, 0x51, 0x26, 0x96, + 0x99, 0x92, 0x5a, 0x1e, 0x45, 0x99, 0xa0, 0x66, 0xc2, 0x38, 0xe6, 0x5b, 0x2d, 0x65, 0x92, 0xd3, + 0x55, 0x21, 0x92, 0x58, 0xbe, 0x70, 0xe5, 0xbf, 0x35, 0xc1, 0x99, 0x15, 0x3a, 0x2b, 0x34, 0x3e, + 0x05, 0x57, 0xf1, 0x3b, 0xa9, 0xe2, 0x9c, 0x20, 0xaf, 0x19, 0x74, 0x46, 0x43, 0xfa, 0x1d, 0xa0, + 0x95, 0x99, 0x32, 0xe3, 0x64, 0x3b, 0x62, 0xf0, 0xde, 0x00, 0xa7, 0xda, 0xe1, 0x33, 0x70, 0xee, + 0x05, 0x4f, 0x3e, 0x63, 0xf6, 0x7f, 0x8d, 0xa1, 0x17, 0xa5, 0x9f, 0xd5, 0xd8, 0xe0, 0xb5, 0x01, + 0xb6, 0xd9, 0xe0, 0x3d, 0x68, 0x69, 0xfe, 0xac, 0x09, 0xf2, 0x50, 0xd0, 0x9e, 0x58, 0xcc, 0x28, + 0x4c, 0xc0, 0x49, 0x8b, 0x87, 0x15, 0x57, 0xa4, 0xe1, 0xa1, 0xc0, 0x9e, 0x58, 0xac, 0xd6, 0x78, + 0x0c, 0x36, 0x57, 0x4a, 0x2a, 0xd2, 0xf4, 0x50, 0xd0, 0x1d, 0x1d, 0xfe, 0xb1, 0x99, 0x8e, 0x19, + 0x9b, 0xb1, 0x89, 0xc5, 0x2a, 0x1a, 0x9f, 0x40, 0x2b, 0x11, 0xb9, 0x26, 0xb6, 0x87, 0x82, 0xce, + 0xc8, 0xff, 0x29, 0x85, 0xf1, 0x8c, 0x47, 0x9a, 0xc7, 0x73, 0xad, 0x44, 0xba, 0x2e, 0x3f, 0xad, + 0x24, 0x30, 0x85, 0xfe, 0x63, 0x21, 0x35, 0x5f, 0x3e, 0x6d, 0x78, 0xba, 0xcc, 0x94, 0x48, 0xb5, + 0x48, 0xd7, 0xc4, 0xf5, 0x50, 0xf0, 0x8f, 0xfd, 0x37, 0xa7, 0xc5, 0x86, 0xa7, 0x37, 0xf5, 0xc1, + 0x1f, 0x82, 0x6d, 0xba, 0x71, 0x07, 0xdc, 0xdb, 0xf0, 0x2a, 0x9c, 0x2d, 0xc2, 0x9e, 0x55, 0x8a, + 0xeb, 0xe9, 0x7c, 0x3e, 0x0d, 0x2f, 0x7b, 0xe8, 0xdc, 0x05, 0x7b, 0x1b, 0x25, 0x05, 0xf7, 0x0f, + 0xa0, 0xfb, 0xb5, 0x15, 0x13, 0x70, 0x73, 0x33, 0x55, 0xbf, 0xba, 0xcd, 0x76, 0x72, 0xe5, 0x98, + 0x17, 0x3f, 0xfe, 0x08, 0x00, 0x00, 0xff, 0xff, 0x8d, 0x62, 0x58, 0xc4, 0x08, 0x02, 0x00, 0x00, +} diff --git a/vendor/github.com/bazelbuild/buildtools/api_proto/api.proto b/vendor/github.com/bazelbuild/buildtools/api_proto/api.proto new file mode 100644 index 00000000000..a991dccbdcd --- /dev/null +++ b/vendor/github.com/bazelbuild/buildtools/api_proto/api.proto @@ -0,0 +1,42 @@ +/* +Copyright 2016 Google Inc. All Rights Reserved. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +syntax = "proto3"; + +package devtools.buildozer; + +message Output { + repeated Record records = 1; + message Record { + repeated Field fields = 1; + message Field { + oneof value { + string text = 1; + int32 number = 2; + ERROR error = 3; + RepeatedString list = 5; + } + // Used internally by Buildozer to decide whether a field should be quoted + // when printing. This does not affect the contents of 'value'. + bool quote_when_printing = 7; + + enum ERROR { + UNKNOWN = 0; + MISSING = 1; + } + } + } +} + +message RepeatedString { + repeated string strings = 1; +} diff --git a/vendor/github.com/bazelbuild/buildtools/build_proto/BUILD b/vendor/github.com/bazelbuild/buildtools/build_proto/BUILD new file mode 100644 index 00000000000..a7ad3a12fa6 --- /dev/null +++ b/vendor/github.com/bazelbuild/buildtools/build_proto/BUILD @@ -0,0 +1,24 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["build.gen.pb.go"], + importmap = "k8s.io/kubernetes/vendor/github.com/bazelbuild/buildtools/build_proto", + importpath = "github.com/bazelbuild/buildtools/build_proto", + visibility = ["//visibility:public"], + deps = ["//vendor/github.com/golang/protobuf/proto:go_default_library"], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/vendor/github.com/bazelbuild/buildtools/build_proto/build.gen.pb.go b/vendor/github.com/bazelbuild/buildtools/build_proto/build.gen.pb.go new file mode 100755 index 00000000000..3e974de16c6 --- /dev/null +++ b/vendor/github.com/bazelbuild/buildtools/build_proto/build.gen.pb.go @@ -0,0 +1,2092 @@ +// Code generated by protoc-gen-go. +// source: build_proto/build.proto +// DO NOT EDIT! + +/* +Package blaze_query is a generated protocol buffer package. + +It is generated from these files: + build_proto/build.proto + +It has these top-level messages: + License + StringDictEntry + LabelDictUnaryEntry + LabelListDictEntry + LabelKeyedStringDictEntry + StringListDictEntry + FilesetEntry + Attribute + Rule + AttributeAspect + SkylarkAspect + RuleSummary + PackageGroup + EnvironmentGroup + SourceFile + GeneratedFile + Target + QueryResult + AllowedRuleClassInfo + AttributeDefinition + RuleDefinition + BuildLanguage + Location + MakeVarBinding + MakeVar + GlobCriteria + Event +*/ +package blaze_query + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package + +// Indicates what to do when a source file is actually a symlink. +type FilesetEntry_SymlinkBehavior int32 + +const ( + FilesetEntry_COPY FilesetEntry_SymlinkBehavior = 1 + FilesetEntry_DEREFERENCE FilesetEntry_SymlinkBehavior = 2 +) + +var FilesetEntry_SymlinkBehavior_name = map[int32]string{ + 1: "COPY", + 2: "DEREFERENCE", +} +var FilesetEntry_SymlinkBehavior_value = map[string]int32{ + "COPY": 1, + "DEREFERENCE": 2, +} + +func (x FilesetEntry_SymlinkBehavior) Enum() *FilesetEntry_SymlinkBehavior { + p := new(FilesetEntry_SymlinkBehavior) + *p = x + return p +} +func (x FilesetEntry_SymlinkBehavior) String() string { + return proto.EnumName(FilesetEntry_SymlinkBehavior_name, int32(x)) +} +func (x *FilesetEntry_SymlinkBehavior) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(FilesetEntry_SymlinkBehavior_value, data, "FilesetEntry_SymlinkBehavior") + if err != nil { + return err + } + *x = FilesetEntry_SymlinkBehavior(value) + return nil +} +func (FilesetEntry_SymlinkBehavior) EnumDescriptor() ([]byte, []int) { + return fileDescriptor0, []int{6, 0} +} + +// Indicates the type of attribute. +type Attribute_Discriminator int32 + +const ( + Attribute_INTEGER Attribute_Discriminator = 1 + Attribute_STRING Attribute_Discriminator = 2 + Attribute_LABEL Attribute_Discriminator = 3 + Attribute_OUTPUT Attribute_Discriminator = 4 + Attribute_STRING_LIST Attribute_Discriminator = 5 + Attribute_LABEL_LIST Attribute_Discriminator = 6 + Attribute_OUTPUT_LIST Attribute_Discriminator = 7 + Attribute_DISTRIBUTION_SET Attribute_Discriminator = 8 + Attribute_LICENSE Attribute_Discriminator = 9 + Attribute_STRING_DICT Attribute_Discriminator = 10 + Attribute_FILESET_ENTRY_LIST Attribute_Discriminator = 11 + Attribute_LABEL_LIST_DICT Attribute_Discriminator = 12 + Attribute_STRING_LIST_DICT Attribute_Discriminator = 13 + Attribute_BOOLEAN Attribute_Discriminator = 14 + Attribute_TRISTATE Attribute_Discriminator = 15 + Attribute_INTEGER_LIST Attribute_Discriminator = 16 + Attribute_UNKNOWN Attribute_Discriminator = 18 + Attribute_LABEL_DICT_UNARY Attribute_Discriminator = 19 + Attribute_SELECTOR_LIST Attribute_Discriminator = 20 + Attribute_LABEL_KEYED_STRING_DICT Attribute_Discriminator = 21 + Attribute_DEPRECATED_STRING_DICT_UNARY Attribute_Discriminator = 17 +) + +var Attribute_Discriminator_name = map[int32]string{ + 1: "INTEGER", + 2: "STRING", + 3: "LABEL", + 4: "OUTPUT", + 5: "STRING_LIST", + 6: "LABEL_LIST", + 7: "OUTPUT_LIST", + 8: "DISTRIBUTION_SET", + 9: "LICENSE", + 10: "STRING_DICT", + 11: "FILESET_ENTRY_LIST", + 12: "LABEL_LIST_DICT", + 13: "STRING_LIST_DICT", + 14: "BOOLEAN", + 15: "TRISTATE", + 16: "INTEGER_LIST", + 18: "UNKNOWN", + 19: "LABEL_DICT_UNARY", + 20: "SELECTOR_LIST", + 21: "LABEL_KEYED_STRING_DICT", + 17: "DEPRECATED_STRING_DICT_UNARY", +} +var Attribute_Discriminator_value = map[string]int32{ + "INTEGER": 1, + "STRING": 2, + "LABEL": 3, + "OUTPUT": 4, + "STRING_LIST": 5, + "LABEL_LIST": 6, + "OUTPUT_LIST": 7, + "DISTRIBUTION_SET": 8, + "LICENSE": 9, + "STRING_DICT": 10, + "FILESET_ENTRY_LIST": 11, + "LABEL_LIST_DICT": 12, + "STRING_LIST_DICT": 13, + "BOOLEAN": 14, + "TRISTATE": 15, + "INTEGER_LIST": 16, + "UNKNOWN": 18, + "LABEL_DICT_UNARY": 19, + "SELECTOR_LIST": 20, + "LABEL_KEYED_STRING_DICT": 21, + "DEPRECATED_STRING_DICT_UNARY": 17, +} + +func (x Attribute_Discriminator) Enum() *Attribute_Discriminator { + p := new(Attribute_Discriminator) + *p = x + return p +} +func (x Attribute_Discriminator) String() string { + return proto.EnumName(Attribute_Discriminator_name, int32(x)) +} +func (x *Attribute_Discriminator) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(Attribute_Discriminator_value, data, "Attribute_Discriminator") + if err != nil { + return err + } + *x = Attribute_Discriminator(value) + return nil +} +func (Attribute_Discriminator) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{7, 0} } + +// Values for the TriState field type. +type Attribute_Tristate int32 + +const ( + Attribute_NO Attribute_Tristate = 0 + Attribute_YES Attribute_Tristate = 1 + Attribute_AUTO Attribute_Tristate = 2 +) + +var Attribute_Tristate_name = map[int32]string{ + 0: "NO", + 1: "YES", + 2: "AUTO", +} +var Attribute_Tristate_value = map[string]int32{ + "NO": 0, + "YES": 1, + "AUTO": 2, +} + +func (x Attribute_Tristate) Enum() *Attribute_Tristate { + p := new(Attribute_Tristate) + *p = x + return p +} +func (x Attribute_Tristate) String() string { + return proto.EnumName(Attribute_Tristate_name, int32(x)) +} +func (x *Attribute_Tristate) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(Attribute_Tristate_value, data, "Attribute_Tristate") + if err != nil { + return err + } + *x = Attribute_Tristate(value) + return nil +} +func (Attribute_Tristate) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{7, 1} } + +type Target_Discriminator int32 + +const ( + Target_RULE Target_Discriminator = 1 + Target_SOURCE_FILE Target_Discriminator = 2 + Target_GENERATED_FILE Target_Discriminator = 3 + Target_PACKAGE_GROUP Target_Discriminator = 4 + Target_ENVIRONMENT_GROUP Target_Discriminator = 5 +) + +var Target_Discriminator_name = map[int32]string{ + 1: "RULE", + 2: "SOURCE_FILE", + 3: "GENERATED_FILE", + 4: "PACKAGE_GROUP", + 5: "ENVIRONMENT_GROUP", +} +var Target_Discriminator_value = map[string]int32{ + "RULE": 1, + "SOURCE_FILE": 2, + "GENERATED_FILE": 3, + "PACKAGE_GROUP": 4, + "ENVIRONMENT_GROUP": 5, +} + +func (x Target_Discriminator) Enum() *Target_Discriminator { + p := new(Target_Discriminator) + *p = x + return p +} +func (x Target_Discriminator) String() string { + return proto.EnumName(Target_Discriminator_name, int32(x)) +} +func (x *Target_Discriminator) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(Target_Discriminator_value, data, "Target_Discriminator") + if err != nil { + return err + } + *x = Target_Discriminator(value) + return nil +} +func (Target_Discriminator) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{16, 0} } + +type AllowedRuleClassInfo_AllowedRuleClasses int32 + +const ( + AllowedRuleClassInfo_ANY AllowedRuleClassInfo_AllowedRuleClasses = 1 + AllowedRuleClassInfo_SPECIFIED AllowedRuleClassInfo_AllowedRuleClasses = 2 +) + +var AllowedRuleClassInfo_AllowedRuleClasses_name = map[int32]string{ + 1: "ANY", + 2: "SPECIFIED", +} +var AllowedRuleClassInfo_AllowedRuleClasses_value = map[string]int32{ + "ANY": 1, + "SPECIFIED": 2, +} + +func (x AllowedRuleClassInfo_AllowedRuleClasses) Enum() *AllowedRuleClassInfo_AllowedRuleClasses { + p := new(AllowedRuleClassInfo_AllowedRuleClasses) + *p = x + return p +} +func (x AllowedRuleClassInfo_AllowedRuleClasses) String() string { + return proto.EnumName(AllowedRuleClassInfo_AllowedRuleClasses_name, int32(x)) +} +func (x *AllowedRuleClassInfo_AllowedRuleClasses) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(AllowedRuleClassInfo_AllowedRuleClasses_value, data, "AllowedRuleClassInfo_AllowedRuleClasses") + if err != nil { + return err + } + *x = AllowedRuleClassInfo_AllowedRuleClasses(value) + return nil +} +func (AllowedRuleClassInfo_AllowedRuleClasses) EnumDescriptor() ([]byte, []int) { + return fileDescriptor0, []int{18, 0} +} + +type Event_EventKind int32 + +const ( + Event_ERROR Event_EventKind = 1 + Event_WARNING Event_EventKind = 2 + Event_INFO Event_EventKind = 3 + Event_PROGRESS Event_EventKind = 4 +) + +var Event_EventKind_name = map[int32]string{ + 1: "ERROR", + 2: "WARNING", + 3: "INFO", + 4: "PROGRESS", +} +var Event_EventKind_value = map[string]int32{ + "ERROR": 1, + "WARNING": 2, + "INFO": 3, + "PROGRESS": 4, +} + +func (x Event_EventKind) Enum() *Event_EventKind { + p := new(Event_EventKind) + *p = x + return p +} +func (x Event_EventKind) String() string { + return proto.EnumName(Event_EventKind_name, int32(x)) +} +func (x *Event_EventKind) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(Event_EventKind_value, data, "Event_EventKind") + if err != nil { + return err + } + *x = Event_EventKind(value) + return nil +} +func (Event_EventKind) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{26, 0} } + +type License struct { + LicenseType []string `protobuf:"bytes,1,rep,name=license_type,json=licenseType" json:"license_type,omitempty"` + Exception []string `protobuf:"bytes,2,rep,name=exception" json:"exception,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *License) Reset() { *m = License{} } +func (m *License) String() string { return proto.CompactTextString(m) } +func (*License) ProtoMessage() {} +func (*License) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } + +func (m *License) GetLicenseType() []string { + if m != nil { + return m.LicenseType + } + return nil +} + +func (m *License) GetException() []string { + if m != nil { + return m.Exception + } + return nil +} + +type StringDictEntry struct { + Key *string `protobuf:"bytes,1,req,name=key" json:"key,omitempty"` + Value *string `protobuf:"bytes,2,req,name=value" json:"value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *StringDictEntry) Reset() { *m = StringDictEntry{} } +func (m *StringDictEntry) String() string { return proto.CompactTextString(m) } +func (*StringDictEntry) ProtoMessage() {} +func (*StringDictEntry) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } + +func (m *StringDictEntry) GetKey() string { + if m != nil && m.Key != nil { + return *m.Key + } + return "" +} + +func (m *StringDictEntry) GetValue() string { + if m != nil && m.Value != nil { + return *m.Value + } + return "" +} + +type LabelDictUnaryEntry struct { + Key *string `protobuf:"bytes,1,req,name=key" json:"key,omitempty"` + Value *string `protobuf:"bytes,2,req,name=value" json:"value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *LabelDictUnaryEntry) Reset() { *m = LabelDictUnaryEntry{} } +func (m *LabelDictUnaryEntry) String() string { return proto.CompactTextString(m) } +func (*LabelDictUnaryEntry) ProtoMessage() {} +func (*LabelDictUnaryEntry) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } + +func (m *LabelDictUnaryEntry) GetKey() string { + if m != nil && m.Key != nil { + return *m.Key + } + return "" +} + +func (m *LabelDictUnaryEntry) GetValue() string { + if m != nil && m.Value != nil { + return *m.Value + } + return "" +} + +type LabelListDictEntry struct { + Key *string `protobuf:"bytes,1,req,name=key" json:"key,omitempty"` + Value []string `protobuf:"bytes,2,rep,name=value" json:"value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *LabelListDictEntry) Reset() { *m = LabelListDictEntry{} } +func (m *LabelListDictEntry) String() string { return proto.CompactTextString(m) } +func (*LabelListDictEntry) ProtoMessage() {} +func (*LabelListDictEntry) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } + +func (m *LabelListDictEntry) GetKey() string { + if m != nil && m.Key != nil { + return *m.Key + } + return "" +} + +func (m *LabelListDictEntry) GetValue() []string { + if m != nil { + return m.Value + } + return nil +} + +type LabelKeyedStringDictEntry struct { + Key *string `protobuf:"bytes,1,req,name=key" json:"key,omitempty"` + Value *string `protobuf:"bytes,2,req,name=value" json:"value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *LabelKeyedStringDictEntry) Reset() { *m = LabelKeyedStringDictEntry{} } +func (m *LabelKeyedStringDictEntry) String() string { return proto.CompactTextString(m) } +func (*LabelKeyedStringDictEntry) ProtoMessage() {} +func (*LabelKeyedStringDictEntry) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } + +func (m *LabelKeyedStringDictEntry) GetKey() string { + if m != nil && m.Key != nil { + return *m.Key + } + return "" +} + +func (m *LabelKeyedStringDictEntry) GetValue() string { + if m != nil && m.Value != nil { + return *m.Value + } + return "" +} + +type StringListDictEntry struct { + Key *string `protobuf:"bytes,1,req,name=key" json:"key,omitempty"` + Value []string `protobuf:"bytes,2,rep,name=value" json:"value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *StringListDictEntry) Reset() { *m = StringListDictEntry{} } +func (m *StringListDictEntry) String() string { return proto.CompactTextString(m) } +func (*StringListDictEntry) ProtoMessage() {} +func (*StringListDictEntry) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} } + +func (m *StringListDictEntry) GetKey() string { + if m != nil && m.Key != nil { + return *m.Key + } + return "" +} + +func (m *StringListDictEntry) GetValue() []string { + if m != nil { + return m.Value + } + return nil +} + +// Represents an entry attribute of a Fileset rule in a build file. +type FilesetEntry struct { + // The label pointing to the source target where files are copied from. + Source *string `protobuf:"bytes,1,req,name=source" json:"source,omitempty"` + // The relative path within the fileset rule where files will be mapped. + DestinationDirectory *string `protobuf:"bytes,2,req,name=destination_directory,json=destinationDirectory" json:"destination_directory,omitempty"` + // Whether the files= attribute was specified. This is necessary because + // no files= attribute and files=[] mean different things. + FilesPresent *bool `protobuf:"varint,7,opt,name=files_present,json=filesPresent" json:"files_present,omitempty"` + // A list of file labels to include from the source directory. + File []string `protobuf:"bytes,3,rep,name=file" json:"file,omitempty"` + // If this is a fileset entry representing files within the rule + // package, this lists relative paths to files that should be excluded from + // the set. This cannot contain values if 'file' also has values. + Exclude []string `protobuf:"bytes,4,rep,name=exclude" json:"exclude,omitempty"` + // This field is optional because there will be some time when the new + // PB is used by tools depending on blaze query, but the new blaze version + // is not yet released. + // TODO(bazel-team): Make this field required once a version of Blaze is + // released that outputs this field. + SymlinkBehavior *FilesetEntry_SymlinkBehavior `protobuf:"varint,5,opt,name=symlink_behavior,json=symlinkBehavior,enum=blaze_query.FilesetEntry_SymlinkBehavior,def=1" json:"symlink_behavior,omitempty"` + // The prefix to strip from the path of the files in this FilesetEntry. Note + // that no value and the empty string as the value mean different things here. + StripPrefix *string `protobuf:"bytes,6,opt,name=strip_prefix,json=stripPrefix" json:"strip_prefix,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *FilesetEntry) Reset() { *m = FilesetEntry{} } +func (m *FilesetEntry) String() string { return proto.CompactTextString(m) } +func (*FilesetEntry) ProtoMessage() {} +func (*FilesetEntry) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} } + +const Default_FilesetEntry_SymlinkBehavior FilesetEntry_SymlinkBehavior = FilesetEntry_COPY + +func (m *FilesetEntry) GetSource() string { + if m != nil && m.Source != nil { + return *m.Source + } + return "" +} + +func (m *FilesetEntry) GetDestinationDirectory() string { + if m != nil && m.DestinationDirectory != nil { + return *m.DestinationDirectory + } + return "" +} + +func (m *FilesetEntry) GetFilesPresent() bool { + if m != nil && m.FilesPresent != nil { + return *m.FilesPresent + } + return false +} + +func (m *FilesetEntry) GetFile() []string { + if m != nil { + return m.File + } + return nil +} + +func (m *FilesetEntry) GetExclude() []string { + if m != nil { + return m.Exclude + } + return nil +} + +func (m *FilesetEntry) GetSymlinkBehavior() FilesetEntry_SymlinkBehavior { + if m != nil && m.SymlinkBehavior != nil { + return *m.SymlinkBehavior + } + return Default_FilesetEntry_SymlinkBehavior +} + +func (m *FilesetEntry) GetStripPrefix() string { + if m != nil && m.StripPrefix != nil { + return *m.StripPrefix + } + return "" +} + +// A rule attribute. Each attribute must have a type and one of the various +// value fields populated - for the most part. +// +// Attributes of BOOLEAN and TRISTATE type may set all of the int, bool, and +// string values for backwards compatibility with clients that expect them to +// be set. +// +// Attributes of INTEGER, STRING, LABEL, LICENSE, BOOLEAN, and TRISTATE type +// may set *none* of the values. This can happen if the Attribute message is +// prepared for a client that doesn't support SELECTOR_LIST, but the rule has +// a selector list value for the attribute. (Selector lists for attributes of +// other types--the collection types--are handled differently when prepared +// for such a client. The possible collection values are gathered together +// and flattened.) +// +// By checking the type, the appropriate value can be extracted - see the +// comments on each type for the associated value. The order of lists comes +// from the blaze parsing. If an attribute is of a list type, the associated +// list should never be empty. +type Attribute struct { + // The name of the attribute + Name *string `protobuf:"bytes,1,req,name=name" json:"name,omitempty"` + // The location of the target in the BUILD file in a machine-parseable form. + DEPRECATEDParseableLocation *Location `protobuf:"bytes,12,opt,name=DEPRECATED_parseable_location,json=DEPRECATEDParseableLocation" json:"DEPRECATED_parseable_location,omitempty"` + // Whether the attribute was explicitly specified + ExplicitlySpecified *bool `protobuf:"varint,13,opt,name=explicitly_specified,json=explicitlySpecified" json:"explicitly_specified,omitempty"` + // If this attribute has a string value or a string list value, then this + // may be set to indicate that the value may be treated as a label that + // isn't a dependency of this attribute's rule. + Nodep *bool `protobuf:"varint,20,opt,name=nodep" json:"nodep,omitempty"` + // The type of attribute. This message is used for all of the different + // attribute types so the discriminator helps for figuring out what is + // stored in the message. + Type *Attribute_Discriminator `protobuf:"varint,2,req,name=type,enum=blaze_query.Attribute_Discriminator" json:"type,omitempty"` + // If this attribute has an integer value this will be populated. + // Boolean and TriState also use this field as [0,1] and [-1,0,1] + // for [false, true] and [auto, no, yes] respectively. + IntValue *int32 `protobuf:"varint,3,opt,name=int_value,json=intValue" json:"int_value,omitempty"` + // If the attribute has a string value this will be populated. Label and + // path attributes use this field as the value even though the type may + // be LABEL or something else other than STRING. + StringValue *string `protobuf:"bytes,5,opt,name=string_value,json=stringValue" json:"string_value,omitempty"` + // If the attribute has a boolean value this will be populated. + BooleanValue *bool `protobuf:"varint,14,opt,name=boolean_value,json=booleanValue" json:"boolean_value,omitempty"` + // If the attribute is a Tristate value, this will be populated. + TristateValue *Attribute_Tristate `protobuf:"varint,15,opt,name=tristate_value,json=tristateValue,enum=blaze_query.Attribute_Tristate" json:"tristate_value,omitempty"` + // The value of the attribute has a list of string values (label and path + // note from STRING applies here as well). + StringListValue []string `protobuf:"bytes,6,rep,name=string_list_value,json=stringListValue" json:"string_list_value,omitempty"` + // If this is a license attribute, the license information is stored here. + License *License `protobuf:"bytes,7,opt,name=license" json:"license,omitempty"` + // If this is a string dict, each entry will be stored here. + StringDictValue []*StringDictEntry `protobuf:"bytes,8,rep,name=string_dict_value,json=stringDictValue" json:"string_dict_value,omitempty"` + // If the attribute is part of a Fileset, the fileset entries are stored in + // this field. + FilesetListValue []*FilesetEntry `protobuf:"bytes,9,rep,name=fileset_list_value,json=filesetListValue" json:"fileset_list_value,omitempty"` + // If this is a label list dict, each entry will be stored here. + LabelListDictValue []*LabelListDictEntry `protobuf:"bytes,10,rep,name=label_list_dict_value,json=labelListDictValue" json:"label_list_dict_value,omitempty"` + // If this is a string list dict, each entry will be stored here. + StringListDictValue []*StringListDictEntry `protobuf:"bytes,11,rep,name=string_list_dict_value,json=stringListDictValue" json:"string_list_dict_value,omitempty"` + // The glob criteria. This is non-empty if: + // 1. This attribute is a list of strings or labels, and, + // 2. It contained a glob() expression + GlobCriteria []*GlobCriteria `protobuf:"bytes,16,rep,name=glob_criteria,json=globCriteria" json:"glob_criteria,omitempty"` + // The value of the attribute has a list of int32 values + IntListValue []int32 `protobuf:"varint,17,rep,name=int_list_value,json=intListValue" json:"int_list_value,omitempty"` + // If this is a label dict unary, each entry will be stored here. + LabelDictUnaryValue []*LabelDictUnaryEntry `protobuf:"bytes,19,rep,name=label_dict_unary_value,json=labelDictUnaryValue" json:"label_dict_unary_value,omitempty"` + // If this is a label-keyed string dict, each entry will be stored here. + LabelKeyedStringDictValue []*LabelKeyedStringDictEntry `protobuf:"bytes,22,rep,name=label_keyed_string_dict_value,json=labelKeyedStringDictValue" json:"label_keyed_string_dict_value,omitempty"` + // If this attribute's value is an expression containing one or more select + // expressions, then its type is SELECTOR_LIST and a SelectorList will be + // stored here. + SelectorList *Attribute_SelectorList `protobuf:"bytes,21,opt,name=selector_list,json=selectorList" json:"selector_list,omitempty"` + DEPRECATEDStringDictUnaryValue [][]byte `protobuf:"bytes,18,rep,name=DEPRECATED_string_dict_unary_value,json=DEPRECATEDStringDictUnaryValue" json:"DEPRECATED_string_dict_unary_value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Attribute) Reset() { *m = Attribute{} } +func (m *Attribute) String() string { return proto.CompactTextString(m) } +func (*Attribute) ProtoMessage() {} +func (*Attribute) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} } + +func (m *Attribute) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *Attribute) GetDEPRECATEDParseableLocation() *Location { + if m != nil { + return m.DEPRECATEDParseableLocation + } + return nil +} + +func (m *Attribute) GetExplicitlySpecified() bool { + if m != nil && m.ExplicitlySpecified != nil { + return *m.ExplicitlySpecified + } + return false +} + +func (m *Attribute) GetNodep() bool { + if m != nil && m.Nodep != nil { + return *m.Nodep + } + return false +} + +func (m *Attribute) GetType() Attribute_Discriminator { + if m != nil && m.Type != nil { + return *m.Type + } + return Attribute_INTEGER +} + +func (m *Attribute) GetIntValue() int32 { + if m != nil && m.IntValue != nil { + return *m.IntValue + } + return 0 +} + +func (m *Attribute) GetStringValue() string { + if m != nil && m.StringValue != nil { + return *m.StringValue + } + return "" +} + +func (m *Attribute) GetBooleanValue() bool { + if m != nil && m.BooleanValue != nil { + return *m.BooleanValue + } + return false +} + +func (m *Attribute) GetTristateValue() Attribute_Tristate { + if m != nil && m.TristateValue != nil { + return *m.TristateValue + } + return Attribute_NO +} + +func (m *Attribute) GetStringListValue() []string { + if m != nil { + return m.StringListValue + } + return nil +} + +func (m *Attribute) GetLicense() *License { + if m != nil { + return m.License + } + return nil +} + +func (m *Attribute) GetStringDictValue() []*StringDictEntry { + if m != nil { + return m.StringDictValue + } + return nil +} + +func (m *Attribute) GetFilesetListValue() []*FilesetEntry { + if m != nil { + return m.FilesetListValue + } + return nil +} + +func (m *Attribute) GetLabelListDictValue() []*LabelListDictEntry { + if m != nil { + return m.LabelListDictValue + } + return nil +} + +func (m *Attribute) GetStringListDictValue() []*StringListDictEntry { + if m != nil { + return m.StringListDictValue + } + return nil +} + +func (m *Attribute) GetGlobCriteria() []*GlobCriteria { + if m != nil { + return m.GlobCriteria + } + return nil +} + +func (m *Attribute) GetIntListValue() []int32 { + if m != nil { + return m.IntListValue + } + return nil +} + +func (m *Attribute) GetLabelDictUnaryValue() []*LabelDictUnaryEntry { + if m != nil { + return m.LabelDictUnaryValue + } + return nil +} + +func (m *Attribute) GetLabelKeyedStringDictValue() []*LabelKeyedStringDictEntry { + if m != nil { + return m.LabelKeyedStringDictValue + } + return nil +} + +func (m *Attribute) GetSelectorList() *Attribute_SelectorList { + if m != nil { + return m.SelectorList + } + return nil +} + +func (m *Attribute) GetDEPRECATEDStringDictUnaryValue() [][]byte { + if m != nil { + return m.DEPRECATEDStringDictUnaryValue + } + return nil +} + +type Attribute_SelectorEntry struct { + // The key of the selector entry. At this time, this is the label of a + // config_setting rule, or the pseudo-label "//conditions:default". + Label *string `protobuf:"bytes,1,opt,name=label" json:"label,omitempty"` + // True if the entry's value is the default value for the type as a + // result of the condition value being specified as None (ie: + // {"//condition": None}). + IsDefaultValue *bool `protobuf:"varint,16,opt,name=is_default_value,json=isDefaultValue" json:"is_default_value,omitempty"` + // Exactly one of the following fields (except for glob_criteria) must be + // populated - note that the BOOLEAN and TRISTATE caveat in Attribute's + // comment does not apply here. The type field in the SelectorList + // containing this entry indicates which of these fields is populated, + // in accordance with the comments on Discriminator enum values above. + // (To be explicit: BOOLEAN populates the boolean_value field and TRISTATE + // populates the tristate_value field.) + IntValue *int32 `protobuf:"varint,2,opt,name=int_value,json=intValue" json:"int_value,omitempty"` + StringValue *string `protobuf:"bytes,3,opt,name=string_value,json=stringValue" json:"string_value,omitempty"` + BooleanValue *bool `protobuf:"varint,4,opt,name=boolean_value,json=booleanValue" json:"boolean_value,omitempty"` + TristateValue *Attribute_Tristate `protobuf:"varint,5,opt,name=tristate_value,json=tristateValue,enum=blaze_query.Attribute_Tristate" json:"tristate_value,omitempty"` + StringListValue []string `protobuf:"bytes,6,rep,name=string_list_value,json=stringListValue" json:"string_list_value,omitempty"` + License *License `protobuf:"bytes,7,opt,name=license" json:"license,omitempty"` + StringDictValue []*StringDictEntry `protobuf:"bytes,8,rep,name=string_dict_value,json=stringDictValue" json:"string_dict_value,omitempty"` + FilesetListValue []*FilesetEntry `protobuf:"bytes,9,rep,name=fileset_list_value,json=filesetListValue" json:"fileset_list_value,omitempty"` + LabelListDictValue []*LabelListDictEntry `protobuf:"bytes,10,rep,name=label_list_dict_value,json=labelListDictValue" json:"label_list_dict_value,omitempty"` + StringListDictValue []*StringListDictEntry `protobuf:"bytes,11,rep,name=string_list_dict_value,json=stringListDictValue" json:"string_list_dict_value,omitempty"` + GlobCriteria []*GlobCriteria `protobuf:"bytes,12,rep,name=glob_criteria,json=globCriteria" json:"glob_criteria,omitempty"` + IntListValue []int32 `protobuf:"varint,13,rep,name=int_list_value,json=intListValue" json:"int_list_value,omitempty"` + LabelDictUnaryValue []*LabelDictUnaryEntry `protobuf:"bytes,15,rep,name=label_dict_unary_value,json=labelDictUnaryValue" json:"label_dict_unary_value,omitempty"` + LabelKeyedStringDictValue []*LabelKeyedStringDictEntry `protobuf:"bytes,17,rep,name=label_keyed_string_dict_value,json=labelKeyedStringDictValue" json:"label_keyed_string_dict_value,omitempty"` + DEPRECATEDStringDictUnaryValue [][]byte `protobuf:"bytes,14,rep,name=DEPRECATED_string_dict_unary_value,json=DEPRECATEDStringDictUnaryValue" json:"DEPRECATED_string_dict_unary_value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Attribute_SelectorEntry) Reset() { *m = Attribute_SelectorEntry{} } +func (m *Attribute_SelectorEntry) String() string { return proto.CompactTextString(m) } +func (*Attribute_SelectorEntry) ProtoMessage() {} +func (*Attribute_SelectorEntry) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7, 0} } + +func (m *Attribute_SelectorEntry) GetLabel() string { + if m != nil && m.Label != nil { + return *m.Label + } + return "" +} + +func (m *Attribute_SelectorEntry) GetIsDefaultValue() bool { + if m != nil && m.IsDefaultValue != nil { + return *m.IsDefaultValue + } + return false +} + +func (m *Attribute_SelectorEntry) GetIntValue() int32 { + if m != nil && m.IntValue != nil { + return *m.IntValue + } + return 0 +} + +func (m *Attribute_SelectorEntry) GetStringValue() string { + if m != nil && m.StringValue != nil { + return *m.StringValue + } + return "" +} + +func (m *Attribute_SelectorEntry) GetBooleanValue() bool { + if m != nil && m.BooleanValue != nil { + return *m.BooleanValue + } + return false +} + +func (m *Attribute_SelectorEntry) GetTristateValue() Attribute_Tristate { + if m != nil && m.TristateValue != nil { + return *m.TristateValue + } + return Attribute_NO +} + +func (m *Attribute_SelectorEntry) GetStringListValue() []string { + if m != nil { + return m.StringListValue + } + return nil +} + +func (m *Attribute_SelectorEntry) GetLicense() *License { + if m != nil { + return m.License + } + return nil +} + +func (m *Attribute_SelectorEntry) GetStringDictValue() []*StringDictEntry { + if m != nil { + return m.StringDictValue + } + return nil +} + +func (m *Attribute_SelectorEntry) GetFilesetListValue() []*FilesetEntry { + if m != nil { + return m.FilesetListValue + } + return nil +} + +func (m *Attribute_SelectorEntry) GetLabelListDictValue() []*LabelListDictEntry { + if m != nil { + return m.LabelListDictValue + } + return nil +} + +func (m *Attribute_SelectorEntry) GetStringListDictValue() []*StringListDictEntry { + if m != nil { + return m.StringListDictValue + } + return nil +} + +func (m *Attribute_SelectorEntry) GetGlobCriteria() []*GlobCriteria { + if m != nil { + return m.GlobCriteria + } + return nil +} + +func (m *Attribute_SelectorEntry) GetIntListValue() []int32 { + if m != nil { + return m.IntListValue + } + return nil +} + +func (m *Attribute_SelectorEntry) GetLabelDictUnaryValue() []*LabelDictUnaryEntry { + if m != nil { + return m.LabelDictUnaryValue + } + return nil +} + +func (m *Attribute_SelectorEntry) GetLabelKeyedStringDictValue() []*LabelKeyedStringDictEntry { + if m != nil { + return m.LabelKeyedStringDictValue + } + return nil +} + +func (m *Attribute_SelectorEntry) GetDEPRECATEDStringDictUnaryValue() [][]byte { + if m != nil { + return m.DEPRECATEDStringDictUnaryValue + } + return nil +} + +type Attribute_Selector struct { + // The list of (label, value) pairs in the map that defines the selector. + // At this time, this cannot be empty, i.e. a selector has at least one + // entry. + Entries []*Attribute_SelectorEntry `protobuf:"bytes,1,rep,name=entries" json:"entries,omitempty"` + // Whether or not this has any default values. + HasDefaultValue *bool `protobuf:"varint,2,opt,name=has_default_value,json=hasDefaultValue" json:"has_default_value,omitempty"` + // The error message when no condition matches. + NoMatchError *string `protobuf:"bytes,3,opt,name=no_match_error,json=noMatchError" json:"no_match_error,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Attribute_Selector) Reset() { *m = Attribute_Selector{} } +func (m *Attribute_Selector) String() string { return proto.CompactTextString(m) } +func (*Attribute_Selector) ProtoMessage() {} +func (*Attribute_Selector) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7, 1} } + +func (m *Attribute_Selector) GetEntries() []*Attribute_SelectorEntry { + if m != nil { + return m.Entries + } + return nil +} + +func (m *Attribute_Selector) GetHasDefaultValue() bool { + if m != nil && m.HasDefaultValue != nil { + return *m.HasDefaultValue + } + return false +} + +func (m *Attribute_Selector) GetNoMatchError() string { + if m != nil && m.NoMatchError != nil { + return *m.NoMatchError + } + return "" +} + +type Attribute_SelectorList struct { + // The type that this selector list evaluates to, and the type that each + // selector in the list evaluates to. At this time, this cannot be + // SELECTOR_LIST, i.e. selector lists do not nest. + Type *Attribute_Discriminator `protobuf:"varint,1,opt,name=type,enum=blaze_query.Attribute_Discriminator" json:"type,omitempty"` + // The list of selector elements in this selector list. At this time, this + // cannot be empty, i.e. a selector list is never empty. + Elements []*Attribute_Selector `protobuf:"bytes,2,rep,name=elements" json:"elements,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Attribute_SelectorList) Reset() { *m = Attribute_SelectorList{} } +func (m *Attribute_SelectorList) String() string { return proto.CompactTextString(m) } +func (*Attribute_SelectorList) ProtoMessage() {} +func (*Attribute_SelectorList) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7, 2} } + +func (m *Attribute_SelectorList) GetType() Attribute_Discriminator { + if m != nil && m.Type != nil { + return *m.Type + } + return Attribute_INTEGER +} + +func (m *Attribute_SelectorList) GetElements() []*Attribute_Selector { + if m != nil { + return m.Elements + } + return nil +} + +// A rule from a BUILD file (e.g., cc_library, java_binary). The rule class +// is the actual name of the rule (e.g., cc_library) and the name is the full +// label of the rule (e.g., //foo/bar:baz). +type Rule struct { + // The name of the rule + Name *string `protobuf:"bytes,1,req,name=name" json:"name,omitempty"` + // The rule class (e.g., java_library) + RuleClass *string `protobuf:"bytes,2,req,name=rule_class,json=ruleClass" json:"rule_class,omitempty"` + // The BUILD file and line number of the rule. + Location *string `protobuf:"bytes,3,opt,name=location" json:"location,omitempty"` + // All of the attributes that describe the rule. + Attribute []*Attribute `protobuf:"bytes,4,rep,name=attribute" json:"attribute,omitempty"` + // All of the inputs to the rule. These are predecessors in the dependency + // graph. A rule_input for a rule should always be described as a + // source_file in some package (either the rule's package or some other one). + RuleInput []string `protobuf:"bytes,5,rep,name=rule_input,json=ruleInput" json:"rule_input,omitempty"` + // All of the outputs of the rule. These are the successors in the + // dependency graph. + RuleOutput []string `protobuf:"bytes,6,rep,name=rule_output,json=ruleOutput" json:"rule_output,omitempty"` + // The set of all default settings affecting this rule. The name of a default + // setting is "_". There currently defined setting + // types are: + // + // - 'blaze': settings implemented in Blaze itself + DefaultSetting []string `protobuf:"bytes,7,rep,name=default_setting,json=defaultSetting" json:"default_setting,omitempty"` + // The location of the target in the BUILD file in a machine-parseable form. + DEPRECATEDParseableLocation *Location `protobuf:"bytes,8,opt,name=DEPRECATED_parseable_location,json=DEPRECATEDParseableLocation" json:"DEPRECATED_parseable_location,omitempty"` + // The rule's class's public by default value. + PublicByDefault *bool `protobuf:"varint,9,opt,name=public_by_default,json=publicByDefault" json:"public_by_default,omitempty"` + // If this rule is of a skylark-defined RuleClass. + IsSkylark *bool `protobuf:"varint,10,opt,name=is_skylark,json=isSkylark" json:"is_skylark,omitempty"` + // List of Skylark aspects that this rule applies. + SkylarkAttributeAspects []*AttributeAspect `protobuf:"bytes,11,rep,name=skylark_attribute_aspects,json=skylarkAttributeAspects" json:"skylark_attribute_aspects,omitempty"` + // Hash encapsulating the behavior of this Skylark rule. Any change to this + // rule's definition that could change its behavior will be reflected here. + SkylarkEnvironmentHashCode *string `protobuf:"bytes,12,opt,name=skylark_environment_hash_code,json=skylarkEnvironmentHashCode" json:"skylark_environment_hash_code,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Rule) Reset() { *m = Rule{} } +func (m *Rule) String() string { return proto.CompactTextString(m) } +func (*Rule) ProtoMessage() {} +func (*Rule) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} } + +func (m *Rule) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *Rule) GetRuleClass() string { + if m != nil && m.RuleClass != nil { + return *m.RuleClass + } + return "" +} + +func (m *Rule) GetLocation() string { + if m != nil && m.Location != nil { + return *m.Location + } + return "" +} + +func (m *Rule) GetAttribute() []*Attribute { + if m != nil { + return m.Attribute + } + return nil +} + +func (m *Rule) GetRuleInput() []string { + if m != nil { + return m.RuleInput + } + return nil +} + +func (m *Rule) GetRuleOutput() []string { + if m != nil { + return m.RuleOutput + } + return nil +} + +func (m *Rule) GetDefaultSetting() []string { + if m != nil { + return m.DefaultSetting + } + return nil +} + +func (m *Rule) GetDEPRECATEDParseableLocation() *Location { + if m != nil { + return m.DEPRECATEDParseableLocation + } + return nil +} + +func (m *Rule) GetPublicByDefault() bool { + if m != nil && m.PublicByDefault != nil { + return *m.PublicByDefault + } + return false +} + +func (m *Rule) GetIsSkylark() bool { + if m != nil && m.IsSkylark != nil { + return *m.IsSkylark + } + return false +} + +func (m *Rule) GetSkylarkAttributeAspects() []*AttributeAspect { + if m != nil { + return m.SkylarkAttributeAspects + } + return nil +} + +func (m *Rule) GetSkylarkEnvironmentHashCode() string { + if m != nil && m.SkylarkEnvironmentHashCode != nil { + return *m.SkylarkEnvironmentHashCode + } + return "" +} + +// A pairing of attribute name and a Skylark aspect that is applied to that attribute. +type AttributeAspect struct { + AttributeName *string `protobuf:"bytes,1,req,name=attribute_name,json=attributeName" json:"attribute_name,omitempty"` + Aspect *SkylarkAspect `protobuf:"bytes,2,req,name=aspect" json:"aspect,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *AttributeAspect) Reset() { *m = AttributeAspect{} } +func (m *AttributeAspect) String() string { return proto.CompactTextString(m) } +func (*AttributeAspect) ProtoMessage() {} +func (*AttributeAspect) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} } + +func (m *AttributeAspect) GetAttributeName() string { + if m != nil && m.AttributeName != nil { + return *m.AttributeName + } + return "" +} + +func (m *AttributeAspect) GetAspect() *SkylarkAspect { + if m != nil { + return m.Aspect + } + return nil +} + +// Aspect defined in Skylark. +type SkylarkAspect struct { + ExtensionFileLabel *string `protobuf:"bytes,1,req,name=extension_file_label,json=extensionFileLabel" json:"extension_file_label,omitempty"` + ExportedName *string `protobuf:"bytes,2,req,name=exported_name,json=exportedName" json:"exported_name,omitempty"` + Attribute []*Attribute `protobuf:"bytes,3,rep,name=attribute" json:"attribute,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *SkylarkAspect) Reset() { *m = SkylarkAspect{} } +func (m *SkylarkAspect) String() string { return proto.CompactTextString(m) } +func (*SkylarkAspect) ProtoMessage() {} +func (*SkylarkAspect) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} } + +func (m *SkylarkAspect) GetExtensionFileLabel() string { + if m != nil && m.ExtensionFileLabel != nil { + return *m.ExtensionFileLabel + } + return "" +} + +func (m *SkylarkAspect) GetExportedName() string { + if m != nil && m.ExportedName != nil { + return *m.ExportedName + } + return "" +} + +func (m *SkylarkAspect) GetAttribute() []*Attribute { + if m != nil { + return m.Attribute + } + return nil +} + +// Summary of all transitive dependencies of 'rule,' where each dependent +// rule is included only once in the 'dependency' field. Gives complete +// information to analyze the single build target labeled rule.name, +// including optional location of target in BUILD file. +type RuleSummary struct { + Rule *Rule `protobuf:"bytes,1,req,name=rule" json:"rule,omitempty"` + Dependency []*Rule `protobuf:"bytes,2,rep,name=dependency" json:"dependency,omitempty"` + Location *string `protobuf:"bytes,3,opt,name=location" json:"location,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *RuleSummary) Reset() { *m = RuleSummary{} } +func (m *RuleSummary) String() string { return proto.CompactTextString(m) } +func (*RuleSummary) ProtoMessage() {} +func (*RuleSummary) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} } + +func (m *RuleSummary) GetRule() *Rule { + if m != nil { + return m.Rule + } + return nil +} + +func (m *RuleSummary) GetDependency() []*Rule { + if m != nil { + return m.Dependency + } + return nil +} + +func (m *RuleSummary) GetLocation() string { + if m != nil && m.Location != nil { + return *m.Location + } + return "" +} + +// A package group. Aside from the name, it contains the list of packages +// present in the group (as specified in the BUILD file). +type PackageGroup struct { + // The name of the package group + Name *string `protobuf:"bytes,1,req,name=name" json:"name,omitempty"` + // The list of packages as specified in the BUILD file. Currently this is + // only a list of packages, but some time in the future, there might be + // some type of wildcard mechanism. + ContainedPackage []string `protobuf:"bytes,2,rep,name=contained_package,json=containedPackage" json:"contained_package,omitempty"` + // The list of sub package groups included in this one. + IncludedPackageGroup []string `protobuf:"bytes,3,rep,name=included_package_group,json=includedPackageGroup" json:"included_package_group,omitempty"` + // The location of the target in the BUILD file in a machine-parseable form. + DEPRECATEDParseableLocation *Location `protobuf:"bytes,4,opt,name=DEPRECATED_parseable_location,json=DEPRECATEDParseableLocation" json:"DEPRECATED_parseable_location,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *PackageGroup) Reset() { *m = PackageGroup{} } +func (m *PackageGroup) String() string { return proto.CompactTextString(m) } +func (*PackageGroup) ProtoMessage() {} +func (*PackageGroup) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{12} } + +func (m *PackageGroup) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *PackageGroup) GetContainedPackage() []string { + if m != nil { + return m.ContainedPackage + } + return nil +} + +func (m *PackageGroup) GetIncludedPackageGroup() []string { + if m != nil { + return m.IncludedPackageGroup + } + return nil +} + +func (m *PackageGroup) GetDEPRECATEDParseableLocation() *Location { + if m != nil { + return m.DEPRECATEDParseableLocation + } + return nil +} + +// An environment group. +type EnvironmentGroup struct { + // The name of the environment group. + Name *string `protobuf:"bytes,1,req,name=name" json:"name,omitempty"` + // The environments that belong to this group (as labels). + Environment []string `protobuf:"bytes,2,rep,name=environment" json:"environment,omitempty"` + // The member environments that rules implicitly support if not otherwise + // specified. + Default []string `protobuf:"bytes,3,rep,name=default" json:"default,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *EnvironmentGroup) Reset() { *m = EnvironmentGroup{} } +func (m *EnvironmentGroup) String() string { return proto.CompactTextString(m) } +func (*EnvironmentGroup) ProtoMessage() {} +func (*EnvironmentGroup) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{13} } + +func (m *EnvironmentGroup) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *EnvironmentGroup) GetEnvironment() []string { + if m != nil { + return m.Environment + } + return nil +} + +func (m *EnvironmentGroup) GetDefault() []string { + if m != nil { + return m.Default + } + return nil +} + +// A file that is an input into the build system. +// Next-Id: 10 +type SourceFile struct { + // The name of the source file (a label). + Name *string `protobuf:"bytes,1,req,name=name" json:"name,omitempty"` + // The location of the source file. This is a path with line numbers, not + // a label in the build system. + Location *string `protobuf:"bytes,2,opt,name=location" json:"location,omitempty"` + // The location of the corresponding label in the BUILD file in a + // machine-parseable form. + DEPRECATEDParseableLocation *Location `protobuf:"bytes,7,opt,name=DEPRECATED_parseable_location,json=DEPRECATEDParseableLocation" json:"DEPRECATED_parseable_location,omitempty"` + // Labels of files that are transitively subincluded in this BUILD file. This + // is present only when the SourceFile represents a BUILD file that + // subincludes other files. The subincluded file can be either a Python + // preprocessed build extension or a Skylark file. + Subinclude []string `protobuf:"bytes,3,rep,name=subinclude" json:"subinclude,omitempty"` + // Labels of package groups that are mentioned in the visibility declaration + // for this source file. + PackageGroup []string `protobuf:"bytes,4,rep,name=package_group,json=packageGroup" json:"package_group,omitempty"` + // Labels mentioned in the visibility declaration (including :__pkg__ and + // //visibility: ones) + VisibilityLabel []string `protobuf:"bytes,5,rep,name=visibility_label,json=visibilityLabel" json:"visibility_label,omitempty"` + // The package-level features enabled for this package. Only present if the + // SourceFile represents a BUILD file. + Feature []string `protobuf:"bytes,6,rep,name=feature" json:"feature,omitempty"` + // License attribute for the file. + License *License `protobuf:"bytes,8,opt,name=license" json:"license,omitempty"` + // True if the package contains an error. Only present if the SourceFile + // represents a BUILD file. + PackageContainsErrors *bool `protobuf:"varint,9,opt,name=package_contains_errors,json=packageContainsErrors" json:"package_contains_errors,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *SourceFile) Reset() { *m = SourceFile{} } +func (m *SourceFile) String() string { return proto.CompactTextString(m) } +func (*SourceFile) ProtoMessage() {} +func (*SourceFile) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{14} } + +func (m *SourceFile) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *SourceFile) GetLocation() string { + if m != nil && m.Location != nil { + return *m.Location + } + return "" +} + +func (m *SourceFile) GetDEPRECATEDParseableLocation() *Location { + if m != nil { + return m.DEPRECATEDParseableLocation + } + return nil +} + +func (m *SourceFile) GetSubinclude() []string { + if m != nil { + return m.Subinclude + } + return nil +} + +func (m *SourceFile) GetPackageGroup() []string { + if m != nil { + return m.PackageGroup + } + return nil +} + +func (m *SourceFile) GetVisibilityLabel() []string { + if m != nil { + return m.VisibilityLabel + } + return nil +} + +func (m *SourceFile) GetFeature() []string { + if m != nil { + return m.Feature + } + return nil +} + +func (m *SourceFile) GetLicense() *License { + if m != nil { + return m.License + } + return nil +} + +func (m *SourceFile) GetPackageContainsErrors() bool { + if m != nil && m.PackageContainsErrors != nil { + return *m.PackageContainsErrors + } + return false +} + +// A file that is the output of a build rule. +type GeneratedFile struct { + // The name of the generated file (a label). + Name *string `protobuf:"bytes,1,req,name=name" json:"name,omitempty"` + // The label of the target that generates the file. + GeneratingRule *string `protobuf:"bytes,2,req,name=generating_rule,json=generatingRule" json:"generating_rule,omitempty"` + // The path of the output file (not a label). + Location *string `protobuf:"bytes,3,opt,name=location" json:"location,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GeneratedFile) Reset() { *m = GeneratedFile{} } +func (m *GeneratedFile) String() string { return proto.CompactTextString(m) } +func (*GeneratedFile) ProtoMessage() {} +func (*GeneratedFile) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{15} } + +func (m *GeneratedFile) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *GeneratedFile) GetGeneratingRule() string { + if m != nil && m.GeneratingRule != nil { + return *m.GeneratingRule + } + return "" +} + +func (m *GeneratedFile) GetLocation() string { + if m != nil && m.Location != nil { + return *m.Location + } + return "" +} + +// A target from a blaze query execution. Similar to the Attribute message, +// the Discriminator is used to determine which field contains information. +// For any given type, only one of these can be populated in a single Target. +type Target struct { + // The type of target contained in the message. + Type *Target_Discriminator `protobuf:"varint,1,req,name=type,enum=blaze_query.Target_Discriminator" json:"type,omitempty"` + // If this target represents a rule, the rule is stored here. + Rule *Rule `protobuf:"bytes,2,opt,name=rule" json:"rule,omitempty"` + // A file that is not generated by the build system (version controlled + // or created by the test harness). + SourceFile *SourceFile `protobuf:"bytes,3,opt,name=source_file,json=sourceFile" json:"source_file,omitempty"` + // A generated file that is the output of a rule. + GeneratedFile *GeneratedFile `protobuf:"bytes,4,opt,name=generated_file,json=generatedFile" json:"generated_file,omitempty"` + // A package group. + PackageGroup *PackageGroup `protobuf:"bytes,5,opt,name=package_group,json=packageGroup" json:"package_group,omitempty"` + // An environment group. + EnvironmentGroup *EnvironmentGroup `protobuf:"bytes,6,opt,name=environment_group,json=environmentGroup" json:"environment_group,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Target) Reset() { *m = Target{} } +func (m *Target) String() string { return proto.CompactTextString(m) } +func (*Target) ProtoMessage() {} +func (*Target) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{16} } + +func (m *Target) GetType() Target_Discriminator { + if m != nil && m.Type != nil { + return *m.Type + } + return Target_RULE +} + +func (m *Target) GetRule() *Rule { + if m != nil { + return m.Rule + } + return nil +} + +func (m *Target) GetSourceFile() *SourceFile { + if m != nil { + return m.SourceFile + } + return nil +} + +func (m *Target) GetGeneratedFile() *GeneratedFile { + if m != nil { + return m.GeneratedFile + } + return nil +} + +func (m *Target) GetPackageGroup() *PackageGroup { + if m != nil { + return m.PackageGroup + } + return nil +} + +func (m *Target) GetEnvironmentGroup() *EnvironmentGroup { + if m != nil { + return m.EnvironmentGroup + } + return nil +} + +// Container for all of the blaze query results. +type QueryResult struct { + // All of the targets returned by the blaze query. + Target []*Target `protobuf:"bytes,1,rep,name=target" json:"target,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *QueryResult) Reset() { *m = QueryResult{} } +func (m *QueryResult) String() string { return proto.CompactTextString(m) } +func (*QueryResult) ProtoMessage() {} +func (*QueryResult) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{17} } + +func (m *QueryResult) GetTarget() []*Target { + if m != nil { + return m.Target + } + return nil +} + +// Information about allowed rule classes for a specific attribute of a rule. +type AllowedRuleClassInfo struct { + Policy *AllowedRuleClassInfo_AllowedRuleClasses `protobuf:"varint,1,req,name=policy,enum=blaze_query.AllowedRuleClassInfo_AllowedRuleClasses" json:"policy,omitempty"` + // Rule class names of rules allowed in this attribute, e.g "cc_library", + // "py_binary". Only present if the allowed_rule_classes field is set to + // SPECIFIED. + AllowedRuleClass []string `protobuf:"bytes,2,rep,name=allowed_rule_class,json=allowedRuleClass" json:"allowed_rule_class,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *AllowedRuleClassInfo) Reset() { *m = AllowedRuleClassInfo{} } +func (m *AllowedRuleClassInfo) String() string { return proto.CompactTextString(m) } +func (*AllowedRuleClassInfo) ProtoMessage() {} +func (*AllowedRuleClassInfo) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{18} } + +func (m *AllowedRuleClassInfo) GetPolicy() AllowedRuleClassInfo_AllowedRuleClasses { + if m != nil && m.Policy != nil { + return *m.Policy + } + return AllowedRuleClassInfo_ANY +} + +func (m *AllowedRuleClassInfo) GetAllowedRuleClass() []string { + if m != nil { + return m.AllowedRuleClass + } + return nil +} + +// This message represents a single attribute of a single rule. +type AttributeDefinition struct { + // Attribute name, i.e. "name", "srcs", "deps" + Name *string `protobuf:"bytes,1,req,name=name" json:"name,omitempty"` + Type *Attribute_Discriminator `protobuf:"varint,2,req,name=type,enum=blaze_query.Attribute_Discriminator" json:"type,omitempty"` + Mandatory *bool `protobuf:"varint,3,req,name=mandatory" json:"mandatory,omitempty"` + // Only present for attributes of type LABEL and LABEL_LIST. + AllowedRuleClasses *AllowedRuleClassInfo `protobuf:"bytes,4,opt,name=allowed_rule_classes,json=allowedRuleClasses" json:"allowed_rule_classes,omitempty"` + Documentation *string `protobuf:"bytes,5,opt,name=documentation" json:"documentation,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *AttributeDefinition) Reset() { *m = AttributeDefinition{} } +func (m *AttributeDefinition) String() string { return proto.CompactTextString(m) } +func (*AttributeDefinition) ProtoMessage() {} +func (*AttributeDefinition) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{19} } + +func (m *AttributeDefinition) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *AttributeDefinition) GetType() Attribute_Discriminator { + if m != nil && m.Type != nil { + return *m.Type + } + return Attribute_INTEGER +} + +func (m *AttributeDefinition) GetMandatory() bool { + if m != nil && m.Mandatory != nil { + return *m.Mandatory + } + return false +} + +func (m *AttributeDefinition) GetAllowedRuleClasses() *AllowedRuleClassInfo { + if m != nil { + return m.AllowedRuleClasses + } + return nil +} + +func (m *AttributeDefinition) GetDocumentation() string { + if m != nil && m.Documentation != nil { + return *m.Documentation + } + return "" +} + +type RuleDefinition struct { + Name *string `protobuf:"bytes,1,req,name=name" json:"name,omitempty"` + // Only contains documented attributes + Attribute []*AttributeDefinition `protobuf:"bytes,2,rep,name=attribute" json:"attribute,omitempty"` + Documentation *string `protobuf:"bytes,3,opt,name=documentation" json:"documentation,omitempty"` + // Only for build extensions: label to file that defines the extension + Label *string `protobuf:"bytes,4,opt,name=label" json:"label,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *RuleDefinition) Reset() { *m = RuleDefinition{} } +func (m *RuleDefinition) String() string { return proto.CompactTextString(m) } +func (*RuleDefinition) ProtoMessage() {} +func (*RuleDefinition) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{20} } + +func (m *RuleDefinition) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *RuleDefinition) GetAttribute() []*AttributeDefinition { + if m != nil { + return m.Attribute + } + return nil +} + +func (m *RuleDefinition) GetDocumentation() string { + if m != nil && m.Documentation != nil { + return *m.Documentation + } + return "" +} + +func (m *RuleDefinition) GetLabel() string { + if m != nil && m.Label != nil { + return *m.Label + } + return "" +} + +type BuildLanguage struct { + // Only contains documented rule definitions + Rule []*RuleDefinition `protobuf:"bytes,1,rep,name=rule" json:"rule,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *BuildLanguage) Reset() { *m = BuildLanguage{} } +func (m *BuildLanguage) String() string { return proto.CompactTextString(m) } +func (*BuildLanguage) ProtoMessage() {} +func (*BuildLanguage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{21} } + +func (m *BuildLanguage) GetRule() []*RuleDefinition { + if m != nil { + return m.Rule + } + return nil +} + +type Location struct { + StartOffset *int32 `protobuf:"varint,1,opt,name=start_offset,json=startOffset" json:"start_offset,omitempty"` + StartLine *int32 `protobuf:"varint,2,opt,name=start_line,json=startLine" json:"start_line,omitempty"` + StartColumn *int32 `protobuf:"varint,3,opt,name=start_column,json=startColumn" json:"start_column,omitempty"` + EndOffset *int32 `protobuf:"varint,4,opt,name=end_offset,json=endOffset" json:"end_offset,omitempty"` + EndLine *int32 `protobuf:"varint,5,opt,name=end_line,json=endLine" json:"end_line,omitempty"` + EndColumn *int32 `protobuf:"varint,6,opt,name=end_column,json=endColumn" json:"end_column,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Location) Reset() { *m = Location{} } +func (m *Location) String() string { return proto.CompactTextString(m) } +func (*Location) ProtoMessage() {} +func (*Location) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{22} } + +func (m *Location) GetStartOffset() int32 { + if m != nil && m.StartOffset != nil { + return *m.StartOffset + } + return 0 +} + +func (m *Location) GetStartLine() int32 { + if m != nil && m.StartLine != nil { + return *m.StartLine + } + return 0 +} + +func (m *Location) GetStartColumn() int32 { + if m != nil && m.StartColumn != nil { + return *m.StartColumn + } + return 0 +} + +func (m *Location) GetEndOffset() int32 { + if m != nil && m.EndOffset != nil { + return *m.EndOffset + } + return 0 +} + +func (m *Location) GetEndLine() int32 { + if m != nil && m.EndLine != nil { + return *m.EndLine + } + return 0 +} + +func (m *Location) GetEndColumn() int32 { + if m != nil && m.EndColumn != nil { + return *m.EndColumn + } + return 0 +} + +type MakeVarBinding struct { + Value *string `protobuf:"bytes,1,req,name=value" json:"value,omitempty"` + PlatformSetRegexp *string `protobuf:"bytes,2,req,name=platform_set_regexp,json=platformSetRegexp" json:"platform_set_regexp,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *MakeVarBinding) Reset() { *m = MakeVarBinding{} } +func (m *MakeVarBinding) String() string { return proto.CompactTextString(m) } +func (*MakeVarBinding) ProtoMessage() {} +func (*MakeVarBinding) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{23} } + +func (m *MakeVarBinding) GetValue() string { + if m != nil && m.Value != nil { + return *m.Value + } + return "" +} + +func (m *MakeVarBinding) GetPlatformSetRegexp() string { + if m != nil && m.PlatformSetRegexp != nil { + return *m.PlatformSetRegexp + } + return "" +} + +type MakeVar struct { + Name *string `protobuf:"bytes,1,req,name=name" json:"name,omitempty"` + Binding []*MakeVarBinding `protobuf:"bytes,2,rep,name=binding" json:"binding,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *MakeVar) Reset() { *m = MakeVar{} } +func (m *MakeVar) String() string { return proto.CompactTextString(m) } +func (*MakeVar) ProtoMessage() {} +func (*MakeVar) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{24} } + +func (m *MakeVar) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *MakeVar) GetBinding() []*MakeVarBinding { + if m != nil { + return m.Binding + } + return nil +} + +type GlobCriteria struct { + // List of includes (or items if this criteria did not come from a glob) + Include []string `protobuf:"bytes,1,rep,name=include" json:"include,omitempty"` + // List of exclude expressions + Exclude []string `protobuf:"bytes,2,rep,name=exclude" json:"exclude,omitempty"` + // Whether this message came from a glob + Glob *bool `protobuf:"varint,3,opt,name=glob" json:"glob,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GlobCriteria) Reset() { *m = GlobCriteria{} } +func (m *GlobCriteria) String() string { return proto.CompactTextString(m) } +func (*GlobCriteria) ProtoMessage() {} +func (*GlobCriteria) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{25} } + +func (m *GlobCriteria) GetInclude() []string { + if m != nil { + return m.Include + } + return nil +} + +func (m *GlobCriteria) GetExclude() []string { + if m != nil { + return m.Exclude + } + return nil +} + +func (m *GlobCriteria) GetGlob() bool { + if m != nil && m.Glob != nil { + return *m.Glob + } + return false +} + +type Event struct { + Kind *Event_EventKind `protobuf:"varint,1,req,name=kind,enum=blaze_query.Event_EventKind" json:"kind,omitempty"` + DEPRECATEDLocation *Location `protobuf:"bytes,2,opt,name=DEPRECATED_location,json=DEPRECATEDLocation" json:"DEPRECATED_location,omitempty"` + Message *string `protobuf:"bytes,3,opt,name=message" json:"message,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Event) Reset() { *m = Event{} } +func (m *Event) String() string { return proto.CompactTextString(m) } +func (*Event) ProtoMessage() {} +func (*Event) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{26} } + +func (m *Event) GetKind() Event_EventKind { + if m != nil && m.Kind != nil { + return *m.Kind + } + return Event_ERROR +} + +func (m *Event) GetDEPRECATEDLocation() *Location { + if m != nil { + return m.DEPRECATEDLocation + } + return nil +} + +func (m *Event) GetMessage() string { + if m != nil && m.Message != nil { + return *m.Message + } + return "" +} + +func init() { + proto.RegisterType((*License)(nil), "blaze_query.License") + proto.RegisterType((*StringDictEntry)(nil), "blaze_query.StringDictEntry") + proto.RegisterType((*LabelDictUnaryEntry)(nil), "blaze_query.LabelDictUnaryEntry") + proto.RegisterType((*LabelListDictEntry)(nil), "blaze_query.LabelListDictEntry") + proto.RegisterType((*LabelKeyedStringDictEntry)(nil), "blaze_query.LabelKeyedStringDictEntry") + proto.RegisterType((*StringListDictEntry)(nil), "blaze_query.StringListDictEntry") + proto.RegisterType((*FilesetEntry)(nil), "blaze_query.FilesetEntry") + proto.RegisterType((*Attribute)(nil), "blaze_query.Attribute") + proto.RegisterType((*Attribute_SelectorEntry)(nil), "blaze_query.Attribute.SelectorEntry") + proto.RegisterType((*Attribute_Selector)(nil), "blaze_query.Attribute.Selector") + proto.RegisterType((*Attribute_SelectorList)(nil), "blaze_query.Attribute.SelectorList") + proto.RegisterType((*Rule)(nil), "blaze_query.Rule") + proto.RegisterType((*AttributeAspect)(nil), "blaze_query.AttributeAspect") + proto.RegisterType((*SkylarkAspect)(nil), "blaze_query.SkylarkAspect") + proto.RegisterType((*RuleSummary)(nil), "blaze_query.RuleSummary") + proto.RegisterType((*PackageGroup)(nil), "blaze_query.PackageGroup") + proto.RegisterType((*EnvironmentGroup)(nil), "blaze_query.EnvironmentGroup") + proto.RegisterType((*SourceFile)(nil), "blaze_query.SourceFile") + proto.RegisterType((*GeneratedFile)(nil), "blaze_query.GeneratedFile") + proto.RegisterType((*Target)(nil), "blaze_query.Target") + proto.RegisterType((*QueryResult)(nil), "blaze_query.QueryResult") + proto.RegisterType((*AllowedRuleClassInfo)(nil), "blaze_query.AllowedRuleClassInfo") + proto.RegisterType((*AttributeDefinition)(nil), "blaze_query.AttributeDefinition") + proto.RegisterType((*RuleDefinition)(nil), "blaze_query.RuleDefinition") + proto.RegisterType((*BuildLanguage)(nil), "blaze_query.BuildLanguage") + proto.RegisterType((*Location)(nil), "blaze_query.Location") + proto.RegisterType((*MakeVarBinding)(nil), "blaze_query.MakeVarBinding") + proto.RegisterType((*MakeVar)(nil), "blaze_query.MakeVar") + proto.RegisterType((*GlobCriteria)(nil), "blaze_query.GlobCriteria") + proto.RegisterType((*Event)(nil), "blaze_query.Event") + proto.RegisterEnum("blaze_query.FilesetEntry_SymlinkBehavior", FilesetEntry_SymlinkBehavior_name, FilesetEntry_SymlinkBehavior_value) + proto.RegisterEnum("blaze_query.Attribute_Discriminator", Attribute_Discriminator_name, Attribute_Discriminator_value) + proto.RegisterEnum("blaze_query.Attribute_Tristate", Attribute_Tristate_name, Attribute_Tristate_value) + proto.RegisterEnum("blaze_query.Target_Discriminator", Target_Discriminator_name, Target_Discriminator_value) + proto.RegisterEnum("blaze_query.AllowedRuleClassInfo_AllowedRuleClasses", AllowedRuleClassInfo_AllowedRuleClasses_name, AllowedRuleClassInfo_AllowedRuleClasses_value) + proto.RegisterEnum("blaze_query.Event_EventKind", Event_EventKind_name, Event_EventKind_value) +} + +func init() { proto.RegisterFile("build_proto/build.proto", fileDescriptor0) } + +var fileDescriptor0 = []byte{ + // 2621 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x59, 0x49, 0x73, 0xeb, 0xc6, + 0xf1, 0xff, 0x83, 0x3b, 0x9b, 0x1b, 0x34, 0xda, 0xf8, 0x36, 0x9b, 0x86, 0x9f, 0xff, 0xa6, 0x97, + 0x92, 0x6d, 0xe6, 0xd9, 0xe5, 0xd8, 0xc9, 0xab, 0x50, 0x24, 0x24, 0xd3, 0x8f, 0x26, 0x95, 0x21, + 0xf9, 0x1c, 0xe5, 0x82, 0x02, 0x89, 0x11, 0x35, 0x25, 0x10, 0x60, 0x00, 0x50, 0x11, 0x73, 0x4d, + 0xe5, 0xe0, 0x7c, 0x06, 0x1f, 0xf2, 0x2d, 0x72, 0xcd, 0x31, 0x1f, 0x21, 0xa9, 0x5c, 0x72, 0xcc, + 0x87, 0xc8, 0x21, 0x35, 0x0b, 0x48, 0x40, 0xa2, 0x2c, 0xf9, 0x39, 0xb9, 0xa4, 0x72, 0x61, 0x71, + 0x7a, 0xf9, 0x4d, 0xf7, 0x4c, 0x77, 0x4f, 0xcf, 0x00, 0xf6, 0xc7, 0x0b, 0x6a, 0x5b, 0xc6, 0xdc, + 0x73, 0x03, 0xf7, 0x03, 0xfe, 0xff, 0x80, 0xff, 0x47, 0x85, 0xb1, 0x6d, 0xfe, 0x86, 0x18, 0xbf, + 0x5a, 0x10, 0x6f, 0xa9, 0x7d, 0x09, 0xd9, 0x2e, 0x9d, 0x10, 0xc7, 0x27, 0xe8, 0x0d, 0x28, 0xda, + 0xe2, 0xaf, 0x11, 0x2c,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x39, 0xe4, 0x88, 0x4d, 0x66, 0xc4, 0x09, 0x7c, 0xde, 0x70, 0x17, 0x6e, + 0x2d, 0x1c, 0xe1, 0x84, 0x78, 0xa5, 0xa0, 0xfd, 0x3e, 0x09, 0xa5, 0x18, 0x28, 0x2a, 0x40, 0xb6, + 0xd3, 0x1b, 0xea, 0xc7, 0x3a, 0x56, 0x15, 0x04, 0x90, 0x19, 0x0c, 0x71, 0xa7, 0x77, 0xac, 0x26, + 0x50, 0x1e, 0xd2, 0xdd, 0xe6, 0xa1, 0xde, 0x55, 0x93, 0x8c, 0xdc, 0x1f, 0x0d, 0x4f, 0x46, 0x43, + 0x35, 0xc5, 0x3a, 0x51, 0x21, 0x62, 0x74, 0x3b, 0x83, 0xa1, 0x9a, 0x46, 0x65, 0x00, 0x2e, 0x27, + 0xc6, 0x19, 0x26, 0x20, 0x84, 0x05, 0x21, 0x8b, 0x76, 0x40, 0x6d, 0x77, 0x98, 0xce, 0xe1, 0x68, + 0xd8, 0xe9, 0xf7, 0x8c, 0x81, 0x3e, 0x54, 0x73, 0x6c, 0xde, 0x6e, 0xa7, 0xa5, 0xf7, 0x06, 0xba, + 0x9a, 0x8f, 0x80, 0xb6, 0x3b, 0xad, 0xa1, 0x0a, 0x68, 0x0f, 0xd0, 0x51, 0xa7, 0xab, 0x0f, 0xf4, + 0xa1, 0xa1, 0xf7, 0x86, 0xf8, 0x54, 0x60, 0x15, 0xd0, 0x36, 0x54, 0xd6, 0x93, 0x09, 0xe1, 0x22, + 0x9b, 0x20, 0x62, 0x92, 0xa0, 0x96, 0xd8, 0x04, 0x87, 0xfd, 0x7e, 0x57, 0x6f, 0xf6, 0xd4, 0x32, + 0x2a, 0x42, 0x6e, 0x88, 0x3b, 0x83, 0x61, 0x73, 0xa8, 0xab, 0x15, 0xa4, 0x42, 0x51, 0xfa, 0x2c, + 0x70, 0x55, 0x26, 0x3c, 0xea, 0xbd, 0xe8, 0xf5, 0xbf, 0xee, 0xa9, 0x88, 0xe1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xe2, 0xfb, 0xac, 0x43, 0x14, 0xc1, + 0x1c, 0x0e, 0xb5, 0xcf, 0x21, 0xbf, 0x9a, 0x94, 0xdd, 0xe6, 0x75, 0x8c, 0xfb, 0xec, 0x92, 0x5f, + 0x80, 0xec, 0xd7, 0x4d, 0xdc, 0x13, 0xb7, 0xfc, 0x1c, 0xa4, 0x3a, 0xbd, 0xa3, 0xbe, 0x9a, 0x64, + 0x57, 0xe4, 0x13, 0xdc, 0x3f, 0xc6, 0xfa, 0x60, 0xa0, 0xa6, 0x0e, 0x3f, 0x81, 0x67, 0x13, 0x77, + 0x76, 0x30, 0x75, 0xdd, 0xa9, 0x4d, 0x0e, 0x2c, 0x72, 0x19, 0xb8, 0xae, 0xed, 0x1f, 0x88, 0xaf, + 0xae, 0x36, 0x1d, 0x1f, 0x70, 0xd3, 0x1a, 0xe2, 0x03, 0xac, 0xf8, 0x6d, 0x98, 0x73, 0xfa, 0xaf, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x1e, 0xc0, 0x9c, 0xa4, 0xa4, 0x1d, 0x00, 0x00, +} diff --git a/vendor/github.com/bazelbuild/buildtools/buildozer/BUILD b/vendor/github.com/bazelbuild/buildtools/buildozer/BUILD new file mode 100644 index 00000000000..ad212a63ae7 --- /dev/null +++ b/vendor/github.com/bazelbuild/buildtools/buildozer/BUILD @@ -0,0 +1,33 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") + +go_library( + name = "go_default_library", + srcs = ["main.go"], + importmap = "k8s.io/kubernetes/vendor/github.com/bazelbuild/buildtools/buildozer", + importpath = "github.com/bazelbuild/buildtools/buildozer", + visibility = ["//visibility:private"], + deps = [ + "//vendor/github.com/bazelbuild/buildtools/edit:go_default_library", + "//vendor/github.com/bazelbuild/buildtools/tables:go_default_library", + ], +) + +go_binary( + name = "buildozer", + embed = [":go_default_library"], + visibility = ["//visibility:public"], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/vendor/github.com/bazelbuild/buildtools/buildozer/README.md b/vendor/github.com/bazelbuild/buildtools/buildozer/README.md new file mode 100644 index 00000000000..f83eb9c829d --- /dev/null +++ b/vendor/github.com/bazelbuild/buildtools/buildozer/README.md @@ -0,0 +1,266 @@ +# Buildozer + +Buildozer is a command line tool to rewrite multiple +[Bazel](https://github.com/bazelbuild/bazel) BUILD files using +standard commands. + +## Dependencies + +1. Protobuf go runtime: to download +`go get -u github.com/golang/protobuf/{proto,protoc-gen-go}` + + +## Installation + +1. Change directory to the buildifier/buildozer + +```bash +gopath=$(go env GOPATH) +cd $gopath/src/github.com/bazelbuild/buildtools/buildozer +``` + +2. Install + +```bash +go install +``` + +## Usage + +```shell +buildozer [OPTIONS] ['command args' | -f FILE ] label-list +``` + +Here, `label-list` is a comma-separated list of Bazel labels, for example +`//path/to/pkg1:rule1, //path/to/pkg2:rule2`. Buildozer reads commands from +`FILE` (`-` for stdin (format: `|`-separated command line arguments to buildozer, +excluding flags)) + +You should specify at least one command and one target. Buildozer will execute +all commands on all targets. Commands are executed in order, files are processed +in parallel. + +### Targets + +Targets look like Bazel labels, but there can be some differences in presence of +macros. + + * Use the label notation to refer to a rule: `//buildtools/buildozer:edit` + * Use the `__pkg__` suffix to refer to the package declaration: + `//buildtools/buildozer:__pkg__` + * Use an asterisk to refer to all rules in a file: `//pkg:*` + * Use `...` to refer to all descendant BUILD files in a directory: `//pkg/...:*` + * Use percent to refer to all rules of a certain kind: `//pkg:%java_library` + * Use percent-and-number to refer to a rule that begins at a certain line: + `//pkg:%123`. + * Use `-` for the package name if you want to process standard input stream + instead of a file: `-:all_tests`. + +### Options + +OPTIONS include the following options: + + * `-stdout` : write changed BUILD file to stdout + * `-buildifier` : format output using a specific buildifier binary. If empty, use built-in formatter. + * `-k` : apply all commands, even if there are failures + * `-quiet` : suppress informational messages + * `-shorten_labels` : convert added labels to short form, e.g. //foo:bar => :bar + * `-types`: Filter the targets, keeping only those of the given types, e.g. + `buildozer -types go_library,go_binary 'print rule' '//buildtools/buildozer:*'` + * `-eol-comments=false`: When adding new comments, put them on a separate line. + +See `buildozer -help` for the full list. + +### Edit commands + +Buildozer supports the following commands(`'command args'`): + + * `add `: Adds value(s) to a list attribute of a rule. If a + value is already present in the list, it is not added. + * `new_load `: Add a load statement for the given path, + importing the symbols. Before using this, make sure to run + `buildozer 'fix movePackageToTop'`. Afterwards, consider running + `buildozer 'fix unusedLoads'`. + * `comment ? ? `: Add a comment to a rule, an attribute, + or a specific value in a list. Spaces in the comment should be escaped with + backslashes. + * `print_comment ? ?` + * `delete`: Delete a rule. + * `fix ?`: Apply a fix. + * `move `: Moves `value(s)` from the list `old_attr` + to the list `new_attr`. The wildcard `*` matches all values. + * `new [(before|after) ]`: Add a + new rule at the end of the BUILD file (before/after ``). + * `print ` + * `remove `: Removes `value(s)` from the list `attr`. The + wildcard `*` matches all attributes. Lists containing none of the `value(s)` are + not modified. + * `rename `: Rename the `old_attr` to `new_attr` which must + not yet exist. + * `replace `: Replaces `old_value` with `new_value` + in the list `attr`. Wildcard `*` matches all attributes. Lists not containing + `old_value` are not modified. + * `set `: Sets the value of an attribute. If the attribute + was already present, its old value is replaced. + * `set_if_absent `: Sets the value of an attribute. If the + attribute was already present, no action is taken. + * `set kind `: Set the target type to value. + * `copy `: Copies the value of `attr` between rules. If it + exists in the `to_rule`, it will be overwritten. + * `copy_no_overwrite `: Copies the value of `attr` between + rules. If it exists in the `to_rule`, no action is taken. + +Here, `` represents an attribute (being `add`ed/`rename`d/`delete`d etc.), +e.g.: `srcs`, `` represents values of the attribute and so on. +A '?' indicates that the preceding argument is optional. + +The fix command without a fix specified applied to all eligible fixes. +Use `//path/to/pkg:__pkg__` as label for file level changes like `new_load` and +`new_rule`. +A transformation can be applied to all rules of a particular kind by using +`%rule_kind` at the end of the label(see examples below). + +#### Examples + +```bash +# Edit //pkg:rule and //pkg:rule2, and add a dependency on //base +buildozer 'add deps //base' //pkg:rule //pkg:rule2 + +# A load for a skylark file in //pkg +buildozer 'new_load /tools/build_rules/build_test build_test' //pkg:__pkg__ + +# Change the default_visibility to public for the package //pkg +buildozer 'set default_visibility //visibility:public' //pkg:__pkg__ + +# Change all gwt_module targets to java_library in the package //pkg +buildozer 'set kind java_library' //pkg:%gwt_module + +# Replace the dependency on pkg_v1 with a dependency on pkg_v2 +buildozer 'replace deps //pkg_v1 //pkg_v2' //pkg:rule + +# Delete the dependency on foo in every cc_library in the package +buildozer 'remove deps foo' //pkg:%cc_library + +# Delete the testonly attribute in every rule in the package +buildozer 'remove testonly' '//pkg:*' + +# Add a comment to the timeout attribute of //pkg:rule_test +buildozer 'comment timeout Delete\ this\ after\ 2015-12-31.' //pkg:rule_test + +# Add a new rule at the end of the file +buildozer 'new java_library foo' //pkg:__pkg__ + +# Add a cc_binary rule named new_bin before the rule named tests +buildozer 'new cc_binary new_bin before tests' //:__pkg__ + +# Copy an attribute from `protolib` to `py_protolib`. +buildozer 'copy testonly protolib' //pkg:py_protolib + +# Set two attributes in the same rule +buildozer 'set compile 1' 'set srcmap 1' //pkg:rule + +# Make a default explicit in all soy_js rules in a package +buildozer 'set_if_absent allowv1syntax 1' //pkg:%soy_js + +# Add an attribute new_attr with value "def_val" to all cc_binary rules +# Note that special characters will automatically be escaped in the string +buildozer 'add new_attr def_val' //:%cc_binary +``` + +### Print commands + +They work just like the edit commands. Expect a return code of 3 as they are not +modifying any file. + + * `print `: For each target, prints the value of the attributes + (see below). + * `print_comment ? ?`: Prints a comment associated with a rule, + an attribute or a specific value in a list. + +The print command prints the value of the attributes. If a target doesn't have +the attribute, a warning is printed on stderr. + +There are some special attributes in the `print` command: + + * `kind`: displays the name of the function + * `label`: the fully qualified label + * `rule`: the entire rule definition + * `startline`: the line number on which the rule begins in the BUILD file + * `endline`: the line number on which the rule ends in the BUILD file + +#### Examples + +```shell +# Print the kind of a target +buildozer 'print kind' base # output: cc_library + +# Print the name of all cc_library in //base +buildozer 'print name' base:%cc_library + +# Get the default visibility of the //base package +buildozer 'print default_visibility' base:%package + +# Print labels of cc_library targets in //base that have a deps attribute +buildozer 'print label deps' base:%cc_library 2>/dev/null | cut -d' ' -f1 + +# Print the list of labels in //base that explicitly set the testonly attribute: +buildozer 'print label testonly' 'base:*' 2>/dev/null + +# Print the entire definition (including comments) of the //base:heapcheck rule: +buildozer 'print rule' //base:heapcheck +``` + +## Converting labels + +Buildozer works at the syntax-level. It doesn't evaluate the BUILD files. If you +need to query the information Bazel has, please use `bazel query`. If you have a +list of Bazel labels, chances are that some of them are generated by BUILD +extensions. Labels in Buildozer are slightly different from labels in Bazel. +Bazel cares about the generated code, while Buildozer looks at the BUILD file +before macro expansion. + +To see the expanded BUILD files, try: + +```shell +bazel query --output=build //path/to/BUILD +``` + +## Do multiple changes at once + +Use `buildozer -f ` to load a list of commands from a file. The usage is +just like arguments on the command-line, except that arguments are separated by +`|`. + +```shell +$ cat /tmp/cmds +new cc_library foo|//buildtools/buildozer/BUILD +add deps //base //strings|add srcs foo.cc|//buildtools/buildozer:foo +add deps :foo|//buildtools/buildozer + +$ buildozer -f /tmp/cmds +fixed //buildtools/buildozer/BUILD +``` + +The list of commands will typically be generated and can be large. This is +efficient: Commands are grouped so that each file is modified once. Files are +processed in parallel. + +## Error code + +The return code is: + + * `0` on success, if changes were made + * `1` when there is a usage error + * `2` when at least one command has failed + * `3` on success, when no changes were made + +## Source Structure + + * `buildozer/main.go` : Entry point for the buildozer binary + * `edit/buildozer.go` : Implementation of functions for the buildozer commands + * `edit/edit.go`: Library functions to perform various operations on ASTs. These + * functions are called by the impl functions in buildozer.go + * `edit/fix.go`: Functions for various fixes for the `buildozer 'fix '` + command, like cleaning unused loads, changing labels to canonical notation, etc. + * `edit/types.go`: Type information for attributes + diff --git a/vendor/github.com/bazelbuild/buildtools/buildozer/main.go b/vendor/github.com/bazelbuild/buildtools/buildozer/main.go new file mode 100644 index 00000000000..e3baf2e36bf --- /dev/null +++ b/vendor/github.com/bazelbuild/buildtools/buildozer/main.go @@ -0,0 +1,87 @@ +/* +Copyright 2016 Google Inc. All Rights Reserved. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +// Entry-point for Buildozer binary. + +package main + +import ( + "flag" + "fmt" + "os" + "strings" + + "github.com/bazelbuild/buildtools/edit" + "github.com/bazelbuild/buildtools/tables" +) + +var ( + stdout = flag.Bool("stdout", false, "write changed BUILD file to stdout") + buildifier = flag.String("buildifier", "", "format output using a specific buildifier binary. If empty, use built-in formatter") + parallelism = flag.Int("P", 0, "number of cores to use for concurrent actions") + numio = flag.Int("numio", 200, "number of concurrent actions") + commandsFile = flag.String("f", "", "file name to read commands from, use '-' for stdin (format:|-separated command line arguments to buildozer, excluding flags)") + keepGoing = flag.Bool("k", false, "apply all commands, even if there are failures") + filterRuleTypes = stringList("types", "comma-separated list of rule types to change, the default empty list means all rules") + preferEOLComments = flag.Bool("eol-comments", true, "when adding a new comment, put it on the same line if possible") + rootDir = flag.String("root_dir", "", "If present, use this folder rather than $PWD to find the root directory.") + quiet = flag.Bool("quiet", false, "suppress informational messages") + editVariables = flag.Bool("edit-variables", false, "For attributes that simply assign a variable (e.g. hdrs = LIB_HDRS), edit the build variable instead of appending to the attribute.") + isPrintingProto = flag.Bool("output_proto", false, "output serialized devtools.buildozer.Output protos instead of human-readable strings.") + tablesPath = flag.String("tables", "", "path to JSON file with custom table definitions which will replace the built-in tables") + + shortenLabelsFlag = flag.Bool("shorten_labels", true, "convert added labels to short form, e.g. //foo:bar => :bar") + deleteWithComments = flag.Bool("delete_with_comments", true, "If a list attribute should be deleted even if there is a comment attached to it") +) + +func stringList(name, help string) func() []string { + f := flag.String(name, "", help) + return func() []string { + if *f == "" { + return nil + } + res := strings.Split(*f, ",") + for i := range res { + res[i] = strings.TrimSpace(res[i]) + } + return res + } +} + +func main() { + flag.Parse() + + if *tablesPath != "" { + if err := tables.ParseAndUpdateJSONDefinitions(*tablesPath, false); err != nil { + fmt.Fprintf(os.Stderr, "buildifier: failed to parse %s for -tables: %s\n", *tablesPath, err) + os.Exit(2) + } + } + + edit.ShortenLabelsFlag = *shortenLabelsFlag + edit.DeleteWithComments = *deleteWithComments + edit.Opts = edit.Options{ + Stdout: *stdout, + Buildifier: *buildifier, + Parallelism: *parallelism, + NumIO: *numio, + CommandsFile: *commandsFile, + KeepGoing: *keepGoing, + FilterRuleTypes: filterRuleTypes(), + PreferEOLComments: *preferEOLComments, + RootDir: *rootDir, + Quiet: *quiet, + EditVariables: *editVariables, + IsPrintingProto: *isPrintingProto, + } + os.Exit(edit.Buildozer(flag.Args())) +} diff --git a/vendor/github.com/bazelbuild/buildtools/edit/BUILD b/vendor/github.com/bazelbuild/buildtools/edit/BUILD new file mode 100644 index 00000000000..045a980651d --- /dev/null +++ b/vendor/github.com/bazelbuild/buildtools/edit/BUILD @@ -0,0 +1,37 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "buildozer.go", + "edit.go", + "fix.go", + "types.go", + ], + importmap = "k8s.io/kubernetes/vendor/github.com/bazelbuild/buildtools/edit", + importpath = "github.com/bazelbuild/buildtools/edit", + visibility = ["//visibility:public"], + deps = [ + "//vendor/github.com/bazelbuild/buildtools/api_proto:go_default_library", + "//vendor/github.com/bazelbuild/buildtools/build:go_default_library", + "//vendor/github.com/bazelbuild/buildtools/build_proto:go_default_library", + "//vendor/github.com/bazelbuild/buildtools/file:go_default_library", + "//vendor/github.com/bazelbuild/buildtools/lang:go_default_library", + "//vendor/github.com/bazelbuild/buildtools/wspace:go_default_library", + "//vendor/github.com/golang/protobuf/proto:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/vendor/github.com/bazelbuild/buildtools/edit/buildozer.go b/vendor/github.com/bazelbuild/buildtools/edit/buildozer.go new file mode 100644 index 00000000000..5bd618ebbbc --- /dev/null +++ b/vendor/github.com/bazelbuild/buildtools/edit/buildozer.go @@ -0,0 +1,976 @@ +/* +Copyright 2016 Google Inc. All Rights Reserved. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +// Buildozer is a tool for programatically editing BUILD files. + +package edit + +import ( + "bufio" + "bytes" + "errors" + "fmt" + "io" + "io/ioutil" + "log" + "os" + "os/exec" + "path" + "path/filepath" + "regexp" + "runtime" + "strconv" + "strings" + + apipb "github.com/bazelbuild/buildtools/api_proto" + "github.com/bazelbuild/buildtools/build" + "github.com/bazelbuild/buildtools/file" + "github.com/golang/protobuf/proto" +) + +// Options represents choices about how buildozer should behave. +type Options struct { + Stdout bool // write changed BUILD file to stdout + Buildifier string // path to buildifier binary + Parallelism int // number of cores to use for concurrent actions + NumIO int // number of concurrent actions + CommandsFile string // file name to read commands from, use '-' for stdin (format:|-separated command line arguments to buildozer, excluding flags + KeepGoing bool // apply all commands, even if there are failures + FilterRuleTypes []string // list of rule types to change, empty means all + PreferEOLComments bool // when adding a new comment, put it on the same line if possible + RootDir string // If present, use this folder rather than $PWD to find the root dir + Quiet bool // suppress informational messages. + EditVariables bool // for attributes that simply assign a variable (e.g. hdrs = LIB_HDRS), edit the build variable instead of appending to the attribute. + IsPrintingProto bool // output serialized devtools.buildozer.Output protos instead of human-readable strings +} + +// Opts represents the options to be used by buildozer, and can be overriden before calling Buildozer. +var Opts = Options{NumIO: 200, PreferEOLComments: true} + +// Usage is a user-overriden func to print the program usage. +var Usage = func() {} + +var fileModified = false // set to true when a file has been fixed + +const stdinPackageName = "-" // the special package name to represent stdin + +// CmdEnvironment stores the information the commands below have access to. +type CmdEnvironment struct { + File *build.File // the AST + Rule *build.Rule // the rule to modify + Vars map[string]*build.BinaryExpr // global variables set in the build file + Pkg string // the full package name + Args []string // the command-line arguments + output *apipb.Output_Record // output proto, stores whatever a command wants to print +} + +// The cmdXXX functions implement the various commands. + +func cmdAdd(env CmdEnvironment) (*build.File, error) { + attr := env.Args[0] + for _, val := range env.Args[1:] { + if IsIntList(attr) { + AddValueToListAttribute(env.Rule, attr, env.Pkg, &build.LiteralExpr{Token: val}, &env.Vars) + continue + } + strVal := &build.StringExpr{Value: ShortenLabel(val, env.Pkg)} + AddValueToListAttribute(env.Rule, attr, env.Pkg, strVal, &env.Vars) + } + return env.File, nil +} + +func cmdComment(env CmdEnvironment) (*build.File, error) { + // The comment string is always the last argument in the list. + str := env.Args[len(env.Args)-1] + str = strings.Replace(str, "\\n", "\n", -1) + // Multiline comments should go on a separate line. + fullLine := !Opts.PreferEOLComments || strings.Contains(str, "\n") + str = strings.Replace("# "+str, "\n", "\n# ", -1) + comment := []build.Comment{build.Comment{Token: str}} + + // The comment might be attached to a rule, an attribute, or a value in a list, + // depending on how many arguments are passed. + switch len(env.Args) { + case 1: // Attach to a rule + env.Rule.Call.Comments.Before = comment + case 2: // Attach to an attribute + if attr := env.Rule.AttrDefn(env.Args[0]); attr != nil { + if fullLine { + attr.X.Comment().Before = comment + } else { + attr.Y.Comment().Suffix = comment + } + } + case 3: // Attach to a specific value in a list + if attr := env.Rule.Attr(env.Args[0]); attr != nil { + if expr := ListFind(attr, env.Args[1], env.Pkg); expr != nil { + if fullLine { + expr.Comments.Before = comment + } else { + expr.Comments.Suffix = comment + } + } + } + default: + panic("cmdComment") + } + return env.File, nil +} + +// commentsText concatenates comments into a single line. +func commentsText(comments []build.Comment) string { + var segments []string + for _, comment := range comments { + token := comment.Token + if strings.HasPrefix(token, "#") { + token = token[1:] + } + segments = append(segments, strings.TrimSpace(token)) + } + return strings.Replace(strings.Join(segments, " "), "\n", " ", -1) +} + +func cmdPrintComment(env CmdEnvironment) (*build.File, error) { + attrError := func() error { + return fmt.Errorf("rule \"//%s:%s\" has no attribute \"%s\"", env.Pkg, env.Rule.Name(), env.Args[0]) + } + + switch len(env.Args) { + case 0: // Print rule comment. + env.output.Fields = []*apipb.Output_Record_Field{ + &apipb.Output_Record_Field{Value: &apipb.Output_Record_Field_Text{commentsText(env.Rule.Call.Comments.Before)}}, + } + case 1: // Print attribute comment. + attr := env.Rule.AttrDefn(env.Args[0]) + if attr == nil { + return nil, attrError() + } + comments := append(attr.Before, attr.Suffix...) + env.output.Fields = []*apipb.Output_Record_Field{ + &apipb.Output_Record_Field{Value: &apipb.Output_Record_Field_Text{commentsText(comments)}}, + } + case 2: // Print comment of a specific value in a list. + attr := env.Rule.Attr(env.Args[0]) + if attr == nil { + return nil, attrError() + } + value := env.Args[1] + expr := ListFind(attr, value, env.Pkg) + if expr == nil { + return nil, fmt.Errorf("attribute \"%s\" has no value \"%s\"", env.Args[0], value) + } + comments := append(expr.Comments.Before, expr.Comments.Suffix...) + env.output.Fields = []*apipb.Output_Record_Field{ + &apipb.Output_Record_Field{Value: &apipb.Output_Record_Field_Text{commentsText(comments)}}, + } + default: + panic("cmdPrintComment") + } + return nil, nil +} + +func cmdDelete(env CmdEnvironment) (*build.File, error) { + return DeleteRule(env.File, env.Rule), nil +} + +func cmdMove(env CmdEnvironment) (*build.File, error) { + oldAttr := env.Args[0] + newAttr := env.Args[1] + if len(env.Args) == 3 && env.Args[2] == "*" { + if err := MoveAllListAttributeValues(env.Rule, oldAttr, newAttr, env.Pkg, &env.Vars); err != nil { + return nil, err + } + return env.File, nil + } + fixed := false + for _, val := range env.Args[2:] { + if deleted := ListAttributeDelete(env.Rule, oldAttr, val, env.Pkg); deleted != nil { + AddValueToListAttribute(env.Rule, newAttr, env.Pkg, deleted, &env.Vars) + fixed = true + } + } + if fixed { + return env.File, nil + } + return nil, nil +} + +func cmdNew(env CmdEnvironment) (*build.File, error) { + kind := env.Args[0] + name := env.Args[1] + addAtEOF, insertionIndex, err := findInsertionIndex(env) + if err != nil { + return nil, err + } + + if FindRuleByName(env.File, name) != nil { + return nil, fmt.Errorf("rule '%s' already exists", name) + } + + call := &build.CallExpr{X: &build.LiteralExpr{Token: kind}} + rule := &build.Rule{Call: call} + rule.SetAttr("name", &build.StringExpr{Value: name}) + + if addAtEOF { + env.File.Stmt = InsertAfterLastOfSameKind(env.File.Stmt, rule.Call) + } else { + env.File.Stmt = InsertAfter(insertionIndex, env.File.Stmt, call) + } + return env.File, nil +} + +// findInsertionIndex is used by cmdNew to find the place at which to insert the new rule. +func findInsertionIndex(env CmdEnvironment) (bool, int, error) { + if len(env.Args) < 4 { + return true, 0, nil + } + + relativeToRuleName := env.Args[3] + ruleIdx := IndexOfRuleByName(env.File, relativeToRuleName) + if ruleIdx == -1 { + return true, 0, nil + } + + switch env.Args[2] { + case "before": + return false, ruleIdx - 1, nil + case "after": + return false, ruleIdx, nil + default: + return true, 0, fmt.Errorf("Unknown relative operator '%s'; allowed: 'before', 'after'", env.Args[1]) + } +} + +func cmdNewLoad(env CmdEnvironment) (*build.File, error) { + env.File.Stmt = InsertLoad(env.File.Stmt, env.Args) + return env.File, nil +} + +func cmdPrint(env CmdEnvironment) (*build.File, error) { + format := env.Args + if len(format) == 0 { + format = []string{"name", "kind"} + } + fields := make([]*apipb.Output_Record_Field, len(format)) + + for i, str := range format { + value := env.Rule.Attr(str) + if str == "kind" { + fields[i] = &apipb.Output_Record_Field{Value: &apipb.Output_Record_Field_Text{env.Rule.Kind()}} + } else if str == "label" { + if env.Rule.Attr("name") != nil { + fields[i] = &apipb.Output_Record_Field{Value: &apipb.Output_Record_Field_Text{fmt.Sprintf("//%s:%s", env.Pkg, env.Rule.Name())}} + } else { + return nil, nil + } + } else if str == "rule" { + fields[i] = &apipb.Output_Record_Field{ + Value: &apipb.Output_Record_Field_Text{build.FormatString(env.Rule.Call)}, + } + } else if str == "startline" { + fields[i] = &apipb.Output_Record_Field{Value: &apipb.Output_Record_Field_Number{int32(env.Rule.Call.ListStart.Line)}} + } else if str == "endline" { + fields[i] = &apipb.Output_Record_Field{Value: &apipb.Output_Record_Field_Number{int32(env.Rule.Call.End.Pos.Line)}} + } else if value == nil { + fmt.Fprintf(os.Stderr, "rule \"//%s:%s\" has no attribute \"%s\"\n", + env.Pkg, env.Rule.Name(), str) + fields[i] = &apipb.Output_Record_Field{Value: &apipb.Output_Record_Field_Error{Error: apipb.Output_Record_Field_MISSING}} + } else if lit, ok := value.(*build.LiteralExpr); ok { + fields[i] = &apipb.Output_Record_Field{Value: &apipb.Output_Record_Field_Text{lit.Token}} + } else if string, ok := value.(*build.StringExpr); ok { + fields[i] = &apipb.Output_Record_Field{ + Value: &apipb.Output_Record_Field_Text{string.Value}, + QuoteWhenPrinting: true, + } + } else if strList := env.Rule.AttrStrings(str); strList != nil { + fields[i] = &apipb.Output_Record_Field{Value: &apipb.Output_Record_Field_List{List: &apipb.RepeatedString{Strings: strList}}} + } else { + // Some other Expr we haven't listed above. Just print it. + fields[i] = &apipb.Output_Record_Field{Value: &apipb.Output_Record_Field_Text{build.FormatString(value)}} + } + } + + env.output.Fields = fields + return nil, nil +} + +func attrKeysForPattern(rule *build.Rule, pattern string) []string { + if pattern == "*" { + return rule.AttrKeys() + } + return []string{pattern} +} + +func cmdRemove(env CmdEnvironment) (*build.File, error) { + if len(env.Args) == 1 { // Remove the attribute + if env.Rule.DelAttr(env.Args[0]) != nil { + return env.File, nil + } + } else { // Remove values in the attribute. + fixed := false + for _, key := range attrKeysForPattern(env.Rule, env.Args[0]) { + for _, val := range env.Args[1:] { + ListAttributeDelete(env.Rule, key, val, env.Pkg) + fixed = true + } + } + if fixed { + return env.File, nil + } + } + return nil, nil +} + +func cmdRename(env CmdEnvironment) (*build.File, error) { + oldAttr := env.Args[0] + newAttr := env.Args[1] + if err := RenameAttribute(env.Rule, oldAttr, newAttr); err != nil { + return nil, err + } + return env.File, nil +} + +func cmdReplace(env CmdEnvironment) (*build.File, error) { + oldV := env.Args[1] + newV := env.Args[2] + for _, key := range attrKeysForPattern(env.Rule, env.Args[0]) { + attr := env.Rule.Attr(key) + if e, ok := attr.(*build.StringExpr); ok { + if LabelsEqual(e.Value, oldV, env.Pkg) { + env.Rule.SetAttr(key, getAttrValueExpr(key, []string{newV})) + } + } else { + ListReplace(attr, oldV, newV, env.Pkg) + } + } + return env.File, nil +} + +func cmdSet(env CmdEnvironment) (*build.File, error) { + attr := env.Args[0] + args := env.Args[1:] + if attr == "kind" { + env.Rule.SetKind(args[0]) + } else { + env.Rule.SetAttr(attr, getAttrValueExpr(attr, args)) + } + return env.File, nil +} + +func cmdSetIfAbsent(env CmdEnvironment) (*build.File, error) { + attr := env.Args[0] + args := env.Args[1:] + if attr == "kind" { + return nil, fmt.Errorf("setting 'kind' is not allowed for set_if_absent. Got %s", env.Args) + } + if env.Rule.Attr(attr) == nil { + env.Rule.SetAttr(attr, getAttrValueExpr(attr, args)) + } + return env.File, nil +} + +func getAttrValueExpr(attr string, args []string) build.Expr { + switch { + case attr == "kind": + return nil + case IsIntList(attr): + var list []build.Expr + for _, i := range args { + list = append(list, &build.LiteralExpr{Token: i}) + } + return &build.ListExpr{List: list} + case IsList(attr) && !(len(args) == 1 && strings.HasPrefix(args[0], "glob(")): + var list []build.Expr + for _, i := range args { + list = append(list, &build.StringExpr{Value: i}) + } + return &build.ListExpr{List: list} + case IsString(attr): + return &build.StringExpr{Value: args[0]} + default: + return &build.LiteralExpr{Token: args[0]} + } +} + +func cmdCopy(env CmdEnvironment) (*build.File, error) { + attrName := env.Args[0] + from := env.Args[1] + + return copyAttributeBetweenRules(env, attrName, from) +} + +func cmdCopyNoOverwrite(env CmdEnvironment) (*build.File, error) { + attrName := env.Args[0] + from := env.Args[1] + + if env.Rule.Attr(attrName) != nil { + return env.File, nil + } + + return copyAttributeBetweenRules(env, attrName, from) +} + +func copyAttributeBetweenRules(env CmdEnvironment, attrName string, from string) (*build.File, error) { + fromRule := FindRuleByName(env.File, from) + if fromRule == nil { + return nil, fmt.Errorf("could not find rule '%s'", from) + } + attr := fromRule.Attr(attrName) + if attr == nil { + return nil, fmt.Errorf("rule '%s' does not have attribute '%s'", from, attrName) + } + + ast, err := build.Parse("" /* filename */, []byte(build.FormatString(attr))) + if err != nil { + return nil, fmt.Errorf("could not parse attribute value %v", build.FormatString(attr)) + } + + env.Rule.SetAttr(attrName, ast.Stmt[0]) + return env.File, nil +} + +func cmdFix(env CmdEnvironment) (*build.File, error) { + // Fix the whole file + if env.Rule.Kind() == "package" { + return FixFile(env.File, env.Pkg, env.Args), nil + } + // Fix a specific rule + return FixRule(env.File, env.Pkg, env.Rule, env.Args), nil +} + +// CommandInfo provides a command function and info on incoming arguments. +type CommandInfo struct { + Fn func(CmdEnvironment) (*build.File, error) + MinArg int + MaxArg int + Template string +} + +// AllCommands associates the command names with their function and number +// of arguments. +var AllCommands = map[string]CommandInfo{ + "add": {cmdAdd, 2, -1, " "}, + "new_load": {cmdNewLoad, 1, -1, " "}, + "comment": {cmdComment, 1, 3, "? ? "}, + "print_comment": {cmdPrintComment, 0, 2, "? ?"}, + "delete": {cmdDelete, 0, 0, ""}, + "fix": {cmdFix, 0, -1, "?"}, + "move": {cmdMove, 3, -1, " "}, + "new": {cmdNew, 2, 4, " [(before|after) ]"}, + "print": {cmdPrint, 0, -1, ""}, + "remove": {cmdRemove, 1, -1, " "}, + "rename": {cmdRename, 2, 2, " "}, + "replace": {cmdReplace, 3, 3, " "}, + "set": {cmdSet, 2, -1, " "}, + "set_if_absent": {cmdSetIfAbsent, 2, -1, " "}, + "copy": {cmdCopy, 2, 2, " "}, + "copy_no_overwrite": {cmdCopyNoOverwrite, 2, 2, " "}, +} + +func expandTargets(f *build.File, rule string) ([]*build.Rule, error) { + if r := FindRuleByName(f, rule); r != nil { + return []*build.Rule{r}, nil + } else if r := FindExportedFile(f, rule); r != nil { + return []*build.Rule{r}, nil + } else if rule == "all" || rule == "*" { + // "all" is a valid name, it is a wildcard only if no such rule is found. + return f.Rules(""), nil + } else if strings.HasPrefix(rule, "%") { + // "%java_library" will match all java_library functions in the package + // "%" will match the rule which begins at LINENUM. + // This is for convenience, "%" is not a valid character in bazel targets. + kind := rule[1:] + if linenum, err := strconv.Atoi(kind); err == nil { + if r := f.RuleAt(linenum); r != nil { + return []*build.Rule{r}, nil + } + } else { + return f.Rules(kind), nil + } + } + return nil, fmt.Errorf("rule '%s' not found", rule) +} + +func filterRules(rules []*build.Rule) (result []*build.Rule) { + if len(Opts.FilterRuleTypes) == 0 { + return rules + } + for _, rule := range rules { + acceptableType := false + for _, filterType := range Opts.FilterRuleTypes { + if rule.Kind() == filterType { + acceptableType = true + break + } + } + if acceptableType || rule.Kind() == "package" { + result = append(result, rule) + } + } + return +} + +// command contains a list of tokens that describe a buildozer command. +type command struct { + tokens []string +} + +// checkCommandUsage checks the number of argument of a command. +// It prints an error and usage when it is not valid. +func checkCommandUsage(name string, cmd CommandInfo, count int) { + if count >= cmd.MinArg && (cmd.MaxArg == -1 || count <= cmd.MaxArg) { + return + } + + if count < cmd.MinArg { + fmt.Fprintf(os.Stderr, "Too few arguments for command '%s', expected at least %d.\n", + name, cmd.MinArg) + } else { + fmt.Fprintf(os.Stderr, "Too many arguments for command '%s', expected at most %d.\n", + name, cmd.MaxArg) + } + Usage() +} + +// Match text that only contains spaces if they're escaped with '\'. +var spaceRegex = regexp.MustCompile(`(\\ |[^ ])+`) + +// SplitOnSpaces behaves like strings.Fields, except that spaces can be escaped. +// " some dummy\\ string" -> ["some", "dummy string"] +func SplitOnSpaces(input string) []string { + result := spaceRegex.FindAllString(input, -1) + for i, s := range result { + result[i] = strings.Replace(s, `\ `, " ", -1) + } + return result +} + +// parseCommands parses commands and targets they should be applied on from +// a list of arguments. +// Each argument can be either: +// - a command (as defined by AllCommands) and its parameters, separated by +// whitespace +// - a target all commands that are parsed during one call to parseCommands +// should be applied on +func parseCommands(args []string) (commands []command, targets []string) { + for _, arg := range args { + commandTokens := SplitOnSpaces(arg) + cmd, found := AllCommands[commandTokens[0]] + if found { + checkCommandUsage(commandTokens[0], cmd, len(commandTokens)-1) + commands = append(commands, command{commandTokens}) + } else { + targets = append(targets, arg) + } + } + return +} + +// commandsForTarget contains commands to be executed on the given target. +type commandsForTarget struct { + target string + commands []command +} + +// commandsForFile contains the file name and all commands that should be +// applied on that file, indexed by their target. +type commandsForFile struct { + file string + commands []commandsForTarget +} + +// commandError returns an error that formats 'err' in the context of the +// commands to be executed on the given target. +func commandError(commands []command, target string, err error) error { + return fmt.Errorf("error while executing commands %s on target %s: %s", commands, target, err) +} + +// rewriteResult contains the outcome of applying fixes to a single file. +type rewriteResult struct { + file string + errs []error + modified bool + records []*apipb.Output_Record +} + +// getGlobalVariables returns the global variable assignments in the provided list of expressions. +// That is, for each variable assignment of the form +// a = v +// vars["a"] will contain the BinaryExpr whose Y value is the assignment "a = v". +func getGlobalVariables(exprs []build.Expr) (vars map[string]*build.BinaryExpr) { + vars = make(map[string]*build.BinaryExpr) + for _, expr := range exprs { + if binExpr, ok := expr.(*build.BinaryExpr); ok { + if binExpr.Op != "=" { + continue + } + if lhs, ok := binExpr.X.(*build.LiteralExpr); ok { + vars[lhs.Token] = binExpr + } + } + } + return vars +} + +// When checking the filesystem, we need to look for any of the +// possible buildFileNames. For historical reasons, the +// parts of the tool that generate paths that we may want to examine +// continue to assume that build files are all named "BUILD". +var buildFileNames = [...]string{"BUILD.bazel", "BUILD", "BUCK"} +var buildFileNamesSet = map[string]bool{ + "BUILD.bazel": true, + "BUILD": true, + "BUCK": true, +} + +// rewrite parses the BUILD file for the given file, transforms the AST, +// and write the changes back in the file (or on stdout). +func rewrite(commandsForFile commandsForFile) *rewriteResult { + name := commandsForFile.file + var data []byte + var err error + var fi os.FileInfo + records := []*apipb.Output_Record{} + if name == stdinPackageName { // read on stdin + data, err = ioutil.ReadAll(os.Stdin) + if err != nil { + return &rewriteResult{file: name, errs: []error{err}} + } + } else { + origName := name + for _, suffix := range buildFileNames { + if strings.HasSuffix(name, "/"+suffix) { + name = strings.TrimSuffix(name, suffix) + break + } + } + for _, suffix := range buildFileNames { + name = name + suffix + data, fi, err = file.ReadFile(name) + if err == nil { + break + } + name = strings.TrimSuffix(name, suffix) + } + if err != nil { + data, fi, err = file.ReadFile(name) + } + if err != nil { + err = errors.New("file not found or not readable") + return &rewriteResult{file: origName, errs: []error{err}} + } + } + + f, err := build.Parse(name, data) + if err != nil { + return &rewriteResult{file: name, errs: []error{err}} + } + + vars := map[string]*build.BinaryExpr{} + if Opts.EditVariables { + vars = getGlobalVariables(f.Stmt) + } + var errs []error + changed := false + for _, commands := range commandsForFile.commands { + target := commands.target + commands := commands.commands + _, absPkg, rule := InterpretLabelForWorkspaceLocation(Opts.RootDir, target) + _, pkg, _ := ParseLabel(target) + if pkg == stdinPackageName { // Special-case: This is already absolute + absPkg = stdinPackageName + } + + targets, err := expandTargets(f, rule) + if err != nil { + cerr := commandError(commands, target, err) + errs = append(errs, cerr) + if !Opts.KeepGoing { + return &rewriteResult{file: name, errs: errs, records: records} + + } + } + targets = filterRules(targets) + for _, cmd := range commands { + for _, r := range targets { + cmdInfo := AllCommands[cmd.tokens[0]] + record := &apipb.Output_Record{} + newf, err := cmdInfo.Fn(CmdEnvironment{f, r, vars, absPkg, cmd.tokens[1:], record}) + if len(record.Fields) != 0 { + records = append(records, record) + } + if err != nil { + cerr := commandError([]command{cmd}, target, err) + if Opts.KeepGoing { + errs = append(errs, cerr) + } else { + return &rewriteResult{file: name, errs: []error{cerr}, records: records} + } + } + if newf != nil { + changed = true + f = newf + } + } + } + } + if !changed { + return &rewriteResult{file: name, errs: errs, records: records} + } + f = RemoveEmptyPackage(f) + ndata, err := runBuildifier(f) + if err != nil { + return &rewriteResult{file: name, errs: []error{fmt.Errorf("running buildifier: %v", err)}, records: records} + } + + if Opts.Stdout || name == stdinPackageName { + os.Stdout.Write(ndata) + return &rewriteResult{file: name, errs: errs, records: records} + } + + if bytes.Equal(data, ndata) { + return &rewriteResult{file: name, errs: errs, records: records} + } + + if err := EditFile(fi, name); err != nil { + return &rewriteResult{file: name, errs: []error{err}, records: records} + } + + if err := file.WriteFile(name, ndata); err != nil { + return &rewriteResult{file: name, errs: []error{err}, records: records} + } + + fileModified = true + return &rewriteResult{file: name, errs: errs, modified: true, records: records} +} + +// EditFile is a function that does any prework needed before editing a file. +// e.g. "checking out for write" from a locking source control repo. +var EditFile = func(fi os.FileInfo, name string) error { + return nil +} + +// runBuildifier formats the build file f. +// Runs Opts.Buildifier if it's non-empty, otherwise uses built-in formatter. +// Opts.Buildifier is useful to force consistency with other tools that call Buildifier. +func runBuildifier(f *build.File) ([]byte, error) { + if Opts.Buildifier == "" { + build.Rewrite(f, nil) + return build.Format(f), nil + } + + cmd := exec.Command(Opts.Buildifier) + data := build.Format(f) + cmd.Stdin = bytes.NewBuffer(data) + stdout := bytes.NewBuffer(nil) + stderr := bytes.NewBuffer(nil) + cmd.Stdout = stdout + cmd.Stderr = stderr + err := cmd.Run() + if stderr.Len() > 0 { + return nil, fmt.Errorf("%s", stderr.Bytes()) + } + if err != nil { + return nil, err + } + return stdout.Bytes(), nil +} + +// Given a target, whose package may contain a trailing "/...", returns all +// extisting BUILD file paths which match the package. +func targetExpressionToBuildFiles(target string) []string { + file, _, _ := InterpretLabelForWorkspaceLocation(Opts.RootDir, target) + if Opts.RootDir == "" { + var err error + if file, err = filepath.Abs(file); err != nil { + fmt.Printf("Cannot make path absolute: %s\n", err.Error()) + os.Exit(1) + } + } + + if !strings.HasSuffix(file, "/.../BUILD") { + return []string{file} + } + + var buildFiles []string + searchDirs := []string{strings.TrimSuffix(file, "/.../BUILD")} + for len(searchDirs) != 0 { + lastIndex := len(searchDirs) - 1 + dir := searchDirs[lastIndex] + searchDirs = searchDirs[:lastIndex] + + dirFiles, err := ioutil.ReadDir(dir) + if err != nil { + continue + } + + for _, dirFile := range dirFiles { + if dirFile.IsDir() { + searchDirs = append(searchDirs, path.Join(dir, dirFile.Name())) + } else if _, ok := buildFileNamesSet[dirFile.Name()]; ok { + buildFiles = append(buildFiles, path.Join(dir, dirFile.Name())) + } + } + } + + return buildFiles +} + +// appendCommands adds the given commands to be applied to each of the given targets +// via the commandMap. +func appendCommands(commandMap map[string][]commandsForTarget, args []string) { + commands, targets := parseCommands(args) + for _, target := range targets { + if strings.HasSuffix(target, "/BUILD") { + target = strings.TrimSuffix(target, "/BUILD") + ":__pkg__" + } + var buildFiles []string + _, pkg, _ := ParseLabel(target) + if pkg == stdinPackageName { + buildFiles = []string{stdinPackageName} + } else { + buildFiles = targetExpressionToBuildFiles(target) + } + + for _, file := range buildFiles { + commandMap[file] = append(commandMap[file], commandsForTarget{target, commands}) + } + } +} + +func appendCommandsFromFile(commandsByFile map[string][]commandsForTarget, fileName string) { + var reader io.Reader + if Opts.CommandsFile == stdinPackageName { + reader = os.Stdin + } else { + rc := file.OpenReadFile(Opts.CommandsFile) + reader = rc + defer rc.Close() + } + scanner := bufio.NewScanner(reader) + for scanner.Scan() { + line := scanner.Text() + if line == "" { + continue + } + args := strings.Split(line, "|") + appendCommands(commandsByFile, args) + } + if err := scanner.Err(); err != nil { + fmt.Fprintf(os.Stderr, "Error while reading commands file: %v", scanner.Err()) + } +} + +func printRecord(writer io.Writer, record *apipb.Output_Record) { + fields := record.Fields + line := make([]string, len(fields)) + for i, field := range fields { + switch value := field.Value.(type) { + case *apipb.Output_Record_Field_Text: + if field.QuoteWhenPrinting && strings.ContainsRune(value.Text, ' ') { + line[i] = fmt.Sprintf("%q", value.Text) + } else { + line[i] = value.Text + } + break + case *apipb.Output_Record_Field_Number: + line[i] = strconv.Itoa(int(value.Number)) + break + case *apipb.Output_Record_Field_Error: + switch value.Error { + case apipb.Output_Record_Field_UNKNOWN: + line[i] = "(unknown)" + break + case apipb.Output_Record_Field_MISSING: + line[i] = "(missing)" + break + } + break + case *apipb.Output_Record_Field_List: + line[i] = fmt.Sprintf("[%s]", strings.Join(value.List.Strings, " ")) + break + } + } + + fmt.Fprint(writer, strings.Join(line, " ")+"\n") +} + +// Buildozer loops over all arguments on the command line fixing BUILD files. +func Buildozer(args []string) int { + commandsByFile := make(map[string][]commandsForTarget) + if Opts.CommandsFile != "" { + appendCommandsFromFile(commandsByFile, Opts.CommandsFile) + } else { + if len(args) == 0 { + Usage() + } + appendCommands(commandsByFile, args) + } + + numFiles := len(commandsByFile) + if Opts.Parallelism > 0 { + runtime.GOMAXPROCS(Opts.Parallelism) + } + results := make(chan *rewriteResult, numFiles) + data := make(chan commandsForFile) + + for i := 0; i < Opts.NumIO; i++ { + go func(results chan *rewriteResult, data chan commandsForFile) { + for commandsForFile := range data { + results <- rewrite(commandsForFile) + } + }(results, data) + } + + for file, commands := range commandsByFile { + data <- commandsForFile{file, commands} + } + close(data) + records := []*apipb.Output_Record{} + hasErrors := false + for i := 0; i < numFiles; i++ { + fileResults := <-results + if fileResults == nil { + continue + } + hasErrors = hasErrors || len(fileResults.errs) > 0 + for _, err := range fileResults.errs { + fmt.Fprintf(os.Stderr, "%s: %s\n", fileResults.file, err) + } + if fileResults.modified && !Opts.Quiet { + fmt.Fprintf(os.Stderr, "fixed %s\n", fileResults.file) + } + if fileResults.records != nil { + records = append(records, fileResults.records...) + } + } + + if Opts.IsPrintingProto { + data, err := proto.Marshal(&apipb.Output{Records: records}) + if err != nil { + log.Fatal("marshaling error: ", err) + } + fmt.Fprintf(os.Stdout, "%s", data) + } else { + for _, record := range records { + printRecord(os.Stdout, record) + } + } + + if hasErrors { + return 2 + } + if !fileModified && !Opts.Stdout { + return 3 + } + return 0 +} diff --git a/vendor/github.com/bazelbuild/buildtools/edit/edit.go b/vendor/github.com/bazelbuild/buildtools/edit/edit.go new file mode 100644 index 00000000000..c9b541fb595 --- /dev/null +++ b/vendor/github.com/bazelbuild/buildtools/edit/edit.go @@ -0,0 +1,823 @@ +/* +Copyright 2016 Google Inc. All Rights Reserved. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +// Package edit provides high-level auxiliary functions for AST manipulation +// on BUILD files. +package edit + +import ( + "fmt" + "os" + "path" + "path/filepath" + "sort" + "strconv" + "strings" + + "github.com/bazelbuild/buildtools/build" + "github.com/bazelbuild/buildtools/wspace" +) + +var ( + // ShortenLabelsFlag if true converts added labels to short form , e.g. //foo:bar => :bar + ShortenLabelsFlag = true + // DeleteWithComments if true a list attribute will be be deleted in ListDelete, even if there is a comment attached to it + DeleteWithComments = true +) + +// ParseLabel parses a Blaze label (eg. //devtools/buildozer:rule), and returns +// the repo name ("" for the main repo), package (with leading slashes trimmed) +// and rule name (e.g. ["", "devtools/buildozer", "rule"]). +func ParseLabel(target string) (string, string, string) { + repo := "" + if strings.HasPrefix(target, "@") { + target = strings.TrimLeft(target, "@") + parts := strings.SplitN(target, "/", 2) + if len(parts) == 1 { + // "@foo" -> "foo", "", "foo" (ie @foo//:foo) + return target, "", target + } + repo = parts[0] + target = "/" + parts[1] + } + // TODO(bazel-team): check if the next line can now be deleted + target = strings.TrimRight(target, ":") // labels can end with ':' + parts := strings.SplitN(target, ":", 2) + parts[0] = strings.TrimPrefix(parts[0], "//") + if len(parts) == 1 { + if strings.HasPrefix(target, "//") { + // "//absolute/pkg" -> "absolute/pkg", "pkg" + return repo, parts[0], path.Base(parts[0]) + } + // "relative/label" -> "", "relative/label" + return repo, "", parts[0] + } + return repo, parts[0], parts[1] +} + +// ShortenLabel rewrites labels to use the canonical form (the form +// recommended by build-style). This behavior can be disabled using the +// --noshorten_labels flag for projects that consistently use long-form labels. +// "//foo/bar:bar" => "//foo/bar", or ":bar" when possible. +func ShortenLabel(label string, pkg string) string { + if !ShortenLabelsFlag { + return label + } + if !strings.HasPrefix(label, "//") { + // It doesn't look like a long label, so we preserve it. + return label + } + repo, labelPkg, rule := ParseLabel(label) + if repo == "" && labelPkg == pkg { // local label + return ":" + rule + } + slash := strings.LastIndex(labelPkg, "/") + if (slash >= 0 && labelPkg[slash+1:] == rule) || labelPkg == rule { + return "//" + labelPkg + } + return label +} + +// LabelsEqual returns true if label1 and label2 are equal. The function +// takes care of the optional ":" prefix and differences between long-form +// labels and local labels. +func LabelsEqual(label1, label2, pkg string) bool { + str1 := strings.TrimPrefix(ShortenLabel(label1, pkg), ":") + str2 := strings.TrimPrefix(ShortenLabel(label2, pkg), ":") + return str1 == str2 +} + +// isFile returns true if the path refers to a regular file after following +// symlinks. +func isFile(path string) bool { + path, err := filepath.EvalSymlinks(path) + if err != nil { + return false + } + info, err := os.Stat(path) + if err != nil { + return false + } + return info.Mode().IsRegular() +} + +// InterpretLabelForWorkspaceLocation returns the name of the BUILD file to +// edit, the full package name, and the rule. It takes a workspace-rooted +// directory to use. +func InterpretLabelForWorkspaceLocation(root string, target string) (buildFile string, pkg string, rule string) { + repo, pkg, rule := ParseLabel(target) + rootDir, relativePath := wspace.FindWorkspaceRoot(root) + if repo != "" { + files, err := wspace.FindRepoBuildFiles(rootDir) + if err == nil { + if buildFile, ok := files[repo]; ok { + return buildFile, pkg, rule + } + } + // TODO(rodrigoq): report error for other repos + } + + if strings.HasPrefix(target, "//") { + buildFile = path.Join(rootDir, pkg, "BUILD") + return + } + if isFile(pkg) { + // allow operation on other files like WORKSPACE + buildFile = pkg + pkg = path.Join(relativePath, filepath.Dir(pkg)) + return + } + if pkg != "" { + buildFile = pkg + "/BUILD" + } else { + buildFile = "BUILD" + } + pkg = path.Join(relativePath, pkg) + return +} + +// InterpretLabel returns the name of the BUILD file to edit, the full +// package name, and the rule. It uses the pwd for resolving workspace file paths. +func InterpretLabel(target string) (buildFile string, pkg string, rule string) { + return InterpretLabelForWorkspaceLocation("", target) +} + +// ExprToRule returns a Rule from an Expr. +// The boolean is false iff the Expr is not a function call, or does not have +// the expected kind. +func ExprToRule(expr build.Expr, kind string) (*build.Rule, bool) { + call, ok := expr.(*build.CallExpr) + if !ok { + return nil, false + } + k, ok := call.X.(*build.LiteralExpr) + if !ok || k.Token != kind { + return nil, false + } + return &build.Rule{Call: call}, true +} + +// ExistingPackageDeclaration returns the package declaration, or nil if there is none. +func ExistingPackageDeclaration(f *build.File) *build.Rule { + for _, stmt := range f.Stmt { + if rule, ok := ExprToRule(stmt, "package"); ok { + return rule + } + } + return nil +} + +// PackageDeclaration returns the package declaration. If it doesn't +// exist, it is created at the top of the BUILD file, after leading +// comments. +func PackageDeclaration(f *build.File) *build.Rule { + if pkg := ExistingPackageDeclaration(f); pkg != nil { + return pkg + } + all := []build.Expr{} + added := false + call := &build.CallExpr{X: &build.LiteralExpr{Token: "package"}} + // Skip CommentBlocks and find a place to insert the package declaration. + for _, stmt := range f.Stmt { + _, ok := stmt.(*build.CommentBlock) + if !ok && !added { + all = append(all, call) + added = true + } + all = append(all, stmt) + } + if !added { // In case the file is empty. + all = append(all, call) + } + f.Stmt = all + return &build.Rule{Call: call} +} + +// RemoveEmptyPackage removes empty package declarations from the file, i.e.: +// package() +// This might appear because of a buildozer transformation (e.g. when removing a package +// attribute). Removing it is required for the file to be valid. +func RemoveEmptyPackage(f *build.File) *build.File { + var all []build.Expr + for _, stmt := range f.Stmt { + if call, ok := stmt.(*build.CallExpr); ok { + functionName, ok := call.X.(*build.LiteralExpr) + if ok && functionName.Token == "package" && len(call.List) == 0 { + continue + } + } + all = append(all, stmt) + } + return &build.File{Path: f.Path, Comments: f.Comments, Stmt: all} +} + +// InsertAfter inserts an expression after index i. +func InsertAfter(i int, stmt []build.Expr, expr build.Expr) []build.Expr { + i = i + 1 // index after the element at i + result := make([]build.Expr, len(stmt)+1) + copy(result[0:i], stmt[0:i]) + result[i] = expr + copy(result[i+1:], stmt[i:]) + return result +} + +// IndexOfLast finds the index of the last expression of a specific kind. +func IndexOfLast(stmt []build.Expr, Kind string) int { + lastIndex := -1 + for i, s := range stmt { + sAsCallExpr, ok := s.(*build.CallExpr) + if !ok { + continue + } + literal, ok := sAsCallExpr.X.(*build.LiteralExpr) + if ok && literal.Token == Kind { + lastIndex = i + } + } + return lastIndex +} + +// InsertAfterLastOfSameKind inserts an expression after the last expression of the same kind. +func InsertAfterLastOfSameKind(stmt []build.Expr, expr *build.CallExpr) []build.Expr { + index := IndexOfLast(stmt, expr.X.(*build.LiteralExpr).Token) + if index == -1 { + return InsertAtEnd(stmt, expr) + } + return InsertAfter(index, stmt, expr) +} + +// InsertAtEnd inserts an expression at the end of a list, before trailing comments. +func InsertAtEnd(stmt []build.Expr, expr build.Expr) []build.Expr { + var i int + for i = len(stmt) - 1; i >= 0; i-- { + _, ok := stmt[i].(*build.CommentBlock) + if !ok { + break + } + } + return InsertAfter(i, stmt, expr) +} + +// FindRuleByName returns the rule in the file that has the given name. +// If the name is "__pkg__", it returns the global package declaration. +func FindRuleByName(f *build.File, name string) *build.Rule { + if name == "__pkg__" { + return PackageDeclaration(f) + } + i := IndexOfRuleByName(f, name) + if i != -1 { + return &build.Rule{Call: f.Stmt[i].(*build.CallExpr)} + } + return nil +} + +// UseImplicitName returns the rule in the file if it meets these conditions: +// - It is the only unnamed rule in the file. +// - The file path's ending directory name and the passed rule name match. +// In the Pants Build System, by pantsbuild, the use of an implicit name makes +// creating targets easier. This function implements such names. +func UseImplicitName(f *build.File, rule string) *build.Rule { + // We disallow empty names + if f.Path == "BUILD" { + return nil + } + ruleCount := 0 + var temp, found *build.Rule + pkg := filepath.Base(filepath.Dir(f.Path)) + + for _, stmt := range f.Stmt { + call, ok := stmt.(*build.CallExpr) + if !ok { + continue + } + temp = &build.Rule{Call: call} + if temp.Kind() != "" && temp.Name() == "" { + ruleCount++ + found = temp + } + } + + if ruleCount == 1 { + if rule == pkg { + return found + } + } + return nil +} + +// IndexOfRuleByName returns the index (in f.Stmt) of the CallExpr which defines a rule named `name`, or -1 if it doesn't exist. +func IndexOfRuleByName(f *build.File, name string) int { + linenum := -1 + if strings.HasPrefix(name, "%") { + // "%" will match the rule which begins at LINENUM. + // This is for convenience, "%" is not a valid character in bazel targets. + if result, err := strconv.Atoi(name[1:]); err == nil { + linenum = result + } + } + + for i, stmt := range f.Stmt { + call, ok := stmt.(*build.CallExpr) + if !ok { + continue + } + r := &build.Rule{Call: call} + start, _ := call.X.Span() + if r.Name() == name || start.Line == linenum { + return i + } + } + return -1 +} + +// FindExportedFile returns the first exports_files call which contains the +// file 'name', or nil if not found +func FindExportedFile(f *build.File, name string) *build.Rule { + for _, r := range f.Rules("exports_files") { + if len(r.Call.List) == 0 { + continue + } + pkg := "" // Files are not affected by the package name + if ListFind(r.Call.List[0], name, pkg) != nil { + return r + } + } + return nil +} + +// DeleteRule returns the AST without the specified rule +func DeleteRule(f *build.File, rule *build.Rule) *build.File { + var all []build.Expr + for _, stmt := range f.Stmt { + if stmt == rule.Call { + continue + } + all = append(all, stmt) + } + return &build.File{Path: f.Path, Comments: f.Comments, Stmt: all} +} + +// DeleteRuleByName returns the AST without the rules that have the +// given name. +func DeleteRuleByName(f *build.File, name string) *build.File { + var all []build.Expr + for _, stmt := range f.Stmt { + call, ok := stmt.(*build.CallExpr) + if !ok { + all = append(all, stmt) + continue + } + r := &build.Rule{Call: call} + if r.Name() != name { + all = append(all, stmt) + } + } + return &build.File{Path: f.Path, Comments: f.Comments, Stmt: all} +} + +// DeleteRuleByKind removes the rules of the specified kind from the AST. +// Returns an updated copy of f. +func DeleteRuleByKind(f *build.File, kind string) *build.File { + var all []build.Expr + for _, stmt := range f.Stmt { + call, ok := stmt.(*build.CallExpr) + if !ok { + all = append(all, stmt) + continue + } + k, ok := call.X.(*build.LiteralExpr) + if !ok || k.Token != kind { + all = append(all, stmt) + } + } + return &build.File{Path: f.Path, Comments: f.Comments, Stmt: all} +} + +// AllLists returns all the lists concatenated in an expression. +// For example, in: glob(["*.go"]) + [":rule"] +// the function will return [[":rule"]]. +func AllLists(e build.Expr) []*build.ListExpr { + switch e := e.(type) { + case *build.ListExpr: + return []*build.ListExpr{e} + case *build.BinaryExpr: + if e.Op == "+" { + return append(AllLists(e.X), AllLists(e.Y)...) + } + } + return nil +} + +// FirstList works in the same way as AllLists, except that it +// returns only one list, or nil. +func FirstList(e build.Expr) *build.ListExpr { + switch e := e.(type) { + case *build.ListExpr: + return e + case *build.BinaryExpr: + if e.Op == "+" { + li := FirstList(e.X) + if li == nil { + return FirstList(e.Y) + } + return li + } + } + return nil +} + +// AllStrings returns all the string literals concatenated in an expression. +// For example, in: "foo" + x + "bar" +// the function will return ["foo", "bar"]. +func AllStrings(e build.Expr) []*build.StringExpr { + switch e := e.(type) { + case *build.StringExpr: + return []*build.StringExpr{e} + case *build.BinaryExpr: + if e.Op == "+" { + return append(AllStrings(e.X), AllStrings(e.Y)...) + } + } + return nil +} + +// ListFind looks for a string in the list expression (which may be a +// concatenation of lists). It returns the element if it is found. nil +// otherwise. +func ListFind(e build.Expr, item string, pkg string) *build.StringExpr { + item = ShortenLabel(item, pkg) + for _, li := range AllLists(e) { + for _, elem := range li.List { + str, ok := elem.(*build.StringExpr) + if ok && LabelsEqual(str.Value, item, pkg) { + return str + } + } + } + return nil +} + +// hasComments returns whether the StringExpr literal has a comment attached to it. +func hasComments(literal *build.StringExpr) bool { + return len(literal.Before) > 0 || len(literal.Suffix) > 0 +} + +// ContainsComments returns whether the expr has a comment that includes str. +func ContainsComments(expr build.Expr, str string) bool { + str = strings.ToLower(str) + com := expr.Comment() + comments := append(com.Before, com.Suffix...) + comments = append(comments, com.After...) + for _, c := range comments { + if strings.Contains(strings.ToLower(c.Token), str) { + return true + } + } + return false +} + +// ListDelete deletes the item from a list expression in e and returns +// the StringExpr deleted, or nil otherwise. +func ListDelete(e build.Expr, item, pkg string) (deleted *build.StringExpr) { + deleted = nil + item = ShortenLabel(item, pkg) + for _, li := range AllLists(e) { + var all []build.Expr + for _, elem := range li.List { + if str, ok := elem.(*build.StringExpr); ok { + if LabelsEqual(str.Value, item, pkg) && (DeleteWithComments || !hasComments(str)) { + deleted = str + continue + } + } + all = append(all, elem) + } + li.List = all + } + return deleted +} + +// ListAttributeDelete deletes string item from list attribute attr, deletes attr if empty, +// and returns the StringExpr deleted, or nil otherwise. +func ListAttributeDelete(rule *build.Rule, attr, item, pkg string) *build.StringExpr { + deleted := ListDelete(rule.Attr(attr), item, pkg) + if deleted != nil { + if listExpr, ok := rule.Attr(attr).(*build.ListExpr); ok && len(listExpr.List) == 0 { + rule.DelAttr(attr) + } + } + return deleted +} + +// ListReplace replaces old with value in all lists in e and returns a Boolean +// to indicate whether the replacement was successful. +func ListReplace(e build.Expr, old, value, pkg string) bool { + replaced := false + old = ShortenLabel(old, pkg) + for _, li := range AllLists(e) { + for k, elem := range li.List { + str, ok := elem.(*build.StringExpr) + if !ok || !LabelsEqual(str.Value, old, pkg) { + continue + } + li.List[k] = &build.StringExpr{Value: ShortenLabel(value, pkg), Comments: *elem.Comment()} + replaced = true + } + } + return replaced +} + +// isExprLessThan compares two Expr statements. Currently, only labels are supported. +func isExprLessThan(x1, x2 build.Expr) bool { + str1, ok1 := x1.(*build.StringExpr) + str2, ok2 := x2.(*build.StringExpr) + if ok1 != ok2 { + return ok2 + } + if ok1 && ok2 { + // Labels starting with // are put at the end. + pre1 := strings.HasPrefix(str1.Value, "//") + pre2 := strings.HasPrefix(str2.Value, "//") + if pre1 != pre2 { + return pre2 + } + return str1.Value < str2.Value + } + return false +} + +func sortedInsert(list []build.Expr, item build.Expr) []build.Expr { + i := 0 + for ; i < len(list); i++ { + if isExprLessThan(item, list[i]) { + break + } + } + res := make([]build.Expr, 0, len(list)+1) + res = append(res, list[:i]...) + res = append(res, item) + res = append(res, list[i:]...) + return res +} + +// attributeMustNotBeSorted returns true if the list in the attribute cannot be +// sorted. For some attributes, it makes sense to try to do a sorted insert +// (e.g. deps), even when buildifier will not sort it for conservative reasons. +// For a few attributes, sorting will never make sense. +func attributeMustNotBeSorted(rule, attr string) bool { + // TODO(bazel-team): Come up with a more complete list. + return attr == "args" +} + +// getVariable returns the binary expression that assignes a variable to expr, if expr is +// an identifier of a variable that vars contains a mapping for. +func getVariable(expr build.Expr, vars *map[string]*build.BinaryExpr) (varAssignment *build.BinaryExpr) { + if vars == nil { + return nil + } + + if literal, ok := expr.(*build.LiteralExpr); ok { + if varAssignment = (*vars)[literal.Token]; varAssignment != nil { + return varAssignment + } + } + return nil +} + +// AddValueToList adds a value to a list. If the expression is +// not a list, a list with a single element is appended to the original +// expression. +func AddValueToList(oldList build.Expr, pkg string, item build.Expr, sorted bool) build.Expr { + if oldList == nil { + return &build.ListExpr{List: []build.Expr{item}} + } + + str, ok := item.(*build.StringExpr) + if ok && ListFind(oldList, str.Value, pkg) != nil { + // The value is already in the list. + return oldList + } + li := FirstList(oldList) + if li != nil { + if sorted { + li.List = sortedInsert(li.List, item) + } else { + li.List = append(li.List, item) + } + return oldList + } + list := &build.ListExpr{List: []build.Expr{item}} + concat := &build.BinaryExpr{Op: "+", X: oldList, Y: list} + return concat +} + +// AddValueToListAttribute adds the given item to the list attribute identified by name and pkg. +func AddValueToListAttribute(r *build.Rule, name string, pkg string, item build.Expr, vars *map[string]*build.BinaryExpr) { + old := r.Attr(name) + sorted := !attributeMustNotBeSorted(r.Kind(), name) + if varAssignment := getVariable(old, vars); varAssignment != nil { + varAssignment.Y = AddValueToList(varAssignment.Y, pkg, item, sorted) + } else { + r.SetAttr(name, AddValueToList(old, pkg, item, sorted)) + } +} + +// MoveAllListAttributeValues moves all values from list attribute oldAttr to newAttr, +// and deletes oldAttr. +func MoveAllListAttributeValues(rule *build.Rule, oldAttr, newAttr, pkg string, vars *map[string]*build.BinaryExpr) error { + if rule.Attr(oldAttr) == nil { + return fmt.Errorf("no attribute %s found in %s", oldAttr, rule.Name()) + } + if rule.Attr(newAttr) == nil { + RenameAttribute(rule, oldAttr, newAttr) + return nil + } + if listExpr, ok := rule.Attr(oldAttr).(*build.ListExpr); ok { + for _, val := range listExpr.List { + AddValueToListAttribute(rule, newAttr, pkg, val, vars) + } + rule.DelAttr(oldAttr) + return nil + } + return fmt.Errorf("%s already exists and %s is not a simple list", newAttr, oldAttr) +} + +// DictionarySet looks for the key in the dictionary expression. If value is not nil, +// it replaces the current value with it. In all cases, it returns the current value. +func DictionarySet(dict *build.DictExpr, key string, value build.Expr) build.Expr { + for _, e := range dict.List { + kv, _ := e.(*build.KeyValueExpr) + if k, ok := kv.Key.(*build.StringExpr); ok && k.Value == key { + if value != nil { + kv.Value = value + } + return kv.Value + } + } + if value != nil { + kv := &build.KeyValueExpr{Key: &build.StringExpr{Value: key}, Value: value} + dict.List = append(dict.List, kv) + } + return nil +} + +// RenameAttribute renames an attribute in a rule. +func RenameAttribute(r *build.Rule, oldName, newName string) error { + if r.Attr(newName) != nil { + return fmt.Errorf("attribute %s already exists in rule %s", newName, r.Name()) + } + for _, kv := range r.Call.List { + as, ok := kv.(*build.BinaryExpr) + if !ok || as.Op != "=" { + continue + } + k, ok := as.X.(*build.LiteralExpr) + if !ok || k.Token != oldName { + continue + } + k.Token = newName + return nil + } + return fmt.Errorf("no attribute %s found in rule %s", oldName, r.Name()) +} + +// EditFunction is a wrapper around build.Edit. The callback is called only on +// functions 'name'. +func EditFunction(v build.Expr, name string, f func(x *build.CallExpr, stk []build.Expr) build.Expr) build.Expr { + return build.Edit(v, func(expr build.Expr, stk []build.Expr) build.Expr { + call, ok := expr.(*build.CallExpr) + if !ok { + return nil + } + fct, ok := call.X.(*build.LiteralExpr) + if !ok || fct.Token != name { + return nil + } + return f(call, stk) + }) +} + +// UsedSymbols returns the set of symbols used in the BUILD file (variables, function names). +func UsedSymbols(f *build.File) map[string]bool { + symbols := make(map[string]bool) + build.Walk(f, func(expr build.Expr, stack []build.Expr) { + literal, ok := expr.(*build.LiteralExpr) + if !ok { + return + } + // Check if we are on the left-side of an assignment + for _, e := range stack { + if as, ok := e.(*build.BinaryExpr); ok { + if as.Op == "=" && as.X == expr { + return + } + } + } + symbols[literal.Token] = true + }) + return symbols +} + +func newLoad(args []string) *build.CallExpr { + load := &build.CallExpr{ + X: &build.LiteralExpr{ + Token: "load", + }, + List: []build.Expr{}, + ForceCompact: true, + } + for _, a := range args { + load.List = append(load.List, &build.StringExpr{Value: a}) + } + return load +} + +// appendLoad tries to find an existing load location and append symbols to it. +func appendLoad(stmts []build.Expr, args []string) bool { + if len(args) == 0 { + return false + } + location := args[0] + symbolsToLoad := make(map[string]bool) + for _, s := range args[1:] { + symbolsToLoad[s] = true + } + var lastLoad *build.CallExpr + for _, s := range stmts { + call, ok := s.(*build.CallExpr) + if !ok { + continue + } + if l, ok := call.X.(*build.LiteralExpr); !ok || l.Token != "load" { + continue + } + if len(call.List) < 2 { + continue + } + if s, ok := call.List[0].(*build.StringExpr); !ok || s.Value != location { + continue // Loads a different file. + } + for _, arg := range call.List[1:] { + if s, ok := arg.(*build.StringExpr); ok { + delete(symbolsToLoad, s.Value) // Already loaded. + } + } + // Remember the last insert location, but potentially remove more symbols + // that are already loaded in other subsequent calls. + lastLoad = call + } + + if lastLoad == nil { + return false + } + + // Append the remaining loads to the last load location. + sortedSymbols := []string{} + for s := range symbolsToLoad { + sortedSymbols = append(sortedSymbols, s) + } + sort.Strings(sortedSymbols) + for _, s := range sortedSymbols { + lastLoad.List = append(lastLoad.List, &build.StringExpr{Value: s}) + } + return true +} + +// InsertLoad inserts a load statement at the top of the list of statements. +// The load statement is constructed using args. Symbols that are already loaded +// from the given filepath are ignored. If stmts already contains a load for the +// location in arguments, appends the symbols to load to it. +func InsertLoad(stmts []build.Expr, args []string) []build.Expr { + if appendLoad(stmts, args) { + return stmts + } + + load := newLoad(args) + + var all []build.Expr + added := false + for _, stmt := range stmts { + _, isComment := stmt.(*build.CommentBlock) + if isComment || added { + all = append(all, stmt) + continue + } + all = append(all, load) + all = append(all, stmt) + added = true + } + if !added { // Empty file or just comments. + all = append(all, load) + } + return all +} diff --git a/vendor/github.com/bazelbuild/buildtools/edit/fix.go b/vendor/github.com/bazelbuild/buildtools/edit/fix.go new file mode 100644 index 00000000000..e47183fe5d6 --- /dev/null +++ b/vendor/github.com/bazelbuild/buildtools/edit/fix.go @@ -0,0 +1,569 @@ +/* +Copyright 2016 Google Inc. All Rights Reserved. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +// Functions to clean and fix BUILD files + +package edit + +import ( + "regexp" + "sort" + "strings" + + "github.com/bazelbuild/buildtools/build" +) + +// splitOptionsWithSpaces is a cleanup function. +// It splits options strings that contain a space. This change +// should be safe as Blaze is splitting those strings, but we will +// eventually get rid of this misfeature. +// eg. it converts from: +// copts = ["-Dfoo -Dbar"] +// to: +// copts = ["-Dfoo", "-Dbar"] +func splitOptionsWithSpaces(_ *build.File, r *build.Rule, _ string) bool { + var attrToRewrite = []string{ + "copts", + "linkopts", + } + fixed := false + for _, attrName := range attrToRewrite { + attr := r.Attr(attrName) + if attr != nil { + for _, li := range AllLists(attr) { + fixed = splitStrings(li) || fixed + } + } + } + return fixed +} + +func splitStrings(list *build.ListExpr) bool { + var all []build.Expr + fixed := false + for _, e := range list.List { + str, ok := e.(*build.StringExpr) + if !ok { + all = append(all, e) + continue + } + if strings.Contains(str.Value, " ") && !strings.Contains(str.Value, "'\"") { + fixed = true + for i, substr := range strings.Fields(str.Value) { + item := &build.StringExpr{Value: substr} + if i == 0 { + item.Comments = str.Comments + } + all = append(all, item) + } + } else { + all = append(all, str) + } + } + list.List = all + return fixed +} + +// shortenLabels rewrites the labels in the rule using the short notation. +func shortenLabels(_ *build.File, r *build.Rule, pkg string) bool { + fixed := false + for _, attr := range r.AttrKeys() { + e := r.Attr(attr) + if !ContainsLabels(attr) { + continue + } + for _, li := range AllLists(e) { + for _, elem := range li.List { + str, ok := elem.(*build.StringExpr) + if ok && str.Value != ShortenLabel(str.Value, pkg) { + str.Value = ShortenLabel(str.Value, pkg) + fixed = true + } + } + } + } + return fixed +} + +// removeVisibility removes useless visibility attributes. +func removeVisibility(f *build.File, r *build.Rule, pkg string) bool { + pkgDecl := PackageDeclaration(f) + defaultVisibility := pkgDecl.AttrStrings("default_visibility") + + // If no default_visibility is given, it is implicitly private. + if len(defaultVisibility) == 0 { + defaultVisibility = []string{"//visibility:private"} + } + + visibility := r.AttrStrings("visibility") + if len(visibility) == 0 || len(visibility) != len(defaultVisibility) { + return false + } + sort.Strings(defaultVisibility) + sort.Strings(visibility) + for i, vis := range visibility { + if vis != defaultVisibility[i] { + return false + } + } + r.DelAttr("visibility") + return true +} + +// removeTestOnly removes the useless testonly attributes. +func removeTestOnly(f *build.File, r *build.Rule, pkg string) bool { + pkgDecl := PackageDeclaration(f) + + def := strings.HasSuffix(r.Kind(), "_test") || r.Kind() == "test_suite" + if !def { + if pkgDecl.Attr("default_testonly") == nil { + def = strings.HasPrefix(pkg, "javatests/") + } else if pkgDecl.AttrLiteral("default_testonly") == "1" { + def = true + } else if pkgDecl.AttrLiteral("default_testonly") != "0" { + // Non-literal value: it's not safe to do a change. + return false + } + } + + testonly := r.AttrLiteral("testonly") + if def && testonly == "1" { + r.DelAttr("testonly") + return true + } + if !def && testonly == "0" { + r.DelAttr("testonly") + return true + } + return false +} + +func genruleRenameDepsTools(_ *build.File, r *build.Rule, _ string) bool { + return r.Kind() == "genrule" && RenameAttribute(r, "deps", "tools") == nil +} + +// explicitHeuristicLabels adds $(location ...) for each label in the string s. +func explicitHeuristicLabels(s string, labels map[string]bool) string { + // Regexp comes from LABEL_CHAR_MATCHER in + // java/com/google/devtools/build/lib/analysis/LabelExpander.java + re := regexp.MustCompile("[a-zA-Z0-9:/_.+-]+|[^a-zA-Z0-9:/_.+-]+") + parts := re.FindAllString(s, -1) + changed := false + canChange := true + for i, part := range parts { + // We don't want to add $(location when it's already present. + // So we skip the next label when we see location(s). + if part == "location" || part == "locations" { + canChange = false + } + if !labels[part] { + if labels[":"+part] { // leading colon is often missing + part = ":" + part + } else { + continue + } + } + + if !canChange { + canChange = true + continue + } + parts[i] = "$(location " + part + ")" + changed = true + } + if changed { + return strings.Join(parts, "") + } + return s +} + +func addLabels(r *build.Rule, attr string, labels map[string]bool) { + a := r.Attr(attr) + if a == nil { + return + } + for _, li := range AllLists(a) { + for _, item := range li.List { + if str, ok := item.(*build.StringExpr); ok { + labels[str.Value] = true + } + } + } +} + +// genruleFixHeuristicLabels modifies the cmd attribute of genrules, so +// that they don't rely on heuristic label expansion anymore. +// Label expansion is made explicit with the $(location ...) command. +func genruleFixHeuristicLabels(_ *build.File, r *build.Rule, _ string) bool { + if r.Kind() != "genrule" { + return false + } + + cmd := r.Attr("cmd") + if cmd == nil { + return false + } + labels := make(map[string]bool) + addLabels(r, "tools", labels) + addLabels(r, "srcs", labels) + + fixed := false + for _, str := range AllStrings(cmd) { + newVal := explicitHeuristicLabels(str.Value, labels) + if newVal != str.Value { + fixed = true + str.Value = newVal + } + } + return fixed +} + +// sortExportsFiles sorts the first argument of exports_files if it is a list. +func sortExportsFiles(_ *build.File, r *build.Rule, _ string) bool { + if r.Kind() != "exports_files" || len(r.Call.List) == 0 { + return false + } + build.SortStringList(r.Call.List[0]) + return true +} + +// removeVarref replaces all varref('x') with '$(x)'. +// The goal is to eventually remove varref from the build language. +func removeVarref(_ *build.File, r *build.Rule, _ string) bool { + fixed := false + EditFunction(r.Call, "varref", func(call *build.CallExpr, stk []build.Expr) build.Expr { + if len(call.List) != 1 { + return nil + } + str, ok := (call.List[0]).(*build.StringExpr) + if !ok { + return nil + } + fixed = true + str.Value = "$(" + str.Value + ")" + // Preserve suffix comments from the function call + str.Comment().Suffix = append(str.Comment().Suffix, call.Comment().Suffix...) + return str + }) + return fixed +} + +// sortGlob sorts the list argument to glob. +func sortGlob(_ *build.File, r *build.Rule, _ string) bool { + fixed := false + EditFunction(r.Call, "glob", func(call *build.CallExpr, stk []build.Expr) build.Expr { + if len(call.List) == 0 { + return nil + } + build.SortStringList(call.List[0]) + fixed = true + return call + }) + return fixed +} + +func evaluateListConcatenation(expr build.Expr) build.Expr { + if _, ok := expr.(*build.ListExpr); ok { + return expr + } + bin, ok := expr.(*build.BinaryExpr) + if !ok || bin.Op != "+" { + return expr + } + li1, ok1 := evaluateListConcatenation(bin.X).(*build.ListExpr) + li2, ok2 := evaluateListConcatenation(bin.Y).(*build.ListExpr) + if !ok1 || !ok2 { + return expr + } + res := *li1 + res.List = append(li1.List, li2.List...) + return &res +} + +// mergeLiteralLists evaluates the concatenation of two literal lists. +// e.g. [1, 2] + [3, 4] -> [1, 2, 3, 4] +func mergeLiteralLists(_ *build.File, r *build.Rule, _ string) bool { + fixed := false + build.Edit(r.Call, func(expr build.Expr, stk []build.Expr) build.Expr { + newexpr := evaluateListConcatenation(expr) + fixed = fixed || (newexpr != expr) + return newexpr + }) + return fixed +} + +// usePlusEqual replaces uses of extend and append with the += operator. +// e.g. foo.extend(bar) => foo += bar +// foo.append(bar) => foo += [bar] +func usePlusEqual(f *build.File) bool { + fixed := false + for i, stmt := range f.Stmt { + call, ok := stmt.(*build.CallExpr) + if !ok { + continue + } + dot, ok := call.X.(*build.DotExpr) + if !ok || len(call.List) != 1 { + continue + } + obj, ok := dot.X.(*build.LiteralExpr) + if !ok { + continue + } + + var fix *build.BinaryExpr + if dot.Name == "extend" { + fix = &build.BinaryExpr{X: obj, Op: "+=", Y: call.List[0]} + } else if dot.Name == "append" { + list := &build.ListExpr{List: []build.Expr{call.List[0]}} + fix = &build.BinaryExpr{X: obj, Op: "+=", Y: list} + } else { + continue + } + fix.Comments = call.Comments // Keep original comments + f.Stmt[i] = fix + fixed = true + } + return fixed +} + +func isNonemptyComment(comment *build.Comments) bool { + return len(comment.Before)+len(comment.Suffix)+len(comment.After) > 0 +} + +// Checks whether a call or any of its arguments have a comment +func hasComment(call *build.CallExpr) bool { + if isNonemptyComment(call.Comment()) { + return true + } + for _, arg := range call.List { + if isNonemptyComment(arg.Comment()) { + return true + } + } + return false +} + +// cleanUnusedLoads removes symbols from load statements that are not used in the file. +// It also cleans symbols loaded multiple times, sorts symbol list, and removes load +// statements when the list is empty. +func cleanUnusedLoads(f *build.File) bool { + // If the file needs preprocessing, leave it alone. + for _, stmt := range f.Stmt { + if _, ok := stmt.(*build.PythonBlock); ok { + return false + } + } + symbols := UsedSymbols(f) + fixed := false + + var all []build.Expr + for _, stmt := range f.Stmt { + rule, ok := ExprToRule(stmt, "load") + if !ok || len(rule.Call.List) == 0 || hasComment(rule.Call) { + all = append(all, stmt) + continue + } + var args []build.Expr + for _, arg := range rule.Call.List[1:] { // first argument is the path, we keep it + symbol, ok := loadedSymbol(arg) + if !ok || symbols[symbol] { + args = append(args, arg) + if ok { + // If the same symbol is loaded twice, we'll remove it. + delete(symbols, symbol) + } + } else { + fixed = true + } + } + if len(args) > 0 { // Keep the load statement if it loads at least one symbol. + li := &build.ListExpr{List: args} + build.SortStringList(li) + rule.Call.List = append(rule.Call.List[:1], li.List...) + all = append(all, rule.Call) + } else { + fixed = true + } + } + f.Stmt = all + return fixed +} + +// loadedSymbol parses the symbol token from a load statement argument, +// supporting aliases. +func loadedSymbol(arg build.Expr) (string, bool) { + symbol, ok := arg.(*build.StringExpr) + if ok { + return symbol.Value, ok + } + // try an aliased symbol + if binExpr, ok := arg.(*build.BinaryExpr); ok && binExpr.Op == "=" { + if keyExpr, ok := binExpr.X.(*build.LiteralExpr); ok { + return keyExpr.Token, ok + } + } + return "", false +} + +// movePackageDeclarationToTheTop ensures that the call to package() is done +// before everything else (except comments). +func movePackageDeclarationToTheTop(f *build.File) bool { + pkg := ExistingPackageDeclaration(f) + if pkg == nil { + return false + } + all := []build.Expr{} + inserted := false // true when the package declaration has been inserted + for _, stmt := range f.Stmt { + _, isComment := stmt.(*build.CommentBlock) + _, isBinaryExpr := stmt.(*build.BinaryExpr) // e.g. variable declaration + _, isLoad := ExprToRule(stmt, "load") + if isComment || isBinaryExpr || isLoad { + all = append(all, stmt) + continue + } + if stmt == pkg.Call { + if inserted { + // remove the old package + continue + } + return false // the file was ok + } + if !inserted { + all = append(all, pkg.Call) + inserted = true + } + all = append(all, stmt) + } + f.Stmt = all + return true +} + +// moveToPackage is an auxilliary function used by moveLicensesAndDistribs. +// The function shouldn't appear more than once in the file (depot cleanup has +// been done). +func moveToPackage(f *build.File, attrname string) bool { + var all []build.Expr + fixed := false + for _, stmt := range f.Stmt { + rule, ok := ExprToRule(stmt, attrname) + if !ok || len(rule.Call.List) != 1 { + all = append(all, stmt) + continue + } + pkgDecl := PackageDeclaration(f) + pkgDecl.SetAttr(attrname, rule.Call.List[0]) + pkgDecl.AttrDefn(attrname).Comments = *stmt.Comment() + fixed = true + } + f.Stmt = all + return fixed +} + +// moveLicensesAndDistribs replaces the 'licenses' and 'distribs' functions +// with an attribute in package. +// Before: licenses(["notice"]) +// After: package(licenses = ["notice"]) +func moveLicensesAndDistribs(f *build.File) bool { + fixed1 := moveToPackage(f, "licenses") + fixed2 := moveToPackage(f, "distribs") + return fixed1 || fixed2 +} + +// AllRuleFixes is a list of all Buildozer fixes that can be applied on a rule. +var AllRuleFixes = []struct { + Name string + Fn func(file *build.File, rule *build.Rule, pkg string) bool + Message string +}{ + {"sortGlob", sortGlob, + "Sort the list in a call to glob"}, + {"splitOptions", splitOptionsWithSpaces, + "Each option should be given separately in the list"}, + {"shortenLabels", shortenLabels, + "Style: Use the canonical label notation"}, + {"removeVisibility", removeVisibility, + "This visibility attribute is useless (it corresponds to the default value)"}, + {"removeTestOnly", removeTestOnly, + "This testonly attribute is useless (it corresponds to the default value)"}, + {"genruleRenameDepsTools", genruleRenameDepsTools, + "'deps' attribute in genrule has been renamed 'tools'"}, + {"genruleFixHeuristicLabels", genruleFixHeuristicLabels, + "$(location) should be called explicitely"}, + {"sortExportsFiles", sortExportsFiles, + "Files in exports_files should be sorted"}, + {"varref", removeVarref, + "All varref('foo') should be replaced with '$foo'"}, + {"mergeLiteralLists", mergeLiteralLists, + "Remove useless list concatenation"}, +} + +// FileLevelFixes is a list of all Buildozer fixes that apply on the whole file. +var FileLevelFixes = []struct { + Name string + Fn func(file *build.File) bool + Message string +}{ + {"movePackageToTop", movePackageDeclarationToTheTop, + "The package declaration should be the first rule in a file"}, + {"usePlusEqual", usePlusEqual, + "Prefer '+=' over 'extend' or 'append'"}, + {"unusedLoads", cleanUnusedLoads, + "Remove unused symbols from load statements"}, + {"moveLicensesAndDistribs", moveLicensesAndDistribs, + "Move licenses and distribs to the package function"}, +} + +// FixRule aims to fix errors in BUILD files, remove deprecated features, and +// simplify the code. +func FixRule(f *build.File, pkg string, rule *build.Rule, fixes []string) *build.File { + fixesAsMap := make(map[string]bool) + for _, fix := range fixes { + fixesAsMap[fix] = true + } + fixed := false + for _, fix := range AllRuleFixes { + if len(fixes) == 0 || fixesAsMap[fix.Name] { + fixed = fix.Fn(f, rule, pkg) || fixed + } + } + if !fixed { + return nil + } + return f +} + +// FixFile fixes everything it can in the BUILD file. +func FixFile(f *build.File, pkg string, fixes []string) *build.File { + fixesAsMap := make(map[string]bool) + for _, fix := range fixes { + fixesAsMap[fix] = true + } + fixed := false + for _, rule := range f.Rules("") { + res := FixRule(f, pkg, rule, fixes) + if res != nil { + fixed = true + f = res + } + } + for _, fix := range FileLevelFixes { + if len(fixes) == 0 || fixesAsMap[fix.Name] { + fixed = fix.Fn(f) || fixed + } + } + if !fixed { + return nil + } + return f +} diff --git a/vendor/github.com/bazelbuild/buildtools/edit/types.go b/vendor/github.com/bazelbuild/buildtools/edit/types.go new file mode 100644 index 00000000000..2b55328ac71 --- /dev/null +++ b/vendor/github.com/bazelbuild/buildtools/edit/types.go @@ -0,0 +1,59 @@ +/* +Copyright 2016 Google Inc. All Rights Reserved. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +// Type information for attributes. + +package edit + +import ( + buildpb "github.com/bazelbuild/buildtools/build_proto" + "github.com/bazelbuild/buildtools/lang" +) + +var typeOf = lang.TypeOf + +// IsList returns true for all attributes whose type is a list. +func IsList(attr string) bool { + ty := typeOf[attr] + return ty == buildpb.Attribute_STRING_LIST || + ty == buildpb.Attribute_LABEL_LIST || + ty == buildpb.Attribute_OUTPUT_LIST || + ty == buildpb.Attribute_FILESET_ENTRY_LIST || + ty == buildpb.Attribute_INTEGER_LIST || + ty == buildpb.Attribute_LICENSE || + ty == buildpb.Attribute_DISTRIBUTION_SET +} + +// IsIntList returns true for all attributes whose type is an int list. +func IsIntList(attr string) bool { + return typeOf[attr] == buildpb.Attribute_INTEGER_LIST +} + +// IsString returns true for all attributes whose type is a string or a label. +func IsString(attr string) bool { + ty := typeOf[attr] + return ty == buildpb.Attribute_LABEL || + ty == buildpb.Attribute_STRING || + ty == buildpb.Attribute_OUTPUT +} + +// IsStringDict returns true for all attributes whose type is a string dictionary. +func IsStringDict(attr string) bool { + return typeOf[attr] == buildpb.Attribute_STRING_DICT +} + +// ContainsLabels returns true for all attributes whose type is a label or a label list. +func ContainsLabels(attr string) bool { + ty := typeOf[attr] + return ty == buildpb.Attribute_LABEL_LIST || + ty == buildpb.Attribute_LABEL +} diff --git a/vendor/github.com/bazelbuild/buildtools/file/BUILD b/vendor/github.com/bazelbuild/buildtools/file/BUILD new file mode 100644 index 00000000000..574f1f56e2f --- /dev/null +++ b/vendor/github.com/bazelbuild/buildtools/file/BUILD @@ -0,0 +1,23 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["file.go"], + importmap = "k8s.io/kubernetes/vendor/github.com/bazelbuild/buildtools/file", + importpath = "github.com/bazelbuild/buildtools/file", + visibility = ["//visibility:public"], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/vendor/github.com/bazelbuild/buildtools/file/file.go b/vendor/github.com/bazelbuild/buildtools/file/file.go new file mode 100644 index 00000000000..a311099b184 --- /dev/null +++ b/vendor/github.com/bazelbuild/buildtools/file/file.go @@ -0,0 +1,48 @@ +/* +Copyright 2016 Google Inc. All Rights Reserved. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +// Package file provides utility file operations. +package file + +import ( + "fmt" + "io" + "io/ioutil" + "os" +) + +// ReadFile is like ioutil.ReadFile. +func ReadFile(name string) ([]byte, os.FileInfo, error) { + fi, err := os.Stat(name) + if err != nil { + return nil, nil, err + } + + data, err := ioutil.ReadFile(name) + return data, fi, err +} + +// WriteFile is like ioutil.WriteFile +func WriteFile(name string, data []byte) error { + return ioutil.WriteFile(name, data, 0644) +} + +// OpenReadFile is like os.Open. +func OpenReadFile(name string) io.ReadCloser { + f, err := os.Open(name) + if err != nil { + fmt.Fprintf(os.Stderr, "Could not open %s\n", name) + os.Exit(1) + } + return f +} diff --git a/vendor/github.com/bazelbuild/buildtools/lang/BUILD b/vendor/github.com/bazelbuild/buildtools/lang/BUILD new file mode 100644 index 00000000000..684538930e6 --- /dev/null +++ b/vendor/github.com/bazelbuild/buildtools/lang/BUILD @@ -0,0 +1,24 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["tables.gen.go"], + importmap = "k8s.io/kubernetes/vendor/github.com/bazelbuild/buildtools/lang", + importpath = "github.com/bazelbuild/buildtools/lang", + visibility = ["//visibility:public"], + deps = ["//vendor/github.com/bazelbuild/buildtools/build_proto:go_default_library"], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/vendor/github.com/bazelbuild/buildtools/lang/build-language.pb b/vendor/github.com/bazelbuild/buildtools/lang/build-language.pb new file mode 100644 index 0000000000000000000000000000000000000000..d046e8187c6d75eec95fb0b420a66a8b201ed787 GIT binary patch literal 30512 zcmeHQOK&7s6`pQC+CJk)PtD7jhnbm#Ab}Do0U~7wLJ%aREC{TN>guw)#?@7odf09j z2$4uESg-)Z1{4HH>_B1zYnFttK(IiHSnvao0tzdL_|AP*RX;t>cyL*@bKhIO)%SHC z-}%mI`t2HBj(QJWyXS{aGO~!4Lucr9+dG%6Yea{B>i7J>&qm#qol6heYc1;vUG95v z;<--dN1=ES|CBlVDL-Ou(OTxESri7N?w0(#=Q&xPc(VT~+IFL1jDPM0o_*wJgYK#r zxozE~O+1w)zMFY{JBv&Q#teMd3sa1-F30Tq{9rHbuHp0NX&GNB70*Y-o# z4*XssCWX)X@29-u*h~DO7iLaii>d3bEezvij(RQ6w8Jk6F*ErUTbSMQF~3!RzD}1h z*JRX-oTOhgU!`@-B+3&P-&jApOV==5?($mn?a6*DH@|)u^}V3@uN~TQ($vdrthWh$ukAE;M6gNa|2TPa%2jMe^%M(pWU+CQ-O5^VBOlpN?yxq9R|2lkY%E)lo( zM_47j!^?wyQhdW3w2^toS&rqbv}4z>2|?ahJ8#hjk5p;9Oe<~_XJ+6u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z$L^DL%TbdT6TvNEjMXVTA zvSV2|&U%J+&Gt#?KgU;uG+|^(aDO@Uj~wzoXVPSXk;&Nwij4p~8 zAicn>LyO*R>0bhnmEvn@hu~c4QoiEK7BT!^wrE9=GtPe9PxBK8U@4d)u`<{48)UJX zJYDS;-1rl#P27uVbza^@RCio7*78i8g(hIx55zJf$5P#0yb$o^>x% z(gEolgAtMmdK-kn&`(|ct1n#b(%1&DF-5gZ6pvE%S^39CI5UR%<}g`BuX#U8&vJth zSOTl~8W;eOD9Sd&(-AbY{W zIG-9}k@kj(F$_`0EA&y_W(AvrTwj0-#=BwF*Lon>T;*nZdxgd<+&Z#y8^GbQ0uHm) zgj-b$XH&j+qU6#^wFCXAEyTg=xmVX8uVPbTUS0}>WeSeJX9OT;1q0eZ#XXj#u=Jo` z*>`~tB7`*LvX;Ywxhl9&Cf-?3VfPpa>-cdavk1y~kRp=ZYOJCUw_BDV7dXfVOA3}% z^`C2L`aXFnIc`-xfkND~W!HpQf$0eBK+*?`Qq?Gwzp0@HX0iI>0K9{ow-WYK%l%&@ zTOQeM!B4MYO@Q>s5Z}kE%Hj3|&Q>fS{d0+`HOS94b>lQn_#%_*;xWM=EkSGnvTqX5 zP&D4_i%ax0tqGhT#`#Q)pWZ_nB|`0WMw=I1v?m^HU$9m57S_D@;f7iYx6=`MO`VNJ zEA$F&oGe6z#hV*;`aO^aVS@?2IP}lMdfH&$YL_h4_ggIM%QXA3--4{>{?D%+P*fhB gUWIBFC%=+hI+21hhp9c4-YMQ)n21UoReAsa1D6mz$N&HU literal 0 HcmV?d00001 diff --git a/vendor/github.com/bazelbuild/buildtools/lang/tables.gen.go b/vendor/github.com/bazelbuild/buildtools/lang/tables.gen.go new file mode 100755 index 00000000000..f91ef181cd3 --- /dev/null +++ b/vendor/github.com/bazelbuild/buildtools/lang/tables.gen.go @@ -0,0 +1,245 @@ +// Generated file, do not edit. +package lang + +import buildpb "github.com/bazelbuild/buildtools/build_proto" + +var TypeOf = map[string]buildpb.Attribute_Discriminator{ + "aar": buildpb.Attribute_LABEL, + "actual": buildpb.Attribute_LABEL, + "aliases": buildpb.Attribute_STRING_LIST, + "all_files": buildpb.Attribute_LABEL, + "alwayslink": buildpb.Attribute_BOOLEAN, + "app_asset_catalogs": buildpb.Attribute_LABEL_LIST, + "app_bundle_id": buildpb.Attribute_STRING, + "app_deps": buildpb.Attribute_LABEL_LIST, + "app_entitlements": buildpb.Attribute_LABEL, + "app_icon": buildpb.Attribute_STRING, + "app_infoplists": buildpb.Attribute_LABEL_LIST, + "app_name": buildpb.Attribute_STRING, + "app_provisioning_profile": buildpb.Attribute_LABEL, + "app_resources": buildpb.Attribute_LABEL_LIST, + "app_storyboards": buildpb.Attribute_LABEL_LIST, + "app_strings": buildpb.Attribute_LABEL_LIST, + "app_structured_resources": buildpb.Attribute_LABEL_LIST, + "archives": buildpb.Attribute_LABEL_LIST, + "args": buildpb.Attribute_STRING_LIST, + "artifact": buildpb.Attribute_STRING, + "asset_catalogs": buildpb.Attribute_LABEL_LIST, + "assets": buildpb.Attribute_LABEL_LIST, + "assets_dir": buildpb.Attribute_STRING, + "avoid_deps": buildpb.Attribute_LABEL_LIST, + "binary": buildpb.Attribute_LABEL, + "binary_type": buildpb.Attribute_STRING, + "blacklisted_protos": buildpb.Attribute_LABEL_LIST, + "bootclasspath": buildpb.Attribute_LABEL_LIST, + "build_file": buildpb.Attribute_STRING, + "build_file_content": buildpb.Attribute_STRING, + "bundle_id": buildpb.Attribute_STRING, + "bundle_imports": buildpb.Attribute_LABEL_LIST, + "bundle_loader": buildpb.Attribute_LABEL, + "bundles": buildpb.Attribute_LABEL_LIST, + "classpath_resources": buildpb.Attribute_LABEL_LIST, + "cmd": buildpb.Attribute_STRING, + "command_line": buildpb.Attribute_STRING, + "commit": buildpb.Attribute_STRING, + "compatible_with": buildpb.Attribute_LABEL_LIST, + "compiler_files": buildpb.Attribute_LABEL, + "constraints": buildpb.Attribute_STRING_LIST, + "copts": buildpb.Attribute_STRING_LIST, + "cpu": buildpb.Attribute_STRING, + "create_executable": buildpb.Attribute_BOOLEAN, + "crunch_png": buildpb.Attribute_BOOLEAN, + "custom_package": buildpb.Attribute_STRING, + "data": buildpb.Attribute_LABEL_LIST, + "datamodels": buildpb.Attribute_LABEL_LIST, + "default": buildpb.Attribute_LABEL, + "default_copts": buildpb.Attribute_STRING_LIST, + "default_deprecation": buildpb.Attribute_STRING, + "default_hdrs_check": buildpb.Attribute_STRING, + "default_ios_sdk_version": buildpb.Attribute_STRING, + "default_macosx_sdk_version": buildpb.Attribute_STRING, + "default_python_version": buildpb.Attribute_STRING, + "default_testonly": buildpb.Attribute_BOOLEAN, + "default_tvos_sdk_version": buildpb.Attribute_STRING, + "default_visibility": buildpb.Attribute_STRING_LIST, + "default_watchos_sdk_version": buildpb.Attribute_STRING, + "defines": buildpb.Attribute_STRING_LIST, + "densities": buildpb.Attribute_STRING_LIST, + "deploy_manifest_lines": buildpb.Attribute_STRING_LIST, + "deprecation": buildpb.Attribute_STRING, + "deps": buildpb.Attribute_LABEL_LIST, + "dex_shards": buildpb.Attribute_INTEGER, + "dexopts": buildpb.Attribute_STRING_LIST, + "distribs": buildpb.Attribute_DISTRIBUTION_SET, + "dwp_files": buildpb.Attribute_LABEL, + "dylibs": buildpb.Attribute_LABEL_LIST, + "dynamic_runtime_libs": buildpb.Attribute_LABEL_LIST, + "enable_modules": buildpb.Attribute_BOOLEAN, + "encoding": buildpb.Attribute_STRING, + "entitlements": buildpb.Attribute_LABEL, + "entry_classes": buildpb.Attribute_STRING_LIST, + "executable": buildpb.Attribute_BOOLEAN, + "exported_plugins": buildpb.Attribute_LABEL_LIST, + "exports": buildpb.Attribute_LABEL_LIST, + "exports_manifest": buildpb.Attribute_BOOLEAN, + "expression": buildpb.Attribute_STRING, + "ext_bundle_id": buildpb.Attribute_STRING, + "ext_entitlements": buildpb.Attribute_LABEL, + "ext_families": buildpb.Attribute_STRING_LIST, + "ext_infoplists": buildpb.Attribute_LABEL_LIST, + "ext_provisioning_profile": buildpb.Attribute_LABEL, + "ext_resources": buildpb.Attribute_LABEL_LIST, + "ext_strings": buildpb.Attribute_LABEL_LIST, + "ext_structured_resources": buildpb.Attribute_LABEL_LIST, + "extclasspath": buildpb.Attribute_LABEL_LIST, + "extensions": buildpb.Attribute_LABEL_LIST, + "extra_actions": buildpb.Attribute_LABEL_LIST, + "extra_srcs": buildpb.Attribute_LABEL_LIST, + "families": buildpb.Attribute_STRING_LIST, + "features": buildpb.Attribute_STRING_LIST, + "flaky": buildpb.Attribute_BOOLEAN, + "framework_imports": buildpb.Attribute_LABEL_LIST, + "genclass": buildpb.Attribute_LABEL_LIST, + "generates_api": buildpb.Attribute_BOOLEAN, + "hdrs": buildpb.Attribute_LABEL_LIST, + "header_compiler": buildpb.Attribute_LABEL_LIST, + "heuristic_label_expansion": buildpb.Attribute_BOOLEAN, + "idl_import_root": buildpb.Attribute_STRING, + "idl_parcelables": buildpb.Attribute_LABEL_LIST, + "idl_srcs": buildpb.Attribute_LABEL_LIST, + "ijar": buildpb.Attribute_LABEL_LIST, + "imports": buildpb.Attribute_STRING_LIST, + "includes": buildpb.Attribute_STRING_LIST, + "incremental_dexing": buildpb.Attribute_TRISTATE, + "infoplist": buildpb.Attribute_LABEL, + "infoplists": buildpb.Attribute_LABEL_LIST, + "init_submodules": buildpb.Attribute_BOOLEAN, + "ios_device_arg": buildpb.Attribute_STRING_LIST, + "ios_test_target_device": buildpb.Attribute_LABEL, + "ios_version": buildpb.Attribute_STRING, + "ipa_post_processor": buildpb.Attribute_LABEL, + "is_dynamic": buildpb.Attribute_BOOLEAN, + "jars": buildpb.Attribute_LABEL_LIST, + "javabuilder": buildpb.Attribute_LABEL_LIST, + "javac": buildpb.Attribute_LABEL_LIST, + "javac_supports_workers": buildpb.Attribute_BOOLEAN, + "javacopts": buildpb.Attribute_STRING_LIST, + "jre_deps": buildpb.Attribute_LABEL_LIST, + "jvm_flags": buildpb.Attribute_STRING_LIST, + "jvm_opts": buildpb.Attribute_STRING_LIST, + "launch_image": buildpb.Attribute_STRING, + "launch_storyboard": buildpb.Attribute_LABEL, + "launcher": buildpb.Attribute_LABEL, + "licenses": buildpb.Attribute_LICENSE, + "linker_files": buildpb.Attribute_LABEL, + "linkopts": buildpb.Attribute_STRING_LIST, + "linkshared": buildpb.Attribute_BOOLEAN, + "linkstamp": buildpb.Attribute_LABEL, + "linkstatic": buildpb.Attribute_BOOLEAN, + "local": buildpb.Attribute_BOOLEAN, + "main": buildpb.Attribute_LABEL, + "main_class": buildpb.Attribute_STRING, + "main_dex_list": buildpb.Attribute_LABEL, + "main_dex_list_opts": buildpb.Attribute_STRING_LIST, + "main_dex_proguard_specs": buildpb.Attribute_LABEL_LIST, + "malloc": buildpb.Attribute_LABEL, + "manifest": buildpb.Attribute_LABEL, + "manifest_merger": buildpb.Attribute_STRING, + "manifest_values": buildpb.Attribute_STRING_DICT, + "message": buildpb.Attribute_STRING, + "misc": buildpb.Attribute_STRING_LIST, + "mnemonics": buildpb.Attribute_STRING_LIST, + "module_map": buildpb.Attribute_LABEL, + "multidex": buildpb.Attribute_STRING, + "name": buildpb.Attribute_STRING, + "neverlink": buildpb.Attribute_BOOLEAN, + "nocompress_extensions": buildpb.Attribute_STRING_LIST, + "nocopts": buildpb.Attribute_STRING, + "non_arc_srcs": buildpb.Attribute_LABEL_LIST, + "non_propagated_deps": buildpb.Attribute_LABEL_LIST, + "objcopy_files": buildpb.Attribute_LABEL, + "options_file": buildpb.Attribute_LABEL, + "opts": buildpb.Attribute_STRING_LIST, + "out": buildpb.Attribute_STRING, + "out_templates": buildpb.Attribute_STRING_LIST, + "output_group": buildpb.Attribute_STRING, + "output_licenses": buildpb.Attribute_LICENSE, + "output_to_bindir": buildpb.Attribute_BOOLEAN, + "outs": buildpb.Attribute_STRING_LIST, + "path": buildpb.Attribute_STRING, + "pch": buildpb.Attribute_LABEL, + "per_proto_includes": buildpb.Attribute_BOOLEAN, + "platform_type": buildpb.Attribute_STRING, + "plugin": buildpb.Attribute_LABEL, + "plugins": buildpb.Attribute_LABEL_LIST, + "portable_proto_filters": buildpb.Attribute_LABEL_LIST, + "prefix": buildpb.Attribute_STRING, + "processor_class": buildpb.Attribute_STRING, + "proguard_apply_mapping": buildpb.Attribute_LABEL, + "proguard_generate_mapping": buildpb.Attribute_BOOLEAN, + "proguard_specs": buildpb.Attribute_LABEL_LIST, + "provisioning_profile": buildpb.Attribute_LABEL, + "pytype_deps": buildpb.Attribute_LABEL_LIST, + "remote": buildpb.Attribute_STRING, + "repository": buildpb.Attribute_STRING, + "require_defined_version": buildpb.Attribute_BOOLEAN, + "requires_action_output": buildpb.Attribute_BOOLEAN, + "resource_configuration_filters": buildpb.Attribute_STRING_LIST, + "resource_files": buildpb.Attribute_LABEL_LIST, + "resource_strip_prefix": buildpb.Attribute_STRING, + "resources": buildpb.Attribute_LABEL_LIST, + "restricted_to": buildpb.Attribute_LABEL_LIST, + "runtime": buildpb.Attribute_LABEL, + "runtime_deps": buildpb.Attribute_LABEL_LIST, + "scope": buildpb.Attribute_LABEL_LIST, + "sdk_dylibs": buildpb.Attribute_STRING_LIST, + "sdk_frameworks": buildpb.Attribute_STRING_LIST, + "sdk_includes": buildpb.Attribute_STRING_LIST, + "server": buildpb.Attribute_STRING, + "settings_file": buildpb.Attribute_STRING, + "sha1": buildpb.Attribute_STRING, + "sha256": buildpb.Attribute_STRING, + "shard_count": buildpb.Attribute_INTEGER, + "singlejar": buildpb.Attribute_LABEL_LIST, + "size": buildpb.Attribute_STRING, + "source_version": buildpb.Attribute_STRING, + "srcjar": buildpb.Attribute_LABEL, + "srcs": buildpb.Attribute_LABEL_LIST, + "srcs_version": buildpb.Attribute_STRING, + "stamp": buildpb.Attribute_TRISTATE, + "static_runtime_libs": buildpb.Attribute_LABEL_LIST, + "storyboards": buildpb.Attribute_LABEL_LIST, + "strict": buildpb.Attribute_BOOLEAN, + "strings": buildpb.Attribute_LABEL_LIST, + "strip": buildpb.Attribute_BOOLEAN, + "strip_files": buildpb.Attribute_LABEL, + "strip_prefix": buildpb.Attribute_STRING, + "structured_resources": buildpb.Attribute_LABEL_LIST, + "supports_header_parsing": buildpb.Attribute_BOOLEAN, + "supports_param_files": buildpb.Attribute_BOOLEAN, + "tag": buildpb.Attribute_STRING, + "tags": buildpb.Attribute_STRING_LIST, + "target_device": buildpb.Attribute_LABEL, + "target_version": buildpb.Attribute_STRING, + "test_class": buildpb.Attribute_STRING, + "testonly": buildpb.Attribute_BOOLEAN, + "tests": buildpb.Attribute_LABEL_LIST, + "textual_hdrs": buildpb.Attribute_LABEL_LIST, + "timeout": buildpb.Attribute_STRING, + "toolchains": buildpb.Attribute_LABEL_LIST, + "tools": buildpb.Attribute_LABEL_LIST, + "type": buildpb.Attribute_STRING, + "url": buildpb.Attribute_STRING, + "use_objc_header_names": buildpb.Attribute_BOOLEAN, + "use_testrunner": buildpb.Attribute_BOOLEAN, + "values": buildpb.Attribute_STRING_DICT, + "version": buildpb.Attribute_STRING, + "versions": buildpb.Attribute_LABEL_LIST, + "visibility": buildpb.Attribute_STRING_LIST, + "weak_sdk_frameworks": buildpb.Attribute_STRING_LIST, + "xcode": buildpb.Attribute_LABEL, + "xctest": buildpb.Attribute_BOOLEAN, + "xctest_app": buildpb.Attribute_LABEL, + "xibs": buildpb.Attribute_LABEL_LIST, + "xlint": buildpb.Attribute_STRING_LIST, +} diff --git a/vendor/github.com/bazelbuild/buildtools/wspace/BUILD b/vendor/github.com/bazelbuild/buildtools/wspace/BUILD new file mode 100644 index 00000000000..8deb2e44fe3 --- /dev/null +++ b/vendor/github.com/bazelbuild/buildtools/wspace/BUILD @@ -0,0 +1,24 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["workspace.go"], + importmap = "k8s.io/kubernetes/vendor/github.com/bazelbuild/buildtools/wspace", + importpath = "github.com/bazelbuild/buildtools/wspace", + visibility = ["//visibility:public"], + deps = ["//vendor/github.com/bazelbuild/buildtools/build:go_default_library"], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/vendor/github.com/bazelbuild/buildtools/wspace/workspace.go b/vendor/github.com/bazelbuild/buildtools/wspace/workspace.go new file mode 100644 index 00000000000..5680d5874fa --- /dev/null +++ b/vendor/github.com/bazelbuild/buildtools/wspace/workspace.go @@ -0,0 +1,114 @@ +/* +Copyright 2016 Google Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +// Package wspace provides a method to find the root of the bazel tree. +package wspace + +import ( + "io/ioutil" + "os" + "path/filepath" + "strings" + + "github.com/bazelbuild/buildtools/build" +) + +const workspaceFile = "WORKSPACE" + +func alwaysTrue(fi os.FileInfo) bool { + return true +} + +var repoRootFiles = map[string]func(os.FileInfo) bool{ + workspaceFile: alwaysTrue, + ".buckconfig": alwaysTrue, + "pants": func(fi os.FileInfo) bool { + return fi.Mode()&os.ModeType == 0 && fi.Mode()&0100 == 0100 + }, +} + +// findContextPath finds the context path inside of a WORKSPACE-rooted source tree. +func findContextPath(rootDir string) (string, error) { + if rootDir == "" { + return os.Getwd() + } + return rootDir, nil +} + +// FindWorkspaceRoot splits the current code context (the rootDir if present, +// the working directory if not.) It returns the path of the directory +// containing the WORKSPACE file, and the rest. +func FindWorkspaceRoot(rootDir string) (root string, rest string) { + wd, err := findContextPath(rootDir) + if err != nil { + return "", "" + } + if root, err = Find(wd); err != nil { + return "", "" + } + if len(wd) == len(root) { + return root, "" + } + return root, wd[len(root)+1:] +} + +// Find searches from the given dir and up for the WORKSPACE file +// returning the directory containing it, or an error if none found in the tree. +func Find(dir string) (string, error) { + if dir == "" || dir == "/" || dir == "." { + return "", os.ErrNotExist + } + for repoRootFile, fiFunc := range repoRootFiles { + if fi, err := os.Stat(filepath.Join(dir, repoRootFile)); err == nil && fiFunc(fi) { + return dir, nil + } else if !os.IsNotExist(err) { + return "", err + } + } + return Find(filepath.Dir(dir)) +} + +// FindRepoBuildFiles parses the WORKSPACE to find BUILD files for non-Bazel +// external repositories, specifically those defined by one of these rules: +// new_local_repository(), new_git_repository(), new_http_archive() +func FindRepoBuildFiles(root string) (map[string]string, error) { + ws := filepath.Join(root, workspaceFile) + kinds := []string{ + "new_local_repository", + "new_git_repository", + "new_http_archive", + } + data, err := ioutil.ReadFile(ws) + if err != nil { + return nil, err + } + ast, err := build.Parse(ws, data) + if err != nil { + return nil, err + } + files := make(map[string]string) + for _, kind := range kinds { + for _, r := range ast.Rules(kind) { + buildFile := r.AttrString("build_file") + if buildFile == "" { + continue + } + buildFile = strings.Replace(buildFile, ":", "/", -1) + files[r.Name()] = filepath.Join(root, buildFile) + } + } + return files, nil +} From cb68f3edf9dd24a2aaa7d369f412b7be28165cb0 Mon Sep 17 00:00:00 2001 From: Benjamin Elder Date: Tue, 12 Feb 2019 18:02:22 -0800 Subject: [PATCH 3/5] autotag vendor as manual in update-bazel --- hack/update-bazel.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hack/update-bazel.sh b/hack/update-bazel.sh index 7ee5131105b..b6ae73146bf 100755 --- a/hack/update-bazel.sh +++ b/hack/update-bazel.sh @@ -26,6 +26,7 @@ PATH="${GOBIN}:${PATH}" # Install tools we need, but only from vendor/... go install k8s.io/kubernetes/vendor/github.com/bazelbuild/bazel-gazelle/cmd/gazelle +go install k8s.io/kubernetes/vendor/github.com/bazelbuild/buildtools/buildozer go install k8s.io/kubernetes/vendor/k8s.io/repo-infra/kazel touch "${KUBE_ROOT}/vendor/BUILD" @@ -43,3 +44,11 @@ gazelle fix \ "${KUBE_ROOT}" kazel + +# make targets in vendor manual +# buildozer exits 3 when no changes are made ¯\_(ツ)_/¯ +# https://github.com/bazelbuild/buildtools/tree/master/buildozer#error-code +buildozer -quiet 'add tags manual' '//vendor/...:%go_binary' '//vendor/...:%go_test' && ret=$? || ret=$? +if [[ $ret != 0 && $ret != 3 ]]; then + exit 1 +fi From 91ddb093b8691f0b2632ea9dd828eb33aa360467 Mon Sep 17 00:00:00 2001 From: Benjamin Elder Date: Tue, 12 Feb 2019 18:21:18 -0800 Subject: [PATCH 4/5] run hack/update-bazel.sh --- vendor/github.com/bazelbuild/bazel-gazelle/cmd/gazelle/BUILD | 1 + vendor/github.com/bazelbuild/buildtools/buildozer/BUILD | 1 + vendor/github.com/cespare/prettybench/BUILD | 1 + vendor/github.com/client9/misspell/cmd/misspell/BUILD | 1 + vendor/github.com/cloudflare/cfssl/cmd/cfssl/BUILD | 1 + vendor/github.com/cloudflare/cfssl/cmd/cfssljson/BUILD | 1 + vendor/github.com/jstemmer/go-junit-report/BUILD | 1 + vendor/github.com/jteeuwen/go-bindata/go-bindata/BUILD | 1 + vendor/github.com/onsi/ginkgo/ginkgo/BUILD | 1 + vendor/golang.org/x/lint/golint/BUILD | 1 + vendor/k8s.io/kube-openapi/cmd/openapi-gen/BUILD | 1 + vendor/k8s.io/repo-infra/kazel/BUILD | 1 + 12 files changed, 12 insertions(+) diff --git a/vendor/github.com/bazelbuild/bazel-gazelle/cmd/gazelle/BUILD b/vendor/github.com/bazelbuild/bazel-gazelle/cmd/gazelle/BUILD index 5ae277b7643..28779390bfc 100644 --- a/vendor/github.com/bazelbuild/bazel-gazelle/cmd/gazelle/BUILD +++ b/vendor/github.com/bazelbuild/bazel-gazelle/cmd/gazelle/BUILD @@ -35,6 +35,7 @@ go_library( go_binary( name = "gazelle", embed = [":go_default_library"], + tags = ["manual"], visibility = ["//visibility:public"], ) diff --git a/vendor/github.com/bazelbuild/buildtools/buildozer/BUILD b/vendor/github.com/bazelbuild/buildtools/buildozer/BUILD index ad212a63ae7..1a68b760328 100644 --- a/vendor/github.com/bazelbuild/buildtools/buildozer/BUILD +++ b/vendor/github.com/bazelbuild/buildtools/buildozer/BUILD @@ -15,6 +15,7 @@ go_library( go_binary( name = "buildozer", embed = [":go_default_library"], + tags = ["manual"], visibility = ["//visibility:public"], ) diff --git a/vendor/github.com/cespare/prettybench/BUILD b/vendor/github.com/cespare/prettybench/BUILD index 399021cae77..2dd6a282298 100644 --- a/vendor/github.com/cespare/prettybench/BUILD +++ b/vendor/github.com/cespare/prettybench/BUILD @@ -12,6 +12,7 @@ go_library( go_binary( name = "prettybench", embed = [":go_default_library"], + tags = ["manual"], visibility = ["//visibility:public"], ) diff --git a/vendor/github.com/client9/misspell/cmd/misspell/BUILD b/vendor/github.com/client9/misspell/cmd/misspell/BUILD index cabd8d0614a..dc5bc396918 100644 --- a/vendor/github.com/client9/misspell/cmd/misspell/BUILD +++ b/vendor/github.com/client9/misspell/cmd/misspell/BUILD @@ -12,6 +12,7 @@ go_library( go_binary( name = "misspell", embed = [":go_default_library"], + tags = ["manual"], visibility = ["//visibility:public"], ) diff --git a/vendor/github.com/cloudflare/cfssl/cmd/cfssl/BUILD b/vendor/github.com/cloudflare/cfssl/cmd/cfssl/BUILD index 0318b1e72aa..91b703f302f 100644 --- a/vendor/github.com/cloudflare/cfssl/cmd/cfssl/BUILD +++ b/vendor/github.com/cloudflare/cfssl/cmd/cfssl/BUILD @@ -36,6 +36,7 @@ go_library( go_binary( name = "cfssl", embed = [":go_default_library"], + tags = ["manual"], visibility = ["//visibility:public"], ) diff --git a/vendor/github.com/cloudflare/cfssl/cmd/cfssljson/BUILD b/vendor/github.com/cloudflare/cfssl/cmd/cfssljson/BUILD index e0804f2400e..b5f19dd5f83 100644 --- a/vendor/github.com/cloudflare/cfssl/cmd/cfssljson/BUILD +++ b/vendor/github.com/cloudflare/cfssl/cmd/cfssljson/BUILD @@ -12,6 +12,7 @@ go_library( go_binary( name = "cfssljson", embed = [":go_default_library"], + tags = ["manual"], visibility = ["//visibility:public"], ) diff --git a/vendor/github.com/jstemmer/go-junit-report/BUILD b/vendor/github.com/jstemmer/go-junit-report/BUILD index 72b9407c871..6e0bce9e535 100644 --- a/vendor/github.com/jstemmer/go-junit-report/BUILD +++ b/vendor/github.com/jstemmer/go-junit-report/BUILD @@ -15,6 +15,7 @@ go_library( go_binary( name = "go-junit-report", embed = [":go_default_library"], + tags = ["manual"], visibility = ["//visibility:public"], ) diff --git a/vendor/github.com/jteeuwen/go-bindata/go-bindata/BUILD b/vendor/github.com/jteeuwen/go-bindata/go-bindata/BUILD index ddf9138a253..b6260250451 100644 --- a/vendor/github.com/jteeuwen/go-bindata/go-bindata/BUILD +++ b/vendor/github.com/jteeuwen/go-bindata/go-bindata/BUILD @@ -16,6 +16,7 @@ go_library( go_binary( name = "go-bindata", embed = [":go_default_library"], + tags = ["manual"], visibility = ["//visibility:public"], ) diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/BUILD b/vendor/github.com/onsi/ginkgo/ginkgo/BUILD index 1c76cef8697..6d5c4eeee04 100644 --- a/vendor/github.com/onsi/ginkgo/ginkgo/BUILD +++ b/vendor/github.com/onsi/ginkgo/ginkgo/BUILD @@ -37,6 +37,7 @@ go_library( go_binary( name = "ginkgo", embed = [":go_default_library"], + tags = ["manual"], visibility = ["//visibility:public"], ) diff --git a/vendor/golang.org/x/lint/golint/BUILD b/vendor/golang.org/x/lint/golint/BUILD index 28d1384cca3..2f4b66435a0 100644 --- a/vendor/golang.org/x/lint/golint/BUILD +++ b/vendor/golang.org/x/lint/golint/BUILD @@ -16,6 +16,7 @@ go_library( go_binary( name = "golint", embed = [":go_default_library"], + tags = ["manual"], visibility = ["//visibility:public"], ) diff --git a/vendor/k8s.io/kube-openapi/cmd/openapi-gen/BUILD b/vendor/k8s.io/kube-openapi/cmd/openapi-gen/BUILD index 89bd7b5b1a2..596ae2dc683 100644 --- a/vendor/k8s.io/kube-openapi/cmd/openapi-gen/BUILD +++ b/vendor/k8s.io/kube-openapi/cmd/openapi-gen/BUILD @@ -17,6 +17,7 @@ go_library( go_binary( name = "openapi-gen", embed = [":go_default_library"], + tags = ["manual"], visibility = ["//visibility:public"], ) diff --git a/vendor/k8s.io/repo-infra/kazel/BUILD b/vendor/k8s.io/repo-infra/kazel/BUILD index c033f44643f..3b5c1cb21ab 100644 --- a/vendor/k8s.io/repo-infra/kazel/BUILD +++ b/vendor/k8s.io/repo-infra/kazel/BUILD @@ -21,6 +21,7 @@ go_library( go_binary( name = "kazel", embed = [":go_default_library"], + tags = ["manual"], visibility = ["//visibility:public"], ) From 14ff4625d0c0197636e4c326ce91cb74df6fbb98 Mon Sep 17 00:00:00 2001 From: Benjamin Elder Date: Tue, 12 Feb 2019 18:22:28 -0800 Subject: [PATCH 5/5] fix csi-api filegroup --- staging/src/k8s.io/csi-api/pkg/crd/BUILD | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/staging/src/k8s.io/csi-api/pkg/crd/BUILD b/staging/src/k8s.io/csi-api/pkg/crd/BUILD index 71a403cd573..8571f80248b 100644 --- a/staging/src/k8s.io/csi-api/pkg/crd/BUILD +++ b/staging/src/k8s.io/csi-api/pkg/crd/BUILD @@ -12,8 +12,8 @@ go_test( name = "go_default_test", srcs = ["crd_test.go"], data = [ + ":csi-manifests", "//cluster/addons:addon-srcs", - "//staging/src/k8s.io/csi-api/pkg/crd:manifests", ], embed = [":go_default_library"], deps = ["//staging/src/k8s.io/apimachinery/pkg/util/diff:go_default_library"], @@ -28,9 +28,7 @@ filegroup( filegroup( name = "csi-manifests", - srcs = [ - "//staging/src/k8s.io/csi-api/pkg/crd:manifests", - ], + srcs = glob(["manifests/**"]), visibility = ["//visibility:public"], )