blob: 35178cf553ce92f3e3272dc42cdf344c1ccf282f [file] [log] [blame]
Jiyong Park74595c12018-07-23 15:22:50 +09001/*
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
17#include "aidl.h"
18#include "io_delegate.h"
19#include "logging.h"
20#include "options.h"
21
22#include <iostream>
Steven Morelandbb654e32020-01-08 19:52:05 -080023
Steven Moreland3981d9e2020-03-31 14:11:44 -070024using android::aidl::Options;
25
Steven Morelandbb654e32020-01-08 19:52:05 -080026#ifdef AIDL_CPP_BUILD
27constexpr Options::Language kDefaultLang = Options::Language::CPP;
28#else
29constexpr Options::Language kDefaultLang = Options::Language::JAVA;
30#endif
Jiyong Park74595c12018-07-23 15:22:50 +090031
Steven Morelandfdb57cd2020-01-08 20:03:30 -080032int main(int argc, char* argv[]) {
33 android::base::InitLogging(argv);
34 LOG(DEBUG) << "aidl starting";
35
36 Options options(argc, argv, kDefaultLang);
37 if (!options.Ok()) {
38 std::cerr << options.GetErrorMessage();
39 std::cerr << options.GetUsage();
40 return 1;
41 }
42
Steven Moreland3981d9e2020-03-31 14:11:44 -070043 // Only minimal functionality should go here, so that as much of possible of
44 // the aidl compiler is mocked with the single function `aidl_entry`
Steven Morelandfdb57cd2020-01-08 20:03:30 -080045
Steven Moreland3981d9e2020-03-31 14:11:44 -070046 android::aidl::IoDelegate io_delegate;
47 int ret = aidl_entry(options, io_delegate);
Steven Morelandfdb57cd2020-01-08 20:03:30 -080048
49 return ret;
50}