aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2019-12-05 02:17:15 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2019-12-05 02:17:15 +0000
commit131227c2e783525b730639361dcf12fce5d40557 (patch)
treec9df4a54ab15bb9215047a6842814e832ae61ea3
parentc34c45be4ee0612974848004942f143a7882683d (diff)
parentc6b9c777fba7d233036fd253319b006c46c222d8 (diff)
downloadaidl-131227c2e783525b730639361dcf12fce5d40557.tar.gz
Snap for 6050436 from c6b9c777fba7d233036fd253319b006c46c222d8 to qt-d4-release
Change-Id: I4c8a4076f262e4c10a8da3f4449555e135da08b5
-rw-r--r--aidl.cpp18
-rw-r--r--aidl_unittest.cpp41
-rw-r--r--generate_java.cpp13
3 files changed, 53 insertions, 19 deletions
diff --git a/aidl.cpp b/aidl.cpp
index 83142710..25609c07 100644
--- a/aidl.cpp
+++ b/aidl.cpp
@@ -232,7 +232,14 @@ bool write_dep_file(const Options& options, const AidlDefinedType& defined_type,
}
// Encode that the output file depends on aidl input files.
- writer->Write("%s : \\\n", output_file.c_str());
+ if (defined_type.AsUnstructuredParcelable() != nullptr &&
+ options.TargetLanguage() == Options::Language::JAVA) {
+ // Legacy behavior. For parcelable declarations in Java, don't emit output file as
+ // the dependency target. b/141372861
+ writer->Write(" : \\\n");
+ } else {
+ writer->Write("%s : \\\n", output_file.c_str());
+ }
writer->Write(" %s", Join(source_aidl, " \\\n ").c_str());
writer->Write("\n");
@@ -769,8 +776,13 @@ int compile_aidl(const Options& options, const IoDelegate& io_delegate) {
io_delegate);
success = true;
} else if (lang == Options::Language::JAVA) {
- success =
- java::generate_java(output_file_name, defined_type, &java_types, io_delegate, options);
+ if (defined_type->AsUnstructuredParcelable() != nullptr) {
+ // Legacy behavior. For parcelable declarations in Java, don't generate output file.
+ success = true;
+ } else {
+ success =
+ java::generate_java(output_file_name, defined_type, &java_types, io_delegate, options);
+ }
} else {
LOG(FATAL) << "Should not reach here" << endl;
return 1;
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index 3c5c6413..7cf81722 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -55,7 +55,14 @@ R"(place/for/output/p/IFoo.java : \
p/IFoo.aidl
)";
-const char kExpectedParcelableDepFileContents[] =
+const char kExpectedParcelableDeclarationDepFileContents[] =
+ R"( : \
+ p/Foo.aidl
+
+p/Foo.aidl :
+)";
+
+const char kExpectedStructuredParcelableDepFileContents[] =
R"(place/for/output/p/Foo.java : \
p/Foo.aidl
@@ -571,7 +578,7 @@ TEST_F(AidlTest, WritesCorrectDependencyFileNinja) {
EXPECT_EQ(actual_dep_file_contents, kExpectedNinjaDepFileContents);
}
-TEST_F(AidlTest, WritesTrivialDependencyFileForParcelable) {
+TEST_F(AidlTest, WritesTrivialDependencyFileForParcelableDeclaration) {
// The SDK uses aidl to decide whether a .aidl file is a parcelable. It does
// this by calling aidl with every .aidl file it finds, then parsing the
// generated dependency files. Those that reference .java output files are
@@ -587,7 +594,35 @@ TEST_F(AidlTest, WritesTrivialDependencyFileForParcelable) {
EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
string actual_dep_file_contents;
EXPECT_TRUE(io_delegate_.GetWrittenContents(options.DependencyFile(), &actual_dep_file_contents));
- EXPECT_EQ(actual_dep_file_contents, kExpectedParcelableDepFileContents);
+ EXPECT_EQ(actual_dep_file_contents, kExpectedParcelableDeclarationDepFileContents);
+}
+
+TEST_F(AidlTest, WritesDependencyFileForStructuredParcelable) {
+ vector<string> args = {
+ "aidl",
+ "--structured",
+ "-o place/for/output",
+ "-d dep/file/path",
+ "p/Foo.aidl"};
+ Options options = Options::From(args);
+ io_delegate_.SetFileContents(options.InputFiles().front(), "package p; parcelable Foo {int a;}");
+ EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ string actual_dep_file_contents;
+ EXPECT_TRUE(io_delegate_.GetWrittenContents(options.DependencyFile(), &actual_dep_file_contents));
+ EXPECT_EQ(actual_dep_file_contents, kExpectedStructuredParcelableDepFileContents);
+}
+
+TEST_F(AidlTest, NoJavaOutputForParcelableDeclaration) {
+ vector<string> args = {
+ "aidl",
+ "--lang=java",
+ "-o place/for/output",
+ "p/Foo.aidl"};
+ Options options = Options::From(args);
+ io_delegate_.SetFileContents(options.InputFiles().front(), "package p; parcelable Foo;");
+ EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ string output_file_contents;
+ EXPECT_FALSE(io_delegate_.GetWrittenContents(options.OutputFile(), &output_file_contents));
}
/* not working until type_namespace.h is fixed
diff --git a/generate_java.cpp b/generate_java.cpp
index 777d530a..0d962035 100644
--- a/generate_java.cpp
+++ b/generate_java.cpp
@@ -63,14 +63,6 @@ bool generate_java_parcel(const std::string& filename, const AidlStructuredParce
return true;
}
-bool generate_java_parcel_declaration(const std::string& filename, const IoDelegate& io_delegate) {
- CodeWriterPtr code_writer = io_delegate.GetCodeWriter(filename);
- *code_writer
- << "// This file is intentionally left blank as placeholder for parcel declaration.\n";
-
- return true;
-}
-
bool generate_java(const std::string& filename, const AidlDefinedType* defined_type,
JavaTypeNamespace* types, const IoDelegate& io_delegate,
const Options& options) {
@@ -79,11 +71,6 @@ bool generate_java(const std::string& filename, const AidlDefinedType* defined_t
return generate_java_parcel(filename, parcelable, types->typenames_, io_delegate);
}
- const AidlParcelable* parcelable_decl = defined_type->AsParcelable();
- if (parcelable_decl != nullptr) {
- return generate_java_parcel_declaration(filename, io_delegate);
- }
-
const AidlInterface* interface = defined_type->AsInterface();
if (interface != nullptr) {
return generate_java_interface(filename, interface, types, io_delegate, options);