Jan Tattermusch | 4d5c310 | 2017-06-07 10:23:56 +0200 | [diff] [blame] | 1 | # Copyright 2016 gRPC authors. |
Craig Tiller | 423ecff | 2016-10-20 09:45:09 -0700 | [diff] [blame] | 2 | # |
Jan Tattermusch | 4d5c310 | 2017-06-07 10:23:56 +0200 | [diff] [blame] | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
Craig Tiller | 423ecff | 2016-10-20 09:45:09 -0700 | [diff] [blame] | 6 | # |
Jan Tattermusch | 4d5c310 | 2017-06-07 10:23:56 +0200 | [diff] [blame] | 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
Craig Tiller | 423ecff | 2016-10-20 09:45:09 -0700 | [diff] [blame] | 8 | # |
Jan Tattermusch | 4d5c310 | 2017-06-07 10:23:56 +0200 | [diff] [blame] | 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
Craig Tiller | 423ecff | 2016-10-20 09:45:09 -0700 | [diff] [blame] | 14 | |
Nicolas "Pixel" Noble | e8dbd8a | 2016-10-20 18:54:36 +0200 | [diff] [blame] | 15 | # |
| 16 | # This is for the gRPC build system. This isn't intended to be used outsite of |
| 17 | # the BUILD file for gRPC. It contains the mapping for the template system we |
| 18 | # use to generate other platform's build system files. |
| 19 | # |
Craig Tiller | f66de6e | 2017-05-15 08:29:10 -0700 | [diff] [blame] | 20 | # Please consider that there should be a high bar for additions and changes to |
| 21 | # this file. |
| 22 | # Each rule listed must be re-written for Google's internal build system, and |
| 23 | # each change must be ported from one to the other. |
| 24 | # |
Nicolas "Pixel" Noble | e8dbd8a | 2016-10-20 18:54:36 +0200 | [diff] [blame] | 25 | |
Nicolas "Pixel" Noble | 15cd5ce | 2017-04-18 06:32:11 +0200 | [diff] [blame] | 26 | def grpc_cc_library(name, srcs = [], public_hdrs = [], hdrs = [], |
| 27 | external_deps = [], deps = [], standalone = False, |
Ian Coolidge | 6b08cf4 | 2017-06-16 12:56:23 -0700 | [diff] [blame] | 28 | language = "C++", testonly = False, visibility = None, |
| 29 | alwayslink = 0): |
Nicolas "Pixel" Noble | 31d11db | 2016-10-20 09:29:46 +0200 | [diff] [blame] | 30 | copts = [] |
Craig Tiller | 674c66c | 2016-10-20 13:08:52 -0700 | [diff] [blame] | 31 | if language.upper() == "C": |
Nicolas "Pixel" Noble | 31d11db | 2016-10-20 09:29:46 +0200 | [diff] [blame] | 32 | copts = ["-std=c99"] |
| 33 | native.cc_library( |
| 34 | name = name, |
| 35 | srcs = srcs, |
Nicolas "Pixel" Noble | e8dbd8a | 2016-10-20 18:54:36 +0200 | [diff] [blame] | 36 | hdrs = hdrs + public_hdrs, |
| 37 | deps = deps + ["//external:" + dep for dep in external_deps], |
Nicolas "Pixel" Noble | 31d11db | 2016-10-20 09:29:46 +0200 | [diff] [blame] | 38 | copts = copts, |
Nicolas "Pixel" Noble | 15cd5ce | 2017-04-18 06:32:11 +0200 | [diff] [blame] | 39 | visibility = visibility, |
| 40 | testonly = testonly, |
Nicolas "Pixel" Noble | 60ca22f | 2016-10-20 10:23:53 +0200 | [diff] [blame] | 41 | linkopts = ["-pthread"], |
Nicolas "Pixel" Noble | 31d11db | 2016-10-20 09:29:46 +0200 | [diff] [blame] | 42 | includes = [ |
| 43 | "include" |
Ian Coolidge | 6b08cf4 | 2017-06-16 12:56:23 -0700 | [diff] [blame] | 44 | ], |
| 45 | alwayslink = alwayslink, |
Nicolas "Pixel" Noble | 31d11db | 2016-10-20 09:29:46 +0200 | [diff] [blame] | 46 | ) |
Nicolas "Pixel" Noble | 4dc6431 | 2016-10-20 23:07:37 +0200 | [diff] [blame] | 47 | |
| 48 | def grpc_proto_plugin(name, srcs = [], deps = []): |
| 49 | native.cc_binary( |
| 50 | name = name, |
| 51 | srcs = srcs, |
| 52 | deps = deps, |
| 53 | ) |
Nicolas "Pixel" Noble | 799bd5e | 2016-10-21 01:54:32 +0200 | [diff] [blame] | 54 | |
| 55 | load("//:bazel/cc_grpc_library.bzl", "cc_grpc_library") |
| 56 | |
Craig Tiller | a753371 | 2017-05-16 13:09:33 -0700 | [diff] [blame] | 57 | def grpc_proto_library(name, srcs = [], deps = [], well_known_protos = False, |
Mahak Mukhi | 443a75d | 2017-04-14 15:33:55 -0700 | [diff] [blame] | 58 | has_services = True, use_external = False, generate_mock = False): |
Nicolas "Pixel" Noble | 799bd5e | 2016-10-21 01:54:32 +0200 | [diff] [blame] | 59 | cc_grpc_library( |
| 60 | name = name, |
| 61 | srcs = srcs, |
| 62 | deps = deps, |
Makarand Dharmapurikar | e3e3b2a | 2017-03-07 16:12:56 -0800 | [diff] [blame] | 63 | well_known_protos = well_known_protos, |
Nicolas "Pixel" Noble | 799bd5e | 2016-10-21 01:54:32 +0200 | [diff] [blame] | 64 | proto_only = not has_services, |
Makarand Dharmapurikar | 9098fcc | 2017-03-02 17:13:10 -0800 | [diff] [blame] | 65 | use_external = use_external, |
Mahak Mukhi | 443a75d | 2017-04-14 15:33:55 -0700 | [diff] [blame] | 66 | generate_mock = generate_mock, |
Nicolas "Pixel" Noble | 799bd5e | 2016-10-21 01:54:32 +0200 | [diff] [blame] | 67 | ) |
| 68 | |
Nicolas "Pixel" Noble | 15cd5ce | 2017-04-18 06:32:11 +0200 | [diff] [blame] | 69 | def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data = [], language = "C++"): |
Craig Tiller | f66de6e | 2017-05-15 08:29:10 -0700 | [diff] [blame] | 70 | copts = [] |
| 71 | if language.upper() == "C": |
| 72 | copts = ["-std=c99"] |
Nicolas "Pixel" Noble | 7c26eed | 2017-04-13 01:40:54 +0200 | [diff] [blame] | 73 | native.cc_test( |
| 74 | name = name, |
| 75 | srcs = srcs, |
| 76 | args = args, |
| 77 | data = data, |
| 78 | deps = deps + ["//external:" + dep for dep in external_deps], |
Craig Tiller | f66de6e | 2017-05-15 08:29:10 -0700 | [diff] [blame] | 79 | copts = copts, |
Nicolas "Pixel" Noble | 7c26eed | 2017-04-13 01:40:54 +0200 | [diff] [blame] | 80 | linkopts = ["-pthread"], |
| 81 | ) |
| 82 | |
Vijay Pai | 4280725 | 2017-07-28 15:08:24 -0700 | [diff] [blame^] | 83 | def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], data = [], language = "C++", testonly = False, linkshared = False, linkopts = []): |
Nicolas "Pixel" Noble | 15cd5ce | 2017-04-18 06:32:11 +0200 | [diff] [blame] | 84 | copts = [] |
| 85 | if language.upper() == "C": |
| 86 | copts = ["-std=c99"] |
Nicolas "Pixel" Noble | 7c26eed | 2017-04-13 01:40:54 +0200 | [diff] [blame] | 87 | native.cc_binary( |
| 88 | name = name, |
| 89 | srcs = srcs, |
| 90 | args = args, |
| 91 | data = data, |
Nicolas "Pixel" Noble | 15cd5ce | 2017-04-18 06:32:11 +0200 | [diff] [blame] | 92 | testonly = testonly, |
Nicolas "Pixel" Noble | d69f776 | 2017-05-12 17:10:13 +0200 | [diff] [blame] | 93 | linkshared = linkshared, |
Nicolas "Pixel" Noble | 7c26eed | 2017-04-13 01:40:54 +0200 | [diff] [blame] | 94 | deps = deps + ["//external:" + dep for dep in external_deps], |
Nicolas "Pixel" Noble | 15cd5ce | 2017-04-18 06:32:11 +0200 | [diff] [blame] | 95 | copts = copts, |
Vijay Pai | 4280725 | 2017-07-28 15:08:24 -0700 | [diff] [blame^] | 96 | linkopts = ["-pthread"] + linkopts, |
Nicolas "Pixel" Noble | 7c26eed | 2017-04-13 01:40:54 +0200 | [diff] [blame] | 97 | ) |
Nicolas "Pixel" Noble | 2b0f001 | 2017-04-24 19:59:19 +0200 | [diff] [blame] | 98 | |
| 99 | def grpc_generate_one_off_targets(): |
Nicolas "Pixel" Noble | 3dedf65 | 2017-05-24 02:29:02 +0200 | [diff] [blame] | 100 | pass |
Nicolas "Pixel" Noble | 3bd8177 | 2017-04-25 22:23:40 +0200 | [diff] [blame] | 101 | |
| 102 | def grpc_sh_test(name, srcs, args = [], data = []): |
Nicolas "Pixel" Noble | 3dedf65 | 2017-05-24 02:29:02 +0200 | [diff] [blame] | 103 | native.sh_test( |
| 104 | name = name, |
| 105 | srcs = srcs, |
| 106 | args = args, |
| 107 | data = data) |