Flutter Engine
The Flutter Engine
with_envs.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
3# for details. All rights reserved. Use of this source code is governed by a
4# BSD-style license that can be found in the LICENSE file.
5
6import os
7import platform
8import subprocess
9import sys
10
11sys.path.insert(
12 0,
13 os.path.abspath(
14 os.path.join(os.path.dirname(__file__),
15 '../../third_party/fuchsia/test_scripts/test/')))
16
17from common import catch_sigterm, wait_for_sigterm
18
19
20def Main():
21 """
22 Execute the test-scripts with required environment variables. It acts like
23 /usr/bin/env, but provides some extra functionality to dynamically set up
24 the environment variables.
25 """
26 # Ensures the signals can be correctly forwarded to the subprocesses.
27 catch_sigterm()
28
29 os.environ['SRC_ROOT'] = os.path.abspath(
30 os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
31 os.environ['FUCHSIA_IMAGES_ROOT'] = os.path.join(os.environ['SRC_ROOT'],
32 'third_party', 'fuchsia',
33 'images')
34 sdk_dir = ''
35 if platform.system() == 'Linux':
36 sdk_dir = 'linux'
37 elif platform.system() == 'Darwin':
38 sdk_dir = 'mac'
39 else:
40 assert False, 'Unsupported OS'
41 os.environ['FUCHSIA_SDK_ROOT'] = os.path.join(os.environ['SRC_ROOT'],
42 'third_party', 'fuchsia',
43 'sdk', sdk_dir)
44
45 os.environ['FUCHSIA_GN_SDK_ROOT'] = os.path.join(os.environ['SRC_ROOT'],
46 'third_party', 'fuchsia',
47 'gn-sdk', 'src')
48
49 with subprocess.Popen(sys.argv[1:]) as proc:
50 try:
51 proc.wait()
52 except:
53 # Use terminate / SIGTERM to allow the subprocess exiting cleanly.
54 proc.terminate()
55 return proc.returncode
56
57
58if __name__ == '__main__':
59 sys.exit(Main())
def Main()
Definition: with_envs.py:20