Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
with_envs.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# Copyright (c) 2013, the Flutter project authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be found
4# in the LICENSE file.
5
6import os
7import platform
8import subprocess
9import sys
10
11sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'test_scripts/test/')))
12
13from common import catch_sigterm, wait_for_sigterm
14
15
16def Main():
17 """
18 Executes the test-scripts with required environment variables. It acts like
19 /usr/bin/env, but provides some extra functionality to dynamically set up
20 the environment variables.
21 """
22 # Ensures the signals can be correctly forwarded to the subprocesses.
23 catch_sigterm()
24
25 os.environ['SRC_ROOT'] = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../'))
26 # Flutter uses a different repo structure and fuchsia sdk is not in the
27 # third_party/, so images root and sdk root need to be explicitly set.
28 os.environ['FUCHSIA_IMAGES_ROOT'] = os.path.join(os.environ['SRC_ROOT'], 'fuchsia/images/')
29
30 assert platform.system() == 'Linux', 'Unsupported OS ' + platform.system()
31 os.environ['FUCHSIA_SDK_ROOT'] = os.path.join(os.environ['SRC_ROOT'], 'fuchsia/sdk/linux/')
32 os.environ['FUCHSIA_GN_SDK_ROOT'] = os.path.join(
33 os.environ['SRC_ROOT'], 'flutter/tools/fuchsia/gn-sdk/src'
34 )
35
36 if os.getenv('DOWNLOAD_FUCHSIA_SDK') == 'True':
37 sdk_path = os.environ['FUCHSIA_SDK_PATH']
38 assert sdk_path.endswith('/linux-amd64/core.tar.gz')
39 assert not sdk_path.startswith('/')
40 os.environ['FUCHSIA_SDK_OVERRIDE'
41 ] = 'gs://fuchsia-artifacts/' + sdk_path[:-len('/linux-amd64/core.tar.gz')]
42
43 with subprocess.Popen(sys.argv[1:]) as proc:
44 try:
45 proc.wait()
46 except:
47 # Use terminate / SIGTERM to allow the subprocess exiting cleanly.
48 proc.terminate()
49 return proc.returncode
50
51
52if __name__ == '__main__':
53 sys.exit(Main())