1# Copyright (c) 2009-2021, Google LLC 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions are met: 6# * Redistributions of source code must retain the above copyright 7# notice, this list of conditions and the following disclaimer. 8# * Redistributions in binary form must reproduce the above copyright 9# notice, this list of conditions and the following disclaimer in the 10# documentation and/or other materials provided with the distribution. 11# * Neither the name of Google LLC nor the 12# names of its contributors may be used to endorse or promote products 13# derived from this software without specific prior written permission. 14# 15# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY 19# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 26load( 27 "//bazel:build_defs.bzl", 28 "UPB_DEFAULT_COPTS", 29 "UPB_DEFAULT_CPPOPTS", 30) 31load( 32 "//lua:lua_proto_library.bzl", 33 "lua_proto_library", 34) 35 36licenses(["notice"]) 37 38cc_library( 39 name = "lupb", 40 srcs = [ 41 "def.c", 42 "msg.c", 43 "upb.c", 44 ], 45 hdrs = [ 46 "upb.h", 47 ], 48 copts = UPB_DEFAULT_COPTS, 49 visibility = ["//visibility:public"], 50 deps = [ 51 "//:json", 52 "//:reflection", 53 "//:textformat", 54 "//:upb", 55 "@lua//:liblua", 56 ], 57) 58 59cc_binary( 60 name = "protoc-gen-lua", 61 srcs = ["upbc.cc"], 62 copts = UPB_DEFAULT_CPPOPTS, 63 visibility = ["//visibility:public"], 64 deps = [ 65 "@com_google_absl//absl/strings", 66 "@com_google_protobuf//src/google/protobuf/compiler:code_generator", 67 ], 68) 69 70exports_files(["upb.lua"]) 71 72cc_test( 73 name = "test_lua", 74 srcs = ["main.c"], 75 copts = UPB_DEFAULT_COPTS, 76 data = [ 77 "test_upb.lua", 78 ":descriptor_proto_lua", 79 ":empty_proto_lua", 80 ":test_messages_proto2_proto_lua", 81 ":test_messages_proto3_proto_lua", 82 ":test_proto_lua", 83 "//:third_party/lunit/console.lua", 84 "//:third_party/lunit/lunit.lua", 85 "//lua:upb.lua", 86 "@com_google_protobuf//:descriptor_proto", 87 "@com_google_protobuf//conformance:conformance_proto", 88 ], 89 linkstatic = 1, 90 deps = [ 91 "//lua:lupb", 92 "@lua//:liblua", 93 ], 94) 95 96proto_library( 97 name = "test_proto", 98 testonly = 1, 99 srcs = ["test.proto"], 100 deps = ["@com_google_protobuf//:timestamp_proto"], 101) 102 103lua_proto_library( 104 name = "test_proto_lua", 105 testonly = 1, 106 deps = [":test_proto"], 107) 108 109lua_proto_library( 110 name = "descriptor_proto_lua", 111 deps = ["@com_google_protobuf//:descriptor_proto"], 112) 113 114lua_proto_library( 115 name = "empty_proto_lua", 116 deps = ["@com_google_protobuf//:empty_proto"], 117) 118 119lua_proto_library( 120 name = "test_messages_proto3_proto_lua", 121 testonly = 1, 122 deps = ["@com_google_protobuf//src/google/protobuf:test_messages_proto3_proto"], 123) 124 125lua_proto_library( 126 name = "test_messages_proto2_proto_lua", 127 testonly = 1, 128 deps = ["@com_google_protobuf//src/google/protobuf:test_messages_proto2_proto"], 129) 130