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 2017 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 grp
15import os
16import pwd
17import shutil
18import subprocess
19import sys
20import tempfile
21from urllib.request import urlopen
22
23FILE_DIR = os.path.dirname(os.path.abspath(__file__))
24INFRA_BOTS_DIR = os.path.realpath(os.path.join(FILE_DIR, os.pardir, os.pardir))
25sys.path.insert(0, INFRA_BOTS_DIR)
26import utils
27
28
29VALGRIND = 'valgrind-3.15.0'
30TARBALL = '%s.tar.bz2' % VALGRIND
31DOWNLOAD_URL = 'ftp://sourceware.org/pub/valgrind/%s' % TARBALL
32TEMP_DIR = os.path.join(tempfile.gettempdir(), 'skia-%s' % VALGRIND)
33INSTALL_DIR = os.path.join(TEMP_DIR, 'valgrind_install')
34
35
37 with utils.chdir(TEMP_DIR):
38 if os.path.isfile(TARBALL):
39 return
40 with open(TARBALL, 'wb') as f:
41 f.write(urlopen(DOWNLOAD_URL).read())
42
43
45 with utils.chdir(TEMP_DIR):
46 if os.path.isdir(VALGRIND):
47 return
48 subprocess.check_call(['tar', 'xvjf', TARBALL])
49
50
52 if os.path.isdir(INSTALL_DIR):
53 return
54 os.makedirs(INSTALL_DIR)
55
56
58 if os.path.isfile(os.path.join(INSTALL_DIR, 'bin', 'valgrind')):
59 return
60 with utils.chdir(os.path.join(TEMP_DIR, VALGRIND)):
61 subprocess.check_call(['./configure', '--prefix=%s' % INSTALL_DIR])
62 subprocess.check_call(['make'])
63 subprocess.check_call(['make', 'install'])
64
65
66def copy_files(target_dir):
67 with utils.chdir(os.path.join(TEMP_DIR, VALGRIND)):
68 os.mkdir(os.path.join(target_dir, 'bin'))
69 shutil.copy(os.path.join(INSTALL_DIR, 'bin', 'valgrind'),
70 os.path.join(target_dir, 'bin', 'valgrind'))
71 os.mkdir(os.path.join(target_dir, 'lib'))
72 os.mkdir(os.path.join(target_dir, 'lib', 'valgrind'))
73 for lib in ['memcheck-amd64-linux']:
74 shutil.copy(os.path.join(INSTALL_DIR, 'lib', 'valgrind', lib),
75 os.path.join(target_dir, 'lib', 'valgrind', lib))
76 for lib in ['core', 'memcheck']:
77 libname = 'vgpreload_%s-amd64-linux.so' % lib
78 shutil.copy(os.path.join(INSTALL_DIR, 'lib', 'valgrind', libname),
79 os.path.join(target_dir, 'lib', 'valgrind', libname))
80
81 shutil.copy('default.supp',
82 os.path.join(target_dir, 'lib', 'valgrind', 'default.supp'))
83
84
85def create_asset(target_dir):
86 """Create the asset."""
87 if os.name == 'nt':
88 print('This script does not run on Windows.')
89 sys.exit(1)
90
92 if not os.path.isdir(TEMP_DIR):
93 os.makedirs(TEMP_DIR)
97 copy_files(target_dir)
98
99
100def main():
101 parser = argparse.ArgumentParser()
102 parser.add_argument('--target_dir', '-t', required=True)
103 args = parser.parse_args()
104 create_asset(args.target_dir)
105
106
107if __name__ == '__main__':
108 main()
static bool read(SkStream *stream, void *buffer, size_t amount)
void print(void *str)
Definition bridge.cpp:126
build_valgrind()
Definition create.py:57
download_tarball()
Definition create.py:36
create_install_dir()
Definition create.py:51
copy_files(target_dir)
Definition create.py:66
create_asset(target_dir)
Definition create.py:32
main()
Definition create.py:69
unzip_tarball()
Definition create.py:44
Definition main.py:1