summaryrefslogtreecommitdiffstats
path: root/tools/aidl
diff options
context:
space:
mode:
authorJean-Baptiste Queru <jbq@google.com>2009-03-18 11:33:14 -0700
committerJean-Baptiste Queru <jbq@google.com>2009-03-18 11:33:14 -0700
commit2a73de7b21a89aa2ba4c254d28658b49793425b2 (patch)
treeded5bcd581464b4174d81c373044b6d36eee58d2 /tools/aidl
parent42e48026b21a962e5bf40344d738665ecbd9d74d (diff)
parentba87e3e6c985e7175152993b5efcc7dd2f0e1c93 (diff)
downloadframeworks_base-2a73de7b21a89aa2ba4c254d28658b49793425b2.zip
frameworks_base-2a73de7b21a89aa2ba4c254d28658b49793425b2.tar.gz
frameworks_base-2a73de7b21a89aa2ba4c254d28658b49793425b2.tar.bz2
Merge commit 'remotes/korg/cupcake' into merge
Conflicts: core/java/android/view/animation/TranslateAnimation.java core/jni/Android.mk core/res/res/values-en-rGB/strings.xml libs/audioflinger/AudioFlinger.cpp libs/surfaceflinger/LayerScreenshot.cpp packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
Diffstat (limited to 'tools/aidl')
-rw-r--r--tools/aidl/aidl.cpp70
-rw-r--r--tools/aidl/options.cpp23
-rw-r--r--tools/aidl/options.h1
3 files changed, 86 insertions, 8 deletions
diff --git a/tools/aidl/aidl.cpp b/tools/aidl/aidl.cpp
index dc61567..fc658f5 100644
--- a/tools/aidl/aidl.cpp
+++ b/tools/aidl/aidl.cpp
@@ -610,6 +610,62 @@ generate_dep_file(const Options& options)
}
// ==========================================================
+static string
+generate_outputFileName(const Options& options, const document_item_type* items)
+{
+ string result;
+
+ // items has already been checked to have only one interface.
+ if (items->item_type == INTERFACE_TYPE) {
+ interface_type* type = (interface_type*)items;
+
+ // create the path to the destination folder based on the
+ // interface package name
+ result = options.outputBaseFolder;
+ result += OS_PATH_SEPARATOR;
+
+ string package = type->package;
+ size_t len = package.length();
+ for (size_t i=0; i<len; i++) {
+ if (package[i] == '.') {
+ package[i] = OS_PATH_SEPARATOR;
+ }
+ }
+
+ result += package;
+
+ // add the filename by replacing the .aidl extension to .java
+ const char* p = strchr(type->name.data, '.');
+ len = p ? p-type->name.data : strlen(type->name.data);
+
+ result += OS_PATH_SEPARATOR;
+ result.append(type->name.data, len);
+ result += ".java";
+ }
+
+ return result;
+}
+
+// ==========================================================
+static void
+check_outputFileName(const string& path) {
+ size_t len = path.length();
+ for (size_t i=0; i<len ; i++) {
+ if (path[i] == OS_PATH_SEPARATOR) {
+ string p = path.substr(0, i);
+ if (access(path.data(), F_OK) != 0) {
+#ifdef HAVE_MS_C_RUNTIME
+ _mkdir(p.data());
+#else
+ mkdir(p.data(), S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP);
+#endif
+ }
+ }
+ }
+}
+
+
+// ==========================================================
static int
parse_preprocessed_file(const string& filename)
{
@@ -617,7 +673,7 @@ parse_preprocessed_file(const string& filename)
FILE* f = fopen(filename.c_str(), "rb");
if (f == NULL) {
- fprintf(stderr, "aidl: can't open preprocessd file: %s\n",
+ fprintf(stderr, "aidl: can't open preprocessed file: %s\n",
filename.c_str());
return 1;
}
@@ -804,7 +860,17 @@ compile_aidl(const Options& options)
generate_dep_file(options);
}
- err = generate_java(options.outputFileName, options.inputFileName.c_str(),
+ // if needed, generate the outputFileName from the outputBaseFolder
+ string outputFileName = options.outputFileName;
+ if (outputFileName.length() == 0 &&
+ options.outputBaseFolder.length() > 0) {
+ outputFileName = generate_outputFileName(options, mainDoc);
+ }
+
+ // make sure the folders of the output file all exists
+ check_outputFileName(outputFileName);
+
+ err = generate_java(outputFileName, options.inputFileName.c_str(),
(interface_type*)mainDoc);
return err;
diff --git a/tools/aidl/options.cpp b/tools/aidl/options.cpp
index 57b10ae..0aa7db2 100644
--- a/tools/aidl/options.cpp
+++ b/tools/aidl/options.cpp
@@ -13,16 +13,19 @@ usage()
" aidl --preprocess OUTPUT INPUT...\n"
"\n"
"OPTIONS:\n"
- " -I<DIR> search path for import statements.\n"
- " -d<FILE> generate dependency file.\n"
- " -p<FILE> file created by --preprocess to import.\n"
- " -b fail when trying to compile a parcelable.\n"
+ " -I<DIR> search path for import statements.\n"
+ " -d<FILE> generate dependency file.\n"
+ " -p<FILE> file created by --preprocess to import.\n"
+ " -o<FOLDER> base output folder for generated files.\n"
+ " -b fail when trying to compile a parcelable.\n"
"\n"
"INPUT:\n"
" An aidl interface file.\n"
"\n"
"OUTPUT:\n"
- " The generated interface files. If omitted, the input filename is used, with the .aidl extension changed to a .java extension.\n"
+ " The generated interface files.\n"
+ " If omitted and the -o option is not used, the input filename is used, with the .aidl extension changed to a .java extension.\n"
+ " If the -o option is used, the generated files will be placed in the base output folder, under their package folder\n"
);
return 1;
}
@@ -78,6 +81,14 @@ parse_options(int argc, const char* const* argv, Options *options)
return usage();
}
}
+ else if (s[1] == 'o') {
+ if (len > 2) {
+ options->outputBaseFolder = s+2;
+ } else {
+ fprintf(stderr, "-o option (%d) requires a path.\n", i);
+ return usage();
+ }
+ }
else if (len == 2 && s[1] == 'b') {
options->failOnParcelable = true;
}
@@ -111,7 +122,7 @@ parse_options(int argc, const char* const* argv, Options *options)
if (i < argc) {
options->outputFileName = argv[i];
i++;
- } else {
+ } else if (options->outputBaseFolder.length() == 0) {
// copy input into output and change the extension from .aidl to .java
options->outputFileName = options->inputFileName;
string::size_type pos = options->outputFileName.size()-5;
diff --git a/tools/aidl/options.h b/tools/aidl/options.h
index e7e62ec..d88d988 100644
--- a/tools/aidl/options.h
+++ b/tools/aidl/options.h
@@ -21,6 +21,7 @@ struct Options
vector<string> preprocessedFiles;
string inputFileName;
string outputFileName;
+ string outputBaseFolder;
string depFileName;
vector<string> filesToPreprocess;