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 # Directory within which we can find the gyp source. | 25 def main(target_dir, target_file, skia_arch_type, have_neon, |
26 gyp_source_dir = os.path.join(SKIA_DIR, 'third_party', 'externals', 'gyp') | 26 gyp_source_dir=None): |
27 if not os.path.exists(gyp_source_dir): | |
28 # In an Android tree, there is no third_party/externals/gyp, which would | |
29 # require running gclient sync. Use chromium's instead. | |
30 gyp_source_dir = os.path.join(SKIA_DIR, os.pardir, 'chromium_org', 'tools', | |
31 'gyp') | |
32 | |
33 assert os.path.exists(gyp_source_dir) | |
34 | |
35 # Ensure we import our current gyp source's module, not any version | |
36 # pre-installed in your PYTHONPATH. | |
37 sys.path.insert(0, os.path.join(gyp_source_dir, 'pylib')) | |
38 | |
39 import gyp | |
40 | |
41 def main(target_dir, target_file, skia_arch_type, have_neon): | |
42 """Create gypd files based on target_file. | 27 """Create gypd files based on target_file. |
43 | 28 |
44 Args: | 29 Args: |
45 target_dir: Directory containing all gyp files, including common.gypi | 30 target_dir: Directory containing all gyp files, including common.gypi |
46 target_file: Gyp file to start on. Other files within target_dir will | 31 target_file: Gyp file to start on. Other files within target_dir will |
47 be read if target_file depends on them. | 32 be read if target_file depends on them. |
48 skia_arch_type: Target architecture to pass to gyp. | 33 skia_arch_type: Target architecture to pass to gyp. |
49 have_neon: Whether to generate files including neon optimizations. | 34 have_neon: Whether to generate files including neon optimizations. |
50 Only meaningful if skia_arch_type is 'arm'. | 35 Only meaningful if skia_arch_type is 'arm'. |
| 36 gyp_source_dir: Directory of the gyp source code. The default is in |
| 37 third_party/externals/gyp. |
51 | 38 |
52 Returns: | 39 Returns: |
53 path: Path to root gypd file created by running gyp. | 40 path: Path to root gypd file created by running gyp. |
54 """ | 41 """ |
| 42 # Ensure we import our current gyp source's module, not any version |
| 43 # pre-installed in your PYTHONPATH. |
| 44 if not gyp_source_dir: |
| 45 gyp_source_dir = os.path.join(SKIA_DIR, 'third_party', 'externals', 'gyp') |
| 46 assert os.path.exists(gyp_source_dir) |
| 47 |
| 48 sys.path.insert(0, os.path.join(gyp_source_dir, 'pylib')) |
| 49 |
| 50 import gyp |
| 51 |
55 # Set GYP_DEFINES for building for the android framework. | 52 # Set GYP_DEFINES for building for the android framework. |
56 gyp_defines = ('skia_android_framework=1 OS=android skia_arch_type=%s ' | 53 gyp_defines = ('skia_android_framework=1 OS=android skia_arch_type=%s ' |
57 % skia_arch_type) | 54 % skia_arch_type) |
58 if skia_arch_type == 'arm': | 55 if skia_arch_type == 'arm': |
59 # Always use thumb and version 7 for arm | 56 # Always use thumb and version 7 for arm |
60 gyp_defines += 'arm_thumb=1 arm_version=7 ' | 57 gyp_defines += 'arm_thumb=1 arm_version=7 ' |
61 if have_neon: | 58 if have_neon: |
62 gyp_defines += 'arm_neon=1 ' | 59 gyp_defines += 'arm_neon=1 ' |
63 else: | 60 else: |
64 gyp_defines += 'arm_neon=0 ' | 61 gyp_defines += 'arm_neon=0 ' |
(...skipping 28 matching lines...) Expand all Loading... |
93 """Remove the gypd files generated by main(). | 90 """Remove the gypd files generated by main(). |
94 | 91 |
95 Args: | 92 Args: |
96 folder: Folder in which to delete all files ending with 'gypd'. | 93 folder: Folder in which to delete all files ending with 'gypd'. |
97 """ | 94 """ |
98 assert os.path.isdir(folder) | 95 assert os.path.isdir(folder) |
99 files = os.listdir(folder) | 96 files = os.listdir(folder) |
100 for f in files: | 97 for f in files: |
101 if f.endswith('gypd'): | 98 if f.endswith('gypd'): |
102 os.remove(os.path.join(folder, f)) | 99 os.remove(os.path.join(folder, f)) |
OLD | NEW |