• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2# Copyright 2013 The Flutter Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6import argparse
7import errno
8import os
9import shutil
10import subprocess
11import sys
12
13
14def main():
15  parser = argparse.ArgumentParser(
16      description='Removes existing files and installs the specified headers' +
17                  'at the given location.')
18
19  parser.add_argument('--headers',
20    nargs='+', help='The headers to install at the location.', required=True)
21  parser.add_argument('--location', type=str, required=True)
22
23  args = parser.parse_args()
24
25  # Remove old headers.
26  try:
27    shutil.rmtree(os.path.normpath(args.location))
28  except OSError as e:
29    # Ignore only "not found" errors.
30    if e.errno != errno.ENOENT:
31      raise e
32
33  # Create the directory to copy the files to.
34  if not os.path.isdir(args.location):
35    os.makedirs(args.location)
36
37  # Copy all files specified in the args.
38  for header_file in args.headers:
39    shutil.copyfile(header_file,
40      os.path.join(args.location, os.path.basename(header_file)))
41
42
43
44if __name__ == '__main__':
45  sys.exit(main())
46