Flutter Engine
The Flutter Engine
gen_app_invocation.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# Copyright 2013 The Flutter Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6import argparse
7import os
8import stat
9import string
10import sys
11
12
13def main():
14 parser = argparse.ArgumentParser(description='Generate a script that invokes a Dart application')
15 parser.add_argument('--out', help='Path to the invocation file to generate', required=True)
16 parser.add_argument('--dart', help='Path to the Dart binary', required=True)
17 parser.add_argument('--snapshot', help='Path to the app snapshot', required=True)
18 args = parser.parse_args()
19
20 app_file = args.out
21 app_path = os.path.dirname(app_file)
22 if not os.path.exists(app_path):
23 os.makedirs(app_path)
24
25 script_template = string.Template('''#!/bin/sh
26
27$dart \\
28 $snapshot \\
29 "$$@"
30''')
31 with open(app_file, 'w') as file:
32 file.write(script_template.substitute(args.__dict__))
33 permissions = (
34 stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRGRP | stat.S_IWGRP
35 | stat.S_IXGRP | stat.S_IROTH
36 )
37 os.chmod(app_file, permissions)
38
39
40if __name__ == '__main__':
41 sys.exit(main())
Definition: main.py:1