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 | 25 DEBUG_FAILURE = True |
26 | 26 |
27 def main(target_dir, target_file, skia_arch_type, have_neon, | 27 def main(target_dir, target_file, skia_arch_type, have_neon, |
28 gyp_source_dir=None): | 28 have_mips_dspr2, have_mips_dspr1, gyp_source_dir=None): |
29 """Create gypd files based on target_file. | 29 """Create gypd files based on target_file. |
30 | 30 |
31 Args: | 31 Args: |
32 target_dir: Directory containing all gyp files, including common.gypi | 32 target_dir: Directory containing all gyp files, including common.gypi |
33 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 |
34 be read if target_file depends on them. | 34 be read if target_file depends on them. |
35 skia_arch_type: Target architecture to pass to gyp. | 35 skia_arch_type: Target architecture to pass to gyp. |
36 have_neon: Whether to generate files including neon optimizations. | 36 have_neon: Whether to generate files including neon optimizations. |
37 Only meaningful if skia_arch_type is 'arm'. | 37 Only meaningful if skia_arch_type is 'arm'. |
38 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 |
(...skipping 24 matching lines...) Expand all Loading... |
63 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 ' |
64 % skia_arch_type) | 64 % skia_arch_type) |
65 if skia_arch_type == 'arm': | 65 if skia_arch_type == 'arm': |
66 # Always version 7 (which implies thumb) for arm | 66 # Always version 7 (which implies thumb) for arm |
67 gyp_defines += 'arm_version=7 ' | 67 gyp_defines += 'arm_version=7 ' |
68 if have_neon: | 68 if have_neon: |
69 gyp_defines += 'arm_neon=1 ' | 69 gyp_defines += 'arm_neon=1 ' |
70 else: | 70 else: |
71 gyp_defines += 'arm_neon=0 ' | 71 gyp_defines += 'arm_neon=0 ' |
72 | 72 |
| 73 if skia_arch_type == 'mips': |
| 74 if have_mips_dspr2: |
| 75 gyp_defines += 'mips_arch_variant=mips32r2 ' |
| 76 gyp_defines += 'mips_dsp=2 ' |
| 77 elif have_mips_dspr1: |
| 78 gyp_defines += 'mips_arch_variant=mips32r2 ' |
| 79 gyp_defines += 'mips_dsp=1 ' |
| 80 |
73 os.environ['GYP_DEFINES'] = gyp_defines | 81 os.environ['GYP_DEFINES'] = gyp_defines |
74 | 82 |
75 args = [] | 83 args = [] |
76 args.extend(['--depth', '.']) | 84 args.extend(['--depth', '.']) |
77 full_path = os.path.join(target_dir, target_file) | 85 full_path = os.path.join(target_dir, target_file) |
78 args.extend([full_path]) | 86 args.extend([full_path]) |
79 # Common conditions | 87 # Common conditions |
80 args.extend(['-I', os.path.join(target_dir, 'common.gypi')]) | 88 args.extend(['-I', os.path.join(target_dir, 'common.gypi')]) |
81 # Use the debugging format. We'll use these to create one master make file. | 89 # Use the debugging format. We'll use these to create one master make file. |
82 args.extend(['-f', 'gypd']) | 90 args.extend(['-f', 'gypd']) |
(...skipping 17 matching lines...) Expand all Loading... |
100 """Remove the gypd files generated by main(). | 108 """Remove the gypd files generated by main(). |
101 | 109 |
102 Args: | 110 Args: |
103 folder: Folder in which to delete all files ending with 'gypd'. | 111 folder: Folder in which to delete all files ending with 'gypd'. |
104 """ | 112 """ |
105 assert os.path.isdir(folder) | 113 assert os.path.isdir(folder) |
106 files = os.listdir(folder) | 114 files = os.listdir(folder) |
107 for f in files: | 115 for f in files: |
108 if f.endswith('gypd'): | 116 if f.endswith('gypd'): |
109 os.remove(os.path.join(folder, f)) | 117 os.remove(os.path.join(folder, f)) |
OLD | NEW |