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. |
(...skipping 17 matching lines...) Expand all Loading... |
28 import gyp_gen.gypd_parser as gypd_parser | 28 import gyp_gen.gypd_parser as gypd_parser |
29 import gyp_gen.generate_user_config as generate_user_config | 29 import gyp_gen.generate_user_config as generate_user_config |
30 import gyp_gen.makefile_writer as makefile_writer | 30 import gyp_gen.makefile_writer as makefile_writer |
31 import gyp_gen.tool_makefile_writer as tool_makefile_writer | 31 import gyp_gen.tool_makefile_writer as tool_makefile_writer |
32 import gyp_gen.vars_dict_lib as vars_dict_lib | 32 import gyp_gen.vars_dict_lib as vars_dict_lib |
33 | 33 |
34 # Folder containing all gyp files and generated gypd files. | 34 # Folder containing all gyp files and generated gypd files. |
35 GYP_FOLDER = 'gyp' | 35 GYP_FOLDER = 'gyp' |
36 | 36 |
37 | 37 |
38 def generate_var_dict(target_dir, target_file, skia_arch_type, have_neon): | 38 def generate_var_dict(target_dir, target_file, skia_arch_type, have_neon, |
| 39 gyp_source_dir): |
39 """Create a VarsDict for a particular arch type. | 40 """Create a VarsDict for a particular arch type. |
40 | 41 |
41 Each paramater is passed directly to android_framework_gyp.main(). | 42 Each paramater is passed directly to android_framework_gyp.main(). |
42 | 43 |
43 Args: | 44 Args: |
44 target_dir: Directory containing gyp files. | 45 target_dir: Directory containing gyp files. |
45 target_file: Target gyp file. | 46 target_file: Target gyp file. |
46 skia_arch_type: Target architecture. | 47 skia_arch_type: Target architecture. |
47 have_neon: Whether the target should build for neon. | 48 have_neon: Whether the target should build for neon. |
| 49 gyp_source_dir: Directory for gyp source. |
48 Returns: | 50 Returns: |
49 A VarsDict containing the variable definitions determined by gyp. | 51 A VarsDict containing the variable definitions determined by gyp. |
50 """ | 52 """ |
51 result_file = android_framework_gyp.main(target_dir, target_file, | 53 result_file = android_framework_gyp.main(target_dir, target_file, |
52 skia_arch_type, have_neon) | 54 skia_arch_type, have_neon, |
| 55 gyp_source_dir) |
53 var_dict = vars_dict_lib.VarsDict() | 56 var_dict = vars_dict_lib.VarsDict() |
54 gypd_parser.parse_gypd(var_dict, result_file, '.') | 57 gypd_parser.parse_gypd(var_dict, result_file, '.') |
55 android_framework_gyp.clean_gypd_files(target_dir) | 58 android_framework_gyp.clean_gypd_files(target_dir) |
56 print '.', | 59 print '.', |
57 return var_dict | 60 return var_dict |
58 | 61 |
59 def main(target_dir=None, require_sk_user_config=False): | 62 def main(target_dir=None, require_sk_user_config=False, gyp_source_dir=None): |
60 """Create Android.mk for the Android framework's external/skia. | 63 """Create Android.mk for the Android framework's external/skia. |
61 | 64 |
62 Builds Android.mk using Skia's gyp files. | 65 Builds Android.mk using Skia's gyp files. |
63 | 66 |
64 Args: | 67 Args: |
65 target_dir: Directory in which to place 'Android.mk'. If None, the file | 68 target_dir: Directory in which to place 'Android.mk'. If None, the file |
66 will be placed in skia's root directory. | 69 will be placed in skia's root directory. |
67 require_sk_user_config: If True, raise an AssertionError if | 70 require_sk_user_config: If True, raise an AssertionError if |
68 SkUserConfig.h does not exist. | 71 SkUserConfig.h does not exist. |
| 72 gyp_source_dir: Source directory for gyp. |
69 """ | 73 """ |
70 # Create a temporary folder to hold gyp and gypd files. Create it in SKIA_DIR | 74 # Create a temporary folder to hold gyp and gypd files. Create it in SKIA_DIR |
71 # so that it is a sibling of gyp/, so the relationships between gyp files and | 75 # so that it is a sibling of gyp/, so the relationships between gyp files and |
72 # other files (e.g. platform_tools/android/gyp/dependencies.gypi, referenced | 76 # other files (e.g. platform_tools/android/gyp/dependencies.gypi, referenced |
73 # by android_deps.gyp as a relative path) is unchanged. | 77 # by android_deps.gyp as a relative path) is unchanged. |
74 # Use mkdtemp to find an unused folder name, but then delete it so copytree | 78 # Use mkdtemp to find an unused folder name, but then delete it so copytree |
75 # can be called with a non-existent directory. | 79 # can be called with a non-existent directory. |
76 tmp_folder = tempfile.mkdtemp(dir=SKIA_DIR) | 80 tmp_folder = tempfile.mkdtemp(dir=SKIA_DIR) |
77 os.rmdir(tmp_folder) | 81 os.rmdir(tmp_folder) |
78 shutil.copytree(os.path.join(SKIA_DIR, GYP_FOLDER), tmp_folder) | 82 shutil.copytree(os.path.join(SKIA_DIR, GYP_FOLDER), tmp_folder) |
79 | 83 |
80 try: | 84 try: |
81 main_gyp_file = 'android_framework_lib.gyp' | 85 main_gyp_file = 'android_framework_lib.gyp' |
82 | 86 |
83 print 'Creating Android.mk', | 87 print 'Creating Android.mk', |
84 | 88 |
85 # Generate a separate VarsDict for each architecture type. For each | 89 # Generate a separate VarsDict for each architecture type. For each |
86 # archtype: | 90 # archtype: |
87 # 1. call android_framework_gyp.main() to generate gypd files | 91 # 1. call android_framework_gyp.main() to generate gypd files |
88 # 2. call parse_gypd to read those gypd files into the VarsDict | 92 # 2. call parse_gypd to read those gypd files into the VarsDict |
89 # 3. delete the gypd files | 93 # 3. delete the gypd files |
90 # | 94 # |
91 # Once we have the VarsDict for each architecture type, we combine them all | 95 # Once we have the VarsDict for each architecture type, we combine them all |
92 # into a single Android.mk file, which can build targets of any | 96 # into a single Android.mk file, which can build targets of any |
93 # architecture type. | 97 # architecture type. |
94 | 98 |
95 # The default uses a non-existant archtype, to find all the general | 99 # The default uses a non-existant archtype, to find all the general |
96 # variable definitions. | 100 # variable definitions. |
97 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', |
98 False) | 102 False, gyp_source_dir) |
99 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, |
| 104 gyp_source_dir) |
100 arm_neon_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'arm', | 105 arm_neon_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'arm', |
101 True) | 106 True, gyp_source_dir) |
102 x86_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'x86', False) | 107 x86_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'x86', False, |
| 108 gyp_source_dir) |
103 | 109 |
104 mips_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'mips', False) | 110 mips_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'mips', False, |
| 111 gyp_source_dir) |
105 | 112 |
106 mips64_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'mips64', | 113 mips64_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'mips64', |
107 False) | 114 False, gyp_source_dir) |
108 | 115 |
109 arm64_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'arm64', | 116 arm64_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'arm64', |
110 False) | 117 False, gyp_source_dir) |
111 | 118 |
112 # Compute the intersection of all targets. All the files in the intersection | 119 # Compute the intersection of all targets. All the files in the intersection |
113 # should be part of the makefile always. Each dict will now contain trimmed | 120 # should be part of the makefile always. Each dict will now contain trimmed |
114 # lists containing only variable definitions specific to that configuration. | 121 # lists containing only variable definitions specific to that configuration. |
115 var_dict_list = [default_var_dict, arm_var_dict, arm_neon_var_dict, | 122 var_dict_list = [default_var_dict, arm_var_dict, arm_neon_var_dict, |
116 x86_var_dict, mips_var_dict, mips64_var_dict, | 123 x86_var_dict, mips_var_dict, mips64_var_dict, |
117 arm64_var_dict] | 124 arm64_var_dict] |
118 common = vars_dict_lib.intersect(var_dict_list) | 125 common = vars_dict_lib.intersect(var_dict_list) |
119 | 126 |
120 common.LOCAL_MODULE.add('libskia') | 127 common.LOCAL_MODULE.add('libskia') |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 'arm64')) | 198 'arm64')) |
192 | 199 |
193 makefile_writer.write_android_mk(target_dir=target_dir, | 200 makefile_writer.write_android_mk(target_dir=target_dir, |
194 common=common, deviations_from_common=deviations_from_common) | 201 common=common, deviations_from_common=deviations_from_common) |
195 | 202 |
196 finally: | 203 finally: |
197 shutil.rmtree(tmp_folder) | 204 shutil.rmtree(tmp_folder) |
198 | 205 |
199 if __name__ == '__main__': | 206 if __name__ == '__main__': |
200 main() | 207 main() |
OLD | NEW |