• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2# Copyright (C) 2018 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16import os
17import argparse
18import subprocess
19
20ROOT_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
21
22
23def protoc_path(out_directory):
24  path = os.path.join(out_directory, 'gcc_like_host', 'protoc')
25  assert os.path.isfile(path)
26  return path
27
28
29def call(cmd, *args):
30  path = os.path.join('tools', cmd)
31  command = [path] + list(args)
32  try:
33    subprocess.check_call([path] + list(args), cwd=ROOT_DIR)
34  except subprocess.CalledProcessError as e:
35    assert False, 'Command: {} failed'.format(' '.join(command))
36
37
38def main():
39  parser = argparse.ArgumentParser()
40  parser.add_argument('OUT')
41  args = parser.parse_args()
42  out = args.OUT
43
44  try:
45    assert os.path.isdir(out), \
46        'Output directory "{}" is not a directory'.format(out)
47    call('fix_include_guards')
48    call('gen_build')
49    call('gen_android_bp')
50    call('gen_merged_protos')
51    call('gen_binary_descriptors', '--protoc', protoc_path(out))
52    call('gen_tracing_cpp_headers_from_protos', out)
53
54  except AssertionError as e:
55    if not str(e):
56      raise
57    print('Error: {}'.format(e))
58    return 1
59
60  return 0
61
62if __name__ == '__main__':
63  exit(main())
64