Loading tools/aidl/aidl.cpp +75 −44 Original line number Diff line number Diff line Loading @@ -575,12 +575,19 @@ exactly_one_interface(const char* filename, const document_item_type* items, con // ========================================================== void generate_dep_file(const Options& options) generate_dep_file(const Options& options, const document_item_type* items) { /* we open the file in binary mode to ensure that the same output is * generated on all platforms !! */ FILE* to = fopen(options.depFileName.c_str(), "wb"); FILE* to = NULL; if (options.autoDepFile) { string fileName = options.outputFileName + ".d"; to = fopen(fileName.c_str(), "wb"); } else { to = fopen(options.depFileName.c_str(), "wb"); } if (to == NULL) { return; } Loading @@ -591,7 +598,12 @@ generate_dep_file(const Options& options) slash = ""; } if (items->item_type == INTERFACE_TYPE) { fprintf(to, "%s: \\\n", options.outputFileName.c_str()); } else { // parcelable: there's no output file. fprintf(to, " : \\\n"); } fprintf(to, " %s %s\n", options.inputFileName.c_str(), slash); while (import) { Loading @@ -611,44 +623,60 @@ generate_dep_file(const Options& options) // ========================================================== static string generate_outputFileName(const Options& options, const document_item_type* items) generate_outputFileName2(const Options& options, const buffer_type& name, const char* package) { 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(); string packageStr = package; size_t len = packageStr.length(); for (size_t i=0; i<len; i++) { if (package[i] == '.') { package[i] = OS_PATH_SEPARATOR; if (packageStr[i] == '.') { packageStr[i] = OS_PATH_SEPARATOR; } } result += package; result += packageStr; // 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); const char* p = strchr(name.data, '.'); len = p ? p-name.data : strlen(name.data); result += OS_PATH_SEPARATOR; result.append(type->name.data, len); result.append(name.data, len); result += ".java"; return result; } // ========================================================== static string generate_outputFileName(const Options& options, const document_item_type* items) { // items has already been checked to have only one interface. if (items->item_type == INTERFACE_TYPE) { interface_type* type = (interface_type*)items; return generate_outputFileName2(options, type->name, type->package); } else if (items->item_type == PARCELABLE_TYPE) { parcelable_type* type = (parcelable_type*)items; return generate_outputFileName2(options, type->name, type->package); } // I don't think we can come here, but safer than returning NULL. string result; return result; } // ========================================================== static void check_outputFileName(const string& path) { check_outputFilePath(const string& path) { size_t len = path.length(); for (size_t i=0; i<len ; i++) { if (path[i] == OS_PATH_SEPARATOR) { Loading Loading @@ -756,7 +784,7 @@ parse_preprocessed_file(const string& filename) // ========================================================== static int compile_aidl(const Options& options) compile_aidl(Options& options) { int err = 0, N; Loading Loading @@ -850,27 +878,30 @@ compile_aidl(const Options& options) return 1; } // they didn't ask to fail on parcelables, so just exit quietly. if (onlyParcelable && !options.failOnParcelable) { return 0; // if needed, generate the outputFileName from the outputBaseFolder if (options.outputFileName.length() == 0 && options.outputBaseFolder.length() > 0) { options.outputFileName = generate_outputFileName(options, mainDoc); } // if we were asked to, generate a make dependency file if (options.depFileName != "") { generate_dep_file(options); // unless it's a parcelable *and* it's supposed to fail on parcelable if ((options.autoDepFile || options.depFileName != "") && !(onlyParcelable && options.failOnParcelable)) { // make sure the folders of the output file all exists check_outputFilePath(options.outputFileName); generate_dep_file(options, mainDoc); } // 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); // they didn't ask to fail on parcelables, so just exit quietly. if (onlyParcelable && !options.failOnParcelable) { return 0; } // make sure the folders of the output file all exists check_outputFileName(outputFileName); check_outputFilePath(options.outputFileName); err = generate_java(outputFileName, options.inputFileName.c_str(), err = generate_java(options.outputFileName, options.inputFileName.c_str(), (interface_type*)mainDoc); return err; Loading tools/aidl/options.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ usage() "OPTIONS:\n" " -I<DIR> search path for import statements.\n" " -d<FILE> generate dependency file.\n" " -a generate dependency file next to the output file with the name based on the input 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" Loading Loading @@ -49,6 +50,7 @@ parse_options(int argc, const char* const* argv, Options *options) options->task = COMPILE_AIDL; options->failOnParcelable = false; options->autoDepFile = false; // OPTIONS while (i < argc) { Loading @@ -73,6 +75,9 @@ parse_options(int argc, const char* const* argv, Options *options) return usage(); } } else if (s[1] == 'a') { options->autoDepFile = true; } else if (s[1] == 'p') { if (len > 2) { options->preprocessedFiles.push_back(s+2); Loading tools/aidl/options.h +1 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ struct Options string outputFileName; string outputBaseFolder; string depFileName; bool autoDepFile; vector<string> filesToPreprocess; }; Loading Loading
tools/aidl/aidl.cpp +75 −44 Original line number Diff line number Diff line Loading @@ -575,12 +575,19 @@ exactly_one_interface(const char* filename, const document_item_type* items, con // ========================================================== void generate_dep_file(const Options& options) generate_dep_file(const Options& options, const document_item_type* items) { /* we open the file in binary mode to ensure that the same output is * generated on all platforms !! */ FILE* to = fopen(options.depFileName.c_str(), "wb"); FILE* to = NULL; if (options.autoDepFile) { string fileName = options.outputFileName + ".d"; to = fopen(fileName.c_str(), "wb"); } else { to = fopen(options.depFileName.c_str(), "wb"); } if (to == NULL) { return; } Loading @@ -591,7 +598,12 @@ generate_dep_file(const Options& options) slash = ""; } if (items->item_type == INTERFACE_TYPE) { fprintf(to, "%s: \\\n", options.outputFileName.c_str()); } else { // parcelable: there's no output file. fprintf(to, " : \\\n"); } fprintf(to, " %s %s\n", options.inputFileName.c_str(), slash); while (import) { Loading @@ -611,44 +623,60 @@ generate_dep_file(const Options& options) // ========================================================== static string generate_outputFileName(const Options& options, const document_item_type* items) generate_outputFileName2(const Options& options, const buffer_type& name, const char* package) { 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(); string packageStr = package; size_t len = packageStr.length(); for (size_t i=0; i<len; i++) { if (package[i] == '.') { package[i] = OS_PATH_SEPARATOR; if (packageStr[i] == '.') { packageStr[i] = OS_PATH_SEPARATOR; } } result += package; result += packageStr; // 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); const char* p = strchr(name.data, '.'); len = p ? p-name.data : strlen(name.data); result += OS_PATH_SEPARATOR; result.append(type->name.data, len); result.append(name.data, len); result += ".java"; return result; } // ========================================================== static string generate_outputFileName(const Options& options, const document_item_type* items) { // items has already been checked to have only one interface. if (items->item_type == INTERFACE_TYPE) { interface_type* type = (interface_type*)items; return generate_outputFileName2(options, type->name, type->package); } else if (items->item_type == PARCELABLE_TYPE) { parcelable_type* type = (parcelable_type*)items; return generate_outputFileName2(options, type->name, type->package); } // I don't think we can come here, but safer than returning NULL. string result; return result; } // ========================================================== static void check_outputFileName(const string& path) { check_outputFilePath(const string& path) { size_t len = path.length(); for (size_t i=0; i<len ; i++) { if (path[i] == OS_PATH_SEPARATOR) { Loading Loading @@ -756,7 +784,7 @@ parse_preprocessed_file(const string& filename) // ========================================================== static int compile_aidl(const Options& options) compile_aidl(Options& options) { int err = 0, N; Loading Loading @@ -850,27 +878,30 @@ compile_aidl(const Options& options) return 1; } // they didn't ask to fail on parcelables, so just exit quietly. if (onlyParcelable && !options.failOnParcelable) { return 0; // if needed, generate the outputFileName from the outputBaseFolder if (options.outputFileName.length() == 0 && options.outputBaseFolder.length() > 0) { options.outputFileName = generate_outputFileName(options, mainDoc); } // if we were asked to, generate a make dependency file if (options.depFileName != "") { generate_dep_file(options); // unless it's a parcelable *and* it's supposed to fail on parcelable if ((options.autoDepFile || options.depFileName != "") && !(onlyParcelable && options.failOnParcelable)) { // make sure the folders of the output file all exists check_outputFilePath(options.outputFileName); generate_dep_file(options, mainDoc); } // 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); // they didn't ask to fail on parcelables, so just exit quietly. if (onlyParcelable && !options.failOnParcelable) { return 0; } // make sure the folders of the output file all exists check_outputFileName(outputFileName); check_outputFilePath(options.outputFileName); err = generate_java(outputFileName, options.inputFileName.c_str(), err = generate_java(options.outputFileName, options.inputFileName.c_str(), (interface_type*)mainDoc); return err; Loading
tools/aidl/options.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ usage() "OPTIONS:\n" " -I<DIR> search path for import statements.\n" " -d<FILE> generate dependency file.\n" " -a generate dependency file next to the output file with the name based on the input 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" Loading Loading @@ -49,6 +50,7 @@ parse_options(int argc, const char* const* argv, Options *options) options->task = COMPILE_AIDL; options->failOnParcelable = false; options->autoDepFile = false; // OPTIONS while (i < argc) { Loading @@ -73,6 +75,9 @@ parse_options(int argc, const char* const* argv, Options *options) return usage(); } } else if (s[1] == 'a') { options->autoDepFile = true; } else if (s[1] == 'p') { if (len > 2) { options->preprocessedFiles.push_back(s+2); Loading
tools/aidl/options.h +1 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ struct Options string outputFileName; string outputBaseFolder; string depFileName; bool autoDepFile; vector<string> filesToPreprocess; }; Loading