forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Android targets create final zip artifacts (flutter#13059)
- Loading branch information
Showing
5 changed files
with
334 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env python | ||
# 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 argparse | ||
import zipfile | ||
import os | ||
import sys | ||
|
||
|
||
def _zip_dir(path, zip_file, prefix): | ||
path = path.rstrip('/\\') | ||
for root, dirs, files in os.walk(path): | ||
for file in files: | ||
zip_file.write(os.path.join(root, file), os.path.join( | ||
root.replace(path, prefix), file)) | ||
|
||
|
||
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) | ||
zip_file.close() | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser( | ||
description='This script creates zip files.') | ||
parser.add_argument('-o', dest='output', action='store', | ||
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.') | ||
sys.exit(main(parser.parse_args())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# 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" | ||
} | ||
|
||
# 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}" ] | ||
inputs = [] | ||
deps = invoker.deps | ||
|
||
args = [ "-o", rebase_path(outputs[0]) ] | ||
foreach(input, invoker.files) { | ||
args += [ | ||
"-i", | ||
rebase_path(input.source), | ||
rebase_path(input.destination), | ||
] | ||
inputs += [ input.source ] | ||
} | ||
} | ||
} |
Oops, something went wrong.