Write Makefile code to produce the final target of the gyp spec. spec, configs: input from gyp. deps, link_deps: dependency lists; see ComputeDeps() part_of_all: flag indicating this target is part of 'all' write_alias_target: flag indicating whether to create short
(
self, spec, configs, deps, link_deps, part_of_all, write_alias_target
)
| 883 | self.WriteList(dynamic_libs + shared_link_deps, "LOCAL_SHARED_LIBRARIES") |
| 884 | |
| 885 | def WriteTarget( |
| 886 | self, spec, configs, deps, link_deps, part_of_all, write_alias_target |
| 887 | ): |
| 888 | """Write Makefile code to produce the final target of the gyp spec. |
| 889 | |
| 890 | spec, configs: input from gyp. |
| 891 | deps, link_deps: dependency lists; see ComputeDeps() |
| 892 | part_of_all: flag indicating this target is part of 'all' |
| 893 | write_alias_target: flag indicating whether to create short aliases for this |
| 894 | target |
| 895 | """ |
| 896 | self.WriteLn("### Rules for final target.") |
| 897 | |
| 898 | if self.type != "none": |
| 899 | self.WriteTargetFlags(spec, configs, link_deps) |
| 900 | |
| 901 | if settings := spec.get("aosp_build_settings", {}): |
| 902 | self.WriteLn("### Set directly by aosp_build_settings.") |
| 903 | for k, v in settings.items(): |
| 904 | if isinstance(v, list): |
| 905 | self.WriteList(v, k) |
| 906 | else: |
| 907 | self.WriteLn(f"{k} := {make.QuoteIfNecessary(v)}") |
| 908 | self.WriteLn("") |
| 909 | |
| 910 | # Add to the set of targets which represent the gyp 'all' target. We use the |
| 911 | # name 'gyp_all_modules' as the Android build system doesn't allow the use |
| 912 | # of the Make target 'all' and because 'all_modules' is the equivalent of |
| 913 | # the Make target 'all' on Android. |
| 914 | if part_of_all and write_alias_target: |
| 915 | self.WriteLn('# Add target alias to "gyp_all_modules" target.') |
| 916 | self.WriteLn(".PHONY: gyp_all_modules") |
| 917 | self.WriteLn("gyp_all_modules: %s" % self.android_module) |
| 918 | self.WriteLn("") |
| 919 | |
| 920 | # Add an alias from the gyp target name to the Android module name. This |
| 921 | # simplifies manual builds of the target, and is required by the test |
| 922 | # framework. |
| 923 | if self.target != self.android_module and write_alias_target: |
| 924 | self.WriteLn("# Alias gyp target name.") |
| 925 | self.WriteLn(".PHONY: %s" % self.target) |
| 926 | self.WriteLn(f"{self.target}: {self.android_module}") |
| 927 | self.WriteLn("") |
| 928 | |
| 929 | # Add the command to trigger build of the target type depending |
| 930 | # on the toolset. Ex: BUILD_STATIC_LIBRARY vs. BUILD_HOST_STATIC_LIBRARY |
| 931 | # NOTE: This has to come last! |
| 932 | modifier = "" |
| 933 | if self.toolset == "host": |
| 934 | modifier = "HOST_" |
| 935 | if self.type == "static_library": |
| 936 | self.WriteLn("include $(BUILD_%sSTATIC_LIBRARY)" % modifier) |
| 937 | elif self.type == "shared_library": |
| 938 | self.WriteLn("LOCAL_PRELINK_MODULE := false") |
| 939 | self.WriteLn("include $(BUILD_%sSHARED_LIBRARY)" % modifier) |
| 940 | elif self.type == "executable": |
| 941 | self.WriteLn("LOCAL_CXX_STL := libc++_static") |
| 942 | # Executables are for build and test purposes only, so they're installed |