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 generate_user_config |
29 import makefile_writer | 30 import makefile_writer |
30 import vars_dict_lib | 31 import vars_dict_lib |
31 | 32 |
32 # Folder containing all gyp files and generated gypd files. | 33 # Folder containing all gyp files and generated gypd files. |
33 GYP_FOLDER = 'gyp' | 34 GYP_FOLDER = 'gyp' |
34 | 35 |
35 # TODO(scroggo): Update the docstrings to match the style guide: | 36 # TODO(scroggo): Update the docstrings to match the style guide: |
36 # http://google-styleguide.googlecode.com/svn/trunk/pyguide.html#Comments | 37 # http://google-styleguide.googlecode.com/svn/trunk/pyguide.html#Comments |
37 def clean_gypd_files(folder): | 38 def clean_gypd_files(folder): |
38 """ | 39 """ |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 # variable definitions. | 100 # variable definitions. |
100 default_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'other', | 101 default_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'other', |
101 False) | 102 False) |
102 arm_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'arm', False) | 103 arm_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'arm', False) |
103 arm_neon_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'arm', | 104 arm_neon_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'arm', |
104 True) | 105 True) |
105 x86_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'x86', False) | 106 x86_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'x86', False) |
106 | 107 |
107 mips_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'mips', False) | 108 mips_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'mips', False) |
108 | 109 |
| 110 arm64_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'arm64', |
| 111 False) |
| 112 |
109 # Compute the intersection of all targets. All the files in the intersection | 113 # 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 | 114 # should be part of the makefile always. Each dict will now contain trimmed |
111 # lists containing only variable definitions specific to that configuration. | 115 # lists containing only variable definitions specific to that configuration. |
112 var_dict_list = [default_var_dict, arm_var_dict, arm_neon_var_dict, | 116 var_dict_list = [default_var_dict, arm_var_dict, arm_neon_var_dict, |
113 x86_var_dict, mips_var_dict] | 117 x86_var_dict, mips_var_dict, arm64_var_dict] |
114 common = vars_dict_lib.intersect(var_dict_list) | 118 common = vars_dict_lib.intersect(var_dict_list) |
115 | 119 |
| 120 # Create SkUserConfig |
| 121 user_config = os.path.join(SKIA_DIR, 'include', 'config', 'SkUserConfig.h') |
| 122 if target_dir: |
| 123 dst_dir = target_dir |
| 124 else: |
| 125 dst_dir = os.path.join(SKIA_DIR, 'include', 'core') |
| 126 |
| 127 generate_user_config.generate_user_config( |
| 128 original_sk_user_config=user_config, target_dir=dst_dir, |
| 129 ordered_set=common.DEFINES) |
| 130 |
| 131 # Now that the defines have been written to SkUserConfig, they are not |
| 132 # needed in Android.mk. |
| 133 common.DEFINES.reset() |
| 134 |
116 # Further trim arm_neon_var_dict with arm_var_dict. After this call, | 135 # Further trim arm_neon_var_dict with arm_var_dict. After this call, |
117 # arm_var_dict (which will now be the intersection) includes all definitions | 136 # arm_var_dict (which will now be the intersection) includes all definitions |
118 # used by both arm and arm + neon, and arm_neon_var_dict will only contain | 137 # used by both arm and arm + neon, and arm_neon_var_dict will only contain |
119 # those specific to arm + neon. | 138 # those specific to arm + neon. |
120 arm_var_dict = vars_dict_lib.intersect([arm_var_dict, arm_neon_var_dict]) | 139 arm_var_dict = vars_dict_lib.intersect([arm_var_dict, arm_neon_var_dict]) |
121 | 140 |
122 # Now create a list of VarsDictData holding everything but common. | 141 # Now create a list of VarsDictData holding everything but common. |
123 deviations_from_common = [] | 142 deviations_from_common = [] |
124 deviations_from_common.append(makefile_writer.VarsDictData( | 143 deviations_from_common.append(makefile_writer.VarsDictData( |
125 arm_var_dict, 'arm')) | 144 arm_var_dict, 'arm')) |
126 deviations_from_common.append(makefile_writer.VarsDictData( | 145 deviations_from_common.append(makefile_writer.VarsDictData( |
127 arm_neon_var_dict, 'arm', 'ARCH_ARM_HAVE_NEON')) | 146 arm_neon_var_dict, 'arm', 'ARCH_ARM_HAVE_NEON')) |
128 deviations_from_common.append(makefile_writer.VarsDictData(x86_var_dict, | 147 deviations_from_common.append(makefile_writer.VarsDictData(x86_var_dict, |
129 'x86')) | 148 'x86')) |
130 # Currently, x86_64 is identical to x86 | 149 # Currently, x86_64 is identical to x86 |
131 deviations_from_common.append(makefile_writer.VarsDictData(x86_var_dict, | 150 deviations_from_common.append(makefile_writer.VarsDictData(x86_var_dict, |
132 'x86_64')) | 151 'x86_64')) |
133 | 152 |
134 deviations_from_common.append(makefile_writer.VarsDictData(mips_var_dict, | 153 deviations_from_common.append(makefile_writer.VarsDictData(mips_var_dict, |
135 'mips')) | 154 'mips')) |
136 | 155 |
| 156 deviations_from_common.append(makefile_writer.VarsDictData(arm64_var_dict, |
| 157 'arm64')) |
| 158 |
137 makefile_writer.write_android_mk(target_dir=target_dir, | 159 makefile_writer.write_android_mk(target_dir=target_dir, |
138 common=common, deviations_from_common=deviations_from_common) | 160 common=common, deviations_from_common=deviations_from_common) |
139 | 161 |
140 finally: | 162 finally: |
141 shutil.rmtree(tmp_folder) | 163 shutil.rmtree(tmp_folder) |
142 | 164 |
143 if __name__ == '__main__': | 165 if __name__ == '__main__': |
144 main() | 166 main() |
OLD | NEW |