blob: 298a6cc7a6c270c8c838d2c08f2bd06639755074 [file] [log] [blame]
Christopher Wiley89eaab52015-09-15 14:46:46 -07001/*
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 Moreland9fccf582018-08-27 20:36:27 -070017#pragma once
Christopher Wiley89e35862015-08-30 10:57:07 -070018
Christopher Wiley632801d2015-11-05 14:15:49 -080019#include <limits>
Christopher Wiley90be4e32015-10-20 14:55:25 -070020#include <memory>
21#include <string>
22#include <vector>
23
Casey Dahlin2cc93162015-10-02 16:14:17 -070024#include "aidl_language.h"
Jiyong Park02da7422018-07-16 16:00:26 +090025#include "import_resolver.h"
Christopher Wiley4a2884b2015-10-07 11:27:45 -070026#include "io_delegate.h"
Christopher Wiley89e35862015-08-30 10:57:07 -070027#include "options.h"
28
Christopher Wileyfdeb0f42015-09-11 15:38:22 -070029namespace android {
30namespace aidl {
31
Christopher Wiley632801d2015-11-05 14:15:49 -080032enum 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 Park3656c3c2018-08-01 20:02:01 +090042 BAD_INPUT,
Steven Moreland1eac5fa2018-08-27 19:35:05 -070043 NOT_STRUCTURED,
Christopher Wiley632801d2015-11-05 14:15:49 -080044
45 OK = 0,
46};
47
Jiyong Parkb034bf02018-07-30 17:44:33 +090048int compile_aidl(const Options& options, const IoDelegate& io_delegate);
Jiyong Park74595c12018-07-23 15:22:50 +090049bool preprocess_aidl(const Options& options, const IoDelegate& io_delegate);
50bool dump_api(const Options& options, const IoDelegate& io_delegate);
Andrei Onea8714b022019-02-01 18:55:54 +000051bool dump_mappings(const Options& options, const IoDelegate& io_delegate);
Christopher Wiley89e35862015-08-30 10:57:07 -070052
Paul Trautrimb5ff1a22020-02-27 13:10:16 +090053const 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 Park309668e2018-07-28 16:55:44 +090073const string kGetInterfaceVersion("getInterfaceVersion");
Paul Trautrim66f00962020-01-21 16:39:32 +090074const string kGetInterfaceHash("getInterfaceHash");
Jiyong Park309668e2018-07-28 16:55:44 +090075
Casey Dahlin2cc93162015-10-02 16:14:17 -070076namespace internals {
77
Jiyong Parkfbbfa932018-07-30 21:44:10 +090078AidlError load_and_validate_aidl(const std::string& input_file_name, const Options& options,
Jeongik Cha047c5ee2019-08-07 23:16:49 +090079 const IoDelegate& io_delegate, AidlTypenames* typenames,
Jiyong Parkb034bf02018-07-30 17:44:33 +090080 vector<AidlDefinedType*>* defined_types,
81 vector<string>* imported_files);
Casey Dahlin2cc93162015-10-02 16:14:17 -070082
Jiyong Park1deecc32018-07-17 01:14:41 +090083bool parse_preprocessed_file(const IoDelegate& io_delegate, const std::string& filename,
Jeongik Cha047c5ee2019-08-07 23:16:49 +090084 AidlTypenames* typenames);
Christopher Wileyef140932015-11-03 09:29:19 -080085
Casey Dahlin2cc93162015-10-02 16:14:17 -070086} // namespace internals
87
Christopher Wileyfdeb0f42015-09-11 15:38:22 -070088} // namespace aidl
Steven Morelandf4c64df2019-07-29 19:54:04 -070089} // namespace android