@@ -61,6 +61,12 @@ newoption({
6161 default = ' host' ,
6262})
6363
64+ newoption ({
65+ trigger = ' android_api' ,
66+ description = ' Target Android API version number' ,
67+ default = ' 21' ,
68+ })
69+
6470newoption ({
6571 trigger = ' variant' ,
6672 value = ' type' ,
@@ -361,6 +367,14 @@ if _OPTIONS['os'] == 'android' then
361367 ndk_toolchain = ndk_toolchain .. ' /linux-x86_64'
362368 end
363369
370+ local android_base_targets = {
371+ arm64 = ' aarch64-linux-android' ,
372+ arm = ' armv7a-linux-androideabi' ,
373+ x64 = ' x86_64-linux-android' ,
374+ x86 = ' i686-linux-android' ,
375+ }
376+ local android_target = android_base_targets [_OPTIONS [' arch' ]] .. _OPTIONS [' android_api' ]
377+
364378 -- clone the clang toolset into a custom one called "android_ndk".
365379 premake .tools .android_ndk = {}
366380 for k , v in pairs (premake .tools .clang ) do
@@ -369,16 +383,20 @@ if _OPTIONS['os'] == 'android' then
369383
370384 -- update the android_ndk toolset to use the appropriate binaries.
371385 local android_ndk_tools = {
372- cc = ndk_toolchain .. ' /bin/clang' ,
373- cxx = ndk_toolchain .. ' /bin/clang++' ,
386+ cc = ndk_toolchain .. ' /bin/' .. android_target .. ' - clang' ,
387+ cxx = ndk_toolchain .. ' /bin/' .. android_target .. ' - clang++' ,
374388 ar = ndk_toolchain .. ' /bin/llvm-ar' ,
375389 }
376390 function premake .tools .android_ndk .gettoolname (cfg , tool )
377391 return android_ndk_tools [tool ]
378392 end
379393
380- valid_cc_tools = premake .action ._list [' gmake2' ].valid_tools [' cc' ]
381- valid_cc_tools [# valid_cc_tools + 1 ] = ' android_ndk'
394+ -- suppress "** Warning: Unsupported toolset 'android_ndk'".
395+ local premake_valid_tools = premake .action ._list [_ACTION ].valid_tools
396+ if premake_valid_tools ~= nil then
397+ premake_valid_tools [' cc' ][# premake_valid_tools [' cc' ] + 1 ] = ' android_ndk'
398+ end
399+
382400 toolset (' android_ndk' )
383401
384402 buildoptions ({
@@ -404,62 +422,6 @@ if _OPTIONS['os'] == 'android' then
404422 ' -static-libstdc++' ,
405423 })
406424
407- filter ({ ' options:arch=x86' , ' options:not for_unreal' })
408- do
409- architecture (' x86' )
410- buildoptions ({ ' --target=i686-none-linux-android21' })
411- linkoptions ({ ' --target=i686-none-linux-android21' })
412- end
413-
414- filter ({ ' options:arch=x86' , ' options:for_unreal' })
415- do
416- architecture (' x86' )
417- buildoptions ({ ' --target=i686-none-linux-android31' })
418- linkoptions ({ ' --target=i686-none-linux-android31' })
419- end
420-
421- filter ({ ' options:arch=x64' , ' options:not for_unreal' })
422- do
423- architecture (' x64' )
424- buildoptions ({ ' --target=x86_64-none-linux-android21' })
425- linkoptions ({ ' --target=x86_64-none-linux-android21' })
426- end
427-
428- filter ({ ' options:arch=x64' , ' options:for_unreal' })
429- do
430- architecture (' x64' )
431- buildoptions ({ ' --target=x86_64-none-linux-android31' })
432- linkoptions ({ ' --target=x86_64-none-linux-android31' })
433- end
434-
435- filter ({ ' options:arch=arm' , ' options:not for_unreal' })
436- do
437- architecture (' arm' )
438- buildoptions ({ ' --target=armv7a-none-linux-android21' })
439- linkoptions ({ ' --target=armv7a-none-linux-android21' })
440- end
441-
442- filter ({ ' options:arch=arm' , ' options:for_unreal' })
443- do
444- architecture (' arm' )
445- buildoptions ({ ' --target=armv7a-none-linux-android31' })
446- linkoptions ({ ' --target=armv7a-none-linux-android31' })
447- end
448-
449- filter ({ ' options:arch=arm64' , ' options:not for_unreal' })
450- do
451- architecture (' arm64' )
452- buildoptions ({ ' --target=aarch64-none-linux-android21' })
453- linkoptions ({ ' --target=aarch64-none-linux-android21' })
454- end
455-
456- filter ({ ' options:arch=arm64' , ' options:for_unreal' })
457- do
458- architecture (' arm64' )
459- buildoptions ({ ' --target=aarch64-none-linux-android31' })
460- linkoptions ({ ' --target=aarch64-none-linux-android31' })
461- end
462-
463425 filter ({})
464426end
465427
@@ -664,10 +626,13 @@ if _OPTIONS['arch'] == 'wasm' or _OPTIONS['arch'] == 'js' then
664626 return emsdk_tools [tool ]
665627 end
666628
667- system (' emscripten' )
629+ -- suppress "** Warning: Unsupported toolset 'emsdk'".
630+ local premake_valid_tools = premake .action ._list [_ACTION ].valid_tools
631+ if premake_valid_tools ~= nil then
632+ premake_valid_tools [' cc' ][# premake_valid_tools [' cc' ] + 1 ] = ' emsdk'
633+ end
668634
669- valid_cc_tools = premake .action ._list [' gmake2' ].valid_tools [' cc' ]
670- valid_cc_tools [# valid_cc_tools + 1 ] = ' emsdk'
635+ system (' emscripten' )
671636 toolset (' emsdk' )
672637
673638 linkoptions ({ ' -sALLOW_MEMORY_GROWTH=1' , ' -sDYNAMIC_EXECUTION=0' })
0 commit comments