/* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include #include #include #include #include #include #include #include using namespace ::android::vintf; static const std::string kColumnSeperator = " "; std::string existString(bool value) { return value ? "GOOD" : "DOES NOT EXIST"; } std::string compatibleString(int32_t value) { switch (value) { case COMPATIBLE: return "GOOD"; case INCOMPATIBLE: return "INCOMPATIBLE"; default: return strerror(-value); } } std::string boolCompatString(bool value) { return compatibleString(value ? COMPATIBLE : INCOMPATIBLE); } std::string deprecateString(int32_t value) { switch (value) { case NO_DEPRECATED_HALS: return "GOOD"; case DEPRECATED: return "DEPRECATED"; default: return strerror(-value); } } enum Status : int { OK = 0, USAGE, }; struct ParsedOptions; void dumpLegacy(const ParsedOptions&); void dumpDm(const ParsedOptions&); void dumpFm(const ParsedOptions&); void dumpDcm(const ParsedOptions&); void dumpFcm(const ParsedOptions&); void dumpRi(const ParsedOptions&); struct DumpTargetOption { std::string name; std::function fn; std::string help; }; std::vector gTargetOptions = { {"legacy", &dumpLegacy, "Print VINTF metadata."}, {"dm", &dumpDm, "Print Device HAL Manifest."}, {"fm", &dumpFm, "Print Framework HAL Manifest."}, {"dcm", &dumpDcm, "Print Device Compatibility Matrix."}, {"fcm", &dumpFcm, "Print Framework Compatibility Matrix."}, {"ri", &dumpRi, "Print Runtime Information."}, }; struct ParsedOptions { bool verbose = false; std::function fn = &dumpLegacy; }; struct Option { char shortOption = '\0'; std::string longOption; std::string help; std::function op; }; std::string getShortOptions(const std::vector