1#!/usr/bin/env python
2# Copyright 2020 The Chromium 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
6"""
7This script is used to download the clang update script. It runs as a gclient
8hook.
9
10It's equivalent to using curl to download the latest update script.
11"""
12
13import argparse
14import curlish
15import sys
16
17SCRIPT_DOWNLOAD_URL = ('https://raw.githubusercontent.com/chromium/' +
18                       'chromium/master/tools/clang/scripts/update.py')
19
20
21def main():
22    parser = argparse.ArgumentParser(description='Download a file.')
23    parser.add_argument('--output', help='Path to file to create/overwrite.')
24    args = parser.parse_args()
25
26    if not args.output:
27        print('usage: download-clang-update-script.py --output=/a/b/update.py')
28        return 1
29
30    return 0 if curlish.curlish(SCRIPT_DOWNLOAD_URL, args.output) else 1
31
32
33if __name__ == '__main__':
34    sys.exit(main())
35