OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright 2014 Google Inc. | 3 # Copyright 2014 Google Inc. |
4 # | 4 # |
5 # Use of this source code is governed by a BSD-style license that can be | 5 # Use of this source code is governed by a BSD-style license that can be |
6 # found in the LICENSE file. | 6 # found in the LICENSE file. |
7 | 7 |
8 """ | 8 """ |
9 Modified version of gyp_skia, used by gyp_to_android.py to generate Android.mk | 9 Modified version of gyp_skia, used by gyp_to_android.py to generate Android.mk |
10 """ | 10 """ |
11 | 11 |
12 import os | 12 import os |
13 import sys | 13 import sys |
14 | 14 |
15 SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__)) | 15 SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__)) |
16 | 16 |
17 # Unlike gyp_skia, this file is nested deep inside Skia. Find Skia's trunk dir. | 17 # Unlike gyp_skia, this file is nested deep inside Skia. Find Skia's trunk dir. |
18 # This line depends on the fact that the script is three levels deep | 18 # This line depends on the fact that the script is three levels deep |
19 # (specifically, it is in platform_tools/android/gyp_gen). | 19 # (specifically, it is in platform_tools/android/gyp_gen). |
20 SKIA_DIR = os.path.normpath(os.path.join(SCRIPT_DIR, os.pardir, os.pardir, | 20 SKIA_DIR = os.path.normpath(os.path.join(SCRIPT_DIR, os.pardir, os.pardir, |
21 os.pardir)) | 21 os.pardir)) |
22 DIR_CONTENTS = os.listdir(SKIA_DIR) | 22 DIR_CONTENTS = os.listdir(SKIA_DIR) |
23 assert 'gyp' in DIR_CONTENTS | 23 assert 'gyp' in DIR_CONTENTS |
24 | 24 |
| 25 DEBUG_FAILURE = True |
| 26 |
25 def main(target_dir, target_file, skia_arch_type, have_neon, | 27 def main(target_dir, target_file, skia_arch_type, have_neon, |
26 gyp_source_dir=None): | 28 gyp_source_dir=None): |
27 """Create gypd files based on target_file. | 29 """Create gypd files based on target_file. |
28 | 30 |
29 Args: | 31 Args: |
30 target_dir: Directory containing all gyp files, including common.gypi | 32 target_dir: Directory containing all gyp files, including common.gypi |
31 target_file: Gyp file to start on. Other files within target_dir will | 33 target_file: Gyp file to start on. Other files within target_dir will |
32 be read if target_file depends on them. | 34 be read if target_file depends on them. |
33 skia_arch_type: Target architecture to pass to gyp. | 35 skia_arch_type: Target architecture to pass to gyp. |
34 have_neon: Whether to generate files including neon optimizations. | 36 have_neon: Whether to generate files including neon optimizations. |
35 Only meaningful if skia_arch_type is 'arm'. | 37 Only meaningful if skia_arch_type is 'arm'. |
36 gyp_source_dir: Directory of the gyp source code. The default is in | 38 gyp_source_dir: Directory of the gyp source code. The default is in |
37 third_party/externals/gyp. | 39 third_party/externals/gyp. |
38 | 40 |
39 Returns: | 41 Returns: |
40 path: Path to root gypd file created by running gyp. | 42 path: Path to root gypd file created by running gyp. |
41 """ | 43 """ |
42 # Ensure we import our current gyp source's module, not any version | 44 # Ensure we import our current gyp source's module, not any version |
43 # pre-installed in your PYTHONPATH. | 45 # pre-installed in your PYTHONPATH. |
44 if not gyp_source_dir: | 46 if not gyp_source_dir: |
| 47 if DEBUG_FAILURE: |
| 48 print 'gyp_source_dir not provided. using the default!' |
45 gyp_source_dir = os.path.join(SKIA_DIR, 'third_party', 'externals', 'gyp') | 49 gyp_source_dir = os.path.join(SKIA_DIR, 'third_party', 'externals', 'gyp') |
| 50 |
| 51 if DEBUG_FAILURE: |
| 52 print 'gyp_source_dir is "%s"' % gyp_source_dir |
| 53 if not os.path.exists(gyp_source_dir): |
| 54 print 'and it does not exist!' |
| 55 |
46 assert os.path.exists(gyp_source_dir) | 56 assert os.path.exists(gyp_source_dir) |
47 | 57 |
48 sys.path.insert(0, os.path.join(gyp_source_dir, 'pylib')) | 58 sys.path.insert(0, os.path.join(gyp_source_dir, 'pylib')) |
49 | 59 |
50 import gyp | 60 import gyp |
51 | 61 |
52 # Set GYP_DEFINES for building for the android framework. | 62 # Set GYP_DEFINES for building for the android framework. |
53 gyp_defines = ('skia_android_framework=1 OS=android skia_arch_type=%s ' | 63 gyp_defines = ('skia_android_framework=1 OS=android skia_arch_type=%s ' |
54 % skia_arch_type) | 64 % skia_arch_type) |
55 if skia_arch_type == 'arm': | 65 if skia_arch_type == 'arm': |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 """Remove the gypd files generated by main(). | 100 """Remove the gypd files generated by main(). |
91 | 101 |
92 Args: | 102 Args: |
93 folder: Folder in which to delete all files ending with 'gypd'. | 103 folder: Folder in which to delete all files ending with 'gypd'. |
94 """ | 104 """ |
95 assert os.path.isdir(folder) | 105 assert os.path.isdir(folder) |
96 files = os.listdir(folder) | 106 files = os.listdir(folder) |
97 for f in files: | 107 for f in files: |
98 if f.endswith('gypd'): | 108 if f.endswith('gypd'): |
99 os.remove(os.path.join(folder, f)) | 109 os.remove(os.path.join(folder, f)) |
OLD | NEW |