• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
12from __future__ import print_function
13import argparse
14import common
15import multiprocessing
16import os
17import shutil
18import subprocess
19import utils
20
21
22def create_asset(target_dir):
23  """Create the asset."""
24  # Check out and build the Intel NEO driver. Following instructions here:
25  # https://github.com/intel/compute-runtime/blob/master/documentation/BUILD_Ubuntu.md
26  with utils.tmp_dir():
27    # Install build deps.
28    neo_build_deps = ['ccache', 'flex', 'bison', 'clang-4.0', 'cmake', 'g++',
29                      'git', 'patch', 'zlib1g-dev', 'autoconf', 'xutils-dev',
30                      'libtool', 'pkg-config', 'libpciaccess-dev']
31    apt_get_cmd = ['sudo', 'apt-get', 'install'] + neo_build_deps
32    print('Running "%s"' % ' '.join(apt_get_cmd))
33    subprocess.check_call(apt_get_cmd)
34    # Check out repos.
35    for [repo, branch, local_name] in [
36        ['llvm-mirror/clang',             'release_40', 'clang_source'],
37        ['intel/opencl-clang',            'master',     'common_clang'],
38        ['intel/llvm-patches',            'master',     'llvm_patches'],
39        ['llvm-mirror/llvm',              'release_40', 'llvm_source'],
40        ['intel/gmmlib',                  'master',     'gmmlib'],
41        ['intel/intel-graphics-compiler', 'master',     'igc'],
42        ['KhronosGroup/OpenCL-Headers',   'master',     'opencl_headers'],
43        ['intel/compute-runtime',         'master',     'neo']
44    ]:
45      subprocess.check_call(['git', 'clone', '--depth', '1', '--branch', branch,
46                             'https://github.com/' + repo, local_name])
47    # Configure the build.
48    build_dir = os.path.join(os.getcwd(), 'build')
49    os.mkdir(build_dir)
50    os.chdir(build_dir)
51    subprocess.check_call(['cmake', '-DBUILD_TYPE=Release',
52                           '-DCMAKE_BUILD_TYPE=Release', '../neo'])
53    # Build and package the library.
54    subprocess.check_call(['make', '-j%d' % multiprocessing.cpu_count(),
55                           'package'])
56    # Extract library and move necessary files to target_dir. We ignore the ICD
57    # file because it's generated on the bot after we know the path to the CIPD
58    # package.
59    subprocess.check_call(['dpkg-deb', '--extract',
60                           'intel-opencl-1.0-0.x86_64-igdrcl.deb', build_dir])
61    lib_dir = os.path.join(build_dir, 'usr', 'local', 'lib')
62    for f in os.listdir(lib_dir):
63      shutil.move(os.path.join(lib_dir, f), target_dir)
64
65
66def main():
67  parser = argparse.ArgumentParser()
68  parser.add_argument('--target_dir', '-t', required=True)
69  args = parser.parse_args()
70  create_asset(args.target_dir)
71
72
73if __name__ == '__main__':
74  main()
75