aboutsummaryrefslogtreecommitdiff
path: root/tools/download-clang-update-script.py
blob: 203862eccd78e661c67c86ad5f9b9e8b209e44fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""
This script is used to download the clang update script. It runs as a gclient
hook.

It's equivalent to using curl to download the latest update script.
"""

import argparse
import curlish
import sys

SCRIPT_DOWNLOAD_URL = ('https://raw.githubusercontent.com/chromium/'
                       'chromium/main/tools/clang/scripts/update.py')


def main():
    parser = argparse.ArgumentParser(description='Download a file.')
    parser.add_argument('--output', help='Path to file to create/overwrite.')
    args = parser.parse_args()

    if not args.output:
        print('usage: download-clang-update-script.py --output=/a/b/update.py')
        return 1

    return 0 if curlish.curlish(SCRIPT_DOWNLOAD_URL, args.output) else 1


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