Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: scripts/slave/recipes/flutter/flutter.py

Issue 1768473002: setup the correct version of Xcode (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import contextlib 5 import contextlib
6 6
7 DEPS = [ 7 DEPS = [
8 'depot_tools/git', 8 'depot_tools/git',
9 'file', 9 'file',
10 'gsutil', 10 'gsutil',
11 'recipe_engine/json',
11 'recipe_engine/path', 12 'recipe_engine/path',
12 'recipe_engine/platform', 13 'recipe_engine/platform',
13 'recipe_engine/properties', 14 'recipe_engine/properties',
14 'recipe_engine/step', 15 'recipe_engine/step',
15 ] 16 ]
16 17
17 BUCKET_NAME = 'flutter_infra' 18 BUCKET_NAME = 'flutter_infra'
18 19
19 20
20 def GetCloudPath(api, git_hash, path): 21 def GetCloudPath(api, git_hash, path):
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 if api.platform.is_linux: 121 if api.platform.is_linux:
121 cloud_path = GetCloudPath(api, git_hash, 'examples/%s' % apk_name) 122 cloud_path = GetCloudPath(api, git_hash, 'examples/%s' % apk_name)
122 api.gsutil.upload(app_path.join('build/app.apk'), BUCKET_NAME, cloud_path, 123 api.gsutil.upload(app_path.join('build/app.apk'), BUCKET_NAME, cloud_path,
123 link_name=apk_name, name='upload %s' % apk_name) 124 link_name=apk_name, name='upload %s' % apk_name)
124 125
125 # TODO(eseidel): We should not have to hard-code the desired apk name here. 126 # TODO(eseidel): We should not have to hard-code the desired apk name here.
126 ArchiveAPK(api, 'examples/stocks', 'Stocks.apk') 127 ArchiveAPK(api, 'examples/stocks', 'Stocks.apk')
127 ArchiveAPK(api, 'examples/material_gallery', 'Gallery.apk') 128 ArchiveAPK(api, 'examples/material_gallery', 'Gallery.apk')
128 129
129 130
131 def RunFindXcode(target_version=None):
132 """Runs the `build/scripts/slave/ios/find_xcode.py` utility to retrieve
133 information about xcode installations and to activate a specific version
134 of Xcode.
135 """
136 import json
137 import os
138 import string
139 import subprocess
140 import sys
141 import tempfile
iannucci 2016/03/04 17:58:05 Whoops. This not lgtm for sure. This will break th
142
143 scripts_dir = os.path.dirname(os.path.dirname(os.path.dirname(
144 os.path.dirname(os.path.abspath(__file__)))))
145
146 find_xcode_py_path = os.path.join(
147 scripts_dir,
eseidel1 2016/03/04 04:25:05 I think this is api.path['build'].join('scripts'),
yjbanov 2016/03/04 17:45:50 I tried that, but for some reason api.path['build'
iannucci 2016/03/04 17:58:05 This should be rewritten to use the recipe apis to
148 'slave/ios/find_xcode.py'
149 )
150
151 json_file = tempfile.mkstemp(prefix='xcode-info')[1]
152
153 args = [
154 find_xcode_py_path,
155 '--json-file', json_file,
156 ]
157
158 if target_version is not None:
159 args.extend(['--version', '7.2.1'])
160
161 find_proc = subprocess.Popen(args, stdout=subprocess.PIPE,
162 stderr=subprocess.PIPE, cwd=scripts_dir, env={'PYTHONPATH': scripts_dir})
163
164 (stdout, stderr) = find_proc.communicate()
165 if find_proc.returncode != 0:
166 raise Exception(find_proc.returncode, stdout, stderr)
167
168 with open(json_file, 'r') as xcode_info_reader:
169 return json.loads(xcode_info_reader.read())
170
171
172 def SetupXcode(api):
173 if api.platform.is_mac:
174 xcode_json = RunFindXcode()
175 installations = xcode_json["installations"]
176 activate_version = None
177 for key in installations:
178 version = installations[key].split()[0]
179 if version.startswith('7.'):
180 activate_version = version
181 break
182 if activate_version is None:
183 raise Exception('Xcode version 7 or above not found')
184 print 'Activating Xcode version %s' % version
185 RunFindXcode(target_version=activate_version)
186
187
130 def RunSteps(api): 188 def RunSteps(api):
131 # buildbot sets 'clobber' to the empty string which is falsey, check with 'in' 189 # buildbot sets 'clobber' to the empty string which is falsey, check with 'in'
132 if 'clobber' in api.properties: 190 if 'clobber' in api.properties:
133 api.file.rmcontents('everything', api.path['slave_build']) 191 api.file.rmcontents('everything', api.path['slave_build'])
134 192
135 git_hash = api.git.checkout( 193 git_hash = api.git.checkout(
136 'https://chromium.googlesource.com/external/github.com/flutter/flutter', 194 'https://chromium.googlesource.com/external/github.com/flutter/flutter',
137 recursive=True, set_got_revision=True) 195 recursive=True, set_got_revision=True)
138 checkout = api.path['checkout'] 196 checkout = api.path['checkout']
139 197
140 api.step('download android tools', 198 api.step('download android tools',
141 [checkout.join('infra', 'download_android_tools.py')]) 199 [checkout.join('infra', 'download_android_tools.py')])
142 200
143 dart_bin = checkout.join('bin', 'cache', 'dart-sdk', 'bin') 201 dart_bin = checkout.join('bin', 'cache', 'dart-sdk', 'bin')
144 flutter_bin = checkout.join('bin') 202 flutter_bin = checkout.join('bin')
145 # TODO(eseidel): This is named exactly '.pub-cache' as a hack around 203 # TODO(eseidel): This is named exactly '.pub-cache' as a hack around
146 # a regexp in flutter_tools analyze.dart which is in turn a hack around: 204 # a regexp in flutter_tools analyze.dart which is in turn a hack around:
147 # https://github.com/dart-lang/sdk/issues/25722 205 # https://github.com/dart-lang/sdk/issues/25722
148 pub_cache = api.path['slave_build'].join('.pub-cache') 206 pub_cache = api.path['slave_build'].join('.pub-cache')
149 env = { 207 env = {
150 'PATH': api.path.pathsep.join((str(flutter_bin), str(dart_bin), 208 'PATH': api.path.pathsep.join((str(flutter_bin), str(dart_bin),
151 '%(PATH)s')), 209 '%(PATH)s')),
152 # Setup our own pub_cache to not affect other slaves on this machine. 210 # Setup our own pub_cache to not affect other slaves on this machine.
153 'PUB_CACHE': pub_cache, 211 'PUB_CACHE': pub_cache,
154 'ANDROID_HOME': checkout.join('infra', 'android_tools'), 212 'ANDROID_HOME': checkout.join('infra', 'android_tools'),
155 } 213 }
156 214
157 # The context adds dart-sdk tools to PATH sets PUB_CACHE. 215 # The context adds dart-sdk tools to PATH sets PUB_CACHE.
158 with api.step.context({'env': env}): 216 with api.step.context({'env': env}):
217 SetupXcode(api)
eseidel1 2016/03/04 04:25:06 Do you need to take the results of finding XCode t
yjbanov 2016/03/04 17:45:50 The `find_xcode.py` utility uses `xcode-select` to
218
159 # Must be first to download dependencies for later steps. 219 # Must be first to download dependencies for later steps.
160 api.step('flutter doctor', ['flutter', 'doctor']) 220 api.step('flutter doctor', ['flutter', 'doctor'])
161 api.step('update packages', ['flutter', 'update-packages']) 221 api.step('update packages', ['flutter', 'update-packages'])
162 AnalyzeFlutter(api) 222 AnalyzeFlutter(api)
163 TestFlutterPackagesAndExamples(api) 223 TestFlutterPackagesAndExamples(api)
164 BuildExamples(api, git_hash) 224 BuildExamples(api, git_hash)
165 225
166 # TODO(yjbanov): we do not yet have Android devices hooked up, nor do we 226 # TODO(yjbanov): we do not yet have Android devices hooked up, nor do we
167 # support the Android emulator. For now, only run on iOS Simulator. 227 # support the Android emulator. For now, only run on iOS Simulator.
168 if api.platform.is_mac: 228 if api.platform.is_mac:
169 TestCreateAndLaunch(api) 229 TestCreateAndLaunch(api)
170 230
171 # TODO(eseidel): We only want to generate one copy of the docs at a time 231 # TODO(eseidel): We only want to generate one copy of the docs at a time
172 # otherwise multiple rsyncs could race, causing badness. We'll eventually 232 # otherwise multiple rsyncs could race, causing badness. We'll eventually
173 # need both a lock on the bucket, as well as some assurance that we're 233 # need both a lock on the bucket, as well as some assurance that we're
174 # always moving the docs forward. Possibly by using a separate builder. 234 # always moving the docs forward. Possibly by using a separate builder.
175 # Until then, only generate on linux to reduce the chance of race. 235 # Until then, only generate on linux to reduce the chance of race.
176 if api.platform.is_linux: 236 if api.platform.is_linux:
177 # TODO(eseidel): Is there a way for GenerateDocs to read PUB_CACHE from 237 # TODO(eseidel): Is there a way for GenerateDocs to read PUB_CACHE from
178 # the env instead of me passing it in? 238 # the env instead of me passing it in?
179 GenerateDocs(api, pub_cache) 239 GenerateDocs(api, pub_cache)
180 240
181 241
182 def GenTests(api): 242 def GenTests(api):
183 for platform in ('mac', 'linux'): 243 for platform in ('mac', 'linux'):
184 yield (api.test(platform) + api.platform(platform, 64) + 244 yield (api.test(platform) + api.platform(platform, 64) +
185 api.properties(clobber='')) 245 api.properties(clobber=''))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698