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))
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
def print(*args, **kwargs)