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 Script for generating the Android framework's version of Skia from gyp | 9 Script for generating the Android framework's version of Skia from gyp |
10 files. | 10 files. |
11 """ | 11 """ |
12 | 12 |
13 import android_framework_gyp | 13 import android_framework_gyp |
14 import os | 14 import os |
15 import shutil | 15 import shutil |
16 import sys | 16 import sys |
17 import tempfile | 17 import tempfile |
18 | 18 |
19 # Find the top of trunk | 19 # Find the top of trunk |
20 SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__)) | 20 SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__)) |
21 SKIA_DIR = os.path.normpath(os.path.join(SCRIPT_DIR, os.pardir, os.pardir, | 21 SKIA_DIR = os.path.normpath(os.path.join(SCRIPT_DIR, os.pardir, os.pardir, |
22 os.pardir)) | 22 os.pardir)) |
23 | 23 |
24 # Find the directory with our helper files, and add it to the path. | 24 # Find the directory with our helper files, and add it to the path. |
25 GYP_GEN_DIR = os.path.join(SKIA_DIR, 'platform_tools', 'android', 'gyp_gen') | 25 GYP_GEN_DIR = os.path.join(SKIA_DIR, 'platform_tools', 'android', 'gyp_gen') |
26 sys.path.append(GYP_GEN_DIR) | 26 sys.path.append(GYP_GEN_DIR) |
27 | 27 |
28 import gypd_parser | 28 import gypd_parser |
29 import makefile_writer | 29 import makefile_writer |
30 import variables | |
31 import vars_dict_lib | 30 import vars_dict_lib |
32 | 31 |
33 # Folder containing all gyp files and generated gypd files. | 32 # Folder containing all gyp files and generated gypd files. |
34 GYP_FOLDER = 'gyp' | 33 GYP_FOLDER = 'gyp' |
35 | 34 |
| 35 # TODO(scroggo): Update the docstrings to match the style guide: |
| 36 # http://google-styleguide.googlecode.com/svn/trunk/pyguide.html#Comments |
36 def clean_gypd_files(folder): | 37 def clean_gypd_files(folder): |
37 """ | 38 """ |
38 Remove the gypd files generated by android_framework_gyp.main(). | 39 Remove the gypd files generated by android_framework_gyp.main(). |
39 @param folder Folder in which to delete all files ending with 'gypd'. | 40 @param folder Folder in which to delete all files ending with 'gypd'. |
40 """ | 41 """ |
41 assert os.path.isdir(folder) | 42 assert os.path.isdir(folder) |
42 files = os.listdir(folder) | 43 files = os.listdir(folder) |
43 for f in files: | 44 for f in files: |
44 if f.endswith('gypd'): | 45 if f.endswith('gypd'): |
45 os.remove(os.path.join(folder, f)) | 46 os.remove(os.path.join(folder, f)) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 # into a single Android.mk file, which can build targets of any | 95 # into a single Android.mk file, which can build targets of any |
95 # architecture type. | 96 # architecture type. |
96 | 97 |
97 # The default uses a non-existant archtype, to find all the general | 98 # The default uses a non-existant archtype, to find all the general |
98 # variable definitions. | 99 # variable definitions. |
99 default_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'other', | 100 default_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'other', |
100 False) | 101 False) |
101 arm_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'arm', False) | 102 arm_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'arm', False) |
102 arm_neon_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'arm', | 103 arm_neon_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'arm', |
103 True) | 104 True) |
104 if variables.INCLUDE_X86_OPTS: | 105 x86_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'x86', False) |
105 x86_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'x86', False) | 106 |
106 else: | 107 mips_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'mips', False) |
107 x86_var_dict = None | |
108 | 108 |
109 # Compute the intersection of all targets. All the files in the intersection | 109 # Compute the intersection of all targets. All the files in the intersection |
110 # should be part of the makefile always. Each dict will now contain trimmed | 110 # should be part of the makefile always. Each dict will now contain trimmed |
111 # lists containing only variable definitions specific to that configuration. | 111 # lists containing only variable definitions specific to that configuration. |
112 var_dict_list = [default_var_dict, arm_var_dict, arm_neon_var_dict] | 112 var_dict_list = [default_var_dict, arm_var_dict, arm_neon_var_dict, |
113 if variables.INCLUDE_X86_OPTS: | 113 x86_var_dict, mips_var_dict] |
114 var_dict_list.append(x86_var_dict) | |
115 common = vars_dict_lib.intersect(var_dict_list) | 114 common = vars_dict_lib.intersect(var_dict_list) |
116 | 115 |
117 # Further trim arm_neon_var_dict with arm_var_dict. After this call, | 116 # Further trim arm_neon_var_dict with arm_var_dict. After this call, |
118 # arm_var_dict (which will now be the intersection) includes all definitions | 117 # arm_var_dict (which will now be the intersection) includes all definitions |
119 # used by both arm and arm + neon, and arm_neon_var_dict will only contain | 118 # used by both arm and arm + neon, and arm_neon_var_dict will only contain |
120 # those specific to arm + neon. | 119 # those specific to arm + neon. |
121 arm_var_dict = vars_dict_lib.intersect([arm_var_dict, arm_neon_var_dict]) | 120 arm_var_dict = vars_dict_lib.intersect([arm_var_dict, arm_neon_var_dict]) |
122 | 121 |
| 122 # Now create a list of VarsDictData holding everything but common. |
| 123 deviations_from_common = [] |
| 124 deviations_from_common.append(makefile_writer.VarsDictData( |
| 125 arm_var_dict, 'arm')) |
| 126 deviations_from_common.append(makefile_writer.VarsDictData( |
| 127 arm_neon_var_dict, 'arm', 'ARCH_ARM_HAVE_NEON')) |
| 128 deviations_from_common.append(makefile_writer.VarsDictData(x86_var_dict, |
| 129 'x86')) |
| 130 # Currently, x86_64 is identical to x86 |
| 131 deviations_from_common.append(makefile_writer.VarsDictData(x86_var_dict, |
| 132 'x86_64')) |
| 133 |
| 134 deviations_from_common.append(makefile_writer.VarsDictData(mips_var_dict, |
| 135 'mips')) |
| 136 |
123 makefile_writer.write_android_mk(target_dir=target_dir, | 137 makefile_writer.write_android_mk(target_dir=target_dir, |
124 common=common, | 138 common=common, deviations_from_common=deviations_from_common) |
125 arm=arm_var_dict, | |
126 arm_neon=arm_neon_var_dict, | |
127 x86=x86_var_dict, | |
128 default=default_var_dict) | |
129 | 139 |
130 finally: | 140 finally: |
131 shutil.rmtree(tmp_folder) | 141 shutil.rmtree(tmp_folder) |
132 | 142 |
133 if __name__ == '__main__': | 143 if __name__ == '__main__': |
134 main() | 144 main() |
OLD | NEW |