From e398144643c090704f54a1da01df299707fd555b Mon Sep 17 00:00:00 2001 From: Dennis Shen Date: Mon, 10 Jul 2023 18:15:42 +0000 Subject: [PATCH] aconfig: cpp codegen update: Move server_configurable_flags header include Move server_configurable_flags header include away from exported header, instead put it in the flag provider headers. Otherwise, it can cause compilation error if the source code who wants to use the generated c flag lib has not added dependency on server_configurable_flags yet. Bug: b/279483801 Test: atest aconfig.test Change-Id: Ib75877ee88f995caf72b3fd2554c3da195032c14 --- tools/aconfig/src/codegen_cpp.rs | 8 ++++---- tools/aconfig/templates/cpp_exported_header.template | 5 +---- tools/aconfig/templates/cpp_prod_flag_provider.template | 4 ++++ tools/aconfig/templates/cpp_test_flag_provider.template | 5 +++++ 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/tools/aconfig/src/codegen_cpp.rs b/tools/aconfig/src/codegen_cpp.rs index a802725841..8acac8e4b1 100644 --- a/tools/aconfig/src/codegen_cpp.rs +++ b/tools/aconfig/src/codegen_cpp.rs @@ -133,8 +133,6 @@ mod tests { #include #include -#include -using namespace server_configurable_flags; namespace com::android::aconfig::test { class flag_provider_interface { @@ -196,8 +194,6 @@ inline void reset_overrides() { #include #include -#include -using namespace server_configurable_flags; namespace com::android::aconfig::test { class flag_provider_interface { @@ -258,6 +254,8 @@ inline void reset_overrides() { #define com_android_aconfig_test_flag_provider_HEADER_H #include "com_android_aconfig_test.h" +#include +using namespace server_configurable_flags; namespace com::android::aconfig::test { class flag_provider : public flag_provider_interface { @@ -294,6 +292,8 @@ public: #define com_android_aconfig_test_flag_provider_HEADER_H #include "com_android_aconfig_test.h" +#include +using namespace server_configurable_flags; #include #include diff --git a/tools/aconfig/templates/cpp_exported_header.template b/tools/aconfig/templates/cpp_exported_header.template index e244de3d62..ee8f0dddac 100644 --- a/tools/aconfig/templates/cpp_exported_header.template +++ b/tools/aconfig/templates/cpp_exported_header.template @@ -3,10 +3,7 @@ #include #include -{{ if readwrite }} -#include -using namespace server_configurable_flags; -{{ endif }} + namespace {cpp_namespace} \{ class flag_provider_interface \{ diff --git a/tools/aconfig/templates/cpp_prod_flag_provider.template b/tools/aconfig/templates/cpp_prod_flag_provider.template index c966ed4eb4..6ba9e410f8 100644 --- a/tools/aconfig/templates/cpp_prod_flag_provider.template +++ b/tools/aconfig/templates/cpp_prod_flag_provider.template @@ -1,6 +1,10 @@ #ifndef {header}_flag_provider_HEADER_H #define {header}_flag_provider_HEADER_H #include "{header}.h" +{{ if readwrite }} +#include +using namespace server_configurable_flags; +{{ endif }} namespace {cpp_namespace} \{ class flag_provider : public flag_provider_interface \{ diff --git a/tools/aconfig/templates/cpp_test_flag_provider.template b/tools/aconfig/templates/cpp_test_flag_provider.template index bd597e7722..a24116b7e1 100644 --- a/tools/aconfig/templates/cpp_test_flag_provider.template +++ b/tools/aconfig/templates/cpp_test_flag_provider.template @@ -2,6 +2,11 @@ #define {header}_flag_provider_HEADER_H #include "{header}.h" +{{ if readwrite }} +#include +using namespace server_configurable_flags; +{{ endif }} + #include #include #include