From ccf347489d78a15dd97e0240aabc00a300905fdc Mon Sep 17 00:00:00 2001 From: Kaushik Iska Date: Tue, 3 Sep 2019 18:51:15 -0700 Subject: [PATCH] Support building standalone far packages with autogenerating manigests Also makes package_dir support testonly mode --- tools/fuchsia/gen_package.py | 22 ++++++++++++++++++---- tools/fuchsia/package_dir.gni | 2 ++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/tools/fuchsia/gen_package.py b/tools/fuchsia/gen_package.py index 00331857e7b5f..089b730e3f832 100755 --- a/tools/fuchsia/gen_package.py +++ b/tools/fuchsia/gen_package.py @@ -13,6 +13,8 @@ import subprocess import sys +from gather_flutter_runner_artifacts import CreateMetaPackage + # Generates the manifest and returns the file. def GenerateManifest(package_dir): @@ -57,23 +59,35 @@ def main(): parser.add_argument( '--signing-key', dest='signing_key', action='store', required=True) parser.add_argument( - '--manifest-file', dest='manifest_file', action='store', required=True) + '--manifest-file', dest='manifest_file', action='store', required=False) + parser.add_argument( + '--far-name', dest='far_name', action='store', required=False) args = parser.parse_args() assert os.path.exists(args.pm_bin) assert os.path.exists(args.package_dir) assert os.path.exists(args.signing_key) - assert os.path.exists(args.manifest_file) + + pkg_dir = args.package_dir + if not os.path.exists(os.path.join(pkg_dir, 'meta', 'package')): + CreateMetaPackage(pkg_dir, args.far_name) + + manifest_file = None + if args.manifest_file is not None: + assert os.path.exists(args.manifest_file) + manifest_file = args.manifest_file + else: + manifest_file = GenerateManifest(args.package_dir) pm_command_base = [ args.pm_bin, '-o', - args.package_dir, + os.path.abspath(os.path.join(pkg_dir, os.pardir)), '-k', args.signing_key, '-m', - args.manifest_file, + manifest_file, ] # Build the package diff --git a/tools/fuchsia/package_dir.gni b/tools/fuchsia/package_dir.gni index 93006f2ecd8cb..0869e41180e0f 100644 --- a/tools/fuchsia/package_dir.gni +++ b/tools/fuchsia/package_dir.gni @@ -9,6 +9,7 @@ template("package_dir") { assert(defined(invoker.binary), "package must define binary") assert(defined(invoker.meta_dir), "package must define meta_dir") + pkg_testonly = defined(invoker.testonly) && invoker.testonly pkg_target_name = target_name pkg = { package_version = "0" # placeholder @@ -72,5 +73,6 @@ template("package_dir") { deps = pkg.deps + [ ":$cmx_target" ] args = [ "--file-list={{response_file_name}}" ] outputs = copy_outputs + testonly = pkg_testonly } }