#!/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.

from __future__ import print_function
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('--check-only', default=False, action='store_true')
  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)
    check_only = ['--check-only'] if args.check_only else []
    call('check_include_violations')
    call('check_proto_comments')
    call('fix_include_guards', *check_only)
    call('gen_bazel', *check_only)
    call('gen_android_bp', *check_only)
    call('gen_merged_protos', *check_only)
    call('ninja', '-C', out, 'protoc')
    call('gen_binary_descriptors', '--protoc', protoc_path(out), *check_only)

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

  return 0


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