Chromium Code Reviews| 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 |
| 36 def clean_gypd_files(folder): | 35 def clean_gypd_files(folder): |
| 37 """ | 36 """ |
| 38 Remove the gypd files generated by android_framework_gyp.main(). | 37 Remove the gypd files generated by android_framework_gyp.main(). |
| 39 @param folder Folder in which to delete all files ending with 'gypd'. | 38 @param folder Folder in which to delete all files ending with 'gypd'. |
| 40 """ | 39 """ |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 # into a single Android.mk file, which can build targets of any | 93 # into a single Android.mk file, which can build targets of any |
| 95 # architecture type. | 94 # architecture type. |
| 96 | 95 |
| 97 # The default uses a non-existant archtype, to find all the general | 96 # The default uses a non-existant archtype, to find all the general |
| 98 # variable definitions. | 97 # variable definitions. |
| 99 default_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'other', | 98 default_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'other', |
| 100 False) | 99 False) |
| 101 arm_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'arm', False) | 100 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', | 101 arm_neon_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'arm', |
| 103 True) | 102 True) |
| 104 if variables.INCLUDE_X86_OPTS: | 103 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) | 104 |
| 106 else: | 105 mips_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'mips', False) |
| 107 x86_var_dict = None | |
| 108 | 106 |
| 109 # Compute the intersection of all targets. All the files in the intersection | 107 # 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 | 108 # should be part of the makefile always. Each dict will now contain trimmed |
| 111 # lists containing only variable definitions specific to that configuration. | 109 # lists containing only variable definitions specific to that configuration. |
| 112 var_dict_list = [default_var_dict, arm_var_dict, arm_neon_var_dict] | 110 var_dict_list = [default_var_dict, arm_var_dict, arm_neon_var_dict, |
| 113 if variables.INCLUDE_X86_OPTS: | 111 x86_var_dict, mips_var_dict] |
| 114 var_dict_list.append(x86_var_dict) | |
| 115 common = vars_dict_lib.intersect(var_dict_list) | 112 common = vars_dict_lib.intersect(var_dict_list) |
| 116 | 113 |
| 117 # Further trim arm_neon_var_dict with arm_var_dict. After this call, | 114 # 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 | 115 # 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 | 116 # used by both arm and arm + neon, and arm_neon_var_dict will only contain |
| 120 # those specific to arm + neon. | 117 # those specific to arm + neon. |
| 121 arm_var_dict = vars_dict_lib.intersect([arm_var_dict, arm_neon_var_dict]) | 118 arm_var_dict = vars_dict_lib.intersect([arm_var_dict, arm_neon_var_dict]) |
| 122 | 119 |
| 120 # Now create a list of VarsDictData holding everything but common. | |
| 121 li = list() | |
|
epoger
2014/02/28 15:56:43
Please use a more descriptive variable name. Mayb
scroggo
2014/02/28 16:16:57
Done.
| |
| 122 li.append(makefile_writer.VarsDictData(arm_var_dict, 'arm')) | |
| 123 li.append(makefile_writer.VarsDictData(arm_neon_var_dict, 'arm', | |
| 124 'ARCH_ARM_HAVE_NEON')) | |
| 125 li.append(makefile_writer.VarsDictData(x86_var_dict, 'x86')) | |
| 126 # Currently, x86_64 is identical to x86 | |
| 127 li.append(makefile_writer.VarsDictData(x86_var_dict, 'x86_64')) | |
| 128 | |
| 129 li.append(makefile_writer.VarsDictData(mips_var_dict, 'mips')) | |
| 130 | |
| 123 makefile_writer.write_android_mk(target_dir=target_dir, | 131 makefile_writer.write_android_mk(target_dir=target_dir, |
| 124 common=common, | 132 common=common, |
| 125 arm=arm_var_dict, | 133 the_rest=li) |
| 126 arm_neon=arm_neon_var_dict, | |
| 127 x86=x86_var_dict, | |
| 128 default=default_var_dict) | |
| 129 | 134 |
| 130 finally: | 135 finally: |
| 131 shutil.rmtree(tmp_folder) | 136 shutil.rmtree(tmp_folder) |
| 132 | 137 |
| 133 if __name__ == '__main__': | 138 if __name__ == '__main__': |
| 134 main() | 139 main() |
| OLD | NEW |