OSDN Git Service

Merge "Avoid acquiring a lock on the InputReader thread" into oc-dev
[android-x86/frameworks-base.git] / tools / aapt2 / Main.cpp
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 <iostream>
18 #include <vector>
19
20 #include "androidfw/StringPiece.h"
21
22 namespace aapt {
23
24 // DO NOT UPDATE, this is more of a marketing version.
25 static const char* sMajorVersion = "2";
26
27 // Update minor version whenever a feature or flag is added.
28 static const char* sMinorVersion = "13";
29
30 int PrintVersion() {
31   std::cerr << "Android Asset Packaging Tool (aapt) " << sMajorVersion << "."
32             << sMinorVersion << std::endl;
33   return 0;
34 }
35
36 extern int Compile(const std::vector<android::StringPiece>& args);
37 extern int Link(const std::vector<android::StringPiece>& args);
38 extern int Dump(const std::vector<android::StringPiece>& args);
39 extern int Diff(const std::vector<android::StringPiece>& args);
40 extern int Optimize(const std::vector<android::StringPiece>& args);
41
42 }  // namespace aapt
43
44 int main(int argc, char** argv) {
45   if (argc >= 2) {
46     argv += 1;
47     argc -= 1;
48
49     std::vector<android::StringPiece> args;
50     for (int i = 1; i < argc; i++) {
51       args.push_back(argv[i]);
52     }
53
54     android::StringPiece command(argv[0]);
55     if (command == "compile" || command == "c") {
56       return aapt::Compile(args);
57     } else if (command == "link" || command == "l") {
58       return aapt::Link(args);
59     } else if (command == "dump" || command == "d") {
60       return aapt::Dump(args);
61     } else if (command == "diff") {
62       return aapt::Diff(args);
63     } else if (command == "optimize") {
64       return aapt::Optimize(args);
65     } else if (command == "version") {
66       return aapt::PrintVersion();
67     }
68     std::cerr << "unknown command '" << command << "'\n";
69   } else {
70     std::cerr << "no command specified\n";
71   }
72
73   std::cerr << "\nusage: aapt2 [compile|link|dump|diff|optimize|version] ..."
74             << std::endl;
75   return 1;
76 }