diff --git a/shell/platform/fuchsia/dart_runner/BUILD.gn b/shell/platform/fuchsia/dart_runner/BUILD.gn index e36ce92743002..1a626e1f7af47 100644 --- a/shell/platform/fuchsia/dart_runner/BUILD.gn +++ b/shell/platform/fuchsia/dart_runner/BUILD.gn @@ -190,12 +190,6 @@ template("aot_runner_package") { "//flutter/shell/platform/fuchsia/runtime/dart/profiler_symbols:dart_aot_runner", "target_gen_dir") + "/dart_aot_runner.dartprofilersymbols") - inputs = [ - vmservice_snapshot, - observatory_archive_file, - dart_profiler_symbols, - ] - resources += [ { path = vmservice_snapshot diff --git a/tools/fuchsia/build_fuchsia_artifacts.py b/tools/fuchsia/build_fuchsia_artifacts.py index 5258466145387..3a30ad47bcd39 100755 --- a/tools/fuchsia/build_fuchsia_artifacts.py +++ b/tools/fuchsia/build_fuchsia_artifacts.py @@ -146,6 +146,8 @@ def CopyZirconFFILibIfExists(source, destination): FindFileAndCopyTo('libzircon_ffi.so', source_root, destination_base) +# TODO(zijiehe): http://crbug.com/368608542, avoid using pm or building far +# packages here, packages should be built by ninja. def CopyToBucketWithMode(source, destination, aot, product, runner_type, api_level): mode = 'aot' if aot else 'jit' product_suff = '_product' if product else '' diff --git a/tools/fuchsia/copy_path.py b/tools/fuchsia/copy_path.py deleted file mode 100755 index 7f46cb0918057..0000000000000 --- a/tools/fuchsia/copy_path.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env python3 -# -# 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 paths, creates if they do not exist. -""" - -import argparse -import errno -import json -import os -import platform -import shutil -import subprocess -import sys - - -def EnsureParentExists(path): - dir_name, _ = os.path.split(path) - if not os.path.exists(dir_name): - os.makedirs(dir_name) - - -def SameStat(s1, s2): - return s1.st_ino == s2.st_ino and s1.st_dev == s2.st_dev - - -def SameFile(f1, f2): - if not os.path.exists(f2): - return False - s1 = os.stat(f1) - s2 = os.stat(f2) - return SameStat(s1, s2) - - -def CopyPath(src, dst): - try: - EnsureParentExists(dst) - shutil.copytree(src, dst) - except OSError as exc: - if exc.errno == errno.ENOTDIR: - if not SameFile(src, dst): - shutil.copyfile(src, dst) - else: - raise - - -def main(): - parser = argparse.ArgumentParser() - - parser.add_argument('--file-list', dest='file_list', action='store', required=True) - - args = parser.parse_args() - - files = open(args.file_list, 'r') - files_to_copy = files.read().split() - num_files = len(files_to_copy) // 2 - - for i in range(num_files): - CopyPath(files_to_copy[i], files_to_copy[num_files + i]) - - return 0 - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/tools/fuchsia/fuchsia_archive.gni b/tools/fuchsia/fuchsia_archive.gni index d18a4c9ec8043..911c30ac3da03 100644 --- a/tools/fuchsia/fuchsia_archive.gni +++ b/tools/fuchsia/fuchsia_archive.gni @@ -5,244 +5,135 @@ import("//flutter/tools/fuchsia/fuchsia_debug_symbols.gni") import("//flutter/tools/fuchsia/fuchsia_libs.gni") import("//flutter/tools/fuchsia/gn-sdk/src/cmc.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/component.gni") import("//flutter/tools/fuchsia/gn-sdk/src/gn_configs.gni") +import("//flutter/tools/fuchsia/gn-sdk/src/package.gni") -# Alias of cmc_compile in gn-sdk/src/cmc.gni -template("_compile_cml") { - assert(defined(invoker.manifest), "_compile_cml must define manifest") - - # Create an empty depfile, it's not used in flutter. - write_file("${target_gen_dir}/${target_name}/${target_name}.d", - [], - "list lines") - - cmc_compile(target_name) { - forward_variables_from(invoker, - [ - "deps", - "manifest", - "testonly", - ]) - output_file = invoker.output - } -} - -# TODO(zijiehe): May use fuchsia_package in gn-sdk if possible. - http://crbug.com/40935282 - -# Creates a Fuchsia archive (.far) file using PM from the Fuchsia SDK. +# Creates a Fuchsia archive (.far) file from the Fuchsia SDK and gn-sdk. # -# binary (required): -# The ELF binary for the archive's program. +# An archive combines an ELF binary and a component manifest to create +# a packaged Fuchsia program that can be deployed to a Fuchsia device. +# +# binary (optional): +# The ELF binary for the archive's program, or target_name if unspecified. # deps (optional): # The code dependencies for the archive. -# inputs (optional): -# When these files are changed, the package should be regenerated. # libraries (optional): # Paths to .so libraries that should be dynamically linked to the binary. +# manifest (optional): +# The component manifest cml file, or meta/binary.cml if unspecified. # resources (optional): # Files that should be placed into the `data/` directory of the archive. # testonly (optional): # Set this to true for archives that are only used for tests. -template("_fuchsia_archive") { - assert(defined(invoker.binary), "package must define binary") +template("fuchsia_archive") { + if (defined(invoker.binary)) { + _binary = invoker.binary + } else { + _binary = target_name + } - pkg_testonly = defined(invoker.testonly) && invoker.testonly - pkg_target_name = target_name - pkg = { - package_version = "0" # placeholder + if (defined(invoker.manifest)) { + _manifest = invoker.manifest + } else { + _manifest = rebase_path("meta/${_binary}.cml") + } + + _component_target = target_name + "__component" + fuchsia_component(_component_target) { forward_variables_from(invoker, [ - "binary", "deps", - "resources", - "libraries", + "testonly", ]) - if (!defined(package_name)) { - package_name = pkg_target_name - } - if (!defined(deps)) { - deps = [] - } - if (!defined(resources)) { - resources = [] - } - if (!defined(libraries)) { - libraries = [] - } - } - - far_base_dir = "$root_out_dir/${pkg_target_name}_far" - - copy_sources = [ "$root_out_dir/${invoker.binary}" ] - copy_outputs = [ "$far_base_dir/bin/app" ] - - foreach(res, pkg.resources) { - copy_sources += [ res.path ] - copy_outputs += [ "$far_base_dir/data/${res.dest}" ] - } - - foreach(lib, pkg.libraries) { - output_path = "" + manifest = _manifest - if (defined(lib.output_path)) { - output_path = lib.output_path + resources = [ + { + path = "$root_out_dir/$_binary" + dest = "bin/app" + }, + ] + if (defined(invoker.resources)) { + foreach(resource, invoker.resources) { + resources += [ + { + path = resource.path + dest = "data/${resource.dest}" + }, + ] + } } - copy_sources += [ "${lib.path}/${lib.name}" ] - copy_outputs += [ "$far_base_dir/lib/${output_path}${lib.name}" ] - } - - pkg_dir_deps = pkg.deps - - write_file("${far_base_dir}/meta/package", - { - name = pkg.package_name - version = pkg.package_version - }, - "json") - - _dbg_symbols_target = "${target_name}_dbg_symbols" - fuchsia_debug_symbols(_dbg_symbols_target) { - deps = pkg.deps - testonly = pkg_testonly - binary = invoker.binary - } - - action("${target_name}_dir") { - script = "//flutter/tools/fuchsia/copy_path.py" - sources = copy_sources - response_file_contents = rebase_path(copy_sources + copy_outputs) - deps = pkg_dir_deps - args = [ "--file-list={{response_file_name}}" ] - outputs = copy_outputs - testonly = pkg_testonly - } - - manifest_json_file = "${root_out_dir}/${target_name}_package_manifest.json" - action(target_name) { - script = "//flutter/tools/fuchsia/gen_package.py" - deps = pkg_dir_deps + [ - ":${target_name}_dir", - ":${_dbg_symbols_target}", - ] - - sources = copy_outputs - - inputs = [] - if (defined(invoker.inputs)) { - inputs += invoker.inputs + _libs = common_libs + if (defined(invoker.libraries)) { + _libs += invoker.libraries } - - args = [ - "--pm-bin", - rebase_path("$fuchsia_tool_dir/pm"), - "--package-dir", - rebase_path(far_base_dir), - "--far-name", - target_name, - "--manifest-json-file", - rebase_path(manifest_json_file, root_build_dir), - ] - - assert(fuchsia_target_api_level != -1, - "Must set a target api level when creating an archive") - if (fuchsia_target_api_level != -1) { - args += [ - "--api-level", - "${fuchsia_target_api_level}", + foreach(lib, _libs) { + output_path = "" + if (defined(lib.output_path)) { + output_path = lib.output_path + } + resources += [ + { + path = "${lib.path}/${lib.name}" + dest = "lib/${output_path}${lib.name}" + }, ] } - - outputs = [ - manifest_json_file, - "${far_base_dir}.manifest", - "$root_out_dir/${target_name}-0.far", - ] - testonly = pkg_testonly - } -} - -# Creates a Fuchsia archive. -# -# An archive combines an ELF binary and a component manifest to create -# a packaged Fuchsia program that can be deployed to a Fuchsia device. -# -# binary (optional): -# The ELF binary for the archive's program, or target_name if unspecified. -# deps (optional): -# The code dependencies for the archive. -# inputs (optional): -# When these files are changed, the package should be regenerated. -# libraries (optional): -# Paths to .so libraries that should be dynamically linked to the binary. -# resources (optional): -# Files that should be placed into the `data/` directory of the archive. -# testonly (optional): -# Set this to true for archives that are only used for tests. -template("fuchsia_archive") { - if (!defined(invoker.binary)) { - _binary = target_name - } else { - _binary = invoker.binary } - _deps = [] - if (defined(invoker.deps)) { - _deps += invoker.deps - } - - _cml_file = rebase_path("meta/${_binary}.cml") - _far_base_dir = "$root_out_dir/${target_name}_far" - _cml_file_name = get_path_info(_cml_file, "name") - _compile_cml_target = "${target_name}_${_cml_file_name}_compile_cml" - _compile_cml(_compile_cml_target) { + _package_target = target_name + "__package" + _package_name = target_name + fuchsia_package(_package_target) { forward_variables_from(invoker, [ "testonly" ]) - - manifest = _cml_file - output = "$_far_base_dir/meta/${_cml_file_name}.cm" + package_name = _package_name + deps = [ ":$_component_target" ] } - _deps += [ ":$_compile_cml_target" ] - _fuchsia_archive(target_name) { - deps = _deps - binary = _binary + # TODO(zijiehe): http://crbug.com/368608542, prefer using + # gn-sdk/build_id_dir.gni + _build_id_target = target_name + "__build_id" + fuchsia_debug_symbols(_build_id_target) { forward_variables_from(invoker, [ - "inputs", - "libraries", - "resources", + "deps", "testonly", ]) + binary = _binary + } + + # TODO(zijiehe): http://crbug.com/368608542, copying the far files is not very + # necessary, try to remove the -0.far copy. + copy(target_name) { + forward_variables_from(invoker, [ "testonly" ]) + package_output_dir = get_label_info(":$_package_target", "target_gen_dir") + sources = [ "$package_output_dir/$_package_name/${_package_name}.far" ] + outputs = [ "$root_out_dir/${_package_name}-0.far" ] + deps = [ + ":$_build_id_target", + ":$_package_target", + ] } } # Creates a Fuchsia archive (.far) file containing a generated test root -# component and test driver component, using PM from the Fuchsia SDK. +# component and test driver component. # -# binary (optional): -# The binary for the test, or target_name if unspecified. +# binary: +# Forward to fuchsia_archive # deps (required): # Dependencies for the test archive. # gen_cml_file (optional): # If is defined and true, an interpolate cml file will be generated. -# libraries (optional): -# Paths to .so libraries that should be dynamically linked to the binary. -# resources (optional): -# Files that should be placed into the `data/` directory of the archive. +# libraries: +# Forward to fuchsia_archive +# resources: +# Forward to fuchsia_archive template("fuchsia_test_archive") { assert(defined(invoker.deps), "package must define deps") - if (!defined(invoker.binary)) { - _binary = target_name - } else { - _binary = invoker.binary - } - _deps = [] - if (defined(invoker.deps)) { - _deps += invoker.deps - } - - _generated_cml = defined(invoker.gen_cml_file) && invoker.gen_cml_file - if (_generated_cml) { + _deps = invoker.deps + if (defined(invoker.gen_cml_file) && invoker.gen_cml_file) { _cml_file = "$root_out_dir/${target_name}.cml" _interpolate_cml_target = "${target_name}_interpolate_cml" action(_interpolate_cml_target) { @@ -259,36 +150,20 @@ template("fuchsia_test_archive") { ] outputs = [ _cml_file ] } - } else { - _cml_file = rebase_path("meta/${_binary}.cml") + _deps += [ ":$_interpolate_cml_target" ] } - _far_base_dir = "$root_out_dir/${target_name}_far" - _cml_file_name = get_path_info(_cml_file, "name") - _compile_cml_target = "${target_name}_${_cml_file_name}_compile_cml" - - _compile_cml(_compile_cml_target) { - testonly = true - - manifest = _cml_file - output = "$_far_base_dir/meta/${_cml_file_name}.cm" - - if (_generated_cml) { - deps = [ ":$_interpolate_cml_target" ] - } - } - _deps += [ ":$_compile_cml_target" ] - - _fuchsia_archive(target_name) { + fuchsia_archive(target_name) { + forward_variables_from(invoker, + [ + "binary", + "libraries", + "resources", + ]) testonly = true - binary = _binary - forward_variables_from(invoker, [ "resources" ]) - - libraries = common_libs - if (defined(invoker.libraries)) { - libraries += invoker.libraries + if (defined(_cml_file)) { + manifest = _cml_file } - deps = _deps } } diff --git a/tools/fuchsia/gen_repo.py b/tools/fuchsia/gen_repo.py deleted file mode 100755 index b795254b8df06..0000000000000 --- a/tools/fuchsia/gen_repo.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env python3 -# -# 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. - -""" Generate a Fuchsia repo capable of serving Fuchsia archives over the -network. -""" -import argparse -import collections -import json -import os -import subprocess -import sys - - -def main(): - parser = argparse.ArgumentParser() - - parser.add_argument('--pm-bin', dest='pm_bin', action='store', required=True) - parser.add_argument('--repo-dir', dest='repo_dir', action='store', required=True) - parser.add_argument('--archive', dest='archives', action='append', required=True) - - args = parser.parse_args() - - assert os.path.exists(args.pm_bin) - - if not os.path.exists(args.repo_dir): - pm_newrepo_command = [args.pm_bin, 'newrepo', '-repo', args.repo_dir] - subprocess.check_call(pm_newrepo_command) - - pm_publish_command = [ - args.pm_bin, - 'publish', - '-C', # Remove all previous registrations. - '-a', # Publish archives from an archive (mode). - '-repo', - args.repo_dir - ] - - for archive in args.archives: - pm_publish_command.append('-f') - pm_publish_command.append(archive) - - subprocess.check_call(pm_publish_command) - - return 0 - - -if __name__ == '__main__': - sys.exit(main())