LEFT | RIGHT |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # coding: utf-8 | 2 # coding: utf-8 |
3 """This script fixes the support of manually compiled static libraries for | 3 """This script fixes the support of manually compiled static libraries for |
4 android NDK build system. | 4 android NDK build system. |
5 | 5 |
6 Issue: | 6 Issue: |
7 Let's say there are some manually compiled libraries specified in | 7 Let's say there are some manually compiled libraries specified in |
8 link_settings.libraries or in ldflags of a gyp file. In this case ndk-build | 8 link_settings.libraries or in ldflags of a gyp file. In this case ndk-build |
9 passes them to a linker after system libraries, like c++_static, and | 9 passes them to a linker after system libraries, like c++_static, and |
10 as the result linker cannot find functions from system libraries. | 10 as the result linker cannot find functions from system libraries. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 However merely to reduce any potential influence we override | 66 However merely to reduce any potential influence we override |
67 MakefileWriter.WriteAndroidNdkModuleRule to define manually compiled libraries | 67 MakefileWriter.WriteAndroidNdkModuleRule to define manually compiled libraries |
68 and override WriteList only while we are in the WriteAndroidNdkModuleRule method
. | 68 and override WriteList only while we are in the WriteAndroidNdkModuleRule method
. |
69 The aim of the latter method is exactly to write Rules for ndk-build and it is | 69 The aim of the latter method is exactly to write Rules for ndk-build and it is |
70 called at the end of Write. However, since WriteAndroidNdkModuleRule lacks | 70 called at the end of Write. However, since WriteAndroidNdkModuleRule lacks |
71 required information, we override method Write to store configurations as | 71 required information, we override method Write to store configurations as |
72 _abp_configs attribute of instance of MakefileWriter. | 72 _abp_configs attribute of instance of MakefileWriter. |
73 """ | 73 """ |
74 | 74 |
75 import os | 75 import os |
| 76 import platform |
76 import sys | 77 import sys |
77 import types | 78 import types |
78 | 79 |
79 base_dir = os.path.abspath(os.path.dirname(__file__)) | 80 base_dir = os.path.abspath(os.path.dirname(__file__)) |
80 sys.path.append(os.path.join(base_dir, 'third_party', 'gyp', 'pylib')) | 81 sys.path.append(os.path.join(base_dir, 'third_party', 'gyp', 'pylib')) |
81 import gyp | 82 import gyp |
82 from gyp.generator.make import MakefileWriter, QuoteIfNecessary | 83 from gyp.generator.make import MakefileWriter, QuoteIfNecessary |
83 | 84 |
84 | 85 |
85 orig_MakefileWriter_Write = MakefileWriter.Write | 86 orig_MakefileWriter_Write = MakefileWriter.Write |
(...skipping 26 matching lines...) Expand all Loading... |
112 value_list.append("${ABP_STATIC_LIBRARIES_${BUILDTYPE}}") | 113 value_list.append("${ABP_STATIC_LIBRARIES_${BUILDTYPE}}") |
113 orig_WriteList(value_list, variable, prefix, quoter) | 114 orig_WriteList(value_list, variable, prefix, quoter) |
114 self.WriteList = types.MethodType(overridden_WriteList, self) | 115 self.WriteList = types.MethodType(overridden_WriteList, self) |
115 orig_MakefileWriter_WriteAndroidNdkModuleRule(self, module_name, all_sources
, link_deps) | 116 orig_MakefileWriter_WriteAndroidNdkModuleRule(self, module_name, all_sources
, link_deps) |
116 self.WriteList = orig_WriteList | 117 self.WriteList = orig_WriteList |
117 | 118 |
118 MakefileWriter.Write = overridden_Write | 119 MakefileWriter.Write = overridden_Write |
119 MakefileWriter.WriteAndroidNdkModuleRule = overridden_WriteAndroidNdkModuleRule | 120 MakefileWriter.WriteAndroidNdkModuleRule = overridden_WriteAndroidNdkModuleRule |
120 | 121 |
121 # Issue 5393 | 122 # Issue 5393 |
122 # replace $(LD_INPUTS) by "-Wl,--start-group $(LD_INPUTS) -Wl,--end-group" but o
nly for cmd_link_host | 123 # replace $(LD_INPUTS) by "-Wl,--start-group $(LD_INPUTS) -Wl,--end-group" but |
123 gyp.generator.make.LINK_COMMANDS_ANDROID = \ | 124 # only for cmd_link_host and only on linux. |
124 gyp.generator.make.LINK_COMMANDS_ANDROID[:663] + \ | 125 print platform.system() |
125 "-Wl,--start-group $(LD_INPUTS) -Wl,--end-group" + \ | 126 if platform.system() == "Linux": |
126 gyp.generator.make.LINK_COMMANDS_ANDROID[675:] | 127 gyp.generator.make.LINK_COMMANDS_ANDROID = \ |
| 128 gyp.generator.make.LINK_COMMANDS_ANDROID[:663] + \ |
| 129 "-Wl,--start-group $(LD_INPUTS) -Wl,--end-group" + \ |
| 130 gyp.generator.make.LINK_COMMANDS_ANDROID[675:] |
127 | 131 |
128 if __name__ == '__main__': | 132 if __name__ == '__main__': |
129 gyp.main(sys.argv[1:]) | 133 gyp.main(sys.argv[1:]) |
LEFT | RIGHT |