Jiyong Park | 74595c1 | 2018-07-23 15:22:50 +0900 | [diff] [blame] | 1 | /* |
| 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 Moreland | bb654e3 | 2020-01-08 19:52:05 -0800 | [diff] [blame] | 23 | |
Steven Moreland | 3981d9e | 2020-03-31 14:11:44 -0700 | [diff] [blame] | 24 | using android::aidl::Options; |
| 25 | |
Steven Moreland | bb654e3 | 2020-01-08 19:52:05 -0800 | [diff] [blame] | 26 | #ifdef AIDL_CPP_BUILD |
| 27 | constexpr Options::Language kDefaultLang = Options::Language::CPP; |
| 28 | #else |
| 29 | constexpr Options::Language kDefaultLang = Options::Language::JAVA; |
| 30 | #endif |
Jiyong Park | 74595c1 | 2018-07-23 15:22:50 +0900 | [diff] [blame] | 31 | |
Steven Moreland | fdb57cd | 2020-01-08 20:03:30 -0800 | [diff] [blame] | 32 | int main(int argc, char* argv[]) { |
Steven Moreland | fdb57cd | 2020-01-08 20:03:30 -0800 | [diff] [blame] | 33 | Options options(argc, argv, kDefaultLang); |
| 34 | if (!options.Ok()) { |
Steven Moreland | 2178081 | 2020-09-11 01:29:45 +0000 | [diff] [blame] | 35 | AIDL_ERROR(options.GetErrorMessage()) << options.GetUsage(); |
Steven Moreland | fdb57cd | 2020-01-08 20:03:30 -0800 | [diff] [blame] | 36 | return 1; |
| 37 | } |
| 38 | |
Steven Moreland | 3981d9e | 2020-03-31 14:11:44 -0700 | [diff] [blame] | 39 | // Only minimal functionality should go here, so that as much of possible of |
| 40 | // the aidl compiler is mocked with the single function `aidl_entry` |
Steven Moreland | fdb57cd | 2020-01-08 20:03:30 -0800 | [diff] [blame] | 41 | |
Steven Moreland | 3981d9e | 2020-03-31 14:11:44 -0700 | [diff] [blame] | 42 | android::aidl::IoDelegate io_delegate; |
| 43 | int ret = aidl_entry(options, io_delegate); |
Steven Moreland | fdb57cd | 2020-01-08 20:03:30 -0800 | [diff] [blame] | 44 | |
| 45 | return ret; |
| 46 | } |