@@ -249,31 +249,36 @@ if ("1".equals(shouldRebuildNativeModules)) {
249
249
String temp_v8_arch;
250
250
String temp_suffix;
251
251
String temp_toolchain_name;
252
+ String cargo_build_target;
252
253
switch ( temp_arch )
253
254
{
254
255
case ' arm' :
255
256
temp_dest_cpu = " ${ temp_arch} "
256
257
temp_v8_arch = " ${ temp_arch} "
257
258
temp_suffix = " ${ temp_arch} -linux-androideabi"
258
259
temp_toolchain_name = " ${ temp_suffix} "
260
+ cargo_build_target = ' arm-linux-androideabi'
259
261
break
260
262
case ' x86' :
261
263
temp_dest_cpu = ' ia32'
262
264
temp_v8_arch = ' ia32'
263
265
temp_suffix = ' i686-linux-android'
264
266
temp_toolchain_name = " ${ temp_arch} "
267
+ cargo_build_target = temp_suffix
265
268
break
266
269
case ' x86_64' :
267
270
temp_dest_cpu = ' x64'
268
271
temp_v8_arch = ' x64'
269
272
temp_suffix = " ${ temp_arch} -linux-android"
270
273
temp_toolchain_name = " ${ temp_arch} "
274
+ cargo_build_target = temp_suffix
271
275
break
272
276
case ' arm64' :
273
277
temp_dest_cpu = " ${ temp_arch} "
274
278
temp_v8_arch = " ${ temp_arch} "
275
279
temp_suffix = ' aarch64-linux-android'
276
280
temp_toolchain_name = ' aarch64'
281
+ cargo_build_target = temp_suffix
277
282
break
278
283
default :
279
284
throw new GradleException (" Unsupported architecture for nodejs-mobile native modules: ${ temp_arch} " )
@@ -287,6 +292,7 @@ if ("1".equals(shouldRebuildNativeModules)) {
287
292
String npm_toolchain_cc = " ${ standalone_toolchain} /bin/${ temp_suffix} -clang"
288
293
String npm_toolchain_cxx = " ${ standalone_toolchain} /bin/${ temp_suffix} -clang++"
289
294
String npm_toolchain_link = " ${ standalone_toolchain} /bin/${ temp_suffix} -clang++"
295
+ String cargo_target_triple = cargo_build_target. toUpperCase(). replaceAll(' -' , ' _' )
290
296
291
297
String npm_gyp_defines = " target_arch=${ temp_arch} "
292
298
npm_gyp_defines + = " v8_target_arch=${ temp_v8_arch} "
@@ -374,6 +380,10 @@ if ("1".equals(shouldRebuildNativeModules)) {
374
380
environment (' PATH' , " ${ original_project_bin} " + System . getProperty(" path.separator" ) + " ${ System.env.PATH} " )
375
381
}
376
382
383
+ environment (' CARGO_BUILD_TARGET' , " ${ cargo_build_target} " )
384
+ environment (" CARGO_TARGET_${ cargo_target_triple} _AR" , " ${ npm_toolchain_ar} " )
385
+ environment (" CARGO_TARGET_${ cargo_target_triple} _LINKER" , " ${ npm_toolchain_link} " )
386
+
377
387
environment (' TOOLCHAIN' ," ${ standalone_toolchain} " )
378
388
environment (' AR' ," ${ npm_toolchain_ar} " )
379
389
environment (' CC' ," ${ npm_toolchain_cc} " )
0 commit comments