Fix web_engine_archive target. (flutter/engine#31751)
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
# found in the LICENSE file.
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import zipfile
|
||||
import os
|
||||
import sys
|
||||
@@ -20,11 +21,20 @@ def _zip_dir(path, zip_file, prefix):
|
||||
|
||||
def main(args):
|
||||
zip_file = zipfile.ZipFile(args.output, 'w', zipfile.ZIP_DEFLATED)
|
||||
for path, archive_name in args.input_pairs:
|
||||
if os.path.isdir(path):
|
||||
_zip_dir(path, zip_file, archive_name)
|
||||
else:
|
||||
zip_file.write(path, archive_name)
|
||||
if args.source_file:
|
||||
with open(args.source_file) as source_file:
|
||||
file_dict_list = json.load(source_file)
|
||||
for file_dict in file_dict_list:
|
||||
if os.path.isdir(file_dict['source']):
|
||||
_zip_dir(file_dict['source'], zip_file, file_dict['destination'])
|
||||
else:
|
||||
zip_file.write(file_dict['source'], file_dict['destination'])
|
||||
else:
|
||||
for path, archive_name in args.input_pairs:
|
||||
if os.path.isdir(path):
|
||||
_zip_dir(path, zip_file, archive_name)
|
||||
else:
|
||||
zip_file.write(path, archive_name)
|
||||
zip_file.close()
|
||||
|
||||
|
||||
@@ -35,4 +45,6 @@ if __name__ == '__main__':
|
||||
help='The name of the output zip file.')
|
||||
parser.add_argument('-i', dest='input_pairs', nargs=2, action='append',
|
||||
help='The input file and its destination location in the zip archive.')
|
||||
parser.add_argument('-f', dest='source_file', action='store',
|
||||
help='The path to the file list to zip.')
|
||||
sys.exit(main(parser.parse_args()))
|
||||
|
||||
@@ -58,3 +58,45 @@ template("zip_bundle") {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# 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) {
|
||||
script = "//flutter/build/zip.py"
|
||||
outputs = [ "$root_build_dir/zip_archives/${invoker.output}" ]
|
||||
sources = []
|
||||
deps = invoker.deps
|
||||
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),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,8 @@ web_engine_sources =
|
||||
],
|
||||
"list lines")
|
||||
|
||||
web_engine_sources += [ "//flutter/lib/web_ui/lib/src/engine.dart" ]
|
||||
web_engine_sources +=
|
||||
[ rebase_path("//flutter/lib/web_ui/lib/src/engine.dart") ]
|
||||
|
||||
group("web_sdk") {
|
||||
deps = [
|
||||
@@ -567,7 +568,7 @@ _kernel_worker("flutter_dartdevc_kernel_sdk_outline_sound") {
|
||||
|
||||
# Archives Flutter Web SDK
|
||||
if (!is_fuchsia) {
|
||||
zip_bundle("flutter_web_sdk_archive") {
|
||||
zip_bundle_from_file("flutter_web_sdk_archive") {
|
||||
output = "flutter-web-sdk-${full_platform_name}.zip"
|
||||
deps = [
|
||||
":flutter_dartdevc_canvaskit_html_kernel_sdk",
|
||||
@@ -597,7 +598,7 @@ if (!is_fuchsia) {
|
||||
foreach(source, sources) {
|
||||
tmp_files += [
|
||||
{
|
||||
source = source
|
||||
source = rebase_path(source)
|
||||
destination = rebase_path(source, "$root_build_dir")
|
||||
},
|
||||
]
|
||||
@@ -606,7 +607,7 @@ if (!is_fuchsia) {
|
||||
rebased_path = rebase_path(source, "//flutter/lib/web_ui/lib")
|
||||
tmp_files += [
|
||||
{
|
||||
source = source
|
||||
source = rebase_path(source)
|
||||
destination = "flutter_web_sdk/lib/ui/$rebased_path"
|
||||
},
|
||||
]
|
||||
@@ -615,7 +616,7 @@ if (!is_fuchsia) {
|
||||
rebased_path = rebase_path(source, "//flutter/lib/web_ui/lib/src")
|
||||
tmp_files += [
|
||||
{
|
||||
source = source
|
||||
source = rebase_path(source)
|
||||
destination = "flutter_web_sdk/lib/_engine/$rebased_path"
|
||||
},
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user