android_build_readme.bat 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 "" "-Wl,-z,max-page-size=16384"
  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 "" "-Wl,-z,max-page-size=16384"
  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 %5"^
  56. TARGET_SHLDFLAGS="%5" ^
  57. TARGET_STRIP=llvm-strip.exe ^
  58. TARGET_SONAME=libluajit.so ^
  59. CCDEBUG=-g ^
  60. "GIT_RELVER=cp ../.relver luajit_relver.txt" ^
  61. amalg -j%NUMBER_OF_PROCESSORS%
  62. if not "%ERRORLEVEL%" == "0" goto :error
  63. copy src\libluajit.a android\%1\libluajit.a
  64. if not "%ERRORLEVEL%" == "0" goto :error
  65. copy src\libluajit.so android\%1\libluajit.so
  66. if not "%ERRORLEVEL%" == "0" goto :error
  67. copy src\luajit.h android\%1\luajit.h
  68. if not "%ERRORLEVEL%" == "0" goto :error
  69. xcopy src\jit android\%1\jit /I
  70. if not "%ERRORLEVEL%" == "0" goto :error
  71. del android\%1\jit\.gitignore
  72. goto :done
  73. :error
  74. exit /b 1
  75. :done
  76. wsl make clean
  77. exit /b 0