blob: 2d15c0649dc08cd8de39ec3bbdb6b4d36be1bf41 [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
Steven Moreland4e059132021-08-11 13:36:30 -070048bool compile_aidl(const Options& options, const IoDelegate& io_delegate);
Andrei Onea8714b022019-02-01 18:55:54 +000049bool dump_mappings(const Options& options, const IoDelegate& io_delegate);
Christopher Wiley89e35862015-08-30 10:57:07 -070050
Steven Moreland3981d9e2020-03-31 14:11:44 -070051// main entry point to AIDL
52int aidl_entry(const Options& options, const IoDelegate& io_delegate);
53
Paul Trautrimb01451d2020-02-27 13:10:16 +090054const char kPreamble[] =
55 R"(///////////////////////////////////////////////////////////////////////////////
56// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
57///////////////////////////////////////////////////////////////////////////////
58
Steven Moreland348fcdd2020-12-23 23:20:56 +000059// 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 Trautrimb01451d2020-02-27 13:10:16 +090065//
Steven Moreland348fcdd2020-12-23 23:20:56 +000066// You must not make a backward incompatible change to any AIDL file built
Paul Trautrimb01451d2020-02-27 13:10:16 +090067// 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 Park309668e2018-07-28 16:55:44 +090075const string kGetInterfaceVersion("getInterfaceVersion");
Paul Trautrimb77048c2020-01-21 16:39:32 +090076const string kGetInterfaceHash("getInterfaceHash");
Jiyong Park309668e2018-07-28 16:55:44 +090077
Casey Dahlin2cc93162015-10-02 16:14:17 -070078namespace internals {
79
Jiyong Parkfbbfa932018-07-30 21:44:10 +090080AidlError load_and_validate_aidl(const std::string& input_file_name, const Options& options,
Jeongik Cha047c5ee2019-08-07 23:16:49 +090081 const IoDelegate& io_delegate, AidlTypenames* typenames,
Jiyong Parkb034bf02018-07-30 17:44:33 +090082 vector<string>* imported_files);
Casey Dahlin2cc93162015-10-02 16:14:17 -070083
84} // namespace internals
85
Christopher Wileyfdeb0f42015-09-11 15:38:22 -070086} // namespace aidl
Steven Morelandf4c64df2019-07-29 19:54:04 -070087} // namespace android