Christopher Wiley | 89eaab5 | 2015-09-15 14:46:46 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015, The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Steven Moreland | 9fccf58 | 2018-08-27 20:36:27 -0700 | [diff] [blame] | 17 | #pragma once |
Christopher Wiley | 89e3586 | 2015-08-30 10:57:07 -0700 | [diff] [blame] | 18 | |
Christopher Wiley | 632801d | 2015-11-05 14:15:49 -0800 | [diff] [blame] | 19 | #include <limits> |
Christopher Wiley | 90be4e3 | 2015-10-20 14:55:25 -0700 | [diff] [blame] | 20 | #include <memory> |
| 21 | #include <string> |
| 22 | #include <vector> |
| 23 | |
Casey Dahlin | 2cc9316 | 2015-10-02 16:14:17 -0700 | [diff] [blame] | 24 | #include "aidl_language.h" |
Jiyong Park | 02da742 | 2018-07-16 16:00:26 +0900 | [diff] [blame] | 25 | #include "import_resolver.h" |
Christopher Wiley | 4a2884b | 2015-10-07 11:27:45 -0700 | [diff] [blame] | 26 | #include "io_delegate.h" |
Christopher Wiley | 89e3586 | 2015-08-30 10:57:07 -0700 | [diff] [blame] | 27 | #include "options.h" |
| 28 | |
Christopher Wiley | fdeb0f4 | 2015-09-11 15:38:22 -0700 | [diff] [blame] | 29 | namespace android { |
| 30 | namespace aidl { |
| 31 | |
Christopher Wiley | 632801d | 2015-11-05 14:15:49 -0800 | [diff] [blame] | 32 | enum class AidlError { |
| 33 | UNKOWN = std::numeric_limits<int32_t>::min(), |
| 34 | BAD_PRE_PROCESSED_FILE, |
| 35 | PARSE_ERROR, |
| 36 | FOUND_PARCELABLE, |
| 37 | BAD_PACKAGE, |
| 38 | BAD_IMPORT, |
| 39 | BAD_TYPE, |
| 40 | BAD_METHOD_ID, |
| 41 | GENERATION_ERROR, |
Jiyong Park | 3656c3c | 2018-08-01 20:02:01 +0900 | [diff] [blame] | 42 | BAD_INPUT, |
Steven Moreland | 1eac5fa | 2018-08-27 19:35:05 -0700 | [diff] [blame] | 43 | NOT_STRUCTURED, |
Christopher Wiley | 632801d | 2015-11-05 14:15:49 -0800 | [diff] [blame] | 44 | |
| 45 | OK = 0, |
| 46 | }; |
| 47 | |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 48 | int compile_aidl(const Options& options, const IoDelegate& io_delegate); |
Jiyong Park | 74595c1 | 2018-07-23 15:22:50 +0900 | [diff] [blame] | 49 | bool preprocess_aidl(const Options& options, const IoDelegate& io_delegate); |
| 50 | bool dump_api(const Options& options, const IoDelegate& io_delegate); |
Andrei Onea | 8714b02 | 2019-02-01 18:55:54 +0000 | [diff] [blame] | 51 | bool dump_mappings(const Options& options, const IoDelegate& io_delegate); |
Christopher Wiley | 89e3586 | 2015-08-30 10:57:07 -0700 | [diff] [blame] | 52 | |
Paul Trautrim | b5ff1a2 | 2020-02-27 13:10:16 +0900 | [diff] [blame] | 53 | const char kPreamble[] = |
| 54 | R"(/////////////////////////////////////////////////////////////////////////////// |
| 55 | // THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // |
| 56 | /////////////////////////////////////////////////////////////////////////////// |
| 57 | |
| 58 | // This file is a snapshot of an AIDL interface (or parcelable). Do not try to |
| 59 | // edit this file. It looks like you are doing that because you have modified |
| 60 | // an AIDL interface in a backward-incompatible way, e.g., deleting a function |
| 61 | // from an interface or a field from a parcelable and it broke the build. That |
| 62 | // breakage is intended. |
| 63 | // |
| 64 | // You must not make a backward incompatible changes to the AIDL files built |
| 65 | // with the aidl_interface module type with versions property set. The module |
| 66 | // type is used to build AIDL files in a way that they can be used across |
| 67 | // independently updatable components of the system. If a device is shipped |
| 68 | // with such a backward incompatible change, it has a high risk of breaking |
| 69 | // later when a module using the interface is updated, e.g., Mainline modules. |
| 70 | |
| 71 | )"; |
| 72 | |
Jiyong Park | 309668e | 2018-07-28 16:55:44 +0900 | [diff] [blame] | 73 | const string kGetInterfaceVersion("getInterfaceVersion"); |
Paul Trautrim | 66f0096 | 2020-01-21 16:39:32 +0900 | [diff] [blame] | 74 | const string kGetInterfaceHash("getInterfaceHash"); |
Jiyong Park | 309668e | 2018-07-28 16:55:44 +0900 | [diff] [blame] | 75 | |
Casey Dahlin | 2cc9316 | 2015-10-02 16:14:17 -0700 | [diff] [blame] | 76 | namespace internals { |
| 77 | |
Jiyong Park | fbbfa93 | 2018-07-30 21:44:10 +0900 | [diff] [blame] | 78 | AidlError load_and_validate_aidl(const std::string& input_file_name, const Options& options, |
Jeongik Cha | 047c5ee | 2019-08-07 23:16:49 +0900 | [diff] [blame] | 79 | const IoDelegate& io_delegate, AidlTypenames* typenames, |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 80 | vector<AidlDefinedType*>* defined_types, |
| 81 | vector<string>* imported_files); |
Casey Dahlin | 2cc9316 | 2015-10-02 16:14:17 -0700 | [diff] [blame] | 82 | |
Jiyong Park | 1deecc3 | 2018-07-17 01:14:41 +0900 | [diff] [blame] | 83 | bool parse_preprocessed_file(const IoDelegate& io_delegate, const std::string& filename, |
Jeongik Cha | 047c5ee | 2019-08-07 23:16:49 +0900 | [diff] [blame] | 84 | AidlTypenames* typenames); |
Christopher Wiley | ef14093 | 2015-11-03 09:29:19 -0800 | [diff] [blame] | 85 | |
Casey Dahlin | 2cc9316 | 2015-10-02 16:14:17 -0700 | [diff] [blame] | 86 | } // namespace internals |
| 87 | |
Christopher Wiley | fdeb0f4 | 2015-09-11 15:38:22 -0700 | [diff] [blame] | 88 | } // namespace aidl |
Steven Moreland | f4c64df | 2019-07-29 19:54:04 -0700 | [diff] [blame] | 89 | } // namespace android |