diff options
author | Jerome Dochez <jedo@google.com> | 2014-10-10 23:21:01 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-10-10 23:21:01 +0000 |
commit | b51644c3c7d428d92202c2c6a8f6ba69700a71f1 (patch) | |
tree | 9885fc7077aaf13d8f629c44a9885b0626050485 /tools/aapt/Command.cpp | |
parent | acb677ad9d8a92c6553ce7316808b0ee77bef1c8 (diff) | |
parent | e36550dc9e202450d0921bf65d00d14e7e3e8a54 (diff) |
am e36550dc: am 0757e5fd: am c9c512e0: am f47f8855: Merge "Added a daemon mode to aapt to receive streams of commands from gradle." into lmp-dev
* commit 'e36550dc9e202450d0921bf65d00d14e7e3e8a54':
Added a daemon mode to aapt to receive streams of commands from gradle.
Diffstat (limited to 'tools/aapt/Command.cpp')
-rw-r--r-- | tools/aapt/Command.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp index 258c7c7f964d..70044f29da95 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, |