From b7e5940e3b1859a3dcd9aac86d3ac11770de8aac Mon Sep 17 00:00:00 2001 From: gaaclarke <30870216+gaaclarke@users.noreply.github.com> Date: Tue, 16 Jul 2019 15:54:26 -0700 Subject: [PATCH] Started adding the engine hash to frameworks' Info.plist. (#9847) Started adding the engine hash to Flutter.framework's Info.plist. --- build/copy_info_plist.py | 33 ++++++++++++++++++ build/git_revision.py | 34 +++++++++++-------- shell/platform/darwin/ios/BUILD.gn | 7 +++- .../platform/darwin/ios/framework/Info.plist | 2 ++ shell/platform/embedder/BUILD.gn | 7 +++- .../embedder/assets/EmbedderInfo.plist | 2 ++ 6 files changed, 69 insertions(+), 16 deletions(-) create mode 100644 build/copy_info_plist.py diff --git a/build/copy_info_plist.py b/build/copy_info_plist.py new file mode 100644 index 000000000..63c9ac261 --- /dev/null +++ b/build/copy_info_plist.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python +# +# Copyright 2013 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. + +""" +Copies the Info.plist and adds extra fields to it like the git hash of the +engine. + +Precondition: $CWD/../../flutter is the path to the flutter engine repo. + +usage: copy_info_plist.py +""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import sys +import git_revision +import os + +def main(): + text = open(sys.argv[1]).read() + engine_path = os.path.join(os.getcwd(), "..", "..", "flutter") + revision = git_revision.GetRepositoryVersion(engine_path) + text = text.format(revision) + with open(sys.argv[2], "w") as outfile: + outfile.write(text) + +if __name__ == "__main__": + main() diff --git a/build/git_revision.py b/build/git_revision.py index 3c16eb58e..5ee807c3a 100755 --- a/build/git_revision.py +++ b/build/git_revision.py @@ -5,26 +5,19 @@ # found in the LICENSE file. """Get the Git HEAD revision of a specified Git repository.""" +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function import sys import subprocess import os import argparse -def main(): - parser = argparse.ArgumentParser(); - - parser.add_argument('--repository', - action='store', - help='Path to the Git repository.', - required=True) - - args = parser.parse_args() - - repository = os.path.abspath(args.repository) - +def GetRepositoryVersion(repository): + "Returns the Git HEAD for the supplied repository path as a string." if not os.path.exists(repository): - exit -1 + raise IOError("path doesn't exist") version = subprocess.check_output([ 'git', @@ -34,7 +27,20 @@ def main(): 'HEAD', ]) - print (version.strip()) + return version.strip() + +def main(): + parser = argparse.ArgumentParser() + + parser.add_argument('--repository', + action='store', + help='Path to the Git repository.', + required=True) + + args = parser.parse_args() + repository = os.path.abspath(args.repository) + version = GetRepositoryVersion(repository) + print(version.strip()) return 0 diff --git a/shell/platform/darwin/ios/BUILD.gn b/shell/platform/darwin/ios/BUILD.gn index 4627c26b3..e9c7489d0 100644 --- a/shell/platform/darwin/ios/BUILD.gn +++ b/shell/platform/darwin/ios/BUILD.gn @@ -177,7 +177,8 @@ action("copy_dylib_and_update_framework_install_name") { ] } -copy("copy_framework_info_plist") { +action("copy_framework_info_plist") { + script = "$flutter_root/build/copy_info_plist.py" visibility = [ ":*" ] sources = [ "framework/Info.plist", @@ -185,6 +186,10 @@ copy("copy_framework_info_plist") { outputs = [ "$_flutter_framework_dir/Info.plist", ] + args = [ + rebase_path(sources[0]), + rebase_path(outputs[0]), + ] } copy("copy_framework_module_map") { diff --git a/shell/platform/darwin/ios/framework/Info.plist b/shell/platform/darwin/ios/framework/Info.plist index b3b025637..72c6081ba 100644 --- a/shell/platform/darwin/ios/framework/Info.plist +++ b/shell/platform/darwin/ios/framework/Info.plist @@ -22,5 +22,7 @@ 1.0 MinimumOSVersion 8.0 + FlutterEngine + {0} diff --git a/shell/platform/embedder/BUILD.gn b/shell/platform/embedder/BUILD.gn index c875d9811..2ccdb119b 100644 --- a/shell/platform/embedder/BUILD.gn +++ b/shell/platform/embedder/BUILD.gn @@ -153,7 +153,8 @@ if (is_mac && !embedder_for_target) { ] } - copy("copy_info_plist") { + action("copy_info_plist") { + script = "$flutter_root/build/copy_info_plist.py" visibility = [ ":*" ] sources = [ "assets/EmbedderInfo.plist", @@ -161,6 +162,10 @@ if (is_mac && !embedder_for_target) { outputs = [ "$_flutter_embedder_framework_dir/Versions/A/Resources/Info.plist", ] + args = [ + rebase_path(sources[0]), + rebase_path(outputs[0]), + ] } copy("copy_module_map") { diff --git a/shell/platform/embedder/assets/EmbedderInfo.plist b/shell/platform/embedder/assets/EmbedderInfo.plist index 02a4027bf..1b5335815 100644 --- a/shell/platform/embedder/assets/EmbedderInfo.plist +++ b/shell/platform/embedder/assets/EmbedderInfo.plist @@ -24,5 +24,7 @@ 1 NSHumanReadableCopyright Copyright 2013 The Flutter Authors. All rights reserved. + FlutterEngine + {0} -- GitLab