summaryrefslogtreecommitdiffstats
path: root/tools/aapt
diff options
context:
space:
mode:
authorJerome Dochez <jedo@google.com>2014-10-10 19:24:33 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-10-10 19:24:33 +0000
commitfc07eb1c7f06f75cca9e32547516e83e115163c3 (patch)
treed18874e15284fa3d10139b79c7e6a9eaad5a1f34 /tools/aapt
parentda37a460ddf85364efa1b93be7dcc9ed38533332 (diff)
parentf47f8855175213b4bf1014593f97bc81c042dfd1 (diff)
downloadframeworks_base-fc07eb1c7f06f75cca9e32547516e83e115163c3.zip
frameworks_base-fc07eb1c7f06f75cca9e32547516e83e115163c3.tar.gz
frameworks_base-fc07eb1c7f06f75cca9e32547516e83e115163c3.tar.bz2
am f47f8855: Merge "Added a daemon mode to aapt to receive streams of commands from gradle." into lmp-dev
* commit 'f47f8855175213b4bf1014593f97bc81c042dfd1': Added a daemon mode to aapt to receive streams of commands from gradle.
Diffstat (limited to 'tools/aapt')
-rw-r--r--tools/aapt/Bundle.h1
-rw-r--r--tools/aapt/Command.cpp35
-rw-r--r--tools/aapt/Main.cpp3
-rw-r--r--tools/aapt/Main.h1
4 files changed, 40 insertions, 0 deletions
diff --git a/tools/aapt/Bundle.h b/tools/aapt/Bundle.h
index 9bed899..cb34448 100644
--- a/tools/aapt/Bundle.h
+++ b/tools/aapt/Bundle.h
@@ -40,6 +40,7 @@ typedef enum Command {
kCommandPackage,
kCommandCrunch,
kCommandSingleCrunch,
+ kCommandDaemon
} Command;
/*
diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp
index 258c7c7..70044f2 100644
--- a/tools/aapt/Command.cpp
+++ b/tools/aapt/Command.cpp
@@ -23,6 +23,10 @@
#include <errno.h>
#include <fcntl.h>
+#include <iostream>
+#include <string>
+#include <sstream>
+
using namespace android;
#ifndef AAPT_VERSION
@@ -2504,6 +2508,37 @@ int doSingleCrunch(Bundle* bundle)
return NO_ERROR;
}
+int runInDaemonMode(Bundle* bundle) {
+ std::cout << "Ready" << std::endl;
+ for (std::string line; std::getline(std::cin, line);) {
+ if (line == "quit") {
+ return NO_ERROR;
+ }
+ std::stringstream ss;
+ ss << line;
+ std::string s;
+
+ std::string command, parameterOne, parameterTwo;
+ std::getline(ss, command, ' ');
+ std::getline(ss, parameterOne, ' ');
+ std::getline(ss, parameterTwo, ' ');
+ if (command[0] == 's') {
+ bundle->setSingleCrunchInputFile(parameterOne.c_str());
+ bundle->setSingleCrunchOutputFile(parameterTwo.c_str());
+ std::cout << "Crunching " << parameterOne << std::endl;
+ if (doSingleCrunch(bundle) != NO_ERROR) {
+ std::cout << "Error" << std::endl;
+ }
+ std::cout << "Done" << std::endl;
+ } else {
+ // in case of invalid command, just bail out.
+ std::cerr << "Unknown command" << std::endl;
+ return -1;
+ }
+ }
+ return -1;
+}
+
char CONSOLE_DATA[2925] = {
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 95, 46, 32, 32, 32, 32, 32, 32, 32, 32, 32,
diff --git a/tools/aapt/Main.cpp b/tools/aapt/Main.cpp
index 736ae26..2857b59 100644
--- a/tools/aapt/Main.cpp
+++ b/tools/aapt/Main.cpp
@@ -234,6 +234,7 @@ int handleCommand(Bundle* bundle)
case kCommandPackage: return doPackage(bundle);
case kCommandCrunch: return doCrunch(bundle);
case kCommandSingleCrunch: return doSingleCrunch(bundle);
+ case kCommandDaemon: return runInDaemonMode(bundle);
default:
fprintf(stderr, "%s: requested command not yet supported\n", gProgName);
return 1;
@@ -275,6 +276,8 @@ int main(int argc, char* const argv[])
bundle.setCommand(kCommandCrunch);
else if (argv[1][0] == 's')
bundle.setCommand(kCommandSingleCrunch);
+ else if (argv[1][0] == 'm')
+ bundle.setCommand(kCommandDaemon);
else {
fprintf(stderr, "ERROR: Unknown command '%s'\n", argv[1]);
wantUsage = true;
diff --git a/tools/aapt/Main.h b/tools/aapt/Main.h
index 089dde5..e84c4c5 100644
--- a/tools/aapt/Main.h
+++ b/tools/aapt/Main.h
@@ -36,6 +36,7 @@ extern int doRemove(Bundle* bundle);
extern int doPackage(Bundle* bundle);
extern int doCrunch(Bundle* bundle);
extern int doSingleCrunch(Bundle* bundle);
+extern int runInDaemonMode(Bundle* bundle);
extern int calcPercent(long uncompressedLen, long compressedLen);