Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
gather_flutter_runner_artifacts.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2#
3# Copyright 2013 The Flutter Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7""" Gather all the fuchsia artifacts to a destination directory.
8"""
9
10import argparse
11import errno
12import json
13import os
14import platform
15import shutil
16import subprocess
17import sys
18
19_ARTIFACT_PATH_TO_DST = {
20 'flutter_jit_runner': 'flutter_jit_runner', 'icudtl.dat': 'data/icudtl.dat',
21 'dart_runner': 'dart_runner', 'flutter_patched_sdk': 'flutter_patched_sdk'
22}
23
24
26 dir_name, _ = os.path.split(path)
27 if not os.path.exists(dir_name):
28 os.makedirs(dir_name)
29
30
31def CopyPath(src, dst):
32 try:
34 shutil.copytree(src, dst)
35 except OSError as exc:
36 if exc.errno == errno.ENOTDIR:
37 shutil.copy(src, dst)
38 else:
39 raise
40
41
42def CreateMetaPackage(dst_root, far_name):
43 meta = os.path.join(dst_root, 'meta')
44 if not os.path.isdir(meta):
45 os.makedirs(meta)
46 content = {}
47 content['name'] = far_name
48 content['version'] = '0'
49 package = os.path.join(meta, 'package')
50 with open(package, 'w') as out_file:
51 json.dump(content, out_file)
52
53
54def GatherArtifacts(src_root, dst_root, create_meta_package=True):
55 if not os.path.exists(dst_root):
56 os.makedirs(dst_root)
57 else:
58 shutil.rmtree(dst_root)
59
60 for src_rel, dst_rel in _ARTIFACT_PATH_TO_DST.items():
61 src_full = os.path.join(src_root, src_rel)
62 dst_full = os.path.join(dst_root, dst_rel)
63 if not os.path.exists(src_full):
64 print('Unable to find artifact: ', str(src_full))
65 sys.exit(1)
66 CopyPath(src_full, dst_full)
67
68 if create_meta_package:
69 CreateMetaPackage(dst_root, 'flutter_runner')
70
71
72def main():
73 parser = argparse.ArgumentParser()
74
75 parser.add_argument('--artifacts-root', dest='artifacts_root', action='store', required=True)
76 parser.add_argument('--dest-dir', dest='dst_dir', action='store', required=True)
77
78 args = parser.parse_args()
79
80 assert os.path.exists(args.artifacts_root)
81 dst_parent = os.path.abspath(os.path.join(args.dst_dir, os.pardir))
82 assert os.path.exists(dst_parent)
83
84 GatherArtifacts(args.artifacts_root, args.dst_dir)
85 return 0
86
87
88if __name__ == '__main__':
89 sys.exit(main())
void print(void *str)
Definition bridge.cpp:126
GatherArtifacts(src_root, dst_root, create_meta_package=True)
Definition main.py:1