kythe.io@v0.0.68-0.20240422202219-7225dbc01741/tools/build_rules/extra_aspects/cxx/rules.bzl (about) 1 # Copyright 2023 The Kythe 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 """C++ extraction rules.""" 16 17 load(":aspect.bzl", "KytheCxxCompilationInfo", "extract_cxx_aspect") 18 19 _EXTRACTION_SETTINGS = { 20 # We don't want and can't use module maps for extraction/indexing. 21 "//command_line_option:features": ["-use_module_maps", "-module_maps"], 22 } 23 24 def _cc_extract_kzip_impl(ctx): 25 return [ 26 DefaultInfo(files = depset(transitive = [ 27 d[KytheCxxCompilationInfo].kzips 28 for d in ctx.attr.deps 29 if KytheCxxCompilationInfo in d and d[KytheCxxCompilationInfo].kzips 30 ])), 31 ] 32 33 def _transition_impl(settings, attr): 34 if not attr.disable_modules: 35 return None 36 return _EXTRACTION_SETTINGS 37 38 _transition = transition( 39 implementation = _transition_impl, 40 inputs = [], 41 outputs = _EXTRACTION_SETTINGS.keys(), 42 ) 43 44 cc_extract_kzip = rule( 45 implementation = _cc_extract_kzip_impl, 46 attrs = { 47 "deps": attr.label_list( 48 mandatory = True, 49 aspects = [extract_cxx_aspect], 50 ), 51 "disable_modules": attr.bool( 52 default = True, 53 ), 54 "_allowlist_function_transition": attr.label( 55 default = "@bazel_tools//tools/allowlists/function_transition_allowlist", 56 ), 57 }, 58 cfg = _transition, 59 )