1#!/usr/bin/env python 2# 3# Copyright 2018 Google Inc. 4# 5# Use of this source code is governed by a BSD-style license that can be 6# found in the LICENSE file. 7 8 9"""Create the asset.""" 10 11 12import argparse 13import common 14import os 15import shutil 16import subprocess 17import utils 18 19# The OpenCL C headers are available at 20# https://github.com/KhronosGroup/OpenCL-Headers, but the C++ header cl.hpp 21# would need to be generated from https://github.com/KhronosGroup/OpenCL-CLHPP. 22# Instead, we just grab the pre-built headers from the Debian packages. 23PKGS = [ 24 'opencl-c-headers', 25 'opencl-clhpp-headers', 26] 27 28def create_asset(target_dir): 29 """Create the asset.""" 30 with utils.tmp_dir(): 31 # Download required Debian packages. 32 subprocess.check_call(['apt-get', 'download'] + PKGS) 33 # Extract to CWD. 34 for f in os.listdir('.'): 35 subprocess.check_call(['dpkg-deb', '--extract', f, '.']) 36 # Copy usr/include/CL to target_dir. 37 shutil.move(os.path.join(os.getcwd(), 'usr', 'include', 'CL'), target_dir) 38 39 40def main(): 41 parser = argparse.ArgumentParser() 42 parser.add_argument('--target_dir', '-t', required=True) 43 args = parser.parse_args() 44 create_asset(args.target_dir) 45 46 47if __name__ == '__main__': 48 main() 49