1# Copyright 2018 The Bazel Authors. All rights reserved. 2# 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 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 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. 14 15"""Starlark rules for building C++ projects.""" 16 17# load("//cc/private/rules_impl:cc_flags_supplier.bzl", _cc_flags_supplier = "cc_flags_supplier") 18# load("//cc/private/rules_impl:compiler_flag.bzl", _compiler_flag = "compiler_flag") 19 20_MIGRATION_TAG = "__CC_RULES_MIGRATION_DO_NOT_USE_WILL_BREAK__" 21 22def _add_tags(attrs): 23 if "tags" in attrs and attrs["tags"] != None: 24 attrs["tags"] = attrs["tags"] + [_MIGRATION_TAG] 25 else: 26 attrs["tags"] = [_MIGRATION_TAG] 27 return attrs 28 29def cc_binary(**attrs): 30 """Bazel cc_binary rule. 31 32 https://docs.bazel.build/versions/master/be/c-cpp.html#cc_binary 33 34 Args: 35 **attrs: Rule attributes 36 """ 37 38 # buildifier: disable=native-cc 39 native.cc_binary(**_add_tags(attrs)) 40 41def cc_test(**attrs): 42 """Bazel cc_test rule. 43 44 https://docs.bazel.build/versions/master/be/c-cpp.html#cc_test 45 46 Args: 47 **attrs: Rule attributes 48 """ 49 50 # buildifier: disable=native-cc 51 native.cc_test(**_add_tags(attrs)) 52 53def cc_library(**attrs): 54 """Bazel cc_library rule. 55 56 https://docs.bazel.build/versions/master/be/c-cpp.html#cc_library 57 58 Args: 59 **attrs: Rule attributes 60 """ 61 62 # buildifier: disable=native-cc 63 native.cc_library(**_add_tags(attrs)) 64 65def cc_import(**attrs): 66 """Bazel cc_import rule. 67 68 https://docs.bazel.build/versions/master/be/c-cpp.html#cc_import 69 70 Args: 71 **attrs: Rule attributes 72 """ 73 74 # buildifier: disable=native-cc 75 native.cc_import(**_add_tags(attrs)) 76 77def cc_proto_library(**attrs): 78 """Bazel cc_proto_library rule. 79 80 https://docs.bazel.build/versions/master/be/c-cpp.html#cc_proto_library 81 82 Args: 83 **attrs: Rule attributes 84 """ 85 86 # buildifier: disable=native-cc 87 native.cc_proto_library(**_add_tags(attrs)) 88 89def fdo_prefetch_hints(**attrs): 90 """Bazel fdo_prefetch_hints rule. 91 92 https://docs.bazel.build/versions/master/be/c-cpp.html#fdo_prefetch_hints 93 94 Args: 95 **attrs: Rule attributes 96 """ 97 98 # buildifier: disable=native-cc 99 native.fdo_prefetch_hints(**_add_tags(attrs)) 100 101def fdo_profile(**attrs): 102 """Bazel fdo_profile rule. 103 104 https://docs.bazel.build/versions/master/be/c-cpp.html#fdo_profile 105 106 Args: 107 **attrs: Rule attributes 108 """ 109 110 # buildifier: disable=native-cc 111 native.fdo_profile(**_add_tags(attrs)) 112 113def cc_toolchain(**attrs): 114 """Bazel cc_toolchain rule. 115 116 https://docs.bazel.build/versions/master/be/c-cpp.html#cc_toolchain 117 118 Args: 119 **attrs: Rule attributes 120 """ 121 122 # buildifier: disable=native-cc 123 native.cc_toolchain(**_add_tags(attrs)) 124 125def cc_toolchain_suite(**attrs): 126 """Bazel cc_toolchain_suite rule. 127 128 https://docs.bazel.build/versions/master/be/c-cpp.html#cc_toolchain_suite 129 130 Args: 131 **attrs: Rule attributes 132 """ 133 134 # buildifier: disable=native-cc 135 native.cc_toolchain_suite(**_add_tags(attrs)) 136 137def objc_library(**attrs): 138 """Bazel objc_library rule. 139 140 https://docs.bazel.build/versions/master/be/objective-c.html#objc_library 141 142 Args: 143 **attrs: Rule attributes 144 """ 145 146 # buildifier: disable=native-cc 147 native.objc_library(**_add_tags(attrs)) 148 149def objc_import(**attrs): 150 """Bazel objc_import rule. 151 152 https://docs.bazel.build/versions/master/be/objective-c.html#objc_import 153 154 Args: 155 **attrs: Rule attributes 156 """ 157 158 # buildifier: disable=native-cc 159 native.objc_import(**_add_tags(attrs)) 160 161# def cc_flags_supplier(**attrs): 162# """Bazel cc_flags_supplier rule. 163 164# Args: 165# **attrs: Rule attributes 166# """ 167# _cc_flags_supplier(**_add_tags(attrs)) 168 169# def compiler_flag(**attrs): 170# """Bazel compiler_flag rule. 171 172# Args: 173# **attrs: Rule attributes 174# """ 175# _compiler_flag(**_add_tags(attrs)) 176