mozilla / rust-android-gradle

Apache License 2.0
1.03k stars 67 forks source link

__main__:make_standalone_toolchain.py is no longer necessary #8

Closed Dexterp37 closed 4 years ago

Dexterp37 commented 5 years ago

While rebuilding, the following warning is shown in Android Studio:

main:make_standalone_toolchain.py is no longer necessary. The

A quick search highlighted that calling this script might not be necessary anymore:

Warning: If using r19 or newer, follow the Other Build Systems document for instructions on using the NDK toolchains with arbitrary build systems. As of r19, the NDK's default toolchains are standalone toolchains, which renders this process unnecessary.

ncalexan commented 5 years ago

Yes -- see https://github.com/ncalexan/rust-android-gradle/pull/36, which I think I have lost track of. Could you do some testing of that pull and see if it works for you?

I see now that mozilla/r-a-g and ncalexan/r-a-g don't share issues. I don't know how to address that, but I'll see if I can.

MaulingMonkey commented 4 years ago

Would be nice to get that PR in. My %LOCALAPPDATA%\Temp keeps getting partially cleaned up - I believe by something in the default install of Windows 10 - resulting in my builds failing with:

  = note: 'C:\Users\MaulingMonkey\AppData\Local\Temp\rust-android-ndk-toolchains\arm-21\bin\clang80.exe' is not recognized as an internal or external command,
          operable program or batch file.

As all the files have been cleaned up - but not the directory structure - so make_standalone_toolchain.py isn't re-invoked. The whole issue would be nicely mooted by using the prebuilt NDK tools. I can take a stab at testing that PR if it'd help...

thomcc commented 4 years ago

I can take a stab at testing that PR if it'd help...

Absolutely, although I think we'd prefer it be configurable. We've had some issues with the newer NDKs and are hesitant to force an update.

MaulingMonkey commented 4 years ago

Works on my machine with NDK 20.0.5594570

Absolutely, although I think we'd prefer it be configurable. We've had some issues with the newer NDKs and are hesitant to force an update.

It looks like it auto-configures here, so it hopefully shouldn't force an upgrade: https://github.com/str4d/rust-android-gradle/blob/1d0eb9181cbacff176b4363ef8e7508c1c969bb9/plugin/src/main/kotlin/com/nishtahir/RustAndroidPlugin.kt#L184-L194

I don't have an NDK 18 install to test against, but if I delete my busted temp toolchains, and modify %LOCALAPPDATA%\Android\Sdk\ndk-bundle\source.properties to have a Pkg.Revision = 18.0.5594570 it seems to fall back on the old behavior and invoke make_standalone_toolchain.py just fine.

NDK 20

C:\local\jni-bindgen\jni-android-sys\examples\android-studio\basic>rmdir /q /s "rust\target" && rmdir /q /s "app\build" && gradlew.bat assembleDebug

> Task :app:cargoBuildArm
   Compiling lazy_static v1.3.0
   Compiling jni-sys v0.3.0
   Compiling cfg-if v0.1.9
   Compiling jni-glue v0.0.8 (C:\local\jni-bindgen\jni-glue)
   Compiling jni-android-sys v0.0.8 (C:\local\jni-bindgen\jni-android-sys)
   Compiling basic v0.0.0 (C:\local\jni-bindgen\jni-android-sys\examples\android-studio\basic\rust)
    Finished dev [unoptimized + debuginfo] target(s) in 3.02s

> Task :app:cargoBuildX86
   Compiling lazy_static v1.3.0
   Compiling jni-sys v0.3.0
   Compiling cfg-if v0.1.9
   Compiling jni-glue v0.0.8 (C:\local\jni-bindgen\jni-glue)
   Compiling jni-android-sys v0.0.8 (C:\local\jni-bindgen\jni-android-sys)
   Compiling basic v0.0.0 (C:\local\jni-bindgen\jni-android-sys\examples\android-studio\basic\rust)
    Finished dev [unoptimized + debuginfo] target(s) in 2.84s

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 12s
30 actionable tasks: 28 executed, 2 up-to-date

NDK "Totally 18 and not 20 wink wink nudge nudge"

C:\local\jni-bindgen\jni-android-sys\examples\android-studio\basic>rmdir /q /s "rust\target" && rmdir /q /s "app\build" && gradlew.bat assembleDebug

> Task :app:generateToolchains
Toolchain for arch arm version 21 does not exist: checked C:\Users\Mike\AppData\Local\Temp\rust-android-ndk-toolchains\arm-21
WARNING:__main__:make_standalone_toolchain.py is no longer necessary. The
%NDK%\toolchains\llvm\prebuilt\windows-x86_64\bin directory contains target-specific scripts that perform
the same task. For example, instead of:

    C:\>python %NDK%\build\tools\make_standalone_toolchain.py \
        --arch arm --api 21 --install-dir toolchain
    C:\>toolchain\bin\clang++ src.cpp

Instead use:

    C:\>%NDK%\toolchains\llvm\prebuilt\windows-x86_64\bin\armv7a-linux-androideabi21-clang++ src.cpp

Toolchain for arch x86 version 21 does not exist: checked C:\Users\Mike\AppData\Local\Temp\rust-android-ndk-toolchains\x86-21
WARNING:__main__:make_standalone_toolchain.py is no longer necessary. The
%NDK%\toolchains\llvm\prebuilt\windows-x86_64\bin directory contains target-specific scripts that perform
the same task. For example, instead of:

    C:\>python %NDK%\build\tools\make_standalone_toolchain.py \
        --arch x86 --api 21 --install-dir toolchain
    C:\>toolchain\bin\clang++ src.cpp

Instead use:

    C:\>%NDK%\toolchains\llvm\prebuilt\windows-x86_64\bin\i686-linux-android21-clang++ src.cpp

> Task :app:cargoBuildArm
   Compiling lazy_static v1.3.0
   Compiling jni-sys v0.3.0
   Compiling cfg-if v0.1.9
   Compiling jni-glue v0.0.8 (C:\local\jni-bindgen\jni-glue)
   Compiling jni-android-sys v0.0.8 (C:\local\jni-bindgen\jni-android-sys)
   Compiling basic v0.0.0 (C:\local\jni-bindgen\jni-android-sys\examples\android-studio\basic\rust)
    Finished dev [unoptimized + debuginfo] target(s) in 2.95s

> Task :app:cargoBuildX86
   Compiling jni-sys v0.3.0
   Compiling lazy_static v1.3.0
   Compiling cfg-if v0.1.9
   Compiling jni-glue v0.0.8 (C:\local\jni-bindgen\jni-glue)
   Compiling jni-android-sys v0.0.8 (C:\local\jni-bindgen\jni-android-sys)
   Compiling basic v0.0.0 (C:\local\jni-bindgen\jni-android-sys\examples\android-studio\basic\rust)
    Finished dev [unoptimized + debuginfo] target(s) in 2.86s

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 1m 8s
31 actionable tasks: 29 executed, 2 up-to-date