Googler | 741ed9c | 2021-10-01 08:00:49 +0000 | [diff] [blame] | 1 | // Part of the Crubit project, under the Apache License v2.0 with LLVM |
| 2 | // Exceptions. See /LICENSE for license information. |
| 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 4 | |
| 5 | #ifndef CRUBIT_RS_BINDINGS_FROM_CC_IR_FROM_CC_H_ |
| 6 | #define CRUBIT_RS_BINDINGS_FROM_CC_IR_FROM_CC_H_ |
| 7 | |
Marcel Hlopko | 7aa38a7 | 2021-11-11 07:39:51 +0000 | [diff] [blame] | 8 | #include <string> |
| 9 | |
| 10 | #include "rs_bindings_from_cc/bazel_types.h" |
Googler | 741ed9c | 2021-10-01 08:00:49 +0000 | [diff] [blame] | 11 | #include "rs_bindings_from_cc/ir.h" |
Marcel Hlopko | 7aa38a7 | 2021-11-11 07:39:51 +0000 | [diff] [blame] | 12 | #include "third_party/absl/container/flat_hash_map.h" |
Michael Forster | 3f323be | 2021-10-11 07:13:28 +0000 | [diff] [blame] | 13 | #include "third_party/absl/status/statusor.h" |
Googler | 741ed9c | 2021-10-01 08:00:49 +0000 | [diff] [blame] | 14 | #include "third_party/absl/strings/string_view.h" |
| 15 | #include "third_party/absl/types/span.h" |
| 16 | |
| 17 | namespace rs_bindings_from_cc { |
| 18 | |
Devin Jeanpierre | df4dc8b | 2021-10-21 12:53:19 +0000 | [diff] [blame] | 19 | // Parses C++ source code into IR. |
| 20 | // |
| 21 | // Parameters: |
Marcel Hlopko | 7aa38a7 | 2021-11-11 07:39:51 +0000 | [diff] [blame] | 22 | // * `extra_source_code`: C++ source code to be written into a virtual header |
| 23 | // and included in binding generation. Intended for testing only. |
| 24 | // * `current_target`: full label of the target for which we generate bindings. |
| 25 | // If not specified `//test:testing_target` is used. |
| 26 | // * `public_headers`: names of headers from which we build the Clang AST. If |
| 27 | // `extra_source_code` is specified its header will be added automatically. |
| 28 | // * `virtual_headers_contents`: names and contents of virtual headers that |
| 29 | // will be created in the virtual filesystem. These headers have to be |
| 30 | // manually added to `public_headers` if needed. |
| 31 | // * `headers_to_targets`: mapping of headers to the label of the owning target. |
| 32 | // If `extra_source_code` is specified it's added automatically under |
| 33 | // `//test:testing_target`. Headers from `virtual_headers_contents` are not |
| 34 | // added automatically. |
Devin Jeanpierre | df4dc8b | 2021-10-21 12:53:19 +0000 | [diff] [blame] | 35 | // * `args`: additional command line arguments for Clang |
| 36 | // |
Michael Forster | 3f323be | 2021-10-11 07:13:28 +0000 | [diff] [blame] | 37 | absl::StatusOr<IR> IrFromCc( |
Marcel Hlopko | 7aa38a7 | 2021-11-11 07:39:51 +0000 | [diff] [blame] | 38 | absl::string_view extra_source_code, |
Googler | e05154d | 2022-01-10 08:39:03 +0000 | [diff] [blame] | 39 | BlazeLabel current_target = BlazeLabel{"//test:testing_target"}, |
Marcel Hlopko | 7aa38a7 | 2021-11-11 07:39:51 +0000 | [diff] [blame] | 40 | absl::Span<const HeaderName> public_headers = {}, |
| 41 | absl::flat_hash_map<const HeaderName, const std::string> |
| 42 | virtual_headers_contents = {}, |
Googler | e05154d | 2022-01-10 08:39:03 +0000 | [diff] [blame] | 43 | absl::flat_hash_map<const HeaderName, const BlazeLabel> headers_to_targets = |
| 44 | {}, |
Michael Forster | 3f323be | 2021-10-11 07:13:28 +0000 | [diff] [blame] | 45 | absl::Span<const absl::string_view> args = {}); |
Googler | 741ed9c | 2021-10-01 08:00:49 +0000 | [diff] [blame] | 46 | |
| 47 | } // namespace rs_bindings_from_cc |
| 48 | |
| 49 | #endif // CRUBIT_RS_BINDINGS_FROM_CC_IR_FROM_CC_H_ |