summaryrefslogtreecommitdiff
path: root/cbuildbot/update_binhost_json.py
blob: 9d1625ac64974e6a975c490e27a35ac5e9be53d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Copyright 2015 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""Update the binhost json. Used by buildbots only."""

from __future__ import print_function

import os

from chromite.cbuildbot import binhost
from chromite.cbuildbot import config_lib
from chromite.cbuildbot import constants
from chromite.lib import commandline
from chromite.lib import cros_build_lib
from chromite.lib import cros_logging as logging
from chromite.lib import git


def _ParseArguments(argv):
  parser = commandline.ArgumentParser(description=__doc__)
  parser.add_argument('--buildroot', default=constants.SOURCE_ROOT,
                      help='Root directory where source is checked out to.')
  parser.add_argument('--skip-regen', default=True, dest='regen',
                      action='store_false',
                      help='Don\'t regenerate configs that have already been'
                           'generated.')
  opts = parser.parse_args(argv)
  opts.Freeze()
  return opts


def main(argv):
  cros_build_lib.AssertInsideChroot()
  opts = _ParseArguments(argv)

  site_config = config_lib.LoadConfigFromFile()

  logging.info('Generating board configs. This takes about 2m...')
  for key in sorted(binhost.GetChromePrebuiltConfigs(site_config)):
    binhost.GenConfigsForBoard(key.board, regen=opts.regen, error_code_ok=True)

  # Fetch all compat IDs.
  fetcher = binhost.CompatIdFetcher()
  keys = binhost.GetChromePrebuiltConfigs(site_config).keys()
  compat_ids = fetcher.FetchCompatIds(keys)

  # Save the PFQ configs.
  pfq_configs = binhost.PrebuiltMapping.Get(keys, compat_ids)
  filename_internal = binhost.PrebuiltMapping.GetFilename(opts.buildroot,
                                                          'chrome')
  pfq_configs.Dump(filename_internal)
  git.AddPath(filename_internal)
  git.Commit(os.path.dirname(filename_internal), 'Update PFQ config dump',
             allow_empty=True)

  filename_external = binhost.PrebuiltMapping.GetFilename(opts.buildroot,
                                                          'chromium',
                                                          internal=False)
  pfq_configs.Dump(filename_external, internal=False)
  git.AddPath(filename_external)
  git.Commit(os.path.dirname(filename_external), 'Update PFQ config dump',
             allow_empty=True)