Returns flags that need to be passed to the linker. Args: configname: The name of the configuration to get ld flags for. product_dir: The directory where products such static and dynamic libraries are placed. This is added to the library search path.
(self, configname, product_dir, gyp_to_build_path, arch=None)
| 892 | return ldflag |
| 893 | |
| 894 | def GetLdflags(self, configname, product_dir, gyp_to_build_path, arch=None): |
| 895 | """Returns flags that need to be passed to the linker. |
| 896 | |
| 897 | Args: |
| 898 | configname: The name of the configuration to get ld flags for. |
| 899 | product_dir: The directory where products such static and dynamic |
| 900 | libraries are placed. This is added to the library search path. |
| 901 | gyp_to_build_path: A function that converts paths relative to the |
| 902 | current gyp file to paths relative to the build directory. |
| 903 | """ |
| 904 | self.configname = configname |
| 905 | ldflags = [] |
| 906 | |
| 907 | # The xcode build is relative to a gyp file's directory, and OTHER_LDFLAGS |
| 908 | # can contain entries that depend on this. Explicitly absolutify these. |
| 909 | for ldflag in self._Settings().get("OTHER_LDFLAGS", []): |
| 910 | ldflags.append(self._MapLinkerFlagFilename(ldflag, gyp_to_build_path)) |
| 911 | |
| 912 | if self._Test("DEAD_CODE_STRIPPING", "YES", default="NO"): |
| 913 | ldflags.append("-Wl,-dead_strip") |
| 914 | |
| 915 | if self._Test("PREBINDING", "YES", default="NO"): |
| 916 | ldflags.append("-Wl,-prebind") |
| 917 | |
| 918 | self._Appendf( |
| 919 | ldflags, "DYLIB_COMPATIBILITY_VERSION", "-compatibility_version %s" |
| 920 | ) |
| 921 | self._Appendf(ldflags, "DYLIB_CURRENT_VERSION", "-current_version %s") |
| 922 | |
| 923 | self._AppendPlatformVersionMinFlags(ldflags) |
| 924 | |
| 925 | if "SDKROOT" in self._Settings() and self._SdkPath(): |
| 926 | ldflags.append("-isysroot") |
| 927 | ldflags.append(self._SdkPath()) |
| 928 | |
| 929 | for library_path in self._Settings().get("LIBRARY_SEARCH_PATHS", []): |
| 930 | ldflags.append("-L" + gyp_to_build_path(library_path)) |
| 931 | |
| 932 | if "ORDER_FILE" in self._Settings(): |
| 933 | ldflags.append("-Wl,-order_file") |
| 934 | ldflags.append("-Wl," + gyp_to_build_path(self._Settings()["ORDER_FILE"])) |
| 935 | |
| 936 | if not gyp.common.CrossCompileRequested(): |
| 937 | if arch is not None: |
| 938 | archs = [arch] |
| 939 | else: |
| 940 | assert self.configname |
| 941 | archs = self.GetActiveArchs(self.configname) |
| 942 | if len(archs) != 1: |
| 943 | # TODO: Supporting fat binaries will be annoying. |
| 944 | self._WarnUnimplemented("ARCHS") |
| 945 | archs = ["i386"] |
| 946 | # Avoid quoting the space between -arch and the arch name |
| 947 | ldflags.append("-arch") |
| 948 | ldflags.append(archs[0]) |
| 949 | |
| 950 | # Xcode adds the product directory by default. |
| 951 | # Rewrite -L. to -L./ to work around http://www.openradar.me/25313838 |