blob: 87aed988b1370fc979e99553f53c28bbce06faeb [file] [log] [blame]
Brian Harring3fec5a82012-03-01 05:57:03 -08001#!/usr/bin/python
2
3# Copyright (c) 2011-2012 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7"""Main builder code for Chromium OS.
8
9Used by Chromium OS buildbot configuration for all Chromium OS builds including
10full and pre-flight-queue builds.
11"""
12
13import distutils.version
14import glob
David James58e0c092012-03-04 20:31:12 -080015import multiprocessing
Brian Harring3fec5a82012-03-01 05:57:03 -080016import optparse
17import os
18import pprint
19import sys
20
21from chromite.buildbot import builderstage as bs
22from chromite.buildbot import cbuildbot_background as background
23from chromite.buildbot import cbuildbot_config
24from chromite.buildbot import cbuildbot_stages as stages
25from chromite.buildbot import cbuildbot_results as results_lib
Brian Harring3fec5a82012-03-01 05:57:03 -080026from chromite.buildbot import constants
27from chromite.buildbot import gerrit_helper
28from chromite.buildbot import patch as cros_patch
29from chromite.buildbot import remote_try
30from chromite.buildbot import repository
31from chromite.buildbot import tee
32
Brian Harringc92a7012012-02-29 10:11:34 -080033from chromite.lib import cgroups
Brian Harringa184efa2012-03-04 11:51:25 -080034from chromite.lib import cleanup
Brian Harring3fec5a82012-03-01 05:57:03 -080035from chromite.lib import cros_build_lib as cros_lib
36from chromite.lib import sudo
37
Ryan Cuiadd49122012-03-21 22:19:58 -070038
Brian Harring3fec5a82012-03-01 05:57:03 -080039cros_lib.STRICT_SUDO = True
40
41_DEFAULT_LOG_DIR = 'cbuildbot_logs'
42_BUILDBOT_LOG_FILE = 'cbuildbot.log'
43_DEFAULT_EXT_BUILDROOT = 'trybot'
44_DEFAULT_INT_BUILDROOT = 'trybot-internal'
45_PATH_TO_CBUILDBOT = 'chromite/bin/cbuildbot'
46_DISTRIBUTED_TYPES = [constants.COMMIT_QUEUE_TYPE, constants.PFQ_TYPE,
47 constants.CANARY_TYPE, constants.CHROME_PFQ_TYPE,
48 constants.PALADIN_TYPE]
Brian Harring351ce442012-03-09 16:38:14 -080049_BUILDBOT_REQUIRED_BINARIES = ('pbzip2',)
Brian Harring3fec5a82012-03-01 05:57:03 -080050
51
Ryan Cui4f6cf7e2012-04-18 16:12:27 -070052def _PrintValidConfigs(display_all=False):
Brian Harring3fec5a82012-03-01 05:57:03 -080053 """Print a list of valid buildbot configs.
54
55 Arguments:
Ryan Cui4f6cf7e2012-04-18 16:12:27 -070056 display_all: Print all configs. Otherwise, prints only configs with
57 trybot_list=True.
Brian Harring3fec5a82012-03-01 05:57:03 -080058 """
Ryan Cui4f6cf7e2012-04-18 16:12:27 -070059 def _GetSortKey(config_name):
60 config_dict = cbuildbot_config.config[config_name]
61 return (not config_dict['trybot_list'], config_dict['description'],
62 config_name)
63
Brian Harring3fec5a82012-03-01 05:57:03 -080064 COLUMN_WIDTH = 45
65 print 'config'.ljust(COLUMN_WIDTH), 'description'
66 print '------'.ljust(COLUMN_WIDTH), '-----------'
67 config_names = cbuildbot_config.config.keys()
Ryan Cui4f6cf7e2012-04-18 16:12:27 -070068 config_names.sort(key=_GetSortKey)
Brian Harring3fec5a82012-03-01 05:57:03 -080069 for name in config_names:
Ryan Cui4f6cf7e2012-04-18 16:12:27 -070070 if display_all or cbuildbot_config.config[name]['trybot_list']:
71 desc = cbuildbot_config.config[name].get('description')
72 desc = desc if desc else ''
Brian Harring3fec5a82012-03-01 05:57:03 -080073 print name.ljust(COLUMN_WIDTH), desc
74
75
76def _GetConfig(config_name):
77 """Gets the configuration for the build"""
78 if not cbuildbot_config.config.has_key(config_name):
79 print 'Non-existent configuration %s specified.' % config_name
80 print 'Please specify one of:'
81 _PrintValidConfigs()
82 sys.exit(1)
83
84 result = cbuildbot_config.config[config_name]
85
86 return result
87
88
89def _GetChromiteTrackingBranch():
David James66009462012-03-25 10:08:38 -070090 """Returns the remote branch associated with chromite."""
Brian Harring3fec5a82012-03-01 05:57:03 -080091 cwd = os.path.dirname(os.path.realpath(__file__))
David James66009462012-03-25 10:08:38 -070092 branch = cros_lib.GetCurrentBranch(cwd)
93 if branch:
94 tracking_branch = cros_lib.GetTrackingBranch(branch, cwd)[1]
95 if tracking_branch.startswith('refs/heads/'):
96 return tracking_branch.replace('refs/heads/', '')
97 # If we are not on a branch, or if the tracking branch is a revision,
David James8b3c1bf2012-03-28 09:10:16 -070098 # use the push branch. For repo repositories, this will be the manifest
99 # branch configured for this project. For other repositories, we'll just
100 # guess 'master', since there's no easy way to find out what branch
101 # we're on.
102 return cros_lib.GetPushBranch(cwd)[1]
Brian Harring3fec5a82012-03-01 05:57:03 -0800103
104
105def _CheckBuildRootBranch(buildroot, tracking_branch):
106 """Make sure buildroot branch is the same as Chromite branch."""
107 manifest_branch = cros_lib.GetManifestDefaultBranch(buildroot)
108 if manifest_branch != tracking_branch:
109 cros_lib.Die('Chromite is not on same branch as buildroot checkout\n' +
110 'Chromite is on branch %s.\n' % tracking_branch +
111 'Buildroot checked out to %s\n' % manifest_branch)
112
113
114def _PreProcessPatches(gerrit_patches, local_patches):
115 """Validate patches ASAP to catch user errors. Also generate patch info.
116
117 Args:
118 gerrit_patches: List of gerrit CL ID's passed in by user.
119 local_patches: List of local project branches to generate patches from.
120
121 Returns:
122 A tuple containing a list of cros_patch.GerritPatch and a list of
Matt Tennantd55b1f42012-04-13 14:15:01 -0700123 cros_patch.LocalGitRepoPatch objects.
Brian Harring3fec5a82012-03-01 05:57:03 -0800124 """
125 gerrit_patch_info = []
126 local_patch_info = []
127
128 try:
129 if gerrit_patches:
130 gerrit_patch_info = gerrit_helper.GetGerritPatchInfo(gerrit_patches)
131 for patch in gerrit_patch_info:
132 if patch.IsAlreadyMerged():
133 cros_lib.Warning('Patch %s has already been merged.' % str(patch))
134 except gerrit_helper.GerritException as e:
135 cros_lib.Die(str(e))
136
137 try:
138 if local_patches:
139 local_patch_info = cros_patch.PrepareLocalPatches(
140 local_patches,
141 _GetChromiteTrackingBranch())
142
143 except cros_patch.PatchException as e:
144 cros_lib.Die(str(e))
145
146 return gerrit_patch_info, local_patch_info
147
148
149def _IsIncrementalBuild(buildroot, clobber):
150 """Returns True if we are reusing an existing buildroot."""
151 repo_dir = os.path.join(buildroot, '.repo')
152 return not clobber and os.path.isdir(repo_dir)
153
154
155class Builder(object):
156 """Parent class for all builder types.
157
158 This class functions as a parent class for various build types. It's intended
159 use is builder_instance.Run().
160
161 Vars:
Brian Harring3fec5a82012-03-01 05:57:03 -0800162 build_config: The configuration dictionary from cbuildbot_config.
163 options: The options provided from optparse in main().
164 completed_stages_file: Where we store resume state.
165 archive_url: Where our artifacts for this builder will be archived.
166 tracking_branch: The tracking branch for this build.
167 release_tag: The associated "chrome os version" of this build.
168 gerrit_patches: Gerrit patches to be included in build.
169 local_patches: Local patches to be included in build.
170 """
171
David James944a48e2012-03-07 12:19:03 -0800172 def __init__(self, options, build_config):
Brian Harring3fec5a82012-03-01 05:57:03 -0800173 """Initializes instance variables. Must be called by all subclasses."""
Brian Harring3fec5a82012-03-01 05:57:03 -0800174 self.build_config = build_config
175 self.options = options
176
177 # TODO, Remove here and in config after bug chromium-os:14649 is fixed.
178 if self.build_config['chromeos_official']:
179 os.environ['CHROMEOS_OFFICIAL'] = '1'
180
181 self.completed_stages_file = os.path.join(options.buildroot,
182 '.completed_stages')
David James58e0c092012-03-04 20:31:12 -0800183 self.archive_stages = {}
Brian Harring3fec5a82012-03-01 05:57:03 -0800184 self.archive_urls = {}
185 self.release_tag = None
186 self.tracking_branch = _GetChromiteTrackingBranch()
187 self.gerrit_patches = None
188 self.local_patches = None
189
190 def Initialize(self):
191 """Runs through the initialization steps of an actual build."""
192 if self.options.resume and os.path.exists(self.completed_stages_file):
193 with open(self.completed_stages_file, 'r') as load_file:
194 results_lib.Results.RestoreCompletedStages(load_file)
195
196 # We only want to do this if we need to patch changes.
197 if not results_lib.Results.GetPrevious().get(
198 self._GetStageInstance(stages.PatchChangesStage, None, None).name):
199 self.gerrit_patches, self.local_patches = _PreProcessPatches(
200 self.options.gerrit_patches, self.options.local_patches)
201
202 bs.BuilderStage.SetTrackingBranch(self.tracking_branch)
203
204 # Check branch matching early.
205 if _IsIncrementalBuild(self.options.buildroot, self.options.clobber):
206 _CheckBuildRootBranch(self.options.buildroot, self.tracking_branch)
207
208 self._RunStage(stages.CleanUpStage)
209
210 def _GetStageInstance(self, stage, *args, **kwargs):
211 """Helper function to get an instance given the args.
212
David James944a48e2012-03-07 12:19:03 -0800213 Useful as almost all stages just take in options and build_config.
Brian Harring3fec5a82012-03-01 05:57:03 -0800214 """
David James944a48e2012-03-07 12:19:03 -0800215 config = kwargs.pop('config', self.build_config)
216 return stage(self.options, config, *args, **kwargs)
Brian Harring3fec5a82012-03-01 05:57:03 -0800217
218 def _SetReleaseTag(self):
219 """Sets the release tag from the manifest_manager.
220
221 Must be run after sync stage as syncing enables us to have a release tag.
222 """
223 # Extract version we have decided to build into self.release_tag.
224 manifest_manager = stages.ManifestVersionedSyncStage.manifest_manager
225 if manifest_manager:
226 self.release_tag = manifest_manager.current_version
227
228 def _RunStage(self, stage, *args, **kwargs):
229 """Wrapper to run a stage."""
230 stage_instance = self._GetStageInstance(stage, *args, **kwargs)
231 return stage_instance.Run()
232
233 def GetSyncInstance(self):
234 """Returns an instance of a SyncStage that should be run.
235
236 Subclasses must override this method.
237 """
238 raise NotImplementedError()
239
240 def RunStages(self):
241 """Subclasses must override this method. Runs the appropriate code."""
242 raise NotImplementedError()
243
244 def _WriteCheckpoint(self):
245 """Drops a completed stages file with current state."""
246 with open(self.completed_stages_file, 'w+') as save_file:
247 results_lib.Results.SaveCompletedStages(save_file)
248
249 def _ShouldReExecuteInBuildRoot(self):
250 """Returns True if this build should be re-executed in the buildroot."""
251 abs_buildroot = os.path.abspath(self.options.buildroot)
252 return not os.path.abspath(__file__).startswith(abs_buildroot)
253
254 def _ReExecuteInBuildroot(self, sync_instance):
255 """Reexecutes self in buildroot and returns True if build succeeds.
256
257 This allows the buildbot code to test itself when changes are patched for
258 buildbot-related code. This is a no-op if the buildroot == buildroot
259 of the running chromite checkout.
260
261 Args:
262 sync_instance: Instance of the sync stage that was run to sync.
263
264 Returns:
265 True if the Build succeeded.
266 """
267 # If we are resuming, use last checkpoint.
268 if not self.options.resume:
269 self._WriteCheckpoint()
270
271 # Re-write paths to use absolute paths.
272 # Suppress any timeout options given from the commandline in the
273 # invoked cbuildbot; our timeout will enforce it instead.
274 args_to_append = ['--resume', '--timeout', '0', '--buildroot',
275 os.path.abspath(self.options.buildroot)]
276
277 if self.options.chrome_root:
278 args_to_append += ['--chrome_root',
279 os.path.abspath(self.options.chrome_root)]
280
281 if stages.ManifestVersionedSyncStage.manifest_manager:
282 ver = stages.ManifestVersionedSyncStage.manifest_manager.current_version
283 args_to_append += ['--version', ver]
284
285 if isinstance(sync_instance, stages.CommitQueueSyncStage):
286 vp_file = sync_instance.SaveValidationPool()
287 args_to_append += ['--validation_pool', vp_file]
288
289 # Re-run the command in the buildroot.
290 # Finally, be generous and give the invoked cbuildbot 30s to shutdown
291 # when something occurs. It should exit quicker, but the sigterm may
292 # hit while the system is particularly busy.
293 return_obj = cros_lib.RunCommand(
294 [_PATH_TO_CBUILDBOT] + sys.argv[1:] + args_to_append,
295 cwd=self.options.buildroot, error_code_ok=True, kill_timeout=30)
296 return return_obj.returncode == 0
297
298 def Run(self):
299 """Main runner for this builder class. Runs build and prints summary."""
300 print_report = True
301 success = True
302 try:
303 self.Initialize()
304 sync_instance = self.GetSyncInstance()
305 sync_instance.Run()
306 self._SetReleaseTag()
307
Ryan Cuicedd8a52012-03-22 02:28:35 -0700308 if (self.gerrit_patches or self.local_patches
309 or self.options.remote_patches):
Brian Harring3fec5a82012-03-01 05:57:03 -0800310 self._RunStage(stages.PatchChangesStage,
311 self.gerrit_patches, self.local_patches)
312
313 if self._ShouldReExecuteInBuildRoot():
314 print_report = False
315 success = self._ReExecuteInBuildroot(sync_instance)
316 else:
317 self.RunStages()
318
319 finally:
320 if print_report:
321 self._WriteCheckpoint()
322 print '\n\n\n@@@BUILD_STEP Report@@@\n'
323 results_lib.Results.Report(sys.stdout, self.archive_urls,
324 self.release_tag)
325 success = results_lib.Results.BuildSucceededSoFar()
326
327 return success
328
329
330class SimpleBuilder(Builder):
331 """Builder that performs basic vetting operations."""
332
333 def GetSyncInstance(self):
334 """Sync to lkgm or TOT as necessary.
335
336 Returns: the instance of the sync stage that was run.
337 """
338 if self.options.lkgm or self.build_config['use_lkgm']:
339 sync_stage = self._GetStageInstance(stages.LKGMSyncStage)
340 else:
341 sync_stage = self._GetStageInstance(stages.SyncStage)
342
343 return sync_stage
344
David James58e0c092012-03-04 20:31:12 -0800345 def _RunBackgroundStagesForBoard(self, board):
346 """Run background board-specific stages for the specified board."""
David James58e0c092012-03-04 20:31:12 -0800347 archive_stage = self.archive_stages[board]
David James944a48e2012-03-07 12:19:03 -0800348 configs = self.build_config['board_specific_configs']
349 config = configs.get(board, self.build_config)
350 stage_list = [[stages.VMTestStage, board, archive_stage],
351 [stages.ChromeTestStage, board, archive_stage],
352 [stages.UnitTestStage, board],
353 [stages.UploadPrebuiltsStage, board]]
Brian Harring3fec5a82012-03-01 05:57:03 -0800354
David James58e0c092012-03-04 20:31:12 -0800355 # We can not run hw tests without archiving the payloads.
356 if self.options.archive:
David James944a48e2012-03-07 12:19:03 -0800357 for suite in config['hw_tests']:
358 stage_list.append([stages.HWTestStage, board, archive_stage, suite])
Chris Sosab50dc932012-03-01 14:00:58 -0800359
David James944a48e2012-03-07 12:19:03 -0800360 steps = [self._GetStageInstance(*x, config=config).Run for x in stage_list]
361 background.RunParallelSteps(steps + [archive_stage.Run])
Brian Harring3fec5a82012-03-01 05:57:03 -0800362
363 def RunStages(self):
364 """Runs through build process."""
365 self._RunStage(stages.BuildBoardStage)
366
367 # TODO(sosa): Split these out into classes.
Brian Harring3fec5a82012-03-01 05:57:03 -0800368 if self.build_config['build_type'] == constants.CHROOT_BUILDER_TYPE:
369 self._RunStage(stages.SDKTestStage)
370 self._RunStage(stages.UploadPrebuiltsStage,
371 constants.CHROOT_BUILDER_BOARD)
372 elif self.build_config['build_type'] == constants.REFRESH_PACKAGES_TYPE:
373 self._RunStage(stages.RefreshPackageStatusStage)
374 else:
375 self._RunStage(stages.UprevStage)
Brian Harring3fec5a82012-03-01 05:57:03 -0800376
David James944a48e2012-03-07 12:19:03 -0800377 configs = self.build_config['board_specific_configs']
David James58e0c092012-03-04 20:31:12 -0800378 for board in self.build_config['boards']:
David James944a48e2012-03-07 12:19:03 -0800379 config = configs.get(board, self.build_config)
380 archive_stage = self._GetStageInstance(stages.ArchiveStage, board,
381 config=config)
David James58e0c092012-03-04 20:31:12 -0800382 self.archive_stages[board] = archive_stage
383
David James944a48e2012-03-07 12:19:03 -0800384 # Set up a process pool to run test/archive stages in the background.
385 # This process runs task(board) for each board added to the queue.
David James58e0c092012-03-04 20:31:12 -0800386 queue = multiprocessing.Queue()
387 task = self._RunBackgroundStagesForBoard
388 with background.BackgroundTaskRunner(queue, task):
David James944a48e2012-03-07 12:19:03 -0800389 for board in self.build_config['boards']:
David James58e0c092012-03-04 20:31:12 -0800390 # Run BuildTarget in the foreground.
David James944a48e2012-03-07 12:19:03 -0800391 archive_stage = self.archive_stages[board]
392 config = configs.get(board, self.build_config)
393 self._RunStage(stages.BuildTargetStage, board, archive_stage,
Chris Sosa1a87b3e2012-04-12 13:20:42 -0700394 self.release_tag, config=config)
David James58e0c092012-03-04 20:31:12 -0800395 self.archive_urls[board] = archive_stage.GetDownloadUrl()
396
David James944a48e2012-03-07 12:19:03 -0800397 # Kick off task(board) in the background.
David James58e0c092012-03-04 20:31:12 -0800398 queue.put([board])
399
Brian Harring3fec5a82012-03-01 05:57:03 -0800400
401class DistributedBuilder(SimpleBuilder):
402 """Build class that has special logic to handle distributed builds.
403
404 These builds sync using git/manifest logic in manifest_versions. In general
405 they use a non-distributed builder code for the bulk of the work.
406 """
David James944a48e2012-03-07 12:19:03 -0800407 def __init__(self, options, build_config):
Brian Harring3fec5a82012-03-01 05:57:03 -0800408 """Initializes a buildbot builder.
409
410 Extra variables:
411 completion_stage_class: Stage used to complete a build. Set in the Sync
412 stage.
413 """
David James944a48e2012-03-07 12:19:03 -0800414 super(DistributedBuilder, self).__init__(options, build_config)
Brian Harring3fec5a82012-03-01 05:57:03 -0800415 self.completion_stage_class = None
416
417 def GetSyncInstance(self):
418 """Syncs the tree using one of the distributed sync logic paths.
419
420 Returns: the instance of the sync stage that was run.
421 """
422 # Determine sync class to use. CQ overrides PFQ bits so should check it
423 # first.
424 if cbuildbot_config.IsCQType(self.build_config['build_type']):
425 sync_stage = self._GetStageInstance(stages.CommitQueueSyncStage)
426 self.completion_stage_class = stages.CommitQueueCompletionStage
427 elif cbuildbot_config.IsPFQType(self.build_config['build_type']):
428 sync_stage = self._GetStageInstance(stages.LKGMCandidateSyncStage)
429 self.completion_stage_class = stages.LKGMCandidateSyncCompletionStage
430 else:
431 sync_stage = self._GetStageInstance(stages.ManifestVersionedSyncStage)
432 self.completion_stage_class = stages.ManifestVersionedSyncCompletionStage
433
434 return sync_stage
435
436 def Publish(self, was_build_successful):
437 """Completes build by publishing any required information."""
438 completion_stage = self._GetStageInstance(self.completion_stage_class,
439 was_build_successful)
440 completion_stage.Run()
441 name = completion_stage.name
442 if not results_lib.Results.WasStageSuccessful(name):
443 should_publish_changes = False
444 else:
445 should_publish_changes = (self.build_config['master'] and
446 was_build_successful)
447
448 if should_publish_changes:
449 self._RunStage(stages.PublishUprevChangesStage)
450
451 def RunStages(self):
452 """Runs simple builder logic and publishes information to overlays."""
453 was_build_successful = False
454 try:
David Jamesf55709e2012-03-13 09:10:15 -0700455 super(DistributedBuilder, self).RunStages()
456 was_build_successful = results_lib.Results.BuildSucceededSoFar()
Brian Harring3fec5a82012-03-01 05:57:03 -0800457 except SystemExit as ex:
458 # If a stage calls sys.exit(0), it's exiting with success, so that means
459 # we should mark ourselves as successful.
460 if ex.code == 0:
461 was_build_successful = True
462 raise
463 finally:
464 self.Publish(was_build_successful)
465
Brian Harring3fec5a82012-03-01 05:57:03 -0800466
467def _ConfirmBuildRoot(buildroot):
468 """Confirm with user the inferred buildroot, and mark it as confirmed."""
469 warning = 'Using default directory %s as buildroot' % buildroot
470 response = cros_lib.YesNoPrompt(default=cros_lib.NO, warning=warning,
471 full=True)
472 if response == cros_lib.NO:
473 print('Please specify a buildroot with the --buildroot option.')
474 sys.exit(0)
475
476 if not os.path.exists(buildroot):
477 os.mkdir(buildroot)
478
479 repository.CreateTrybotMarker(buildroot)
480
481
482def _DetermineDefaultBuildRoot(internal_build):
483 """Default buildroot to be under the directory that contains current checkout.
484
485 Arguments:
486 internal_build: Whether the build is an internal build
487 """
488 repo_dir = cros_lib.FindRepoDir()
489 if not repo_dir:
490 cros_lib.Die('Could not find root of local checkout. Please specify'
491 'using --buildroot option.')
492
493 # Place trybot buildroot under the directory containing current checkout.
494 top_level = os.path.dirname(os.path.realpath(os.path.dirname(repo_dir)))
495 if internal_build:
496 buildroot = os.path.join(top_level, _DEFAULT_INT_BUILDROOT)
497 else:
498 buildroot = os.path.join(top_level, _DEFAULT_EXT_BUILDROOT)
499
500 return buildroot
501
502
503def _BackupPreviousLog(log_file, backup_limit=25):
504 """Rename previous log.
505
506 Args:
507 log_file: The absolute path to the previous log.
508 """
509 if os.path.exists(log_file):
510 old_logs = sorted(glob.glob(log_file + '.*'),
511 key=distutils.version.LooseVersion)
512
513 if len(old_logs) >= backup_limit:
514 os.remove(old_logs[0])
515
516 last = 0
517 if old_logs:
518 last = int(old_logs.pop().rpartition('.')[2])
519
520 os.rename(log_file, log_file + '.' + str(last + 1))
521
522
David James944a48e2012-03-07 12:19:03 -0800523def _RunBuildStagesWrapper(options, build_config):
Brian Harring3fec5a82012-03-01 05:57:03 -0800524 """Helper function that wraps RunBuildStages()."""
525 def IsDistributedBuilder():
526 """Determines whether the build_config should be a DistributedBuilder."""
527 if not options.buildbot:
528 return False
529 elif build_config['build_type'] in _DISTRIBUTED_TYPES:
530 chrome_rev = build_config['chrome_rev']
531 if options.chrome_rev: chrome_rev = options.chrome_rev
532 # We don't do distributed logic to TOT Chrome PFQ's, nor local
533 # chrome roots (e.g. chrome try bots)
534 if chrome_rev not in [constants.CHROME_REV_TOT,
535 constants.CHROME_REV_LOCAL,
536 constants.CHROME_REV_SPEC]:
537 return True
538
539 return False
540
541 # Start tee-ing output to file.
542 log_file = None
543 if options.tee:
544 default_dir = os.path.join(options.buildroot, _DEFAULT_LOG_DIR)
545 dirname = options.log_dir or default_dir
546 log_file = os.path.join(dirname, _BUILDBOT_LOG_FILE)
547
548 cros_lib.SafeMakedirs(dirname)
549 _BackupPreviousLog(log_file)
550
551 try:
552 with cros_lib.AllowDisabling(options.tee, tee.Tee, log_file):
553 cros_lib.Info("cbuildbot executed with args %s"
554 % ' '.join(map(repr, sys.argv)))
555 if IsDistributedBuilder():
David James944a48e2012-03-07 12:19:03 -0800556 buildbot = DistributedBuilder(options, build_config)
Brian Harring3fec5a82012-03-01 05:57:03 -0800557 else:
David James944a48e2012-03-07 12:19:03 -0800558 buildbot = SimpleBuilder(options, build_config)
Brian Harring3fec5a82012-03-01 05:57:03 -0800559
560 if not buildbot.Run():
561 sys.exit(1)
562 finally:
563 if options.tee:
564 cros_lib.Info('Output should be saved to %s' % log_file)
565
566
567# Parser related functions
Ryan Cuicedd8a52012-03-22 02:28:35 -0700568def _CheckLocalPatches(local_patches):
Brian Harring3fec5a82012-03-01 05:57:03 -0800569 """Do an early quick check of the passed-in patches.
570
571 If the branch of a project is not specified we append the current branch the
572 project is on.
573 """
Ryan Cuicedd8a52012-03-22 02:28:35 -0700574 verified_patches = []
575 for patch in local_patches:
Brian Harring3fec5a82012-03-01 05:57:03 -0800576 components = patch.split(':')
577 if len(components) > 2:
578 msg = 'Specify local patches in project[:branch] format.'
579 raise optparse.OptionValueError(msg)
580
581 # validate project
582 project = components[0]
583 if not cros_lib.DoesProjectExist('.', project):
584 raise optparse.OptionValueError('Project %s does not exist.' % project)
585
586 project_dir = cros_lib.GetProjectDir('.', project)
587
588 # If no branch was specified, we use the project's current branch.
589 if len(components) == 1:
590 branch = cros_lib.GetCurrentBranch(project_dir)
591 if not branch:
592 raise optparse.OptionValueError('project %s is not on a branch!'
593 % project)
594 # Append branch information to patch
595 patch = '%s:%s' % (project, branch)
596 else:
597 branch = components[1]
598 if not cros_lib.DoesLocalBranchExist(project_dir, branch):
599 raise optparse.OptionValueError('Project %s does not have branch %s'
600 % (project, branch))
601
Ryan Cuicedd8a52012-03-22 02:28:35 -0700602 verified_patches.append(patch)
Brian Harring3fec5a82012-03-01 05:57:03 -0800603
Ryan Cuicedd8a52012-03-22 02:28:35 -0700604 return verified_patches
Brian Harring3fec5a82012-03-01 05:57:03 -0800605
606
607def _CheckBuildRootOption(_option, _opt_str, value, parser):
608 """Validate and convert buildroot to full-path form."""
609 value = value.strip()
610 if not value or value == '/':
611 raise optparse.OptionValueError('Invalid buildroot specified')
612
613 parser.values.buildroot = os.path.realpath(os.path.expanduser(value))
614
615
616def _CheckLogDirOption(_option, _opt_str, value, parser):
617 """Validate and convert buildroot to full-path form."""
618 parser.values.log_dir = os.path.abspath(os.path.expanduser(value))
619
620
621def _CheckChromeVersionOption(_option, _opt_str, value, parser):
622 """Upgrade other options based on chrome_version being passed."""
623 value = value.strip()
624
625 if parser.values.chrome_rev is None and value:
626 parser.values.chrome_rev = constants.CHROME_REV_SPEC
627
628 parser.values.chrome_version = value
629
630
631def _CheckChromeRootOption(_option, _opt_str, value, parser):
632 """Validate and convert chrome_root to full-path form."""
633 value = value.strip()
634 if not value or value == '/':
635 raise optparse.OptionValueError('Invalid chrome_root specified')
636
637 if parser.values.chrome_rev is None:
638 parser.values.chrome_rev = constants.CHROME_REV_LOCAL
639
640 parser.values.chrome_root = os.path.realpath(os.path.expanduser(value))
641
642
643def _CheckChromeRevOption(_option, _opt_str, value, parser):
644 """Validate the chrome_rev option."""
645 value = value.strip()
646 if value not in constants.VALID_CHROME_REVISIONS:
647 raise optparse.OptionValueError('Invalid chrome rev specified')
648
649 parser.values.chrome_rev = value
650
651
652def _CreateParser():
653 """Generate and return the parser with all the options."""
654 # Parse options
655 usage = "usage: %prog [options] buildbot_config"
656 parser = optparse.OptionParser(usage=usage)
657
658 # Main options
659 parser.add_option('-a', '--all', action='store_true', dest='print_all',
660 default=False,
661 help=('List all of the buildbot configs available. Use '
662 'with the --list option'))
663 parser.add_option('-r', '--buildroot', action='callback', dest='buildroot',
664 type='string', callback=_CheckBuildRootOption,
665 help=('Root directory where source is checked out to, and '
666 'where the build occurs. For external build configs, '
667 "defaults to 'trybot' directory at top level of your "
668 'repo-managed checkout.'))
669 parser.add_option('--chrome_rev', default=None, type='string',
670 action='callback', dest='chrome_rev',
671 callback=_CheckChromeRevOption,
672 help=('Revision of Chrome to use, of type '
673 '[%s]' % '|'.join(constants.VALID_CHROME_REVISIONS)))
Ryan Cuicedd8a52012-03-22 02:28:35 -0700674 parser.add_option('-g', '--gerrit-patches', action='append', default=[],
675 type='string', metavar="'Id1 *int_Id2...IdN'",
Brian Harring3fec5a82012-03-01 05:57:03 -0800676 help=("Space-separated list of short-form Gerrit "
677 "Change-Id's or change numbers to patch. Please "
678 "prepend '*' to internal Change-Id's"))
679 parser.add_option('-l', '--list', action='store_true', dest='list',
680 default=False,
681 help=('List the suggested trybot configs to use. Use '
682 '--all to list all of the available configs.'))
Ryan Cuicedd8a52012-03-22 02:28:35 -0700683 parser.add_option('-p', '--local-patches', action='append', default=[],
Brian Harring3fec5a82012-03-01 05:57:03 -0800684 metavar="'<project1>[:<branch1>]...<projectN>[:<branchN>]'",
685 help=('Space-separated list of project branches with '
686 'patches to apply. Projects are specified by name. '
687 'If no branch is specified the current branch of the '
688 'project will be used.'))
689 parser.add_option('--profile', default=None, type='string', action='store',
690 dest='profile',
691 help=('Name of profile to sub-specify board variant.'))
692 parser.add_option('--remote', default=False, action='store_true',
Brian Harring3fec5a82012-03-01 05:57:03 -0800693 help=('Specifies that this tryjob should be run remotely.'))
694
695 # Advanced options
696 group = optparse.OptionGroup(
697 parser,
698 'Advanced Options',
699 'Caution: use these options at your own risk.')
700
701 group.add_option('--buildbot', dest='buildbot', action='store_true',
702 default=False, help='This is running on a buildbot')
703 group.add_option('--buildnumber',
704 help='build number', type='int', default=0)
705 group.add_option('--chrome_root', default=None, type='string',
706 action='callback', dest='chrome_root',
707 callback=_CheckChromeRootOption,
708 help='Local checkout of Chrome to use.')
709 group.add_option('--chrome_version', default=None, type='string',
710 action='callback', dest='chrome_version',
711 callback=_CheckChromeVersionOption,
712 help='Used with SPEC logic to force a particular SVN '
713 'revision of chrome rather than the latest.')
714 group.add_option('--clobber', action='store_true', dest='clobber',
715 default=False,
716 help='Clears an old checkout before syncing')
717 group.add_option('--lkgm', action='store_true', dest='lkgm', default=False,
718 help='Sync to last known good manifest blessed by PFQ')
719 parser.add_option('--log_dir', action='callback', dest='log_dir',
720 type='string', callback=_CheckLogDirOption,
721 help=('Directory where logs are stored.'))
722 group.add_option('--maxarchives', dest='max_archive_builds',
723 default=3, type='int',
724 help="Change the local saved build count limit.")
725 group.add_option('--noarchive', action='store_false', dest='archive',
726 default=True,
727 help="Don't run archive stage.")
728 group.add_option('--nobuild', action='store_false', dest='build',
729 default=True,
Matt Tennantd55b1f42012-04-13 14:15:01 -0700730 help="Don't actually build (for cbuildbot dev)")
Brian Harring3fec5a82012-03-01 05:57:03 -0800731 group.add_option('--noclean', action='store_false', dest='clean',
732 default=True,
733 help="Don't clean the buildroot")
734 group.add_option('--noprebuilts', action='store_false', dest='prebuilts',
735 default=True,
736 help="Don't upload prebuilts.")
737 group.add_option('--nosync', action='store_false', dest='sync',
738 default=True,
739 help="Don't sync before building.")
740 group.add_option('--nocgroups', action='store_false', dest='cgroups',
741 default=True,
742 help='Disable cbuildbots usage of cgroups.')
Ryan Cuiadd49122012-03-21 22:19:58 -0700743 group.add_option('--notests', action='store_false', dest='tests',
744 default=True,
745 help='Override values from buildconfig and run no tests.')
746 group.add_option('--nouprev', action='store_false', dest='uprev',
747 default=True,
748 help='Override values from buildconfig and never uprev.')
Brian Harring3fec5a82012-03-01 05:57:03 -0800749 group.add_option('--reference-repo', action='store', default=None,
750 dest='reference_repo',
751 help='Reuse git data stored in an existing repo '
752 'checkout. This can drastically reduce the network '
753 'time spent setting up the trybot checkout. By '
754 "default, if this option isn't given but cbuildbot "
755 'is invoked from a repo checkout, cbuildbot will '
756 'use the repo root.')
Ryan Cuicedd8a52012-03-22 02:28:35 -0700757 # Indicates this is running on a remote trybot machine. '
Ryan Cuiba41ad32012-03-08 17:15:29 -0800758 group.add_option('--remote-trybot', dest='remote_trybot', action='store_true',
Ryan Cuicedd8a52012-03-22 02:28:35 -0700759 default=False, help=optparse.SUPPRESS_HELP)
760 # Patches uploaded by trybot client when run using the -p option.
761 group.add_option('--remote-patches', action='append', default=[],
762 help=optparse.SUPPRESS_HELP)
763 group.add_option('--resume', action='store_true', default=False,
Ryan Cuiadd49122012-03-21 22:19:58 -0700764 help='Skip stages already successfully completed.')
Brian Harring3fec5a82012-03-01 05:57:03 -0800765 group.add_option('--timeout', action='store', type='int', default=0,
766 help="Specify the maximum amount of time this job can run "
767 "for, at which point the build will be aborted. If "
768 "set to zero, then there is no timeout")
Ryan Cui39bdbbf2012-02-29 16:15:39 -0800769 group.add_option('--test-tryjob', action='store_true',
770 default=False,
771 help='Submit a tryjob to the test repository. Will not '
772 'show up on the production trybot waterfall.')
Brian Harring3fec5a82012-03-01 05:57:03 -0800773 group.add_option('--validation_pool', default=None,
774 help='Path to a pickled validation pool. Intended for use '
775 'only with the commit queue.')
776 group.add_option('--version', dest='force_version', default=None,
777 help='Used with manifest logic. Forces use of this version '
778 'rather than create or get latest.')
779
780 parser.add_option_group(group)
781
782 # Debug options
783 group = optparse.OptionGroup(parser, "Debug Options")
784
Ryan Cui85867972012-02-23 18:21:49 -0800785 group.add_option('--debug', action='store_true', default=None,
Brian Harring3fec5a82012-03-01 05:57:03 -0800786 help='Override some options to run as a developer.')
787 group.add_option('--dump_config', action='store_true', dest='dump_config',
788 default=False,
789 help='Dump out build config options, and exit.')
790 group.add_option('--notee', action='store_false', dest='tee', default=True,
791 help="Disable logging and internal tee process. Primarily "
792 "used for debugging cbuildbot itself.")
793 parser.add_option_group(group)
794 return parser
795
796
Ryan Cui85867972012-02-23 18:21:49 -0800797def _FinishParsing(options, args):
798 """Perform some parsing tasks that need to take place after optparse.
799
800 This function needs to be easily testable! Keep it free of
801 environment-dependent code. Put more detailed usage validation in
802 _PostParseCheck().
Brian Harring3fec5a82012-03-01 05:57:03 -0800803
804 Args:
Ryan Cui85867972012-02-23 18:21:49 -0800805 options, args: The options/args object returned by optparse
Brian Harring3fec5a82012-03-01 05:57:03 -0800806 """
Brian Harring3fec5a82012-03-01 05:57:03 -0800807 if options.chrome_root:
808 if options.chrome_rev != constants.CHROME_REV_LOCAL:
809 cros_lib.Die('Chrome rev must be %s if chrome_root is set.' %
810 constants.CHROME_REV_LOCAL)
811 else:
812 if options.chrome_rev == constants.CHROME_REV_LOCAL:
813 cros_lib.Die('Chrome root must be set if chrome_rev is %s.' %
814 constants.CHROME_REV_LOCAL)
815
816 if options.chrome_version:
817 if options.chrome_rev != constants.CHROME_REV_SPEC:
818 cros_lib.Die('Chrome rev must be %s if chrome_version is set.' %
819 constants.CHROME_REV_SPEC)
820 else:
821 if options.chrome_rev == constants.CHROME_REV_SPEC:
822 cros_lib.Die('Chrome rev must not be %s if chrome_version is not set.' %
823 constants.CHROME_REV_SPEC)
824
Ryan Cuicedd8a52012-03-22 02:28:35 -0700825 if options.remote and not (options.gerrit_patches or options.local_patches):
Brian Harring3fec5a82012-03-01 05:57:03 -0800826 cros_lib.Die('Must provide patches when running with --remote.')
827
828 if len(args) > 1 and not options.remote:
829 cros_lib.Die('Multiple configs not supported if not running with --remote.')
830
Ryan Cuiba41ad32012-03-08 17:15:29 -0800831 if options.buildbot and options.remote_trybot:
832 cros_lib.Die('--buildbot and --remote-trybot cannot be used together.')
833
Ryan Cui85867972012-02-23 18:21:49 -0800834 # Record whether --debug was set explicitly vs. it was inferred.
835 options.debug_forced = False
836 if options.debug:
837 options.debug_forced = True
838 else:
Ryan Cui16ca5812012-03-08 20:34:27 -0800839 # We don't set debug by default for
840 # 1. --buildbot invocations.
841 # 2. --remote invocations, because it needs to push changes to the tryjob
842 # repo.
843 options.debug = not options.buildbot and not options.remote
Brian Harring3fec5a82012-03-01 05:57:03 -0800844
Brian Harring3fec5a82012-03-01 05:57:03 -0800845
Ryan Cuicedd8a52012-03-22 02:28:35 -0700846def _SplitAndFlatten(appended_items):
847 """Given a list of space-separated items, split into flattened list.
848
849 Given ['abc def', 'hij'] return ['abc', 'def', 'hij'].
850 Arguments:
851 appended_items: List of delimiter-separated items.
852
853 Returns: Flattened list.
854 """
855 new_list = []
856 for item in appended_items:
Mike Frysinger4bd23892012-03-26 15:08:52 -0400857 new_list.extend(item.split())
Ryan Cuicedd8a52012-03-22 02:28:35 -0700858 return new_list
859
860
Ryan Cui85867972012-02-23 18:21:49 -0800861def _PostParseCheck(options, args):
862 """Perform some usage validation after we've parsed the arguments
Brian Harring3fec5a82012-03-01 05:57:03 -0800863
Ryan Cui85867972012-02-23 18:21:49 -0800864 Args:
865 options/args: The options/args object returned by optparse
866 """
867 if not options.resume:
Ryan Cuicedd8a52012-03-22 02:28:35 -0700868 options.gerrit_patches = _SplitAndFlatten(options.gerrit_patches)
869 options.remote_patches = _SplitAndFlatten(options.remote_patches)
Ryan Cui85867972012-02-23 18:21:49 -0800870 try:
871 # TODO(rcui): Split this into two stages, one that parses, another that
872 # validates. Parsing step will be called by _FinishParsing().
Ryan Cuicedd8a52012-03-22 02:28:35 -0700873 options.local_patches = _CheckLocalPatches(
874 _SplitAndFlatten(options.local_patches))
Ryan Cui85867972012-02-23 18:21:49 -0800875 except optparse.OptionValueError as e:
876 cros_lib.Die(str(e))
877
878
879def _ParseCommandLine(parser, argv):
880 """Completely parse the commandline arguments"""
Brian Harring3fec5a82012-03-01 05:57:03 -0800881 (options, args) = parser.parse_args(argv)
882 # Strip out null arguments.
883 # TODO(rcui): Remove when buildbot is fixed
884 args = [arg for arg in args if arg]
Ryan Cui85867972012-02-23 18:21:49 -0800885 _FinishParsing(options, args)
886 return options, args
887
888
889def main(argv):
890 # Set umask to 022 so files created by buildbot are readable.
891 os.umask(022)
892
893 if cros_lib.IsInsideChroot():
894 cros_lib.Die('Please run cbuildbot from outside the chroot.')
895
896 parser = _CreateParser()
897 (options, args) = _ParseCommandLine(parser, argv)
Brian Harring3fec5a82012-03-01 05:57:03 -0800898
899 if options.list:
Ryan Cui4f6cf7e2012-04-18 16:12:27 -0700900 _PrintValidConfigs(options.print_all)
Brian Harring3fec5a82012-03-01 05:57:03 -0800901 sys.exit(0)
902
903 _PostParseCheck(options, args)
904
905 if options.remote:
Ryan Cui16ca5812012-03-08 20:34:27 -0800906 cros_lib.DebugLevel.SetDebugLevel(cros_lib.DebugLevel.WARNING)
907
Brian Harring3fec5a82012-03-01 05:57:03 -0800908 # Verify configs are valid.
909 for bot in args:
910 _GetConfig(bot)
911
912 # Verify gerrit patches are valid.
Ryan Cui16ca5812012-03-08 20:34:27 -0800913 print 'Verifying patches...'
Ryan Cuicedd8a52012-03-22 02:28:35 -0700914 _, local_patches = _PreProcessPatches(options.gerrit_patches,
915 options.local_patches)
Ryan Cui16ca5812012-03-08 20:34:27 -0800916 print 'Submitting tryjob...'
Ryan Cuicedd8a52012-03-22 02:28:35 -0700917 tryjob = remote_try.RemoteTryJob(options, args, local_patches)
Ryan Cui39bdbbf2012-02-29 16:15:39 -0800918 tryjob.Submit(testjob=options.test_tryjob, dryrun=options.debug)
Ryan Cui16ca5812012-03-08 20:34:27 -0800919 print 'Tryjob submitted!'
920 print ('Go to %s to view the status of your job.'
Ryan Cui4906e1c2012-04-03 20:09:34 -0700921 % tryjob.GetTrybotWaterfallLink())
Brian Harring3fec5a82012-03-01 05:57:03 -0800922 sys.exit(0)
923
924 if args:
925 # Only expecting one config
926 bot_id = args[-1]
927 build_config = _GetConfig(bot_id)
928 else:
929 parser.error('Invalid usage. Use -h to see usage.')
930
931 if options.reference_repo is None:
932 repo_path = os.path.join(constants.SOURCE_ROOT, '.repo')
933 # If we're being run from a repo checkout, reuse the repo's git pool to
934 # cut down on sync time.
935 if os.path.exists(repo_path):
936 options.reference_repo = constants.SOURCE_ROOT
937 elif options.reference_repo:
938 if not os.path.exists(options.reference_repo):
939 parser.error('Reference path %s does not exist'
940 % (options.reference_repo,))
941 elif not os.path.exists(os.path.join(options.reference_repo, '.repo')):
942 parser.error('Reference path %s does not look to be the base of a '
943 'repo checkout; no .repo exists in the root.'
944 % (options.reference_repo,))
Ryan Cuid4a24212012-04-04 18:08:12 -0700945
946 if options.buildbot or options.remote_trybot:
Brian Harring470f6112012-03-02 11:47:10 -0800947 if not options.cgroups:
Ryan Cuid4a24212012-04-04 18:08:12 -0700948 parser.error('Options --buildbot/--remote-trybot and --nocgroups cannot '
949 'be used together. Cgroup support is required for '
950 'buildbot/remote-trybot mode.')
Brian Harring470f6112012-03-02 11:47:10 -0800951 if not cgroups.Cgroup.CgroupsSupported():
Ryan Cuid4a24212012-04-04 18:08:12 -0700952 parser.error('Option --buildbot/--remote-trybot was given, but this '
953 'system does not support cgroups. Failing.')
Brian Harring3fec5a82012-03-01 05:57:03 -0800954
Brian Harring351ce442012-03-09 16:38:14 -0800955 missing = []
956 for program in _BUILDBOT_REQUIRED_BINARIES:
957 ret = cros_lib.RunCommand('which %s' % program, shell=True,
958 redirect_stderr=True, redirect_stdout=True,
959 error_code_ok=True, print_cmd=False)
960 if ret.returncode != 0:
961 missing.append(program)
962
963 if missing:
Ryan Cuid4a24212012-04-04 18:08:12 -0700964 parser.error("Option --buildbot/--remote-trybot requires the following "
965 "binaries which couldn't be found in $PATH: %s"
Brian Harring351ce442012-03-09 16:38:14 -0800966 % (', '.join(missing)))
967
Brian Harring3fec5a82012-03-01 05:57:03 -0800968 if options.reference_repo:
969 options.reference_repo = os.path.abspath(options.reference_repo)
970
971 if options.dump_config:
972 # This works, but option ordering is bad...
973 print 'Configuration %s:' % bot_id
974 pretty_printer = pprint.PrettyPrinter(indent=2)
975 pretty_printer.pprint(build_config)
976 sys.exit(0)
977
978 if not options.buildroot:
979 if options.buildbot:
980 parser.error('Please specify a buildroot with the --buildroot option.')
Matt Tennantd55b1f42012-04-13 14:15:01 -0700981
Brian Harring470f6112012-03-02 11:47:10 -0800982 options.buildroot = _DetermineDefaultBuildRoot(build_config['internal'])
983 # We use a marker file in the buildroot to indicate the user has
984 # consented to using this directory.
985 if not os.path.exists(repository.GetTrybotMarkerPath(options.buildroot)):
986 _ConfirmBuildRoot(options.buildroot)
Brian Harring3fec5a82012-03-01 05:57:03 -0800987
988 # Sanity check of buildroot- specifically that it's not pointing into the
989 # midst of an existing repo since git-repo doesn't support nesting.
Brian Harring3fec5a82012-03-01 05:57:03 -0800990 if (not repository.IsARepoRoot(options.buildroot) and
David James6b80dc62012-02-29 15:34:40 -0800991 repository.InARepoRepository(options.buildroot)):
Brian Harring3fec5a82012-03-01 05:57:03 -0800992 parser.error('Configured buildroot %s points into a repository checkout, '
993 'rather than the root of it. This is not supported.'
994 % options.buildroot)
995
Brian Harringa184efa2012-03-04 11:51:25 -0800996 with cleanup.EnforcedCleanupSection() as critical_section:
997 with sudo.SudoKeepAlive():
998 with cros_lib.AllowDisabling(options.cgroups,
Brian Harring4e6412d2012-03-09 20:54:02 -0800999 cgroups.SimpleContainChildren, 'cbuildbot'):
Brian Harringa184efa2012-03-04 11:51:25 -08001000 # Mark everything between EnforcedCleanupSection and here as having to
1001 # be rolled back via the contextmanager cleanup handlers. This ensures
1002 # that sudo bits cannot outlive cbuildbot, that anything cgroups
1003 # would kill gets killed, etc.
1004 critical_section.ForkWatchdog()
1005
1006 with cros_lib.AllowDisabling(options.timeout > 0,
1007 cros_lib.Timeout, options.timeout):
1008 if not options.buildbot:
1009 build_config = cbuildbot_config.OverrideConfigForTrybot(
Ryan Cui3d6b4742012-03-14 11:42:24 -07001010 build_config,
1011 options.remote_trybot)
Brian Harringa184efa2012-03-04 11:51:25 -08001012
1013 _RunBuildStagesWrapper(options, build_config)