• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2# Copyright 2016 The Chromium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6import argparse
7import os
8import sys
9
10sys.path.append(
11    os.path.abspath(os.path.join(os.path.dirname(__file__),
12                                 '..', '..', '..', 'dependency_manager')))
13from dependency_manager import base_config # pylint: disable=import-error
14
15
16_SUPPORTED_ARCHS = [
17    'linux2_x86_64', 'darwin_x86_64', 'win_AMD64', 'win32_AMD64', 'win32_x86',
18    'default'
19]
20_DEFAULT_DEP = 'battor_agent_binary'
21_DEFAULT_CONFIG = os.path.join(os.path.dirname(__file__), '..', 'battor',
22                               'battor_binary_dependencies.json')
23
24
25def UploadBinary(arch, path, config, dep):
26  print 'Uploading binary:'
27  print '  arch: %s' % arch
28  print '  path: %s' % path
29  print '  config: %s' % config
30  print '  dep: %s' % dep
31  c = base_config.BaseConfig(config, writable=True)
32  c.AddCloudStorageDependencyUpdateJob(
33      dep, arch, path, version=None, execute_job=True)
34  print 'Upload complete.'
35
36
37def main():
38  parser = argparse.ArgumentParser()
39  parser.add_argument('--arch', '--architecture', required=True,
40                      help='Architecture binary is built for.')
41  parser.add_argument('--path', required=True, help='Path to binary.')
42  parser.add_argument('--config', default=_DEFAULT_CONFIG,
43                      help='Path to dependency manager config')
44  parser.add_argument('--dep', default=_DEFAULT_DEP,
45                      help='Name of dependency to update.')
46  args = parser.parse_args()
47  if args.arch not in _SUPPORTED_ARCHS:
48    print 'Arch must be one of: %s' % _SUPPORTED_ARCHS
49    return 1
50  UploadBinary(args.arch, args.path, args.config, args.dep)
51  return 0
52
53if __name__ == '__main__':
54  sys.exit(main())
55