blob: b8815898c5550a89433c4badea54f68f57acdf6c [file] [log] [blame]
Andreas Huberc9410c72016-07-28 12:18:40 -07001#include "AST.h"
Andreas Huber5345ec22016-07-29 13:33:27 -07002#include "Coordinator.h"
Andreas Huberc9410c72016-07-28 12:18:40 -07003#include "Formatter.h"
Andreas Huber84f89de2016-07-28 15:39:51 -07004#include "FQName.h"
Andreas Huberc9410c72016-07-28 12:18:40 -07005
Andreas Huber68f24592016-07-29 14:53:48 -07006#include <android-base/logging.h>
Andreas Huberc9410c72016-07-28 12:18:40 -07007#include <stdio.h>
8
9using namespace android;
10
11int main(int argc, const char *const argv[]) {
Andreas Huberdc981332016-07-29 15:46:54 -070012 const char *TOP = getenv("TOP");
13 if (TOP == NULL) {
14 LOG(ERROR) << "Your environment does not define $TOP.";
15 return 1;
16 }
17
18 std::string interfacesPath = TOP;
19 interfacesPath.append("/hardware/interfaces/");
20
21 Coordinator coordinator(interfacesPath);
Andreas Huber5345ec22016-07-29 13:33:27 -070022
Andreas Hubereb1081f2016-07-28 13:13:24 -070023 for (int i = 1; i < argc; ++i) {
Andreas Huber68f24592016-07-29 14:53:48 -070024 FQName fqName(argv[i]);
25 CHECK(fqName.isValid() && fqName.isFullyQualified());
26
27 AST *ast = coordinator.parse(fqName);
Andreas Huber881227d2016-08-02 14:20:21 -070028 CHECK(ast != NULL);
Andreas Huberc9410c72016-07-28 12:18:40 -070029
Andreas Hubereb1081f2016-07-28 13:13:24 -070030 Formatter out;
Andreas Huberc9410c72016-07-28 12:18:40 -070031
Andreas Hubereb1081f2016-07-28 13:13:24 -070032 printf("========================================\n");
Andreas Huberc9410c72016-07-28 12:18:40 -070033
Andreas Hubereb1081f2016-07-28 13:13:24 -070034 ast->dump(out);
Andreas Huberc9410c72016-07-28 12:18:40 -070035
Andreas Huber881227d2016-08-02 14:20:21 -070036 ast->generateCpp();
37
Andreas Hubereb1081f2016-07-28 13:13:24 -070038 delete ast;
39 ast = NULL;
40 }
Andreas Huberc9410c72016-07-28 12:18:40 -070041
Andreas Huberc9410c72016-07-28 12:18:40 -070042 return 0;
43}