diff options
Diffstat (limited to 'infra/bots/assets')
-rw-r--r-- | infra/bots/assets/opencl_headers/VERSION | 1 | ||||
-rwxr-xr-x | infra/bots/assets/opencl_headers/common.py | 26 | ||||
-rwxr-xr-x | infra/bots/assets/opencl_headers/create.py | 48 | ||||
-rwxr-xr-x | infra/bots/assets/opencl_headers/create_and_upload.py | 42 | ||||
-rwxr-xr-x | infra/bots/assets/opencl_headers/download.py | 16 | ||||
-rwxr-xr-x | infra/bots/assets/opencl_headers/upload.py | 16 | ||||
-rw-r--r-- | infra/bots/assets/opencl_ocl_icd_linux/VERSION | 1 | ||||
-rwxr-xr-x | infra/bots/assets/opencl_ocl_icd_linux/common.py | 26 | ||||
-rwxr-xr-x | infra/bots/assets/opencl_ocl_icd_linux/create.py | 47 | ||||
-rwxr-xr-x | infra/bots/assets/opencl_ocl_icd_linux/create_and_upload.py | 42 | ||||
-rwxr-xr-x | infra/bots/assets/opencl_ocl_icd_linux/download.py | 16 | ||||
-rwxr-xr-x | infra/bots/assets/opencl_ocl_icd_linux/upload.py | 16 |
12 files changed, 297 insertions, 0 deletions
diff --git a/infra/bots/assets/opencl_headers/VERSION b/infra/bots/assets/opencl_headers/VERSION new file mode 100644 index 0000000000..c227083464 --- /dev/null +++ b/infra/bots/assets/opencl_headers/VERSION @@ -0,0 +1 @@ +0
\ No newline at end of file diff --git a/infra/bots/assets/opencl_headers/common.py b/infra/bots/assets/opencl_headers/common.py new file mode 100755 index 0000000000..caa0ad899c --- /dev/null +++ b/infra/bots/assets/opencl_headers/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/opencl_headers/create.py b/infra/bots/assets/opencl_headers/create.py new file mode 100755 index 0000000000..690349b514 --- /dev/null +++ b/infra/bots/assets/opencl_headers/create.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# +# Copyright 2018 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 common +import os +import shutil +import subprocess +import utils + +# The OpenCL C headers are available at +# https://github.com/KhronosGroup/OpenCL-Headers, but the C++ header cl.hpp +# would need to be generated from https://github.com/KhronosGroup/OpenCL-CLHPP. +# Instead, we just grab the pre-built headers from the Debian packages. +PKGS = [ + 'opencl-c-headers', + 'opencl-clhpp-headers', +] + +def create_asset(target_dir): + """Create the asset.""" + with utils.tmp_dir(): + # Download required Debian packages. + subprocess.check_call(['apt-get', 'download'] + PKGS) + # Extract to CWD. + for f in os.listdir('.'): + subprocess.check_call(['dpkg-deb', '--extract', f, '.']) + # Copy usr/include/CL to target_dir. + shutil.move(os.path.join(os.getcwd(), 'usr', 'include', 'CL'), target_dir) + + +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/opencl_headers/create_and_upload.py b/infra/bots/assets/opencl_headers/create_and_upload.py new file mode 100755 index 0000000000..de56a80fa8 --- /dev/null +++ b/infra/bots/assets/opencl_headers/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/opencl_headers/download.py b/infra/bots/assets/opencl_headers/download.py new file mode 100755 index 0000000000..ca999e0378 --- /dev/null +++ b/infra/bots/assets/opencl_headers/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/opencl_headers/upload.py b/infra/bots/assets/opencl_headers/upload.py new file mode 100755 index 0000000000..bdfbda783e --- /dev/null +++ b/infra/bots/assets/opencl_headers/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') diff --git a/infra/bots/assets/opencl_ocl_icd_linux/VERSION b/infra/bots/assets/opencl_ocl_icd_linux/VERSION new file mode 100644 index 0000000000..c227083464 --- /dev/null +++ b/infra/bots/assets/opencl_ocl_icd_linux/VERSION @@ -0,0 +1 @@ +0
\ No newline at end of file diff --git a/infra/bots/assets/opencl_ocl_icd_linux/common.py b/infra/bots/assets/opencl_ocl_icd_linux/common.py new file mode 100755 index 0000000000..caa0ad899c --- /dev/null +++ b/infra/bots/assets/opencl_ocl_icd_linux/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/opencl_ocl_icd_linux/create.py b/infra/bots/assets/opencl_ocl_icd_linux/create.py new file mode 100755 index 0000000000..4b2512cfb8 --- /dev/null +++ b/infra/bots/assets/opencl_ocl_icd_linux/create.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +# +# Copyright 2018 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 common +import os +import shutil +import subprocess +import utils + +# Use libOpenCL.so from the ocl-icd-opencl-dev Debian package. +PKGS = [ + 'ocl-icd-opencl-dev', + 'ocl-icd-libopencl1', +] + +def create_asset(target_dir): + """Create the asset.""" + with utils.tmp_dir(): + # Download required Debian packages. + subprocess.check_call(['apt-get', 'download'] + PKGS) + # Extract to CWD. + for f in os.listdir('.'): + subprocess.check_call(['dpkg-deb', '--extract', f, '.']) + # Copy usr/lib/x86_64-linux-gnu/* to target_dir. + lib_dir = os.path.join(os.getcwd(), 'usr', 'lib', 'x86_64-linux-gnu') + for f in os.listdir(lib_dir): + shutil.move(os.path.join(lib_dir, f), target_dir) + + +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/opencl_ocl_icd_linux/create_and_upload.py b/infra/bots/assets/opencl_ocl_icd_linux/create_and_upload.py new file mode 100755 index 0000000000..de56a80fa8 --- /dev/null +++ b/infra/bots/assets/opencl_ocl_icd_linux/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/opencl_ocl_icd_linux/download.py b/infra/bots/assets/opencl_ocl_icd_linux/download.py new file mode 100755 index 0000000000..ca999e0378 --- /dev/null +++ b/infra/bots/assets/opencl_ocl_icd_linux/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/opencl_ocl_icd_linux/upload.py b/infra/bots/assets/opencl_ocl_icd_linux/upload.py new file mode 100755 index 0000000000..bdfbda783e --- /dev/null +++ b/infra/bots/assets/opencl_ocl_icd_linux/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') |