From 046f9893b953854680d6206c2452e79fafa35340 Mon Sep 17 00:00:00 2001 From: Weston Tracey Date: Thu, 6 Feb 2020 14:22:37 -0500 Subject: [PATCH] Add ccache_mac cipd package scripts. Change-Id: If71fc5fe27b4cf60cf963fff86d3e6a8224bf853 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/269150 Auto-Submit: Weston Tracey Reviewed-by: Ben Wagner aka dogben Commit-Queue: Ben Wagner aka dogben --- infra/bots/assets/ccache_mac/VERSION | 1 + infra/bots/assets/ccache_mac/common.py | 26 +++++++++++ infra/bots/assets/ccache_mac/create.py | 44 +++++++++++++++++++ .../assets/ccache_mac/create_and_upload.py | 42 ++++++++++++++++++ infra/bots/assets/ccache_mac/download.py | 16 +++++++ infra/bots/assets/ccache_mac/upload.py | 16 +++++++ 6 files changed, 145 insertions(+) create mode 100644 infra/bots/assets/ccache_mac/VERSION create mode 100755 infra/bots/assets/ccache_mac/common.py create mode 100755 infra/bots/assets/ccache_mac/create.py create mode 100755 infra/bots/assets/ccache_mac/create_and_upload.py create mode 100755 infra/bots/assets/ccache_mac/download.py create mode 100755 infra/bots/assets/ccache_mac/upload.py diff --git a/infra/bots/assets/ccache_mac/VERSION b/infra/bots/assets/ccache_mac/VERSION new file mode 100644 index 0000000000000..56a6051ca2b02 --- /dev/null +++ b/infra/bots/assets/ccache_mac/VERSION @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/infra/bots/assets/ccache_mac/common.py b/infra/bots/assets/ccache_mac/common.py new file mode 100755 index 0000000000000..caa0ad899c2dc --- /dev/null +++ b/infra/bots/assets/ccache_mac/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/ccache_mac/create.py b/infra/bots/assets/ccache_mac/create.py new file mode 100755 index 0000000000000..1d655c0a73f72 --- /dev/null +++ b/infra/bots/assets/ccache_mac/create.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python +# +# Copyright 2016 Google Inc. +# +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + + +"""Create a ccache binary for mac hosts.""" + + +import argparse +import common +import os +import subprocess +import utils + +URL = "https://github.com/ccache/ccache/releases/download/v3.7.7/ccache-3.7.7.tar.gz" +VERSION = "ccache-3.7.7" + +def create_asset(target_dir): + # configure --prefix requires an absolute path. + target_dir = os.path.abspath(target_dir) + + # Download and extract the source. + with utils.tmp_dir(): + subprocess.check_call(["curl", "-L", "-o", VERSION + ".tar.gz", + "https://github.com/ccache/ccache/releases/download/v3.7.7/ccache-3.7.7.tar.gz"]) + subprocess.check_call(["tar", "-xzf", VERSION + ".tar.gz"]) + os.chdir(VERSION) + + subprocess.check_call(["./configure", "--disable-man", "--prefix=" + target_dir]) + subprocess.check_call(["make"]) + subprocess.check_call(["make" ,"install"]) + +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/ccache_mac/create_and_upload.py b/infra/bots/assets/ccache_mac/create_and_upload.py new file mode 100755 index 0000000000000..13564474771e8 --- /dev/null +++ b/infra/bots/assets/ccache_mac/create_and_upload.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python +# +# Copyright 2016 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/ccache_mac/download.py b/infra/bots/assets/ccache_mac/download.py new file mode 100755 index 0000000000000..ca999e03783f9 --- /dev/null +++ b/infra/bots/assets/ccache_mac/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/ccache_mac/upload.py b/infra/bots/assets/ccache_mac/upload.py new file mode 100755 index 0000000000000..bdfbda783ea6f --- /dev/null +++ b/infra/bots/assets/ccache_mac/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')