| 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 """Code for generating Android.mk for a tool.""" | 8 """Code for generating Android.mk for a tool.""" |
| 9 | 9 |
| 10 | 10 |
| 11 import android_framework_gyp | 11 import android_framework_gyp |
| 12 import gypd_parser | 12 import gypd_parser |
| 13 import makefile_writer | 13 import makefile_writer |
| 14 import os | 14 import os |
| 15 import vars_dict_lib | 15 import vars_dict_lib |
| 16 | 16 |
| 17 | 17 |
| 18 def write_tool_android_mk(target_dir, var_dict): | 18 def write_tool_android_mk(target_dir, var_dict, place_in_local_tmp): |
| 19 """Write Android.mk for a Skia tool. | 19 """Write Android.mk for a Skia tool. |
| 20 | 20 |
| 21 Args: | 21 Args: |
| 22 target_dir: Destination for the makefile. Must not be None. | 22 target_dir: Destination for the makefile. Must not be None. |
| 23 var_dict: VarsDict containing variables for the makefile. | 23 var_dict: VarsDict containing variables for the makefile. |
| 24 place_in_local_tmp: If True, the executable will be synced to |
| 25 /data/local/tmp. |
| 24 """ | 26 """ |
| 25 target_file = os.path.join(target_dir, 'Android.mk') | 27 target_file = os.path.join(target_dir, 'Android.mk') |
| 26 with open(target_file, 'w') as f: | 28 with open(target_file, 'w') as f: |
| 27 f.write(makefile_writer.AUTOGEN_WARNING) | 29 f.write(makefile_writer.AUTOGEN_WARNING) |
| 30 |
| 31 if place_in_local_tmp: |
| 32 f.write('local_target_dir := $(TARGET_OUT_DATA)/local/tmp\n') |
| 33 |
| 28 makefile_writer.write_local_path(f) | 34 makefile_writer.write_local_path(f) |
| 29 makefile_writer.write_clear_vars(f) | 35 makefile_writer.write_clear_vars(f) |
| 30 | 36 |
| 31 makefile_writer.write_local_vars(f, var_dict, False, None) | 37 makefile_writer.write_local_vars(f, var_dict, False, None) |
| 32 | 38 |
| 39 if place_in_local_tmp: |
| 40 f.write('LOCAL_MODULE_PATH := $(local_target_dir)\n') |
| 41 |
| 33 makefile_writer.write_include_stlport(f) | 42 makefile_writer.write_include_stlport(f) |
| 34 f.write('include $(BUILD_EXECUTABLE)\n') | 43 f.write('include $(BUILD_EXECUTABLE)\n') |
| 35 | 44 |
| 36 | 45 |
| 37 def generate_tool(gyp_dir, target_file, skia_trunk, dest_dir, | 46 def generate_tool(gyp_dir, target_file, skia_trunk, dest_dir, |
| 38 skia_lib_var_dict, local_module_name, local_module_tags): | 47 skia_lib_var_dict, local_module_name, local_module_tags, |
| 48 place_in_local_tmp=False): |
| 39 """Common steps for building one of the skia tools. | 49 """Common steps for building one of the skia tools. |
| 40 | 50 |
| 41 Parse a gyp file and create an Android.mk for this tool. | 51 Parse a gyp file and create an Android.mk for this tool. |
| 42 | 52 |
| 43 Args: | 53 Args: |
| 44 gyp_dir: Directory containing gyp files. | 54 gyp_dir: Directory containing gyp files. |
| 45 target_file: gyp file for the project to be built, contained in gyp_dir. | 55 target_file: gyp file for the project to be built, contained in gyp_dir. |
| 46 skia_trunk: Trunk of Skia, used for determining the destination to write | 56 skia_trunk: Trunk of Skia, used for determining the destination to write |
| 47 'Android.mk'. | 57 'Android.mk'. |
| 48 dest_dir: Destination for 'Android.mk', relative to skia_trunk. Used for | 58 dest_dir: Destination for 'Android.mk', relative to skia_trunk. Used for |
| 49 both writing relative paths in the makefile and for determining the | 59 both writing relative paths in the makefile and for determining the |
| 50 destination to write the it. | 60 destination to write the it. |
| 51 skia_lib_var_dict: VarsDict representing libskia. Used as a reference to | 61 skia_lib_var_dict: VarsDict representing libskia. Used as a reference to |
| 52 ensure we do not duplicate anything in this Android.mk. | 62 ensure we do not duplicate anything in this Android.mk. |
| 53 local_module_name: Name for this tool, to set as LOCAL_MODULE. | 63 local_module_name: Name for this tool, to set as LOCAL_MODULE. |
| 54 local_module_tags: Tags to pass to LOCAL_MODULE_TAG. | 64 local_module_tags: Tags to pass to LOCAL_MODULE_TAG. |
| 65 place_in_local_tmp: If True, the executable will be synced to |
| 66 /data/local/tmp. |
| 55 """ | 67 """ |
| 56 result_file = android_framework_gyp.main(target_dir=gyp_dir, | 68 result_file = android_framework_gyp.main(target_dir=gyp_dir, |
| 57 target_file=target_file, | 69 target_file=target_file, |
| 58 skia_arch_type='other', | 70 skia_arch_type='other', |
| 59 have_neon=False) | 71 have_neon=False) |
| 60 | 72 |
| 61 var_dict = vars_dict_lib.VarsDict() | 73 var_dict = vars_dict_lib.VarsDict() |
| 62 | 74 |
| 63 # Add known targets from skia_lib, so we do not reparse them. | 75 # Add known targets from skia_lib, so we do not reparse them. |
| 64 var_dict.KNOWN_TARGETS.set(skia_lib_var_dict.KNOWN_TARGETS) | 76 var_dict.KNOWN_TARGETS.set(skia_lib_var_dict.KNOWN_TARGETS) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 82 if skia_trunk: | 94 if skia_trunk: |
| 83 full_dest = os.path.join(skia_trunk, dest_dir) | 95 full_dest = os.path.join(skia_trunk, dest_dir) |
| 84 else: | 96 else: |
| 85 full_dest = dest_dir | 97 full_dest = dest_dir |
| 86 | 98 |
| 87 # If the path does not exist, create it. This will happen during testing, | 99 # If the path does not exist, create it. This will happen during testing, |
| 88 # where there is no subdirectory for each tool (just a temporary folder). | 100 # where there is no subdirectory for each tool (just a temporary folder). |
| 89 if not os.path.exists(full_dest): | 101 if not os.path.exists(full_dest): |
| 90 os.mkdir(full_dest) | 102 os.mkdir(full_dest) |
| 91 | 103 |
| 92 write_tool_android_mk(target_dir=full_dest, var_dict=var_dict) | 104 write_tool_android_mk(target_dir=full_dest, var_dict=var_dict, |
| 105 place_in_local_tmp=place_in_local_tmp) |
| OLD | NEW |