Home | History | Annotate | Download | only in policy_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 policy protobuf Python files.
      7 
      8 The policy protos are used by a bunch of policy_* and login_* autotests, as well
      9 as policy_testserver.py in the Chromium code base. policy_descriptor.proto is
     10 used by session_manager.py to store and retrieve policy from/to disk.
     11 """
     12 
     13 import os
     14 import pipes
     15 from autotest_lib.client.bin import utils
     16 
     17 version = 2
     18 
     19 # cloud_policy.proto and chrome_extension_policy.proto are unreferenced here,
     20 # but used by policy_testserver.py in the Chromium code base, so don't remote
     21 # them!
     22 PROTO_PATHS = [
     23         'usr/share/protofiles/chrome_device_policy.proto',
     24         'usr/share/protofiles/device_management_backend.proto',
     25         'usr/share/protofiles/cloud_policy.proto',
     26         'usr/share/protofiles/chrome_extension_policy.proto',
     27         'usr/include/chromeos/dbus/login_manager/policy_descriptor.proto',
     28 ]
     29 
     30 def setup(top_dir):
     31     sysroot = os.environ['SYSROOT']
     32     dirs = set(os.path.dirname(p) for p in PROTO_PATHS)
     33     include_args = ['--proto_path=' + os.path.join(sysroot, d) for d in dirs]
     34     proto_paths = [os.path.join(sysroot, p) for p in PROTO_PATHS]
     35     cmd = ['protoc', '--python_out=' + top_dir] + include_args + proto_paths
     36     utils.run(' '.join(pipes.quote(arg) for arg in cmd))
     37     return
     38 
     39 
     40 pwd = os.getcwd()
     41 utils.update_version(os.path.join(pwd, 'src'), False, version, setup, pwd)
     42