forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zip_bundle.gni
107 lines (101 loc) · 3.14 KB
/
zip_bundle.gni
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# 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.
import("//flutter/common/config.gni")
if (flutter_runtime_mode == "jit_release") {
android_zip_archive_dir = "android-$target_cpu-jit-release"
} else {
android_zip_archive_dir = "android-$target_cpu"
if (flutter_runtime_mode != "debug") {
android_zip_archive_dir += "-$flutter_runtime_mode"
}
}
# Creates a zip file in the $root_build_dir/zip_archives folder.
#
# The output variable specifies the name of the zip file to create.
# The files variable is an array of scopes that specify a source file or
# directory and a destination path in the archive to create.
#
# For example, to create a zip file named archive.zip with all files in the
# root directory of the archive:
#
# zip_bundle("sample") {
# output = "archive.zip"
# files = [
# {
# source = "$root_build_dir/some/path/to/lib.so"
# destination = "lib.so"
# },
# {
# source = "$root_build_dir/some/other/path/with/files"
# destination = "other_files"
# },
# ]
# }
template("zip_bundle") {
assert(defined(invoker.output), "output must be defined")
assert(defined(invoker.files), "files must be defined as a list of scopes")
action(target_name) {
script = "//flutter/build/zip.py"
outputs = [ "$root_build_dir/zip_archives/${invoker.output}" ]
sources = []
forward_variables_from(invoker, [ "visibility" ])
deps = invoker.deps
args = [
"-o",
rebase_path(outputs[0]),
]
foreach(input, invoker.files) {
args += [
"-i",
rebase_path(input.source),
input.destination,
]
sources += [ input.source ]
}
}
}
# Creates a zip file in the $root_build_dir/zip_archives folder.
#
# The output variable specifies the name of the zip file to create.
# The files variable is an array of scopes that specify a source file or
# directory and a destination path in the archive to create.
#
# For example, to create a zip file named archive.zip with all files in the
# root directory of the archive:
#
# zip_bundle("sample") {
# output = "archive.zip"
# files = [
# {
# source = rebase_path("$root_build_dir/some/path/to/lib.so")
# destination = "lib.so"
# },
# {
# source = rebase_path("$root_build_dir/some/other/path/with/files")
# destination = "other_files"
# },
# ]
# }
template("zip_bundle_from_file") {
assert(defined(invoker.output), "output must be defined")
assert(defined(invoker.files), "files must be defined as a list of scopes")
action(target_name) {
forward_variables_from(invoker,
[
"visibility",
"deps",
])
script = "//flutter/build/zip.py"
outputs = [ "$root_build_dir/zip_archives/${invoker.output}" ]
sources = []
location_source_path = "$target_gen_dir/zip_bundle.txt"
write_file(location_source_path, invoker.files, "json")
args = [
"-o",
rebase_path(outputs[0]),
"-f",
rebase_path(location_source_path),
]
}
}