main.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. #include "aidl.h"
  17. #include "aidl_apicheck.h"
  18. #include "io_delegate.h"
  19. #include "logging.h"
  20. #include "options.h"
  21. #include <iostream>
  22. #include <memory>
  23. using android::aidl::Options;
  24. // aidl is leaky. Turn off LeakSanitizer by default. b/37749857
  25. extern "C" const char* __asan_default_options() {
  26. return "detect_leaks=0";
  27. }
  28. int main(int argc, char* argv[]) {
  29. android::base::InitLogging(argv);
  30. LOG(DEBUG) << "aidl starting";
  31. Options options(argc, argv, Options::Language::JAVA);
  32. if (!options.Ok()) {
  33. std::cerr << options.GetErrorMessage();
  34. std::cerr << options.GetUsage();
  35. return 1;
  36. }
  37. android::aidl::IoDelegate io_delegate;
  38. switch (options.GetTask()) {
  39. case Options::Task::COMPILE:
  40. return android::aidl::compile_aidl(options, io_delegate);
  41. case Options::Task::PREPROCESS:
  42. return android::aidl::preprocess_aidl(options, io_delegate) ? 0 : 1;
  43. case Options::Task::DUMP_API:
  44. return android::aidl::dump_api(options, io_delegate) ? 0 : 1;
  45. case Options::Task::CHECK_API:
  46. return android::aidl::check_api(options, io_delegate) ? 0 : 1;
  47. case Options::Task::DUMP_MAPPINGS:
  48. return android::aidl::dump_mappings(options, io_delegate) ? 0 : 1;
  49. default:
  50. LOG(FATAL) << "aidl: internal error" << std::endl;
  51. return 1;
  52. }
  53. }