Home | History | Annotate | Download | only in dbus_protos
      1 #!/usr/bin/python
      2 
      3 # Copyright 2018 The Chromium 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 """Compile D-Bus protobuf Python files.
      7 
      8 The protos are used by a bunch of cryptohome autotests.
      9 """
     10 
     11 import os
     12 import pipes
     13 from autotest_lib.client.common_lib import utils
     14 
     15 version = 1
     16 
     17 # These proto definitions are installed by system_api.
     18 PROTO_DEFS = {
     19     'cryptohome': ['key.proto', 'rpc.proto'],
     20 }
     21 
     22 
     23 def setup(top_dir):
     24     sysroot = os.environ['SYSROOT']
     25     parent_path = os.path.join(sysroot, 'usr/include/chromeos/dbus/')
     26     for subdir, protos in PROTO_DEFS.items():
     27         proto_path = os.path.join(parent_path, subdir)
     28         cmd = (['protoc', '--proto_path=' + proto_path,
     29                 '--python_out=' + top_dir] +
     30                [os.path.join(proto_path, proto_def) for proto_def in protos])
     31     utils.run(' '.join(pipes.quote(arg) for arg in cmd))
     32     return
     33 
     34 
     35 pwd = os.getcwd()
     36 utils.update_version(os.path.join(pwd, 'src'), False, version, setup, pwd)
     37