c++-impl: gen server stub boilerplate
-Lc++-impl now generates a default implementation for all
the interfaces in the specified package. The method
implementations are all left empty.
The default implementation also contains a special function,
HIDL_FETCH_IFOO(), which is used to retrieve an instance of
a particular interface in pass-through mode. For that to work,
the default implementation must live in a shared-library with
a well-known name, eg android.hardware.tests.foo@1.0.impl.so.
Sample invocation:
hidl-gen -o tmp/impl/ -Lc++-impl -randroid.hardware:hardware/interfaces
android.hardware.tests.foo@1.0
Bug: 31228745
Change-Id: I747aa47cb76931eed85179b8131d2efd3f887471
diff --git a/main.cpp b/main.cpp
index e9c07b7..6e5d3dc 100644
--- a/main.cpp
+++ b/main.cpp
@@ -77,6 +77,9 @@
if (lang == "c++") {
return ast->generateCpp(outputDir);
}
+ if (lang == "c++-impl") {
+ return ast->generateCppImpl(outputDir);
+ }
if (lang == "java") {
return ast->generateJava(outputDir, limitToType);
}
@@ -466,6 +469,27 @@
}
},
+ {"c++-impl",
+ true /* mNeedsOutputDir */,
+ validateForSource,
+ [](const FQName &fqName,
+ const char *hidl_gen, Coordinator *coordinator,
+ const std::string &outputDir) -> status_t {
+ if (fqName.isFullyQualified()) {
+ return generateSourcesForFile(fqName,
+ hidl_gen,
+ coordinator,
+ outputDir, "c++-impl");
+ } else {
+ return generateSourcesForPackage(fqName,
+ hidl_gen,
+ coordinator,
+ outputDir, "c++-impl");
+ }
+ }
+ },
+
+
{"java",
true /* mNeedsOutputDir */,
validateForSource,