diff options
author | Mike Klein <mtklein@chromium.org> | 2018-02-13 12:47:41 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-02-13 18:17:10 +0000 |
commit | 7db58fed32cc63c1a4939f42e05e9a234cf5d37c (patch) | |
tree | 7860baf8e01e2e045d9c7f90968a9a000831432b /infra/bots | |
parent | 655bf8f022a31b8a8624838d267b0e9cab0d8ef8 (diff) |
add win_ninja asset
I will use this in skcms-Win bots.
Change-Id: Id2e253a73e562181649f17908e5d587cc0d098d6
Reviewed-on: https://skia-review.googlesource.com/106973
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'infra/bots')
-rw-r--r-- | infra/bots/assets/win_ninja/VERSION | 1 | ||||
-rwxr-xr-x | infra/bots/assets/win_ninja/common.py | 26 | ||||
-rwxr-xr-x | infra/bots/assets/win_ninja/create.py | 32 | ||||
-rwxr-xr-x | infra/bots/assets/win_ninja/create_and_upload.py | 42 | ||||
-rwxr-xr-x | infra/bots/assets/win_ninja/download.py | 16 | ||||
-rwxr-xr-x | infra/bots/assets/win_ninja/upload.py | 16 |
6 files changed, 133 insertions, 0 deletions
diff --git a/infra/bots/assets/win_ninja/VERSION b/infra/bots/assets/win_ninja/VERSION new file mode 100644 index 0000000000..d8263ee986 --- /dev/null +++ b/infra/bots/assets/win_ninja/VERSION @@ -0,0 +1 @@ +2
\ No newline at end of file diff --git a/infra/bots/assets/win_ninja/common.py b/infra/bots/assets/win_ninja/common.py new file mode 100755 index 0000000000..caa0ad899c --- /dev/null +++ b/infra/bots/assets/win_ninja/common.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python +# +# Copyright 2017 Google Inc. +# +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + + +"""Common vars used by scripts in this directory.""" + + +import os +import sys + +FILE_DIR = os.path.dirname(os.path.abspath(__file__)) +INFRA_BOTS_DIR = os.path.realpath(os.path.join(FILE_DIR, os.pardir, os.pardir)) + +sys.path.insert(0, INFRA_BOTS_DIR) +from assets import assets + +ASSET_NAME = os.path.basename(FILE_DIR) + + +def run(cmd): + """Run a command, eg. "upload" or "download". """ + assets.main([cmd, ASSET_NAME] + sys.argv[1:]) diff --git a/infra/bots/assets/win_ninja/create.py b/infra/bots/assets/win_ninja/create.py new file mode 100755 index 0000000000..1864b0b789 --- /dev/null +++ b/infra/bots/assets/win_ninja/create.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +# +# Copyright 2017 Google Inc. +# +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + + +"""Create the asset.""" + + +import argparse +import subprocess + +VERSION = "v1.8.2" +URL = "https://github.com/ninja-build/ninja/releases/download/%s/ninja-win.zip" + +def create_asset(target_dir): + """Create the asset.""" + subprocess.check_call(["curl", "-L", URL % VERSION, "-o", "ninja-win.zip"]) + subprocess.check_call(["unzip", "ninja-win.zip", "-d", target_dir]) + subprocess.check_call(["rm", "ninja-win.zip"]) + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('--target_dir', '-t', required=True) + args = parser.parse_args() + create_asset(args.target_dir) + + +if __name__ == '__main__': + main() diff --git a/infra/bots/assets/win_ninja/create_and_upload.py b/infra/bots/assets/win_ninja/create_and_upload.py new file mode 100755 index 0000000000..de56a80fa8 --- /dev/null +++ b/infra/bots/assets/win_ninja/create_and_upload.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python +# +# Copyright 2017 Google Inc. +# +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + + +"""Create the asset and upload it.""" + + +import argparse +import common +import os +import subprocess +import sys +import utils + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('--gsutil') + args = parser.parse_args() + + with utils.tmp_dir(): + cwd = os.getcwd() + create_script = os.path.join(common.FILE_DIR, 'create.py') + upload_script = os.path.join(common.FILE_DIR, 'upload.py') + + try: + subprocess.check_call(['python', create_script, '-t', cwd]) + cmd = ['python', upload_script, '-t', cwd] + if args.gsutil: + cmd.extend(['--gsutil', args.gsutil]) + subprocess.check_call(cmd) + except subprocess.CalledProcessError: + # Trap exceptions to avoid printing two stacktraces. + sys.exit(1) + + +if __name__ == '__main__': + main() diff --git a/infra/bots/assets/win_ninja/download.py b/infra/bots/assets/win_ninja/download.py new file mode 100755 index 0000000000..ca999e0378 --- /dev/null +++ b/infra/bots/assets/win_ninja/download.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python +# +# Copyright 2017 Google Inc. +# +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + + +"""Download the current version of the asset.""" + + +import common + + +if __name__ == '__main__': + common.run('download') diff --git a/infra/bots/assets/win_ninja/upload.py b/infra/bots/assets/win_ninja/upload.py new file mode 100755 index 0000000000..bdfbda783e --- /dev/null +++ b/infra/bots/assets/win_ninja/upload.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python +# +# Copyright 2017 Google Inc. +# +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + + +"""Upload a new version of the asset.""" + + +import common + + +if __name__ == '__main__': + common.run('upload') |