1# Copyright 2013 The Flutter Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5# Creates a package dir that we will them use pm to package. 6# 7# This currently ignores the CMX files and does minimal validation. 8template("package_dir") { 9 assert(defined(invoker.binary), "package must define binary") 10 assert(defined(invoker.meta_dir), "package must define meta_dir") 11 12 pkg_target_name = target_name 13 pkg = { 14 package_version = "0" # placeholder 15 forward_variables_from(invoker, 16 [ 17 "binary", 18 "deps", 19 "meta", 20 "resources", 21 "libraries", 22 "meta_dir", 23 ]) 24 if (!defined(package_name)) { 25 package_name = pkg_target_name 26 } 27 if (!defined(meta)) { 28 meta = [] 29 } 30 if (!defined(deps)) { 31 deps = [] 32 } 33 if (!defined(resources)) { 34 resources = [] 35 } 36 if (!defined(libraries)) { 37 libraries = [] 38 } 39 } 40 41 far_base_dir = "$root_out_dir/${pkg_target_name}_far" 42 43 copy_sources = [ "$root_out_dir/${invoker.binary}" ] 44 copy_outputs = [ "$far_base_dir/bin/app" ] 45 46 foreach(res, pkg.resources) { 47 copy_sources += [ res.path ] 48 copy_outputs += [ "$far_base_dir/data/${res.dest}" ] 49 } 50 51 foreach(lib, pkg.libraries) { 52 copy_sources += [ "${lib.path}/${lib.name}" ] 53 copy_outputs += [ "$far_base_dir/lib/${lib.name}" ] 54 } 55 56 meta_dir = pkg.meta_dir 57 58 cmx_target = "$pkg_target_name.copy_cmx" 59 60 copy("$cmx_target") { 61 sources = [ "${meta_dir}/${pkg_target_name}.cmx" ] 62 outputs = [ "$far_base_dir/meta/{{source_file_part}}" ] 63 } 64 65 action(target_name) { 66 script = "$flutter_root/tools/fuchsia/copy_path.py" 67 response_file_contents = rebase_path(copy_sources + copy_outputs) 68 deps = pkg.deps + [ ":$cmx_target" ] 69 args = [ "--file-list={{response_file_name}}" ] 70 outputs = copy_outputs 71 } 72} 73