Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
pub_integration_test.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# Copyright (c) 2018, 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 optparse
7import os
8import subprocess
9import sys
10import shutil
11import tempfile
12
13PUBSPEC = """name: pub_integration_test
14environment:
15 sdk: '^2.19.0'
16dependencies:
17 shelf:
18 test:
19"""
20
21
22def Main():
23 parser = optparse.OptionParser()
24 parser.add_option(
25 '--mode', action='store', dest='mode', type='string', default='release')
26 parser.add_option('--arch',
27 action='store',
28 dest='arch',
29 type='string',
30 default='x64')
31
32 (options, args) = parser.parse_args()
33
34 arch = 'ARM64' if options.arch == 'arm64' else 'X64'
35 mode = ('Debug' if options.mode == 'debug' else 'Release')
36
37 out_dir = 'xcodebuild' if sys.platform == 'darwin' else 'out'
38 extension = '' if not sys.platform == 'win32' else '.exe'
39 dart = os.path.abspath('%s/%s%s/dart-sdk/bin/dart%s' %
40 (out_dir, mode, arch, extension))
41 print(dart)
42
43 working_dir = tempfile.mkdtemp()
44 try:
45 pub_cache_dir = working_dir + '/pub_cache'
46 env = os.environ.copy()
47 env['PUB_CACHE'] = pub_cache_dir
48
49 with open(working_dir + '/pubspec.yaml', 'w') as pubspec_yaml:
50 pubspec_yaml.write(PUBSPEC)
51
52 exit_code = subprocess.call([dart, 'pub', 'get'],
53 cwd=working_dir,
54 env=env)
55 if exit_code != 0:
56 return exit_code
57
58 exit_code = subprocess.call([dart, 'pub', 'upgrade'],
59 cwd=working_dir,
60 env=env)
61 if exit_code != 0:
62 return exit_code
63 finally:
64 shutil.rmtree(working_dir)
65
66
67if __name__ == '__main__':
68 sys.exit(Main())
void print(void *str)
Definition bridge.cpp:126