From deda4a67f661596dfe793af75a5d50b5ef5467f2 Mon Sep 17 00:00:00 2001 From: jingwen Date: Wed, 7 Feb 2018 09:53:09 -0800 Subject: Improved invalid/unsupported NDK revision warning message. Suggestion from @angersson on GitHub: https://github.com/bazelbuild/bazel/issues/4068#issuecomment-347627252 GITHUB: https://github.com/bazelbuild/bazel/issues/4068 RELNOTES: Improved clarity of warning message for unsupported NDK revisions. PiperOrigin-RevId: 184852316 --- .../bazel/rules/android/AndroidNdkRepositoryFunction.java | 14 +++++++++----- .../lib/bazel/rules/android/AndroidNdkRepositoryTest.java | 6 +++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidNdkRepositoryFunction.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidNdkRepositoryFunction.java index 1e4e9b4e82..0f39042e49 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidNdkRepositoryFunction.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidNdkRepositoryFunction.java @@ -175,17 +175,21 @@ public class AndroidNdkRepositoryFunction extends AndroidRepositoryFunction { String warningMessage = String.format( "The revision of the Android NDK referenced by android_ndk_repository rule '%s' " - + "could not be determined (the revision string found is '%s'). Defaulting to " - + "revision %s.", - ruleName, ndkRelease.rawRelease, AndroidNdkCrosstools.LATEST_KNOWN_REVISION.getKey()); + + "could not be determined (the revision string found is '%s'). " + + "Bazel will attempt to treat the NDK as if it was r%s. This may cause " + + "compilation and linkage problems. Please download a supported NDK version.\n", + ruleName, + ndkRelease.rawRelease, + AndroidNdkCrosstools.LATEST_KNOWN_REVISION.getKey()); env.getListener().handle(Event.warn(warningMessage)); ndkMajorRevision = AndroidNdkCrosstools.LATEST_KNOWN_REVISION.getValue(); } else if (!AndroidNdkCrosstools.isKnownNDKRevision(ndkRelease)) { String warningMessage = String.format( "The major revision of the Android NDK referenced by android_ndk_repository rule " - + "'%s' is %s. The major revisions supported by Bazel are %s. Defaulting to " - + "revision %s.", + + "'%s' is %s. The major revisions supported by Bazel are %s. Bazel will attempt " + + "to treat the NDK as if it was r%s. This may cause compilation and linkage " + + "problems. Please download a supported NDK version.\n", ruleName, ndkRelease.majorRevision, AndroidNdkCrosstools.KNOWN_NDK_MAJOR_REVISIONS.keySet(), diff --git a/src/test/java/com/google/devtools/build/lib/bazel/rules/android/AndroidNdkRepositoryTest.java b/src/test/java/com/google/devtools/build/lib/bazel/rules/android/AndroidNdkRepositoryTest.java index 3518fbc216..c2bfad33eb 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/rules/android/AndroidNdkRepositoryTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/rules/android/AndroidNdkRepositoryTest.java @@ -102,7 +102,7 @@ public class AndroidNdkRepositoryTest extends BuildViewTestCase { eventCollector, "The revision of the Android NDK referenced by android_ndk_repository rule 'androidndk' " + "could not be determined (the revision string found is 'not a valid release string')." - + " Defaulting to revision 14."); + + " Bazel will attempt to treat the NDK as if it was r14."); } @Test @@ -128,7 +128,7 @@ public class AndroidNdkRepositoryTest extends BuildViewTestCase { eventCollector, "The revision of the Android NDK referenced by android_ndk_repository rule 'androidndk' " + "could not be determined (the revision string found is 'invalid package revision'). " - + "Defaulting to revision 14."); + + "Bazel will attempt to treat the NDK as if it was r14."); } @Test @@ -153,7 +153,7 @@ public class AndroidNdkRepositoryTest extends BuildViewTestCase { eventCollector, "The major revision of the Android NDK referenced by android_ndk_repository rule " + "'androidndk' is 15. The major revisions supported by Bazel are [10, 11, 12, 13, 14]." - + " Defaulting to revision 14."); + + " Bazel will attempt to treat the NDK as if it was r14."); } @Test -- cgit v1.2.3