| 8 | using namespace ftg; |
| 9 | |
| 10 | int main(int argc, const char **argv) { |
| 11 | cl::ResetCommandLineParser(); |
| 12 | cl::opt<bool> OptHelp("help", cl::desc("Display available options"), |
| 13 | cl::ValueDisallowed, cl::callback([](const bool &) { |
| 14 | cl::PrintHelpMessage(); |
| 15 | exit(0); |
| 16 | })); |
| 17 | cl::opt<bool> OptVersion("version", cl::desc("Display version"), |
| 18 | cl::ValueDisallowed, cl::callback([](const bool &) { |
| 19 | llvm::outs() << "version: " << FTG_VERSION << "\n"; |
| 20 | exit(0); |
| 21 | })); |
| 22 | cl::opt<std::string> OutFilePath("out", |
| 23 | cl::desc("<Required> Output filepath"), |
| 24 | cl::value_desc("filepath"), cl::Required); |
| 25 | cl::opt<std::string> BuildDBPath( |
| 26 | "db", cl::desc("<Required> Path of build db json file"), |
| 27 | cl::value_desc("filepath"), cl::Required); |
| 28 | cl::opt<std::string> ExternReportDir( |
| 29 | "extern", cl::desc("Pre-Analyzed TargetLib analysis results directory"), |
| 30 | cl::value_desc("dir_path")); |
| 31 | cl::opt<std::string> PublicAPIJsonPath( |
| 32 | "public", cl::desc("<Required> PublicAPI.json filepath to analyze"), |
| 33 | cl::value_desc("filepath"), cl::Required); |
| 34 | |
| 35 | cl::ParseCommandLineOptions(argc, argv, "Target Analyzer\n"); |
| 36 | |
| 37 | std::shared_ptr<APILoader> AL; |
| 38 | AL = std::make_shared<APIJsonLoader>(PublicAPIJsonPath); |
| 39 | |
| 40 | try { |
| 41 | TargetLibAnalyzer Analyzer(std::make_shared<BuildDBLoader>(BuildDBPath), AL, |
| 42 | ExternReportDir); |
| 43 | if (!Analyzer.analyze()) |
| 44 | return 1; |
| 45 | |
| 46 | if (!Analyzer.dump(OutFilePath)) |
| 47 | return 1; |
| 48 | } catch (...) { |
| 49 | return 1; |
| 50 | } |
| 51 | |
| 52 | return 0; |
| 53 | } |