#!/usr/bin/env python
# Copyright (C) 2018 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import argparse
import subprocess

ROOT_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))


def protoc_path(out_directory):
  path = os.path.join(out_directory, 'protoc')
  assert os.path.isfile(path)
  return path


def call(cmd, *args):
  path = os.path.join('tools', cmd)
  command = [path] + list(args)
  print 'Running', ' '.join(command)
  try:
    subprocess.check_call(command, cwd=ROOT_DIR)
  except subprocess.CalledProcessError as e:
    assert False, 'Command: {} failed'.format(' '.join(command))


def main():
  parser = argparse.ArgumentParser()
  parser.add_argument('OUT')
  args = parser.parse_args()
  out = args.OUT

  try:
    assert os.path.isdir(out), \
        'Output directory "{}" is not a directory'.format(out)
    call('fix_include_guards')
    call('gen_bazel')
    call('gen_android_bp')
    call('gen_merged_protos')
    call('ninja', '-C', out, 'protoc')
    call('gen_binary_descriptors', '--protoc', protoc_path(out))
    call('gen_tracing_cpp_headers_from_protos', out)

  except AssertionError as e:
    if not str(e):
      raise
    print('Error: {}'.format(e))
    return 1

  return 0

if __name__ == '__main__':
  exit(main())
