blob: 7d32b2422f30717b48865af3e61165bd67b4344b [file] [log] [blame]
Christopher Wiley4427d862015-09-14 11:07:39 -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
17#include <iostream>
18#include <memory>
19
Christopher Wiley89e35862015-08-30 10:57:07 -070020#include "aidl.h"
Christopher Wiley4a2884b2015-10-07 11:27:45 -070021#include "io_delegate.h"
Christopher Wileyb8b59f62015-09-15 12:19:53 -070022#include "logging.h"
Christopher Wiley89e35862015-08-30 10:57:07 -070023#include "options.h"
24
Christopher Wiley89eaab52015-09-15 14:46:46 -070025using android::aidl::JavaOptions;
Christopher Wiley89e35862015-08-30 10:57:07 -070026
Christopher Wileyb8b59f62015-09-15 12:19:53 -070027int main(int argc, char** argv) {
28 android::base::InitLogging(argv);
29 LOG(DEBUG) << "aidl starting";
Christopher Wiley89eaab52015-09-15 14:46:46 -070030 std::unique_ptr<JavaOptions> options = JavaOptions::Parse(argc, argv);
Christopher Wiley4427d862015-09-14 11:07:39 -070031 if (!options) {
Christopher Wiley89e35862015-08-30 10:57:07 -070032 return 1;
Christopher Wiley4427d862015-09-14 11:07:39 -070033 }
34
Christopher Wiley4a2884b2015-10-07 11:27:45 -070035 android::aidl::IoDelegate io_delegate;
Christopher Wiley4427d862015-09-14 11:07:39 -070036 switch (options->task) {
Christopher Wiley89eaab52015-09-15 14:46:46 -070037 case JavaOptions::COMPILE_AIDL_TO_JAVA:
Christopher Wiley4a2884b2015-10-07 11:27:45 -070038 return android::aidl::compile_aidl_to_java(*options, io_delegate);
Christopher Wiley89eaab52015-09-15 14:46:46 -070039 case JavaOptions::PREPROCESS_AIDL:
Casey Dahlinc1f39b42015-11-24 10:34:34 -080040 if (android::aidl::preprocess_aidl(*options, io_delegate))
41 return 0;
42 return 1;
Christopher Wiley4427d862015-09-14 11:07:39 -070043 }
44 std::cerr << "aidl: internal error" << std::endl;
45 return 1;
Christopher Wiley89e35862015-08-30 10:57:07 -070046}