@@ -155,6 +155,31 @@ def CalculateGeneratorInputInfo(params):
155
155
quiet_cmd_link = LINK($(TOOLSET)) $@
156
156
cmd_link = $(LINK.$(TOOLSET)) -o $@ $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,--start-group $(LD_INPUTS) $(LIBS) -Wl,--end-group
157
157
158
+ # Note: this does not handle spaces in paths
159
+ define xargs
160
+ $(1) $(word 1,$(2))
161
+ $(if $(word 2,$(2)),$(call xargs,$(1),$(wordlist 2,$(words $(2)),$(2))))
162
+ endef
163
+
164
+ define write-to-file
165
+ @: >$(1)
166
+ $(call xargs,@printf "%s\\ n" >>$(1),$(2))
167
+ endef
168
+
169
+ OBJ_FILE_LIST := ar-file-list
170
+
171
+ define create_archive
172
+ rm -f $(1) $(1).$(OBJ_FILE_LIST); mkdir -p `dirname $(1)`
173
+ $(call write-to-file,$(1).$(OBJ_FILE_LIST),$(filter %.o,$(2)))
174
+ $(AR.$(TOOLSET)) crs $(1) @$(1).$(OBJ_FILE_LIST)
175
+ endef
176
+
177
+ define create_thin_archive
178
+ rm -f $(1) $(OBJ_FILE_LIST); mkdir -p `dirname $(1)`
179
+ $(call write-to-file,$(1).$(OBJ_FILE_LIST),$(filter %.o,$(2)))
180
+ $(AR.$(TOOLSET)) crsT $(1) @$(1).$(OBJ_FILE_LIST)
181
+ endef
182
+
158
183
# We support two kinds of shared objects (.so):
159
184
# 1) shared_library, which is just bundling together many dependent libraries
160
185
# into a link line.
@@ -199,6 +224,31 @@ def CalculateGeneratorInputInfo(params):
199
224
quiet_cmd_alink_thin = AR($(TOOLSET)) $@
200
225
cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) crsT $@ $(filter %.o,$^)
201
226
227
+ # Note: this does not handle spaces in paths
228
+ define xargs
229
+ $(1) $(word 1,$(2))
230
+ $(if $(word 2,$(2)),$(call xargs,$(1),$(wordlist 2,$(words $(2)),$(2))))
231
+ endef
232
+
233
+ define write-to-file
234
+ @: >$(1)
235
+ $(call xargs,@printf "%s\\ n" >>$(1),$(2))
236
+ endef
237
+
238
+ OBJ_FILE_LIST := ar-file-list
239
+
240
+ define create_archive
241
+ rm -f $(1) $(1).$(OBJ_FILE_LIST); mkdir -p `dirname $(1)`
242
+ $(call write-to-file,$(1).$(OBJ_FILE_LIST),$(filter %.o,$(2)))
243
+ $(AR.$(TOOLSET)) crs $(1) @$(1).$(OBJ_FILE_LIST)
244
+ endef
245
+
246
+ define create_thin_archive
247
+ rm -f $(1) $(OBJ_FILE_LIST); mkdir -p `dirname $(1)`
248
+ $(call write-to-file,$(1).$(OBJ_FILE_LIST),$(filter %.o,$(2)))
249
+ $(AR.$(TOOLSET)) crsT $(1) @$(1).$(OBJ_FILE_LIST)
250
+ endef
251
+
202
252
# Due to circular dependencies between libraries :(, we wrap the
203
253
# special "figure out circular dependencies" flags around the entire
204
254
# input list during linking.
@@ -1766,14 +1816,28 @@ def WriteTarget(
1766
1816
self .flavor not in ("mac" , "openbsd" , "netbsd" , "win" )
1767
1817
and not self .is_standalone_static_library
1768
1818
):
1769
- self .WriteDoCmd (
1819
+ if self .flavor in ('linux' , 'android' ):
1820
+ self .WriteMakeRule (
1770
1821
[self .output_binary ],
1771
1822
link_deps ,
1772
- "alink_thin" ,
1773
- part_of_all ,
1774
- postbuilds = postbuilds ,
1775
- )
1823
+ actions = ['$(call create_thin_archive,$@,$^)' ]
1824
+ )
1825
+ else :
1826
+ self .WriteDoCmd (
1827
+ [self .output_binary ],
1828
+ link_deps ,
1829
+ "alink_thin" ,
1830
+ part_of_all ,
1831
+ postbuilds = postbuilds ,
1832
+ )
1776
1833
else :
1834
+ if self .flavor in ('linux' , 'android' ):
1835
+ self .WriteMakeRule (
1836
+ [self .output_binary ],
1837
+ link_deps ,
1838
+ actions = ['$(call create_archive,$@,$^)' ]
1839
+ )
1840
+ else :
1777
1841
self .WriteDoCmd (
1778
1842
[self .output_binary ],
1779
1843
link_deps ,
0 commit comments