From c39eb514485ed5578461c693d4e2344cb661d1c0 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Wed, 21 Jul 2021 12:56:02 -0700 Subject: [PATCH] Fix android zip bundles (flutter/engine#27604) --- engine/src/flutter/build/zip_bundle.gni | 3 + .../flutter/shell/platform/android/BUILD.gn | 57 +++++++++++++++---- 2 files changed, 48 insertions(+), 12 deletions(-) diff --git a/engine/src/flutter/build/zip_bundle.gni b/engine/src/flutter/build/zip_bundle.gni index 585d5ec4c9..2405e4b02b 100644 --- a/engine/src/flutter/build/zip_bundle.gni +++ b/engine/src/flutter/build/zip_bundle.gni @@ -8,6 +8,9 @@ if (flutter_runtime_mode == "jit_release") { android_zip_archive_dir = "android-$target_cpu-jit-release" } else { android_zip_archive_dir = "android-$target_cpu" + if (flutter_runtime_mode != "debug") { + android_zip_archive_dir += "-$flutter_runtime_mode" + } } # Creates a zip file in the $root_build_dir/zip_archives folder. diff --git a/engine/src/flutter/shell/platform/android/BUILD.gn b/engine/src/flutter/shell/platform/android/BUILD.gn index 95211ca01e..b692865869 100644 --- a/engine/src/flutter/shell/platform/android/BUILD.gn +++ b/engine/src/flutter/shell/platform/android/BUILD.gn @@ -560,7 +560,7 @@ zip_bundle("android_symbols") { deps = [ ":flutter_shell_native" ] } -zip_bundle("android") { +zip_bundle("flutter_jar_zip") { output = "$android_zip_archive_dir/artifacts.zip" files = [ { @@ -569,11 +569,7 @@ zip_bundle("android") { }, ] - deps = [ - ":android_jar", - ":android_javadoc", - ":android_symbols", - ] + deps = [ ":android_jar" ] if (current_cpu == "x86" || current_cpu == "x64") { files += [ @@ -584,12 +580,6 @@ zip_bundle("android") { ] deps += [ ":flutter_shell_native" ] } - - # We only run the robolectric tests for android_debug_unopt (arm CPU), and - # the target is relatively expensive to build. - if (flutter_runtime_mode == "debug" && current_cpu == "arm") { - deps += [ ":robolectric_tests" ] - } } action("gen_android_javadoc") { @@ -624,3 +614,46 @@ zip_bundle("android_javadoc") { ] deps = [ ":gen_android_javadoc" ] } + +if (target_cpu != "x86") { + zip_bundle("gen_snapshot") { + gen_snapshot_bin = "gen_snapshot" + gen_snapshot_path = rebase_path("$root_out_dir/clang_x64/$gen_snapshot_bin") + + if (host_os == "linux") { + output = "$android_zip_archive_dir/linux-x64.zip" + } else if (host_os == "mac") { + output = "$android_zip_archive_dir/darwin-x64.zip" + } else if (host_os == "win") { + output = "$android_zip_archive_dir/windows-x64.zip" + gen_snapshot_bin = "gen_snapshot.exe" + gen_snapshot_path = rebase_path("$root_out_dir/$gen_snapshot_bin") + } + + files = [ + { + source = gen_snapshot_path + destination = gen_snapshot_bin + }, + ] + + deps = [ "//third_party/dart/runtime/bin:gen_snapshot($host_toolchain)" ] + } +} + +group("android") { + deps = [ + ":android_javadoc", + ":android_symbols", + ":flutter_jar_zip", + ] + if (target_cpu != "x86") { + deps += [ ":gen_snapshot" ] + } + + # We only run the robolectric tests for android_debug_unopt (arm CPU), and + # the target is relatively expensive to build. + if (flutter_runtime_mode == "debug" && current_cpu == "arm") { + deps += [ ":robolectric_tests" ] + } +}