| OLD | NEW |
| 1 # Copyright (c) 2012 Google Inc. All rights reserved. | 1 # Copyright (c) 2012 Google Inc. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 # Notes: | 5 # Notes: |
| 6 # | 6 # |
| 7 # This generates makefiles suitable for inclusion into the Android build system | 7 # This generates makefiles suitable for inclusion into the Android build system |
| 8 # via an Android.mk file. It is based on make.py, the standard makefile | 8 # via an Android.mk file. It is based on make.py, the standard makefile |
| 9 # generator. | 9 # generator. |
| 10 # | 10 # |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 # "gyp_all_modules" is a concatenation of the "gyp_all_modules" targets from | 59 # "gyp_all_modules" is a concatenation of the "gyp_all_modules" targets from |
| 60 # all the included sub-makefiles. This is just here to clarify. | 60 # all the included sub-makefiles. This is just here to clarify. |
| 61 gyp_all_modules: | 61 gyp_all_modules: |
| 62 """ | 62 """ |
| 63 | 63 |
| 64 header = """\ | 64 header = """\ |
| 65 # This file is generated by gyp; do not edit. | 65 # This file is generated by gyp; do not edit. |
| 66 | 66 |
| 67 """ | 67 """ |
| 68 | 68 |
| 69 android_standard_include_paths = set([ | |
| 70 # JNI_H_INCLUDE in build/core/binary.mk | |
| 71 'dalvik/libnativehelper/include/nativehelper', | |
| 72 # from SRC_HEADERS in build/core/config.mk | |
| 73 'system/core/include', | |
| 74 'hardware/libhardware/include', | |
| 75 'hardware/libhardware_legacy/include', | |
| 76 'hardware/ril/include', | |
| 77 'dalvik/libnativehelper/include', | |
| 78 'frameworks/native/include', | |
| 79 'frameworks/native/opengl/include', | |
| 80 'frameworks/base/include', | |
| 81 'frameworks/base/opengl/include', | |
| 82 'frameworks/base/native/include', | |
| 83 'external/skia/include', | |
| 84 # TARGET_C_INCLUDES in build/core/combo/TARGET_linux-arm.mk | |
| 85 'bionic/libc/arch-arm/include', | |
| 86 'bionic/libc/include', | |
| 87 'bionic/libstdc++/include', | |
| 88 'bionic/libc/kernel/common', | |
| 89 'bionic/libc/kernel/arch-arm', | |
| 90 'bionic/libm/include', | |
| 91 'bionic/libm/include/arm', | |
| 92 'bionic/libthread_db/include', | |
| 93 ]) | |
| 94 | |
| 95 | |
| 96 # Map gyp target types to Android module classes. | 69 # Map gyp target types to Android module classes. |
| 97 MODULE_CLASSES = { | 70 MODULE_CLASSES = { |
| 98 'static_library': 'STATIC_LIBRARIES', | 71 'static_library': 'STATIC_LIBRARIES', |
| 99 'shared_library': 'SHARED_LIBRARIES', | 72 'shared_library': 'SHARED_LIBRARIES', |
| 100 'executable': 'EXECUTABLES', | 73 'executable': 'EXECUTABLES', |
| 101 } | 74 } |
| 102 | 75 |
| 103 | 76 |
| 104 def IsCPPExtension(ext): | 77 def IsCPPExtension(ext): |
| 105 return make.COMPILABLE_EXTENSIONS.get(ext) == 'cxx' | 78 return make.COMPILABLE_EXTENSIONS.get(ext) == 'cxx' |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 151 |
| 179 # Module class and name. | 152 # Module class and name. |
| 180 self.WriteLn('LOCAL_MODULE_CLASS := ' + self.android_class) | 153 self.WriteLn('LOCAL_MODULE_CLASS := ' + self.android_class) |
| 181 self.WriteLn('LOCAL_MODULE := ' + self.android_module) | 154 self.WriteLn('LOCAL_MODULE := ' + self.android_module) |
| 182 # Only emit LOCAL_MODULE_STEM if it's different to LOCAL_MODULE. | 155 # Only emit LOCAL_MODULE_STEM if it's different to LOCAL_MODULE. |
| 183 # The library module classes fail if the stem is set. ComputeOutputParts | 156 # The library module classes fail if the stem is set. ComputeOutputParts |
| 184 # makes sure that stem == modulename in these cases. | 157 # makes sure that stem == modulename in these cases. |
| 185 if self.android_stem != self.android_module: | 158 if self.android_stem != self.android_module: |
| 186 self.WriteLn('LOCAL_MODULE_STEM := ' + self.android_stem) | 159 self.WriteLn('LOCAL_MODULE_STEM := ' + self.android_stem) |
| 187 self.WriteLn('LOCAL_MODULE_SUFFIX := ' + self.android_suffix) | 160 self.WriteLn('LOCAL_MODULE_SUFFIX := ' + self.android_suffix) |
| 188 self.WriteLn('LOCAL_MODULE_TAGS := optional') | |
| 189 if self.toolset == 'host': | 161 if self.toolset == 'host': |
| 190 self.WriteLn('LOCAL_IS_HOST_MODULE := true') | 162 self.WriteLn('LOCAL_IS_HOST_MODULE := true') |
| 191 self.WriteLn('LOCAL_MULTILIB := $(GYP_HOST_MULTILIB)') | 163 self.WriteLn('LOCAL_MULTILIB := $(GYP_HOST_MULTILIB)') |
| 192 else: | 164 else: |
| 193 self.WriteLn('LOCAL_MODULE_TARGET_ARCH := ' | 165 self.WriteLn('LOCAL_MODULE_TARGET_ARCH := ' |
| 194 '$(TARGET_$(GYP_VAR_PREFIX)ARCH)') | 166 '$(TARGET_$(GYP_VAR_PREFIX)ARCH)') |
| 195 | 167 |
| 196 # Grab output directories; needed for Actions and Rules. | 168 # Grab output directories; needed for Actions and Rules. |
| 197 if self.toolset == 'host': | 169 if self.toolset == 'host': |
| 198 self.WriteLn('gyp_intermediate_dir := ' | 170 self.WriteLn('gyp_intermediate_dir := ' |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 self.android_module)) | 678 self.android_module)) |
| 707 else: | 679 else: |
| 708 path = ('$(call intermediates-dir-for,%s,%s,,,$(GYP_VAR_PREFIX))' | 680 path = ('$(call intermediates-dir-for,%s,%s,,,$(GYP_VAR_PREFIX))' |
| 709 % (self.android_class, self.android_module)) | 681 % (self.android_class, self.android_module)) |
| 710 | 682 |
| 711 assert spec.get('product_dir') is None # TODO: not supported? | 683 assert spec.get('product_dir') is None # TODO: not supported? |
| 712 return os.path.join(path, self.ComputeOutputBasename(spec)) | 684 return os.path.join(path, self.ComputeOutputBasename(spec)) |
| 713 | 685 |
| 714 def NormalizeIncludePaths(self, include_paths): | 686 def NormalizeIncludePaths(self, include_paths): |
| 715 """ Normalize include_paths. | 687 """ Normalize include_paths. |
| 716 Convert absolute paths to relative to the Android top directory; | 688 Convert absolute paths to relative to the Android top directory. |
| 717 filter out include paths that are already brought in by the Android build | |
| 718 system. | |
| 719 | 689 |
| 720 Args: | 690 Args: |
| 721 include_paths: A list of unprocessed include paths. | 691 include_paths: A list of unprocessed include paths. |
| 722 Returns: | 692 Returns: |
| 723 A list of normalized include paths. | 693 A list of normalized include paths. |
| 724 """ | 694 """ |
| 725 normalized = [] | 695 normalized = [] |
| 726 for path in include_paths: | 696 for path in include_paths: |
| 727 if path[0] == '/': | 697 if path[0] == '/': |
| 728 path = gyp.common.RelativePath(path, self.android_top_dir) | 698 path = gyp.common.RelativePath(path, self.android_top_dir) |
| 729 | 699 normalized.append(path) |
| 730 # Filter out the Android standard search path. | |
| 731 if path not in android_standard_include_paths: | |
| 732 normalized.append(path) | |
| 733 return normalized | 700 return normalized |
| 734 | 701 |
| 735 def ExtractIncludesFromCFlags(self, cflags): | 702 def ExtractIncludesFromCFlags(self, cflags): |
| 736 """Extract includes "-I..." out from cflags | 703 """Extract includes "-I..." out from cflags |
| 737 | 704 |
| 738 Args: | 705 Args: |
| 739 cflags: A list of compiler flags, which may be mixed with "-I.." | 706 cflags: A list of compiler flags, which may be mixed with "-I.." |
| 740 Returns: | 707 Returns: |
| 741 A tuple of lists: (clean_clfags, include_paths). "-I.." is trimmed. | 708 A tuple of lists: (clean_clfags, include_paths). "-I.." is trimmed. |
| 742 """ | 709 """ |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 deps.extend(link_deps) | 770 deps.extend(link_deps) |
| 804 return (gyp.common.uniquer(deps), gyp.common.uniquer(link_deps)) | 771 return (gyp.common.uniquer(deps), gyp.common.uniquer(link_deps)) |
| 805 | 772 |
| 806 | 773 |
| 807 def WriteTargetFlags(self, spec, configs, link_deps): | 774 def WriteTargetFlags(self, spec, configs, link_deps): |
| 808 """Write Makefile code to specify the link flags and library dependencies. | 775 """Write Makefile code to specify the link flags and library dependencies. |
| 809 | 776 |
| 810 spec, configs: input from gyp. | 777 spec, configs: input from gyp. |
| 811 link_deps: link dependency list; see ComputeDeps() | 778 link_deps: link dependency list; see ComputeDeps() |
| 812 """ | 779 """ |
| 813 for configname, config in sorted(configs.iteritems()): | 780 if self.type != 'static_library': |
| 814 ldflags = list(config.get('ldflags', [])) | 781 for configname, config in sorted(configs.iteritems()): |
| 815 self.WriteLn('') | 782 ldflags = list(config.get('ldflags', [])) |
| 816 self.WriteList(ldflags, 'LOCAL_LDFLAGS_%s' % configname) | 783 self.WriteLn('') |
| 817 self.WriteLn('\nLOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))') | 784 self.WriteList(ldflags, 'LOCAL_LDFLAGS_%s' % configname) |
| 785 self.WriteLn('\nLOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION))') |
| 818 | 786 |
| 819 # Libraries (i.e. -lfoo) | 787 # Libraries (i.e. -lfoo) |
| 788 # These must be included even for static libraries as some of them provide |
| 789 # implicit include paths through the build system. |
| 820 libraries = gyp.common.uniquer(spec.get('libraries', [])) | 790 libraries = gyp.common.uniquer(spec.get('libraries', [])) |
| 821 static_libs, dynamic_libs = self.ComputeAndroidLibraryModuleNames( | 791 static_libs, dynamic_libs = self.ComputeAndroidLibraryModuleNames( |
| 822 libraries) | 792 libraries) |
| 823 | 793 |
| 824 # Link dependencies (i.e. libfoo.a, libfoo.so) | 794 # Link dependencies (i.e. other gyp targets this target depends on) |
| 825 static_link_deps = [x[1] for x in link_deps if x[0] == 'static'] | 795 # These need not be included for static libraries as within the gyp build |
| 826 shared_link_deps = [x[1] for x in link_deps if x[0] == 'shared'] | 796 # we do not use the implicit include path mechanism. |
| 827 self.WriteLn('') | 797 if self.type != 'static_library': |
| 828 self.WriteList(static_libs + static_link_deps, | 798 static_link_deps = [x[1] for x in link_deps if x[0] == 'static'] |
| 829 'LOCAL_STATIC_LIBRARIES') | 799 shared_link_deps = [x[1] for x in link_deps if x[0] == 'shared'] |
| 830 self.WriteLn('# Enable grouping to fix circular references') | 800 else: |
| 831 self.WriteLn('LOCAL_GROUP_STATIC_LIBRARIES := true') | 801 static_link_deps = [] |
| 832 self.WriteLn('') | 802 shared_link_deps = [] |
| 833 self.WriteList(dynamic_libs + shared_link_deps, | 803 |
| 834 'LOCAL_SHARED_LIBRARIES') | 804 # Only write the lists if they are non-empty. |
| 805 if static_libs or static_link_deps: |
| 806 self.WriteLn('') |
| 807 self.WriteList(static_libs + static_link_deps, |
| 808 'LOCAL_STATIC_LIBRARIES') |
| 809 self.WriteLn('# Enable grouping to fix circular references') |
| 810 self.WriteLn('LOCAL_GROUP_STATIC_LIBRARIES := true') |
| 811 if dynamic_libs or shared_link_deps: |
| 812 self.WriteLn('') |
| 813 self.WriteList(dynamic_libs + shared_link_deps, |
| 814 'LOCAL_SHARED_LIBRARIES') |
| 835 | 815 |
| 836 | 816 |
| 837 def WriteTarget(self, spec, configs, deps, link_deps, part_of_all, | 817 def WriteTarget(self, spec, configs, deps, link_deps, part_of_all, |
| 838 write_alias_target): | 818 write_alias_target): |
| 839 """Write Makefile code to produce the final target of the gyp spec. | 819 """Write Makefile code to produce the final target of the gyp spec. |
| 840 | 820 |
| 841 spec, configs: input from gyp. | 821 spec, configs: input from gyp. |
| 842 deps, link_deps: dependency lists; see ComputeDeps() | 822 deps, link_deps: dependency lists; see ComputeDeps() |
| 843 part_of_all: flag indicating this target is part of 'all' | 823 part_of_all: flag indicating this target is part of 'all' |
| 844 write_alias_target: flag indicating whether to create short aliases for this | 824 write_alias_target: flag indicating whether to create short aliases for this |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 # Write out the sorted list of includes. | 1069 # Write out the sorted list of includes. |
| 1090 root_makefile.write('\n') | 1070 root_makefile.write('\n') |
| 1091 for include_file in sorted(include_list): | 1071 for include_file in sorted(include_list): |
| 1092 root_makefile.write('include $(LOCAL_PATH)/' + include_file + '\n') | 1072 root_makefile.write('include $(LOCAL_PATH)/' + include_file + '\n') |
| 1093 root_makefile.write('\n') | 1073 root_makefile.write('\n') |
| 1094 | 1074 |
| 1095 if write_alias_targets: | 1075 if write_alias_targets: |
| 1096 root_makefile.write(ALL_MODULES_FOOTER) | 1076 root_makefile.write(ALL_MODULES_FOOTER) |
| 1097 | 1077 |
| 1098 root_makefile.close() | 1078 root_makefile.close() |
| OLD | NEW |