aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzuWei Lin <szuweilin@google.com>2020-04-01 15:17:45 +0800
committerSzuWei Lin <szuweilin@google.com>2020-04-01 18:04:45 +0800
commitc87d83118e3107349323f7e76f99d04c29817363 (patch)
treed121101c84365ed43e42c3ff5caf223985ffbd93
parent7dcfe3dbbb172bffeb0fa7c5229f9ae5aa2f0753 (diff)
parentddc4a70ecdf8a4d2bf0669953082171ba47080ac (diff)
downloadaidl-c87d83118e3107349323f7e76f99d04c29817363.tar.gz
Merge branch android10-qpr2-release
Change-Id: I74a520dc8dde64cffe6e70f0adc95c4c6b10fb03
-rw-r--r--Android.bp6
-rw-r--r--aidl.cpp18
-rw-r--r--aidl_unittest.cpp41
-rw-r--r--generate_java.cpp13
4 files changed, 57 insertions, 21 deletions
diff --git a/Android.bp b/Android.bp
index e60468e4..14f2d009 100644
--- a/Android.bp
+++ b/Android.bp
@@ -221,7 +221,9 @@ android_app {
manifest: "tests/java_app/AndroidManifest.xml",
resource_dirs: ["tests/java_app/resources"],
srcs: [
- "tests/android/aidl/tests/*.aidl",
+ "tests/android/aidl/tests/ITestService.aidl",
+ "tests/android/aidl/tests/INamedCallback.aidl",
+ "tests/android/aidl/tests/StructuredParcelable.aidl",
"tests/java_app/src/android/aidl/tests/NullableTests.java",
"tests/java_app/src/android/aidl/tests/SimpleParcelable.java",
"tests/java_app/src/android/aidl/tests/TestFailException.java",
@@ -263,4 +265,4 @@ aidl_interface {
gen_log: true,
},
},
-} \ No newline at end of file
+}
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);