blob: ffc30a133eca74442ecd385e99f67cf97a22d413 [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"
Jiyong Park3656c3c2018-08-01 20:02:01 +090018#include "aidl_apicheck.h"
Jiyong Park74595c12018-07-23 15:22:50 +090019#include "io_delegate.h"
20#include "logging.h"
21#include "options.h"
22
23#include <iostream>
24#include <memory>
25
26using android::aidl::Options;
27
28// aidl is leaky. Turn off LeakSanitizer by default. b/37749857
29extern "C" const char* __asan_default_options() {
30 return "detect_leaks=0";
31}
32
33int main(int argc, char* argv[]) {
34 android::base::InitLogging(argv);
35 LOG(DEBUG) << "aidl starting";
36 Options options(argc, argv, Options::Language::JAVA);
37 if (!options.Ok()) {
38 std::cerr << options.GetErrorMessage();
39 std::cerr << options.GetUsage();
40 return 1;
41 }
42
43 android::aidl::IoDelegate io_delegate;
Jiyong Park74595c12018-07-23 15:22:50 +090044 switch (options.GetTask()) {
45 case Options::Task::COMPILE:
Jiyong Parkb034bf02018-07-30 17:44:33 +090046 return android::aidl::compile_aidl(options, io_delegate);
Jiyong Park74595c12018-07-23 15:22:50 +090047 case Options::Task::PREPROCESS:
Jiyong Park0ce81842018-08-01 20:03:41 +090048 return android::aidl::preprocess_aidl(options, io_delegate) ? 0 : 1;
Jiyong Park3656c3c2018-08-01 20:02:01 +090049 case Options::Task::DUMP_API:
Jiyong Park0ce81842018-08-01 20:03:41 +090050 return android::aidl::dump_api(options, io_delegate) ? 0 : 1;
Jiyong Park3656c3c2018-08-01 20:02:01 +090051 case Options::Task::CHECK_API:
Jiyong Park7e4e7db2018-08-16 16:33:22 +090052 return android::aidl::check_api(options, io_delegate) ? 0 : 1;
Jiyong Park74595c12018-07-23 15:22:50 +090053 default:
54 LOG(FATAL) << "aidl: internal error" << std::endl;
55 return 1;
56 }
57}