88 lines
2.7 KiB
Batchfile
88 lines
2.7 KiB
Batchfile
|
@if "%DEBUG%" == "" @echo off
|
||
|
|
||
|
@rem Set local scope for the variables with windows NT shell
|
||
|
if "%OS%"=="Windows_NT" setlocal
|
||
|
|
||
|
set DIRNAME=%~dp0
|
||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||
|
|
||
|
@rem put this somewhere that's often ignored by git
|
||
|
set output_dir=%DIRNAME%\out\ndk\standalone
|
||
|
|
||
|
@rem check for NDK standalone
|
||
|
if exist "%output_dir%" echo Standalone NDK files found! && exit /b 0
|
||
|
|
||
|
cd %ANDROID_HOME%
|
||
|
for /f "tokens=* usebackq" %%F in (`dir "*make_standalone_toolchain.py" /s /b`) do (
|
||
|
set standalone_script=%%F
|
||
|
)
|
||
|
cd %DIRNAME%
|
||
|
|
||
|
@rem Try to find and print some info about the NDK based on the location of the toolchain script
|
||
|
if exist "%standalone_script%" goto standaloneScriptFound
|
||
|
|
||
|
echo NDK not found. Please make sure that ANDROID_HOME is set and the NDK has been installed there
|
||
|
exit 1
|
||
|
|
||
|
:standaloneScriptFound
|
||
|
echo Standalone NDK files appear to be missing.
|
||
|
echo Attempting to install them...
|
||
|
for %%F in (%standalone_script%) do set tools_dir=%%~dpF
|
||
|
set tools_dir=%tools_dir:~0,-1%
|
||
|
for %%F in (%tools_dir%) do set build_dir=%%~dpF
|
||
|
set build_dir=%build_dir:~0,-1%
|
||
|
for %%F in (%build_dir%) do set ndk_dir=%%~dpF
|
||
|
for /f "tokens=* usebackq" %%F in (`findstr "[0-9.]{5,}" %ndk_dir%\source.properties`) do (
|
||
|
set ndk_version=%%F
|
||
|
)
|
||
|
echo NDK version %ndk_version% found at %ndk_dir%
|
||
|
|
||
|
echo Installing the standalone NDK for "x86|arm|arm64" into %output_dir%
|
||
|
mkdir %output_dir%
|
||
|
"%standalone_script%" --arch x86 --api 16 --install-dir "%output_dir%\x86"
|
||
|
"%standalone_script%" --arch arm --api 16 --install-dir "%output_dir%\arm"
|
||
|
"%standalone_script%" --arch arm64 --api 21 --install-dir "%output_dir%\arm64"
|
||
|
|
||
|
@rem check for our generated cargo file
|
||
|
set cargo_dir=%DIRNAME%\..\.cargo
|
||
|
set generated_cargo_config=%cargo_dir%\config
|
||
|
|
||
|
if exist "%generated_cargo_config%" goto backup
|
||
|
goto generate
|
||
|
|
||
|
:backup
|
||
|
set backup_config=%cargo_dir%\config.backup
|
||
|
echo existing config found. Backing it up from %generated_cargo_config% to %backup_config%
|
||
|
copy %generated_cargo_config% %backup_config%
|
||
|
|
||
|
:generate
|
||
|
echo generating cargo config at %generated_cargo_config%
|
||
|
|
||
|
mkdir %cargo_dir% 2>NUL
|
||
|
|
||
|
@rem Cargo needs forward slashes
|
||
|
set output_dir=%output_dir:\=/%
|
||
|
|
||
|
(
|
||
|
|
||
|
echo #auto-generated by build-ndk-standalone.bat
|
||
|
echo.
|
||
|
echo [target.i686-linux-android]
|
||
|
echo ar = "%output_dir%/x86/bin/i686-linux-android-ar.exe"
|
||
|
echo linker = "%output_dir%/x86/bin/i686-linux-android-clang.cmd"
|
||
|
echo.
|
||
|
echo [target.armv7-linux-androideabi]
|
||
|
echo ar = "%output_dir%/arm/bin/arm-linux-androideabi-ar.exe"
|
||
|
echo linker = "%output_dir%/arm/bin/arm-linux-androideabi-clang.cmd"
|
||
|
echo.
|
||
|
echo [target.aarch64-linux-android]
|
||
|
echo ar = "%output_dir%/arm64/bin/aarch64-linux-android-ar.exe"
|
||
|
echo linker = "%output_dir%/arm64/bin/aarch64-linux-android-clang.cmd"
|
||
|
|
||
|
) > %generated_cargo_config%
|
||
|
|
||
|
echo Done
|
||
|
exit /b 0
|
||
|
|
||
|
|