1#!/usr/bin/env python
2#
3# Copyright 2016 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 glob
14import os
15import shutil
16import subprocess
17import sys
18
19
20def create_asset(target_dir, gl_path):
21  """Create the asset."""
22
23  cmd = [
24    'sudo','apt-get','install',
25    'libgles2-mesa-dev',
26    'libegl1-mesa-dev'
27  ]
28  print 'About to run:'
29  print ' '.join(cmd)
30  print 'Press Enter to Continue'
31  raw_input()
32  subprocess.check_call(cmd)
33
34
35  lib_dir = os.path.join(target_dir, 'lib')
36  os.mkdir(lib_dir)
37
38  for f in glob.glob(os.path.join(gl_path,'libGL*')):
39    shutil.copy(f, lib_dir)
40
41  for f in glob.glob(os.path.join(gl_path,'libEGL*')):
42    shutil.copy(f, lib_dir)
43
44  for f in glob.glob(os.path.join(gl_path,'libmali*')):
45    shutil.copy(f, lib_dir)
46
47  include_dir = os.path.join(target_dir, 'include')
48  os.mkdir(include_dir)
49  shutil.copytree('/usr/include/EGL', os.path.join(include_dir, 'EGL'))
50  shutil.copytree('/usr/include/KHR', os.path.join(include_dir, 'KHR'))
51  shutil.copytree('/usr/include/GLES2', os.path.join(include_dir, 'GLES2'))
52  shutil.copytree('/usr/include/GLES3', os.path.join(include_dir, 'GLES3'))
53
54
55def main():
56  if 'linux' not in sys.platform:
57    print >> sys.stderr, 'This script only runs on Linux.'
58    sys.exit(1)
59  parser = argparse.ArgumentParser()
60  parser.add_argument('--target_dir', '-t', required=True)
61  parser.add_argument('--lib_path', '-l', required=True)
62  args = parser.parse_args()
63  create_asset(args.target_dir, args.lib_path)
64
65
66if __name__ == '__main__':
67  main()
68