#!/usr/bin/env python3
# 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())
