Generate the white list used to validate unresolved externals.
Generate the file used in libbcc to verify that all the unresolved
references found in a loaded script correspond to RenderScript
APIs. We do this to prevent script from accessing functions they
should not use, e.g. malloc().
We also generate slang test files for each API level. These tests
can be used to cross-validate the generator to make sure that all
APIs can be called. These files can also be used to manually check
the white list by looking at the unresolved external references
when these files are compiled.
Change-Id: Idd4bd48e61e81a71d61445e60950bc79de88daf2
diff --git a/api/Specification.cpp b/api/Specification.cpp
index 7634eab..7862d31 100644
--- a/api/Specification.cpp
+++ b/api/Specification.cpp
@@ -811,10 +811,36 @@
return true;
}
+
+static void updateMaxApiLevel(const VersionInfo& info, int* maxApiLevel) {
+ *maxApiLevel = max(*maxApiLevel, max(info.minVersion, info.maxVersion));
+}
+
+int SystemSpecification::getMaximumApiLevel() {
+ int maxApiLevel = 0;
+ for (auto i : mConstants) {
+ for (auto j: i.second->getSpecifications()) {
+ updateMaxApiLevel(j->getVersionInfo(), &maxApiLevel);
+ }
+ }
+ for (auto i : mTypes) {
+ for (auto j: i.second->getSpecifications()) {
+ updateMaxApiLevel(j->getVersionInfo(), &maxApiLevel);
+ }
+ }
+ for (auto i : mFunctions) {
+ for (auto j: i.second->getSpecifications()) {
+ updateMaxApiLevel(j->getVersionInfo(), &maxApiLevel);
+ }
+ }
+ return maxApiLevel;
+}
+
bool SystemSpecification::generateFiles(bool forVerification, int maxApiLevel) const {
bool success = generateHeaderFiles("scriptc") &&
generateDocumentation("docs", forVerification) &&
- generateTestFiles("test", maxApiLevel);
+ generateTestFiles("test", maxApiLevel) &&
+ generateStubsWhiteList("slangtest", maxApiLevel);
if (success) {
cout << "Successfully processed " << mTypes.size() << " types, " << mConstants.size()
<< " constants, and " << mFunctions.size() << " functions.\n";