android_build_readme.bat 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. rem Build instruction assume using WSL.
  2. rem Prerequisite:
  3. rem * Android NDK r23 or later.
  4. rem * GCC in WSL, with multilib.
  5. rem * NDK path appended to %PATH% in Windows. (Protip: path %PATH%;<NDK_ROOT>\toolchains\llvm\prebuilt\windows-x86_64\bin)
  6. rem * LuaJIT interpreter, either in Windows or WSL.
  7. mkdir android\arm64-v8a
  8. mkdir android\armeabi-v7a
  9. mkdir android\x86
  10. mkdir android\x86_64
  11. rem Reset error level
  12. type nul
  13. rem Find LuaJIT
  14. luajit -v
  15. if "%ERRORLEVEL%" == "0" (
  16. set LUAJIT_INTERPRETER=luajit.exe
  17. goto :ljdetermined
  18. )
  19. wsl luajit -v
  20. if "%ERRORLEVEL%" == "0" (
  21. set LUAJIT_INTERPRETER=luajit
  22. goto :ljdetermined
  23. )
  24. echo You need LuaJIT either in Windows or in WSL!
  25. goto :error
  26. :ljdetermined
  27. rem ARMv8
  28. call :compile arm64-v8a aarch64-linux-android 21
  29. if "%ERRORLEVEL%" == "1" goto :error
  30. rem ARMv7
  31. call :compile armeabi-v7a armv7a-linux-androideabi 21 -m32
  32. if not "%ERRORLEVEL%" == "0" goto :error
  33. rem x86
  34. call :compile x86 i686-linux-android 21 -m32
  35. if not "%ERRORLEVEL%" == "0" goto :error
  36. rem x86_64
  37. call :compile x86_64 x86_64-linux-android 21
  38. if not "%ERRORLEVEL%" == "0" goto :error
  39. goto :done
  40. :compile
  41. if exist android\%1\libluajit.a exit /b 0
  42. wsl make clean
  43. if not "%ERRORLEVEL%" == "0" goto :error
  44. wsl make ^
  45. HOST_LUA=%LUAJIT_INTERPRETER% ^
  46. "HOST_CC=gcc %4" ^
  47. HOST_CFLAGS=-D_CRT_SECURE_NO_WARNINGS ^
  48. CC=clang ^
  49. CROSS=%2- ^
  50. "STATIC_CC=%2%3-clang -fPIC" ^
  51. "DYNAMIC_CC=%2%3-clang -fPIC" ^
  52. "TARGET_AR=llvm-ar.exe rcus" ^
  53. TARGET_SYS=Linux ^
  54. TARGET_LD=%2%3-clang ^
  55. TARGET_LDFLAGS=-fuse-ld=lld ^
  56. TARGET_STRIP=llvm-strip.exe ^
  57. TARGET_SONAME=libluajit.so ^
  58. CCDEBUG=-g ^
  59. "GIT_RELVER=cp ../.relver luajit_relver.txt" ^
  60. amalg -j%NUMBER_OF_PROCESSORS%
  61. if not "%ERRORLEVEL%" == "0" goto :error
  62. copy src\libluajit.a android\%1\libluajit.a
  63. if not "%ERRORLEVEL%" == "0" goto :error
  64. copy src\libluajit.so android\%1\libluajit.so
  65. if not "%ERRORLEVEL%" == "0" goto :error
  66. copy src\luajit.h android\%1\luajit.h
  67. if not "%ERRORLEVEL%" == "0" goto :error
  68. xcopy src\jit android\%1\jit /I
  69. if not "%ERRORLEVEL%" == "0" goto :error
  70. del android\%1\jit\.gitignore
  71. goto :done
  72. :error
  73. exit /b 1
  74. :done
  75. wsl make clean
  76. exit /b 0