From 3f85e68cf4341bc5f25e157236d7a1fb9addc433 Mon Sep 17 00:00:00 2001 From: Emmanuel Garcia Date: Mon, 3 Jun 2019 12:51:24 -0700 Subject: [PATCH 1/9] Use shared library when libapp.so is found --- shell/platform/android/io/flutter/view/FlutterMain.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shell/platform/android/io/flutter/view/FlutterMain.java b/shell/platform/android/io/flutter/view/FlutterMain.java index d9cf1adb227c1..c093bdefa64de 100644 --- a/shell/platform/android/io/flutter/view/FlutterMain.java +++ b/shell/platform/android/io/flutter/view/FlutterMain.java @@ -401,6 +401,7 @@ private static Set listLibs(@NonNull Context applicationContext) { * *

When the blobs are contained in the native library directory, * the format `lib_%s.so` is applied to the file name. + * The shared library is named `libapp.so`. * *

Note: The name of the files can be customized in the app's metadata, but the * format is preserved. @@ -415,7 +416,7 @@ private static void initAot(@NonNull Context applicationContext) { String aotVmSnapshotInstrLib = "lib_" + sAotVmSnapshotInstr + ".so"; String aotIsolateSnapshotDataLib = "lib_" + sAotIsolateSnapshotData + ".so"; String aotIsolateSnapshotInstrLib = "lib_" + sAotIsolateSnapshotInstr + ".so"; - String aotSharedLibraryLib = "lib_" + sAotSharedLibraryPath + ".so"; + String aotSharedLibraryLib = "lib" + sAotSharedLibraryPath; boolean isPrecompiledBlobInLib = libs .containsAll(Arrays.asList( From 75351f2b412bc3c4445040eaa0bf54469e301470 Mon Sep 17 00:00:00 2001 From: Emmanuel Garcia Date: Wed, 7 Aug 2019 22:40:13 -0700 Subject: [PATCH 2/9] Include Maven dependency in files.json --- .../download_android_support.py | 9 ++-- tools/android_support/files.json | 52 +++++++++++++++---- 2 files changed, 48 insertions(+), 13 deletions(-) diff --git a/tools/android_support/download_android_support.py b/tools/android_support/download_android_support.py index e622f37ba0cd7..d94bc63534623 100644 --- a/tools/android_support/download_android_support.py +++ b/tools/android_support/download_android_support.py @@ -22,7 +22,10 @@ def GetInstalledVersion(out_file_name): with open(version_file) as f: return f.read().strip() -def getFile(url, out_file_name): +def getFile(entry): + url = entry['url'] + out_file_name = entry['out_file_name'] + # Read latest version. if url == GetInstalledVersion(out_file_name): return @@ -48,8 +51,8 @@ def main(): with open (os.path.join(THIS_DIR, 'files.json')) as f: files = json.load(f) - for file, url in files.items(): - getFile(url, file) + for entry in files: + getFile(entry) if __name__ == '__main__': sys.exit(main()) diff --git a/tools/android_support/files.json b/tools/android_support/files.json index 565e143b731b3..9389af26c2892 100644 --- a/tools/android_support/files.json +++ b/tools/android_support/files.json @@ -1,10 +1,42 @@ -{ - "android_arch_lifecycle_common.jar": "https://dl.google.com/dl/android/maven2/android/arch/lifecycle/common/1.1.1/common-1.1.1.jar", - "android_arch_lifecycle_common_java8.jar": "https://dl.google.com/dl/android/maven2/android/arch/lifecycle/common-java8/1.1.1/common-java8-1.1.1.jar", - "android_arch_lifecycle_runtime.jar": "https://dl.google.com/dl/android/maven2/android/arch/lifecycle/runtime/1.1.1/runtime-1.1.1.aar", - "android_arch_lifecycle_viewmodel.jar": "https://dl.google.com/dl/android/maven2/android/arch/lifecycle/viewmodel/1.1.1/viewmodel-1.1.1.aar", - "android_support_fragment.jar": "https://dl.google.com/dl/android/maven2/com/android/support/support-fragment/28.0.0/support-fragment-28.0.0.aar", - "android_support_v13.jar": "https://dl.google.com/dl/android/maven2/com/android/support/support-v13/28.0.0/support-v13-28.0.0.aar", - "android_support_annotations.jar": "https://dl.google.com/dl/android/maven2/com/android/support/support-annotations/28.0.0/support-annotations-28.0.0.jar", - "android_support_compat.jar": "https://dl.google.com/dl/android/maven2/com/android/support/support-compat/28.0.0/support-compat-28.0.0.aar" -} \ No newline at end of file +[ + { + "url": "https://dl.google.com/dl/android/maven2/android/arch/lifecycle/common/1.1.1/common-1.1.1.jar", + "out_file_name": "android_arch_lifecycle_common.jar", + "maven_dependency": "android.arch.lifecycle:common:1.1.1" + }, + { + "url": "https://dl.google.com/dl/android/maven2/android/arch/lifecycle/common-java8/1.1.1/common-java8-1.1.1.jar", + "out_file_name": "android_arch_lifecycle_common_java8.jar", + "maven_dependency": "android.arch.lifecycle:common-java8:1.1.1" + }, + { + "url": "https://dl.google.com/dl/android/maven2/android/arch/lifecycle/runtime/1.1.1/runtime-1.1.1.aar", + "out_file_name": "android_arch_lifecycle_runtime.jar", + "maven_dependency": "android.arch.lifecycle:runtime:1.1.1" + }, + { + "url": "https://dl.google.com/dl/android/maven2/android/arch/lifecycle/viewmodel/1.1.1/viewmodel-1.1.1.aar", + "out_file_name": "android_arch_lifecycle_viewmodel.jar", + "maven_dependency": "android.arch.lifecycle:viewmodel:1.1.1" + }, + { + "url": "https://dl.google.com/dl/android/maven2/com/android/support/support-fragment/28.0.0/support-fragment-28.0.0.aar", + "out_file_name": "android_support_fragment.jar", + "maven_dependency": "com.android.support:support-fragment:28.0.0" + }, + { + "url": "https://dl.google.com/dl/android/maven2/com/android/support/support-v13/28.0.0/support-v13-28.0.0.aar", + "out_file_name": "android_support_v13.jar", + "maven_dependency": "com.android.support:support-v13:28.0.0" + }, + { + "url": "https://dl.google.com/dl/android/maven2/com/android/support/support-annotations/28.0.0/support-annotations-28.0.0.jar", + "out_file_name": "android_support_annotations.jar", + "maven_dependency": "com.android.support:support-annotations:28.0.0" + }, + { + "url": "https://dl.google.com/dl/android/maven2/com/android/support/support-compat/28.0.0/support-compat-28.0.0.aar", + "out_file_name": "android_support_compat.jar", + "maven_dependency": "com.android.support:support-compat:28.0.0" + } +] \ No newline at end of file From e61bfdd46e8a6cd38fc408979e0fd075d257026c Mon Sep 17 00:00:00 2001 From: Emmanuel Garcia Date: Thu, 8 Aug 2019 10:56:16 -0700 Subject: [PATCH 3/9] Simplify --- tools/android_support/download_android_support.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tools/android_support/download_android_support.py b/tools/android_support/download_android_support.py index d94bc63534623..296243f926e63 100644 --- a/tools/android_support/download_android_support.py +++ b/tools/android_support/download_android_support.py @@ -22,10 +22,7 @@ def GetInstalledVersion(out_file_name): with open(version_file) as f: return f.read().strip() -def getFile(entry): - url = entry['url'] - out_file_name = entry['out_file_name'] - +def getFile(url, out_file_name): # Read latest version. if url == GetInstalledVersion(out_file_name): return @@ -52,7 +49,7 @@ def main(): files = json.load(f) for entry in files: - getFile(entry) + getFile(entry['url'], entry['out_file_name']) if __name__ == '__main__': sys.exit(main()) From 3c1954ce96ee9ff9704ef0ef89631088a5745325 Mon Sep 17 00:00:00 2001 From: Emmanuel Garcia Date: Thu, 8 Aug 2019 13:30:29 -0700 Subject: [PATCH 4/9] Add python script that generates the POM file --- tools/android_support/generate_pom_file.py | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 tools/android_support/generate_pom_file.py diff --git a/tools/android_support/generate_pom_file.py b/tools/android_support/generate_pom_file.py new file mode 100644 index 0000000000000..f875750b370dd --- /dev/null +++ b/tools/android_support/generate_pom_file.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python +# Copyright 2019 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import argparse +import os +import sys +import json + +# Path constants. (All of these should be absolute paths.) +THIS_DIR = os.path.abspath(os.path.dirname(__file__)) +FLUTTER_DIR = os.path.abspath(os.path.join(THIS_DIR, '..', '..', '..')) +INSTALL_DIR = os.path.join(FLUTTER_DIR, 'third_party', 'android_support') + +# The template for the POM file. +POM_FILE_CONTENT = ''' + + + 4.0.0 + io.flutter + {0} + {1} + jar + + {2} + + +''' + +POM_DEPENENCY = ''' + + {0} + {1} + {2} + compile + +''' + +def main(): + with open (os.path.join(THIS_DIR, 'files.json')) as f: + dependencies = json.load(f) + + parser = argparse.ArgumentParser(description='Generate the POM file for the engine artifacts') + parser.add_argument('--engine-artifact-id', type=str, required=True) + parser.add_argument('--engine-version', type=str, required=True) + + args = parser.parse_args() + engine_artifact_id = args.engine_artifact_id + engine_version = args.engine_version + artifact_version = '1.0.0-' + engine_version + out_file_name = '%s-%s.pom' % (engine_artifact_id, engine_version) + + pom_dependencies = '' + for dependency in dependencies: + group_id, artifact_id, version = dependency['maven_dependency'].split(':') + pom_dependencies += POM_DEPENENCY.format(group_id, artifact_id, version) + + # Write the POM file. + with open(os.path.join(INSTALL_DIR, out_file_name), 'w') as f: + f.write(POM_FILE_CONTENT.format(engine_artifact_id, engine_version, pom_dependencies)) + +if __name__ == '__main__': + sys.exit(main()) From 3503efcdc491acd96b45dda9102bdcb75d4b7716 Mon Sep 17 00:00:00 2001 From: Emmanuel Garcia Date: Thu, 8 Aug 2019 13:32:20 -0700 Subject: [PATCH 5/9] Typo --- tools/android_support/generate_pom_file.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/android_support/generate_pom_file.py b/tools/android_support/generate_pom_file.py index f875750b370dd..4856c6c3c802b 100644 --- a/tools/android_support/generate_pom_file.py +++ b/tools/android_support/generate_pom_file.py @@ -29,7 +29,7 @@ ''' -POM_DEPENENCY = ''' +POM_DEPENDENCY = ''' {0} {1} @@ -55,7 +55,7 @@ def main(): pom_dependencies = '' for dependency in dependencies: group_id, artifact_id, version = dependency['maven_dependency'].split(':') - pom_dependencies += POM_DEPENENCY.format(group_id, artifact_id, version) + pom_dependencies += POM_DEPENDENCY.format(group_id, artifact_id, version) # Write the POM file. with open(os.path.join(INSTALL_DIR, out_file_name), 'w') as f: From 050e048038bfbe7336b54bfe15ec949e0d8f579c Mon Sep 17 00:00:00 2001 From: Emmanuel Garcia Date: Thu, 8 Aug 2019 13:43:34 -0700 Subject: [PATCH 6/9] Add flag to indicate the destination directory --- tools/android_support/generate_pom_file.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/android_support/generate_pom_file.py b/tools/android_support/generate_pom_file.py index 4856c6c3c802b..196248fb2d3fe 100644 --- a/tools/android_support/generate_pom_file.py +++ b/tools/android_support/generate_pom_file.py @@ -8,10 +8,7 @@ import sys import json -# Path constants. (All of these should be absolute paths.) THIS_DIR = os.path.abspath(os.path.dirname(__file__)) -FLUTTER_DIR = os.path.abspath(os.path.join(THIS_DIR, '..', '..', '..')) -INSTALL_DIR = os.path.join(FLUTTER_DIR, 'third_party', 'android_support') # The template for the POM file. POM_FILE_CONTENT = ''' @@ -43,8 +40,12 @@ def main(): dependencies = json.load(f) parser = argparse.ArgumentParser(description='Generate the POM file for the engine artifacts') - parser.add_argument('--engine-artifact-id', type=str, required=True) - parser.add_argument('--engine-version', type=str, required=True) + parser.add_argument('--engine-artifact-id', type=str, required=True, + help='The artifact id. e.g. android_arm_release') + parser.add_argument('--engine-version', type=str, required=True, + help='The engine commit hash') + parser.add_argument('--destination', type=str, required=True, + help='The destination directory absolute path') args = parser.parse_args() engine_artifact_id = args.engine_artifact_id @@ -58,7 +59,7 @@ def main(): pom_dependencies += POM_DEPENDENCY.format(group_id, artifact_id, version) # Write the POM file. - with open(os.path.join(INSTALL_DIR, out_file_name), 'w') as f: + with open(os.path.join(args.destination, out_file_name), 'w') as f: f.write(POM_FILE_CONTENT.format(engine_artifact_id, engine_version, pom_dependencies)) if __name__ == '__main__': From 65ec3baa3e904c6c4fc2257d61a676228f1c8005 Mon Sep 17 00:00:00 2001 From: Emmanuel Garcia Date: Thu, 8 Aug 2019 15:38:02 -0700 Subject: [PATCH 7/9] Invoke script to generate POM file --- shell/platform/android/BUILD.gn | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/shell/platform/android/BUILD.gn b/shell/platform/android/BUILD.gn index 3aae6e3d2d5eb..7dd589d0368d0 100644 --- a/shell/platform/android/BUILD.gn +++ b/shell/platform/android/BUILD.gn @@ -6,6 +6,7 @@ import("//build/config/android/config.gni") import("$flutter_root/common/config.gni") import("$flutter_root/shell/config.gni") import("$flutter_root/shell/gpu/gpu.gni") +import("$flutter_root/shell/version/version.gni") shell_gpu_configuration("android_gpu_configuration") { enable_software = true @@ -316,6 +317,28 @@ action("android") { deps = [ ":flutter_shell_java", ":flutter_shell_native", + ":pom", + ] +} + +action("pom") { + script = "$flutter_root/tools/android_support/generate_pom_file.py" + + inputs = [ + "$flutter_root/tools/android_support/files.json", + ] + + outputs = [ + "$root_build_dir/$android_app_abi$flutter_runtime_mode-1.0.0-$engine_version.pom", + ] + + args = [ + "--destination", + root_build_dir, + "--engine-version", + engine_version, + "--engine-artifact-id", + "$android_app_abi$flutter_runtime_mode", ] } From 1e3876aa6bb7c9e6943228ea8ebe7da12b6a0165 Mon Sep 17 00:00:00 2001 From: Emmanuel Garcia Date: Thu, 8 Aug 2019 16:38:25 -0700 Subject: [PATCH 8/9] Generate POM files for the embedding and for libflutter --- shell/platform/android/BUILD.gn | 38 +++++++++++++++++++--- tools/android_support/generate_pom_file.py | 13 +++++--- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/shell/platform/android/BUILD.gn b/shell/platform/android/BUILD.gn index 7dd589d0368d0..31fb61f89f828 100644 --- a/shell/platform/android/BUILD.gn +++ b/shell/platform/android/BUILD.gn @@ -317,28 +317,56 @@ action("android") { deps = [ ":flutter_shell_java", ":flutter_shell_native", - ":pom", + ":pom_embedding", + ":pom_libflutter", ] } -action("pom") { +action("pom_libflutter") { script = "$flutter_root/tools/android_support/generate_pom_file.py" inputs = [ "$flutter_root/tools/android_support/files.json", ] + artifact_id = string_replace(android_app_abi, "-", "_") + "_" + flutter_runtime_mode + + outputs = [ + "$root_build_dir/$artifact_id-1.0.0-$engine_version.pom", + ] + + args = [ + "--destination", + rebase_path(root_build_dir), + "--engine-version", + engine_version, + "--engine-artifact-id", + artifact_id, + ] +} + +action("pom_embedding") { + script = "$flutter_root/tools/android_support/generate_pom_file.py" + + inputs = [ + "$flutter_root/tools/android_support/files.json", + ] + + artifact_id = "flutter_embedding_$flutter_runtime_mode" + outputs = [ - "$root_build_dir/$android_app_abi$flutter_runtime_mode-1.0.0-$engine_version.pom", + "$root_build_dir/$artifact_id-1.0.0-$engine_version.pom", ] args = [ "--destination", - root_build_dir, + rebase_path(root_build_dir), "--engine-version", engine_version, "--engine-artifact-id", - "$android_app_abi$flutter_runtime_mode", + artifact_id, + "--include-embedding-dependencies", + "true", ] } diff --git a/tools/android_support/generate_pom_file.py b/tools/android_support/generate_pom_file.py index 196248fb2d3fe..5ce75d5cf8492 100644 --- a/tools/android_support/generate_pom_file.py +++ b/tools/android_support/generate_pom_file.py @@ -46,21 +46,24 @@ def main(): help='The engine commit hash') parser.add_argument('--destination', type=str, required=True, help='The destination directory absolute path') + parser.add_argument('--include-embedding-dependencies', type=bool, + help='Include the dependencies for the embedding') args = parser.parse_args() engine_artifact_id = args.engine_artifact_id engine_version = args.engine_version artifact_version = '1.0.0-' + engine_version - out_file_name = '%s-%s.pom' % (engine_artifact_id, engine_version) + out_file_name = '%s-%s.pom' % (engine_artifact_id, artifact_version) pom_dependencies = '' - for dependency in dependencies: - group_id, artifact_id, version = dependency['maven_dependency'].split(':') - pom_dependencies += POM_DEPENDENCY.format(group_id, artifact_id, version) + if args.include_embedding_dependencies: + for dependency in dependencies: + group_id, artifact_id, version = dependency['maven_dependency'].split(':') + pom_dependencies += POM_DEPENDENCY.format(group_id, artifact_id, version) # Write the POM file. with open(os.path.join(args.destination, out_file_name), 'w') as f: - f.write(POM_FILE_CONTENT.format(engine_artifact_id, engine_version, pom_dependencies)) + f.write(POM_FILE_CONTENT.format(engine_artifact_id, artifact_version, pom_dependencies)) if __name__ == '__main__': sys.exit(main()) From 1b9c3ff3dfa0b28ff9acf5a0cbe7765faf8fe00c Mon Sep 17 00:00:00 2001 From: Emmanuel Garcia Date: Thu, 8 Aug 2019 18:15:21 -0700 Subject: [PATCH 9/9] Format --- shell/platform/android/BUILD.gn | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shell/platform/android/BUILD.gn b/shell/platform/android/BUILD.gn index 31fb61f89f828..5660c2d70d82d 100644 --- a/shell/platform/android/BUILD.gn +++ b/shell/platform/android/BUILD.gn @@ -329,7 +329,8 @@ action("pom_libflutter") { "$flutter_root/tools/android_support/files.json", ] - artifact_id = string_replace(android_app_abi, "-", "_") + "_" + flutter_runtime_mode + artifact_id = + string_replace(android_app_abi, "-", "_") + "_" + flutter_runtime_mode outputs = [ "$root_build_dir/$artifact_id-1.0.0-$engine_version.pom",