1# Copyright 2022 Google LLC 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# https://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 15load("//sandboxed_api/bazel:build_defs.bzl", "sapi_platform_copts") 16 17licenses(["notice"]) 18 19cc_library( 20 name = "generator", 21 srcs = [ 22 "diagnostics.cc", 23 "emitter.cc", 24 "generator.cc", 25 "types.cc", 26 ], 27 hdrs = [ 28 "diagnostics.h", 29 "emitter.h", 30 "generator.h", 31 "types.h", 32 ], 33 copts = sapi_platform_copts(), 34 deps = [ 35 "//sandboxed_api/util:status", 36 "@com_google_absl//absl/container:flat_hash_set", 37 "@com_google_absl//absl/container:node_hash_set", 38 "@com_google_absl//absl/random", 39 "@com_google_absl//absl/status", 40 "@com_google_absl//absl/status:statusor", 41 "@com_google_absl//absl/strings", 42 "@com_google_absl//absl/strings:cord", 43 "@com_google_absl//absl/strings:str_format", 44 "@com_google_absl//absl/types:optional", 45 "@llvm-project//clang:ast", 46 "@llvm-project//clang:basic", 47 "@llvm-project//clang:format", 48 "@llvm-project//clang:frontend", 49 "@llvm-project//clang:lex", 50 "@llvm-project//clang:tooling", 51 "@llvm-project//llvm:Support", 52 ], 53) 54 55cc_test( 56 name = "generator_test", 57 srcs = [ 58 "emitter_test.cc", 59 "frontend_action_test_util.cc", 60 "frontend_action_test_util.h", 61 ], 62 copts = sapi_platform_copts(), 63 deps = [ 64 ":generator", 65 "//sandboxed_api/util:status_matchers", 66 "@com_google_absl//absl/container:flat_hash_map", 67 "@com_google_absl//absl/memory", 68 "@com_google_absl//absl/status", 69 "@com_google_absl//absl/status:statusor", 70 "@com_google_absl//absl/strings", 71 "@com_google_googletest//:gtest_main", 72 "@llvm-project//clang:basic", 73 "@llvm-project//clang:frontend", 74 "@llvm-project//clang:tooling", 75 "@llvm-project//llvm:Support", 76 ], 77) 78 79# Clang tool that generates Sandboxed API headers 80cc_binary( 81 name = "generator_tool", 82 srcs = [ 83 "compilation_database.cc", 84 "compilation_database.h", 85 "generator_tool.cc", 86 ], 87 copts = sapi_platform_copts(), 88 visibility = ["//visibility:public"], 89 deps = [ 90 ":generator", 91 "//sandboxed_api/util:file_base", 92 "//sandboxed_api/util:file_helpers", 93 "//sandboxed_api/util:fileops", 94 "//sandboxed_api/util:status", 95 "@com_google_absl//absl/status", 96 "@com_google_absl//absl/status:statusor", 97 "@com_google_absl//absl/strings", 98 "@com_google_absl//absl/strings:str_format", 99 "@llvm-project//clang:driver", 100 "@llvm-project//clang:tooling", 101 "@llvm-project//llvm:Support", 102 ], 103) 104