Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
impeller_cmake_build_test.py
Go to the documentation of this file.
1#!/usr/bin/env vpython3
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 subprocess
9import sys
10
11# When passed the --setup flag, this script fetches git submodules and other
12# dependencies for the impeller-cmake-example. When passed the --cmake flag,
13# this script runs cmake on impeller-cmake-example. That will create
14# a build output directory for impeller-cmake-example under
15# out/impeller-cmake-example, so the build can then be performed with
16# e.g. ninja -C out/impeller-cmake-example-out.
17
18SRC_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
19
20
21def parse_args(argv):
22 parser = argparse.ArgumentParser(
23 description='A script that tests the impeller-cmake-example build.',
24 )
25 parser.add_argument(
26 '--cmake',
27 '-c',
28 default=False,
29 action='store_true',
30 help='Run cmake for impeller-cmake-example.',
31 )
32 parser.add_argument(
33 '--path',
34 '-p',
35 type=str,
36 help='The path to the impeller-cmake-example source.',
37 )
38 parser.add_argument(
39 '--setup',
40 '-s',
41 default=False,
42 action='store_true',
43 help='Clone the git submodules.',
44 )
45 parser.add_argument(
46 '--verbose',
47 '-v',
48 default=False,
49 action='store_true',
50 help='Emit verbose output.',
51 )
52 parser.add_argument(
53 '--xcode-symlinks',
54 default=False,
55 action='store_true',
56 help='Symlink the Xcode sysroot to help Goma be successful.',
57 )
58 return parser.parse_args(argv)
59
60
61def validate_args(args):
62 if not os.path.isdir(os.path.join(SRC_ROOT, args.path)):
63 print(
64 'The --path argument must be a valid directory relative to the '
65 'engine src/ directory.'
66 )
67 return False
68
69 return True
70
71
73 find_sdk_command = [
74 'python3',
75 os.path.join(SRC_ROOT, 'build', 'mac', 'find_sdk.py'),
76 '--print_sdk_path',
77 '10.15',
78 '--symlink',
79 os.path.join(SRC_ROOT, 'out', 'impeller-cmake-example-xcode-sysroot'),
80 ]
81 find_sdk_output = subprocess.check_output(find_sdk_command).decode('utf-8')
82 return find_sdk_output.split('\n')[0]
83
84
85def main(argv):
86 args = parse_args(argv[1:])
87 if not validate_args(args):
88 return 1
89
90 impeller_cmake_dir = os.path.join(SRC_ROOT, args.path)
91
92 if args.setup:
93 git_command = [
94 'git',
95 '-C',
96 impeller_cmake_dir,
97 'submodule',
98 'update',
99 '--init',
100 '--recursive',
101 '--depth',
102 '1',
103 '--jobs',
104 str(os.cpu_count()),
105 ]
106 subprocess.check_call(git_command)
107
108 # Run the deps.sh shell script in the repo.
109 subprocess.check_call(['bash', 'deps.sh'], cwd=impeller_cmake_dir)
110 return 0
111
112 if args.cmake:
113 cmake_path = os.path.join(SRC_ROOT, 'buildtools', 'mac-x64', 'cmake', 'bin', 'cmake')
114 cmake_command = [
115 cmake_path,
116 '--preset',
117 'flutter-ci-mac-debug-x64',
118 '-B',
119 os.path.join(SRC_ROOT, 'out', 'impeller-cmake-example'),
120 ]
121 cmake_env = os.environ.copy()
122 ninja_path = os.path.join(SRC_ROOT, 'flutter', 'third_party', 'ninja')
123 cmake_env.update({
124 'PATH': os.environ['PATH'] + ':' + ninja_path,
125 'FLUTTER_ENGINE_SRC_DIR': SRC_ROOT,
126 })
127 if args.xcode_symlinks:
128 xcode_symlink_path = create_xcode_symlink()
129 cmake_env.update({
130 'FLUTTER_OSX_SYSROOT': xcode_symlink_path,
131 })
132 subprocess.check_call(cmake_command, env=cmake_env, cwd=impeller_cmake_dir)
133
134 return 0
135
136
137if __name__ == '__main__':
138 sys.exit(main(sys.argv))
void print(void *str)
Definition bridge.cpp:126
Definition main.py:1
static DecodeResult decode(std::string path)