--checkapi=equal checks the equality of two dumps
Switched from diff-based test, which often breaks for trivial changes.
For example, changing '/* @hide */' to '/** @hide */' shouldn't break
the equality of two dumps.
Similarly, adding license/copyright headers to dumped .aidl files
shouldn't break the equality.
Bug: 172476424
Test: m (triggers checks)
Change-Id: Iea2d3b9f8597977ab276828e943dd6e84debc8ce
diff --git a/options.cpp b/options.cpp
index 620edf6..97eb6b0 100644
--- a/options.cpp
+++ b/options.cpp
@@ -55,9 +55,9 @@
<< myname_ << " --dumpapi --out=DIR INPUT..." << endl
<< " Dump API signature of AIDL file(s) to DIR." << endl
<< endl
- << myname_ << " --checkapi OLD_DIR NEW_DIR" << endl
- << " Checkes whether API dump NEW_DIR is backwards compatible extension " << endl
- << " of the API dump OLD_DIR." << endl
+ << myname_ << " --checkapi[={compatible|equal}] OLD_DIR NEW_DIR" << endl
+ << " Check whether NEW_DIR API dump is {compatible|equal} extension " << endl
+ << " of the API dump OLD_DIR. Default: compatible" << endl
#endif
<< endl;
@@ -215,7 +215,7 @@
{"preprocess", no_argument, 0, 's'},
#ifndef _WIN32
{"dumpapi", no_argument, 0, 'u'},
- {"checkapi", no_argument, 0, 'A'},
+ {"checkapi", optional_argument, 0, 'A'},
#endif
{"apimapping", required_argument, 0, 'i'},
{"include", required_argument, 0, 'I'},
@@ -285,6 +285,16 @@
task_ = Options::Task::CHECK_API;
// to ensure that all parcelables in the api dumpes are structured
structured_ = true;
+ if (optarg) {
+ if (strcmp(optarg, "compatible") == 0)
+ check_api_level_ = CheckApiLevel::COMPATIBLE;
+ else if (strcmp(optarg, "equal") == 0)
+ check_api_level_ = CheckApiLevel::EQUAL;
+ else {
+ error_message_ << "Unsupported --checkapi level: '" << optarg << "'" << endl;
+ return;
+ }
+ }
}
break;
#endif