diff --git a/upb/bindings/lua/BUILD b/upb/bindings/lua/BUILD.bazel similarity index 100% rename from upb/bindings/lua/BUILD rename to upb/bindings/lua/BUILD.bazel diff --git a/upb/bindings/lua/lua_proto_library.bzl b/upb/bindings/lua/lua_proto_library.bzl index 3f34fc18a1..24dfdd6047 100644 --- a/upb/bindings/lua/lua_proto_library.bzl +++ b/upb/bindings/lua/lua_proto_library.bzl @@ -23,12 +23,12 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"""lua_proto_library(): a rule for building Lua protos.""" + load("@bazel_skylib//lib:paths.bzl", "paths") # Generic support code ######################################################### -_is_bazel = not hasattr(native, "genmpm") - def _get_real_short_path(file): # For some reason, files from other archives have short paths that look like: # ../com_google_protobuf/google/protobuf/descriptor.proto @@ -57,7 +57,10 @@ def _generate_output_file(ctx, src, extension): # upb_proto_library / upb_proto_reflection_library shared code ################# -_LuaFiles = provider(fields = ["files"]) +_LuaFilesInfo = provider( + "A set of lua files generated from .proto files", + fields = ["files"], +) def _compile_upb_protos(ctx, proto_info, proto_sources): files = [_generate_output_file(ctx, name, "_pb.lua") for name in proto_sources] @@ -84,9 +87,9 @@ def _lua_proto_rule_impl(ctx): if len(ctx.attr.deps) != 1: fail("only one deps dependency allowed.") dep = ctx.attr.deps[0] - if _LuaFiles not in dep: - fail("proto_library rule must generate _LuaFiles (aspect should have handled this).") - files = dep[_LuaFiles].files + if _LuaFilesInfo not in dep: + fail("proto_library rule must generate _LuaFilesInfo (aspect should have handled this).") + files = dep[_LuaFilesInfo].files return [ DefaultInfo( files = files, @@ -98,8 +101,8 @@ def _lua_proto_library_aspect_impl(target, ctx): proto_info = target[ProtoInfo] files = _compile_upb_protos(ctx, proto_info, proto_info.direct_sources) deps = ctx.rule.attr.deps - transitive = [dep[_LuaFiles].files for dep in deps if _LuaFiles in dep] - return [_LuaFiles(files = depset(direct = files, transitive = transitive))] + transitive = [dep[_LuaFilesInfo].files for dep in deps if _LuaFilesInfo in dep] + return [_LuaFilesInfo(files = depset(direct = files, transitive = transitive))] # lua_proto_library() ########################################################## @@ -117,7 +120,7 @@ _lua_proto_library_aspect = aspect( ), }, implementation = _lua_proto_library_aspect_impl, - provides = [_LuaFiles], + provides = [_LuaFilesInfo], attr_aspects = ["deps"], fragments = ["cpp"], ) diff --git a/upb/bindings/lua/test.proto b/upb/bindings/lua/test.proto index c751436016..fafa753cfc 100644 --- a/upb/bindings/lua/test.proto +++ b/upb/bindings/lua/test.proto @@ -3,7 +3,7 @@ syntax = "proto2"; import "google/protobuf/timestamp.proto"; -package upb_test; +package upb_lua_test; message MapTest { map<string, double> map_string_double = 1; diff --git a/upb/bindings/lua/upbc.cc b/upb/bindings/lua/upbc.cc index 0793922861..78e1473a7e 100644 --- a/upb/bindings/lua/upbc.cc +++ b/upb/bindings/lua/upbc.cc @@ -23,15 +23,14 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include <google/protobuf/compiler/plugin.h> -#include <google/protobuf/io/printer.h> - +#include "google/protobuf/compiler/code_generator.h" +#include "google/protobuf/compiler/plugin.h" +#include "google/protobuf/io/printer.h" +#include "google/protobuf/descriptor.pb.h" +#include "google/protobuf/descriptor.h" #include "absl/strings/str_replace.h" #include "absl/strings/string_view.h" #include "absl/strings/substitute.h" -#include "google/protobuf/compiler/code_generator.h" -#include "google/protobuf/descriptor.h" -#include "google/protobuf/descriptor.pb.h" namespace protoc = ::google::protobuf::compiler; namespace protobuf = ::google::protobuf;