Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
create.py
Go to the documentation of this file.
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
12from __future__ import print_function
13import argparse
14import glob
15import os
16import shutil
17import subprocess
18import sys
19
20
21ENV_VAR = 'CHROMEBOOK_ARM_GLES_LIB_PATH'
22
23
24def getenv(key):
25 val = os.environ.get(key)
26 if not val:
27 print(('Environment variable %s not set; you should run this via '
28 'create_and_upload.py.' % key), file=sys.stderr)
29 sys.exit(1)
30 return val
31
32
33def create_asset(target_dir, gl_path):
34 """Create the asset."""
35
36 cmd = [
37 'sudo','apt-get','install',
38 'libgles2-mesa-dev',
39 'libegl1-mesa-dev'
40 ]
41 subprocess.check_call(cmd)
42
43
44 lib_dir = os.path.join(target_dir, 'lib')
45 os.mkdir(lib_dir)
46
47 to_copy = glob.glob(os.path.join(gl_path,'libGL*'))
48 to_copy.extend(glob.glob(os.path.join(gl_path,'libEGL*')))
49 to_copy.extend(glob.glob(os.path.join(gl_path,'libmali*')))
50 for f in to_copy:
51 shutil.copy(f, lib_dir)
52
53 include_dir = os.path.join(target_dir, 'include')
54 os.mkdir(include_dir)
55 shutil.copytree('/usr/include/EGL', os.path.join(include_dir, 'EGL'))
56 shutil.copytree('/usr/include/KHR', os.path.join(include_dir, 'KHR'))
57 shutil.copytree('/usr/include/GLES2', os.path.join(include_dir, 'GLES2'))
58 shutil.copytree('/usr/include/GLES3', os.path.join(include_dir, 'GLES3'))
59
60
61def main():
62 if 'linux' not in sys.platform:
63 print('This script only runs on Linux.', file=sys.stderr)
64 sys.exit(1)
65 parser = argparse.ArgumentParser()
66 parser.add_argument('--target_dir', '-t', required=True)
67 args = parser.parse_args()
68
69 # Obtain lib_path from create_and_upload via an environment variable, since
70 # this script is called via `sk` and not directly.
71 lib_path = getenv(ENV_VAR)
72
73 create_asset(args.target_dir, lib_path)
74
75
76if __name__ == '__main__':
77 main()
void print(void *str)
Definition bridge.cpp:126
create_asset(target_dir, gl_path)
Definition create.py:33
Definition main.py:1