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 | |
Steven Moreland | 4e05913 | 2021-08-11 13:36:30 -0700 | [diff] [blame] | 48 | bool compile_aidl(const Options& options, const IoDelegate& io_delegate); |
Andrei Onea | 8714b02 | 2019-02-01 18:55:54 +0000 | [diff] [blame] | 49 | bool dump_mappings(const Options& options, const IoDelegate& io_delegate); |
Christopher Wiley | 89e3586 | 2015-08-30 10:57:07 -0700 | [diff] [blame] | 50 | |
Steven Moreland | 3981d9e | 2020-03-31 14:11:44 -0700 | [diff] [blame] | 51 | // main entry point to AIDL |
| 52 | int aidl_entry(const Options& options, const IoDelegate& io_delegate); |
| 53 | |
Paul Trautrim | b01451d | 2020-02-27 13:10:16 +0900 | [diff] [blame] | 54 | const char kPreamble[] = |
| 55 | R"(/////////////////////////////////////////////////////////////////////////////// |
| 56 | // THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // |
| 57 | /////////////////////////////////////////////////////////////////////////////// |
| 58 | |
Steven Moreland | 348fcdd | 2020-12-23 23:20:56 +0000 | [diff] [blame] | 59 | // This file is a snapshot of an AIDL file. Do not edit it manually. There are |
| 60 | // two cases: |
| 61 | // 1). this is a frozen version file - do not edit this in any case. |
| 62 | // 2). this is a 'current' file. If you make a backwards compatible change to |
| 63 | // the interface (from the latest frozen version), the build system will |
| 64 | // prompt you to update this file with `m <name>-update-api`. |
Paul Trautrim | b01451d | 2020-02-27 13:10:16 +0900 | [diff] [blame] | 65 | // |
Steven Moreland | 348fcdd | 2020-12-23 23:20:56 +0000 | [diff] [blame] | 66 | // You must not make a backward incompatible change to any AIDL file built |
Paul Trautrim | b01451d | 2020-02-27 13:10:16 +0900 | [diff] [blame] | 67 | // with the aidl_interface module type with versions property set. The module |
| 68 | // type is used to build AIDL files in a way that they can be used across |
| 69 | // independently updatable components of the system. If a device is shipped |
| 70 | // with such a backward incompatible change, it has a high risk of breaking |
| 71 | // later when a module using the interface is updated, e.g., Mainline modules. |
| 72 | |
| 73 | )"; |
| 74 | |
Jiyong Park | 309668e | 2018-07-28 16:55:44 +0900 | [diff] [blame] | 75 | const string kGetInterfaceVersion("getInterfaceVersion"); |
Paul Trautrim | b77048c | 2020-01-21 16:39:32 +0900 | [diff] [blame] | 76 | const string kGetInterfaceHash("getInterfaceHash"); |
Jiyong Park | 309668e | 2018-07-28 16:55:44 +0900 | [diff] [blame] | 77 | |
Casey Dahlin | 2cc9316 | 2015-10-02 16:14:17 -0700 | [diff] [blame] | 78 | namespace internals { |
| 79 | |
Jiyong Park | fbbfa93 | 2018-07-30 21:44:10 +0900 | [diff] [blame] | 80 | 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] | 81 | const IoDelegate& io_delegate, AidlTypenames* typenames, |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 82 | vector<string>* imported_files); |
Casey Dahlin | 2cc9316 | 2015-10-02 16:14:17 -0700 | [diff] [blame] | 83 | |
| 84 | } // namespace internals |
| 85 | |
Christopher Wiley | fdeb0f4 | 2015-09-11 15:38:22 -0700 | [diff] [blame] | 86 | } // namespace aidl |
Steven Moreland | f4c64df | 2019-07-29 19:54:04 -0700 | [diff] [blame] | 87 | } // namespace android |