| 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 |
| 30 import gen_public_headers |
| 29 import makefile_writer | 31 import makefile_writer |
| 30 import vars_dict_lib | 32 import vars_dict_lib |
| 31 | 33 |
| 32 # Folder containing all gyp files and generated gypd files. | 34 # Folder containing all gyp files and generated gypd files. |
| 33 GYP_FOLDER = 'gyp' | 35 GYP_FOLDER = 'gyp' |
| 34 | 36 |
| 35 # TODO(scroggo): Update the docstrings to match the style guide: | 37 # TODO(scroggo): Update the docstrings to match the style guide: |
| 36 # http://google-styleguide.googlecode.com/svn/trunk/pyguide.html#Comments | 38 # http://google-styleguide.googlecode.com/svn/trunk/pyguide.html#Comments |
| 37 def clean_gypd_files(folder): | 39 def clean_gypd_files(folder): |
| 38 """ | 40 """ |
| (...skipping 24 matching lines...) Expand all Loading... |
| 63 print '.', | 65 print '.', |
| 64 return var_dict | 66 return var_dict |
| 65 | 67 |
| 66 def main(target_dir=None): | 68 def main(target_dir=None): |
| 67 """ | 69 """ |
| 68 Read gyp files and create Android.mk for the Android framework's | 70 Read gyp files and create Android.mk for the Android framework's |
| 69 external/skia. | 71 external/skia. |
| 70 @param target_dir Directory in which to place 'Android.mk'. If None, the file | 72 @param target_dir Directory in which to place 'Android.mk'. If None, the file |
| 71 will be placed in skia's root directory. | 73 will be placed in skia's root directory. |
| 72 """ | 74 """ |
| 75 # Update public_headers.gypi |
| 76 gen_public_headers.generate_public_headers( |
| 77 dst=os.path.join(SKIA_DIR, GYP_FOLDER, 'public_headers.gypi'), |
| 78 top_dir=os.path.join(SKIA_DIR, 'include')) |
| 79 |
| 73 # Create a temporary folder to hold gyp and gypd files. Create it in SKIA_DIR | 80 # Create a temporary folder to hold gyp and gypd files. Create it in SKIA_DIR |
| 74 # so that it is a sibling of gyp/, so the relationships between gyp files and | 81 # so that it is a sibling of gyp/, so the relationships between gyp files and |
| 75 # other files (e.g. platform_tools/android/gyp/dependencies.gypi, referenced | 82 # other files (e.g. platform_tools/android/gyp/dependencies.gypi, referenced |
| 76 # by android_deps.gyp as a relative path) is unchanged. | 83 # by android_deps.gyp as a relative path) is unchanged. |
| 77 # Use mkdtemp to find an unused folder name, but then delete it so copytree | 84 # Use mkdtemp to find an unused folder name, but then delete it so copytree |
| 78 # can be called with a non-existent directory. | 85 # can be called with a non-existent directory. |
| 79 tmp_folder = tempfile.mkdtemp(dir=SKIA_DIR) | 86 tmp_folder = tempfile.mkdtemp(dir=SKIA_DIR) |
| 80 os.rmdir(tmp_folder) | 87 os.rmdir(tmp_folder) |
| 81 shutil.copytree(os.path.join(SKIA_DIR, GYP_FOLDER), tmp_folder) | 88 shutil.copytree(os.path.join(SKIA_DIR, GYP_FOLDER), tmp_folder) |
| 82 | 89 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 99 # variable definitions. | 106 # variable definitions. |
| 100 default_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'other', | 107 default_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'other', |
| 101 False) | 108 False) |
| 102 arm_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'arm', False) | 109 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', | 110 arm_neon_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'arm', |
| 104 True) | 111 True) |
| 105 x86_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'x86', False) | 112 x86_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'x86', False) |
| 106 | 113 |
| 107 mips_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'mips', False) | 114 mips_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'mips', False) |
| 108 | 115 |
| 116 arm64_var_dict = generate_var_dict(tmp_folder, main_gyp_file, 'arm64', |
| 117 False) |
| 118 |
| 109 # 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 |
| 110 # 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 |
| 111 # lists containing only variable definitions specific to that configuration. | 121 # lists containing only variable definitions specific to that configuration. |
| 112 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, |
| 113 x86_var_dict, mips_var_dict] | 123 x86_var_dict, mips_var_dict, arm64_var_dict] |
| 114 common = vars_dict_lib.intersect(var_dict_list) | 124 common = vars_dict_lib.intersect(var_dict_list) |
| 115 | 125 |
| 126 # Create SkUserConfig |
| 127 user_config = os.path.join(SKIA_DIR, 'include', 'config', 'SkUserConfig.h') |
| 128 if target_dir: |
| 129 dst_dir = target_dir |
| 130 else: |
| 131 dst_dir = os.path.join(SKIA_DIR, 'include', 'core') |
| 132 |
| 133 generate_user_config.generate_user_config( |
| 134 original_sk_user_config=user_config, target_dir=dst_dir, |
| 135 ordered_set=common.DEFINES) |
| 136 |
| 137 # Now that the defines have been written to SkUserConfig, they are not |
| 138 # needed in Android.mk. |
| 139 common.DEFINES.reset() |
| 140 |
| 116 # Further trim arm_neon_var_dict with arm_var_dict. After this call, | 141 # 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 | 142 # 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 | 143 # used by both arm and arm + neon, and arm_neon_var_dict will only contain |
| 119 # those specific to arm + neon. | 144 # those specific to arm + neon. |
| 120 arm_var_dict = vars_dict_lib.intersect([arm_var_dict, arm_neon_var_dict]) | 145 arm_var_dict = vars_dict_lib.intersect([arm_var_dict, arm_neon_var_dict]) |
| 121 | 146 |
| 122 # Now create a list of VarsDictData holding everything but common. | 147 # Now create a list of VarsDictData holding everything but common. |
| 123 deviations_from_common = [] | 148 deviations_from_common = [] |
| 124 deviations_from_common.append(makefile_writer.VarsDictData( | 149 deviations_from_common.append(makefile_writer.VarsDictData( |
| 125 arm_var_dict, 'arm')) | 150 arm_var_dict, 'arm')) |
| 126 deviations_from_common.append(makefile_writer.VarsDictData( | 151 deviations_from_common.append(makefile_writer.VarsDictData( |
| 127 arm_neon_var_dict, 'arm', 'ARCH_ARM_HAVE_NEON')) | 152 arm_neon_var_dict, 'arm', 'ARCH_ARM_HAVE_NEON')) |
| 128 deviations_from_common.append(makefile_writer.VarsDictData(x86_var_dict, | 153 deviations_from_common.append(makefile_writer.VarsDictData(x86_var_dict, |
| 129 'x86')) | 154 'x86')) |
| 130 # Currently, x86_64 is identical to x86 | 155 # Currently, x86_64 is identical to x86 |
| 131 deviations_from_common.append(makefile_writer.VarsDictData(x86_var_dict, | 156 deviations_from_common.append(makefile_writer.VarsDictData(x86_var_dict, |
| 132 'x86_64')) | 157 'x86_64')) |
| 133 | 158 |
| 134 deviations_from_common.append(makefile_writer.VarsDictData(mips_var_dict, | 159 deviations_from_common.append(makefile_writer.VarsDictData(mips_var_dict, |
| 135 'mips')) | 160 'mips')) |
| 136 | 161 |
| 162 deviations_from_common.append(makefile_writer.VarsDictData(arm64_var_dict, |
| 163 'arm64')) |
| 164 |
| 137 makefile_writer.write_android_mk(target_dir=target_dir, | 165 makefile_writer.write_android_mk(target_dir=target_dir, |
| 138 common=common, deviations_from_common=deviations_from_common) | 166 common=common, deviations_from_common=deviations_from_common) |
| 139 | 167 |
| 140 finally: | 168 finally: |
| 141 shutil.rmtree(tmp_folder) | 169 shutil.rmtree(tmp_folder) |
| 142 | 170 |
| 143 if __name__ == '__main__': | 171 if __name__ == '__main__': |
| 144 main() | 172 main() |
| OLD | NEW |