diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-03-04 22:10:22 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-03-04 22:10:22 +0000 |
commit | 19b085d6cb360a77c5fac9d5f6b86fd1978e7ca7 (patch) | |
tree | cdd87429d617a4d0ab84f2b4ada9bd156ee22113 | |
parent | 27484dce380f3e4f6212b1b976aecabe331c8ec4 (diff) | |
parent | 44f3e157fc46024b79567d43782ecae5c3229e54 (diff) | |
download | proto_logging-simpleperf-release.tar.gz |
Snap for 11526323 from 44f3e157fc46024b79567d43782ecae5c3229e54 to simpleperf-releasesimpleperf-release
Change-Id: Ie4ce544a6eca81827ae25abc057df0a51afdaf17
-rw-r--r-- | stats/stats_log_api_gen/java_writer.cpp | 33 | ||||
-rw-r--r-- | stats/stats_log_api_gen/java_writer.h | 2 | ||||
-rw-r--r-- | stats/stats_log_api_gen/main.cpp | 41 |
3 files changed, 19 insertions, 57 deletions
diff --git a/stats/stats_log_api_gen/java_writer.cpp b/stats/stats_log_api_gen/java_writer.cpp index 46bba322..dae0c0e6 100644 --- a/stats/stats_log_api_gen/java_writer.cpp +++ b/stats/stats_log_api_gen/java_writer.cpp @@ -42,27 +42,24 @@ static int write_java_q_logger_class(FILE* out, const SignatureInfoMap& signatur return 0; } -static void write_java_annotation_constants(FILE* out, const int minApiLevel, - const int compileApiLevel) { +static void write_java_annotation_constants(FILE* out, const int minApiLevel) { fprintf(out, " // Annotation constants.\n"); const map<AnnotationId, AnnotationStruct>& ANNOTATION_ID_CONSTANTS = get_annotation_id_constants(ANNOTATION_CONSTANT_NAME_PREFIX); for (const auto& [id, annotation] : ANNOTATION_ID_CONSTANTS) { - if (annotation.minApiLevel < API_U) { // we don't generate annotation constants for U+ - if (compileApiLevel <= API_R) { - fprintf(out, " public static final byte %s = %hhu;\n", annotation.name.c_str(), - id); - } else if (minApiLevel <= API_R) { // compileApiLevel = S+ - fprintf(out, " public static final byte %s =\n", annotation.name.c_str()); - fprintf(out, " Build.VERSION.SDK_INT <= %s ?\n", - get_java_build_version_code(API_R).c_str()); - fprintf(out, " %hhu : StatsLog.%s;\n", id, annotation.name.c_str()); - fprintf(out, "\n"); - } else { - fprintf(out, " public static final byte %s = StatsLog.%s;\n", - annotation.name.c_str(), annotation.name.c_str()); - } + if (annotation.minApiLevel >= API_U) { // we don't generate annotation constants for U+ + continue; + } + if (minApiLevel <= API_R) { + fprintf(out, " public static final byte %s =\n", annotation.name.c_str()); + fprintf(out, " Build.VERSION.SDK_INT <= %s ?\n", + get_java_build_version_code(API_R).c_str()); + fprintf(out, " %hhu : StatsLog.%s;\n", id, annotation.name.c_str()); + fprintf(out, "\n"); + } else { + fprintf(out, " public static final byte %s = StatsLog.%s;\n", + annotation.name.c_str(), annotation.name.c_str()); } } @@ -326,7 +323,7 @@ static int write_java_pulled_methods(FILE* out, const SignatureInfoMap& signatur int write_stats_log_java(FILE* out, const Atoms& atoms, const AtomDecl& attributionDecl, const string& javaClass, const string& javaPackage, const int minApiLevel, - const int compileApiLevel, const bool supportWorkSource) { + const bool supportWorkSource) { // Print prelude fprintf(out, "// This file is autogenerated\n"); fprintf(out, "\n"); @@ -353,7 +350,7 @@ int write_stats_log_java(FILE* out, const Atoms& atoms, const AtomDecl& attribut write_java_atom_codes(out, atoms); write_java_enum_values(out, atoms); - write_java_annotation_constants(out, minApiLevel, compileApiLevel); + write_java_annotation_constants(out, minApiLevel); int errors = 0; diff --git a/stats/stats_log_api_gen/java_writer.h b/stats/stats_log_api_gen/java_writer.h index f87be53e..dea06f8c 100644 --- a/stats/stats_log_api_gen/java_writer.h +++ b/stats/stats_log_api_gen/java_writer.h @@ -31,7 +31,7 @@ namespace stats_log_api_gen { int write_stats_log_java(FILE* out, const Atoms& atoms, const AtomDecl& attributionDecl, const string& javaClass, const string& javaPackage, const int minApiLevel, - const int compileApiLevel, const bool supportWorkSource); + const bool supportWorkSource); } // namespace stats_log_api_gen } // namespace android diff --git a/stats/stats_log_api_gen/main.cpp b/stats/stats_log_api_gen/main.cpp index 10bb6ae7..75337082 100644 --- a/stats/stats_log_api_gen/main.cpp +++ b/stats/stats_log_api_gen/main.cpp @@ -61,9 +61,6 @@ static void print_usage() { fprintf(stderr, " --worksource Include support for logging WorkSource " "objects.\n"); - fprintf(stderr, - " --compileApiLevel API_LEVEL specify which API level generated code is " - "compiled against. (Java only).\n"); fprintf(stderr, " Default is \"current\".\n"); fprintf(stderr, " --bootstrap If this logging is from a bootstrap process. " @@ -93,7 +90,6 @@ static int run(int argc, char const* const* argv) { string vendorProto; bool supportWorkSource = false; int minApiLevel = API_LEVEL_CURRENT; - int compileApiLevel = API_LEVEL_CURRENT; bool bootstrap = false; int index = 1; @@ -191,15 +187,6 @@ static int run(int argc, char const* const* argv) { if (0 != strcmp("current", argv[index])) { minApiLevel = atoi(argv[index]); } - } else if (0 == strcmp("--compileApiLevel", argv[index])) { - index++; - if (index >= argc) { - print_usage(); - return 1; - } - if (0 != strcmp("current", argv[index])) { - compileApiLevel = atoi(argv[index]); - } } else if (0 == strcmp("--bootstrap", argv[index])) { bootstrap = true; #ifdef WITH_VENDOR @@ -227,40 +214,18 @@ static int run(int argc, char const* const* argv) { print_usage(); return 1; } - if (DEFAULT_MODULE_NAME == moduleName && - (minApiLevel != API_LEVEL_CURRENT || compileApiLevel != API_LEVEL_CURRENT)) { + if (DEFAULT_MODULE_NAME == moduleName && minApiLevel != API_LEVEL_CURRENT) { // Default module only supports current API level. fprintf(stderr, "%s cannot support older API levels\n", moduleName.c_str()); return 1; } - if (compileApiLevel < API_R) { - // Cannot compile against pre-R. - fprintf(stderr, "compileApiLevel must be %d or higher.\n", API_R); - return 1; - } - if (minApiLevel < API_Q) { // Cannot support pre-Q. fprintf(stderr, "minApiLevel must be %d or higher.\n", API_Q); return 1; } - if (minApiLevel == API_LEVEL_CURRENT) { - if (minApiLevel > compileApiLevel) { - // If minApiLevel is not specified, assume it is not higher than compileApiLevel. - minApiLevel = compileApiLevel; - } - } else { - if (minApiLevel > compileApiLevel) { - // If specified, minApiLevel should always be lower than compileApiLevel. - fprintf(stderr, - "Invalid minApiLevel or compileApiLevel. If minApiLevel and" - " compileApiLevel are specified, minApiLevel should not be higher" - " than compileApiLevel.\n"); - return 1; - } - } if (bootstrap) { if (cppFilename.empty() && headerFilename.empty()) { fprintf(stderr, "Bootstrap flag can only be used for cpp/header files.\n"); @@ -270,7 +235,7 @@ static int run(int argc, char const* const* argv) { fprintf(stderr, "Bootstrap flag does not support worksources"); return 1; } - if ((minApiLevel != API_LEVEL_CURRENT) || (compileApiLevel != API_LEVEL_CURRENT)) { + if (minApiLevel != API_LEVEL_CURRENT) { fprintf(stderr, "Bootstrap flag does not support older API levels"); return 1; } @@ -396,7 +361,7 @@ static int run(int argc, char const* const* argv) { if (vendorProto.empty()) { errorCount = android::stats_log_api_gen::write_stats_log_java( out, atoms, attributionDecl, javaClass, javaPackage, minApiLevel, - compileApiLevel, supportWorkSource); + supportWorkSource); } else { #ifdef WITH_VENDOR if (supportWorkSource) { |