How to programmatically get version of Android NDK?

1,450 views
Skip to first unread message

void.pointer

unread,
Jun 26, 2017, 11:46:00 AM6/26/17
to android-ndk
So I was digging around and found a file named `source.properties` which can be used to obtain the version of the NDK (14.1 for r14b, etc). However, digging further, it looks like this file only exists from r11 and forward per this commit by Dan Albert:


So I can't rely on this pre-r11.

So the question is: Is there a "portable" way to query the version of the NDK? The reason I need to do this is so that I can code functionality into CMake to allow the user to query what version of the NDK is being referenced. This will allow enabling/disabling features based on NDK version.


Alex Cohn

unread,
Jun 26, 2017, 1:11:39 PM6/26/17
to android-ndk
I can understand that r11 is still relevant; for example, it is bundled with WebRTC, and upgrading the toolchain there may be adventurous. But what is you interest with pre-r11 NDKs?

BR,
Alex 

Dan Albert

unread,
Jun 26, 2017, 1:13:37 PM6/26/17
to android-ndk
TBH, just don't support old NDKs. r10 is ancient and things have improved a lot since then.

That information is already on our CMake toolchain file. Look at the top of the file, there's a part where we parse source.properties and save the version to a variable.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+unsubscribe@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/17e64c78-f7ec-49e9-acfe-ae481389432c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kenneth Geisshirt

unread,
Jun 30, 2017, 10:08:06 AM6/30/17
to android-ndk
I know that r10e is old but it is rather difficult to compile OpenSSL 1.0.2 using clang.

- kneth

On Mon, Jun 26, 2017 at 7:13 PM 'Dan Albert' via android-ndk <andro...@googlegroups.com> wrote:
TBH, just don't support old NDKs. r10 is ancient and things have improved a lot since then.

That information is already on our CMake toolchain file. Look at the top of the file, there's a part where we parse source.properties and save the version to a variable.
On Jun 26, 2017 08:45, "void.pointer" <rcda...@gmail.com> wrote:
So I was digging around and found a file named `source.properties` which can be used to obtain the version of the NDK (14.1 for r14b, etc). However, digging further, it looks like this file only exists from r11 and forward per this commit by Dan Albert:


So I can't rely on this pre-r11.

So the question is: Is there a "portable" way to query the version of the NDK? The reason I need to do this is so that I can code functionality into CMake to allow the user to query what version of the NDK is being referenced. This will allow enabling/disabling features based on NDK version.


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.

To post to this group, send email to andro...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.

For more options, visit https://groups.google.com/d/optout.
--

Kenneth Geisshirt, M.Sc., Ph.D.
Majbøl Allé 18, DK-2770 Kastrup, +45 60 62 71 82

Alex Cohn

unread,
Jul 2, 2017, 4:02:57 AM7/2/17
to android-ndk, ken...@geisshirt.dk
FWIW, GCC 4.9 is fully present in NDK r15. It is not going to receive updates, but it is in no sense works than the version included with r10.

BR,
Alex

Dan Albert

unread,
Jul 10, 2017, 11:00:05 PM7/10/17
to android-ndk, Kenneth Geisshirt, enh
Yeah, our GCC actually did get some updates/cleanups post r10, it just didn't go beyond 4.9. It should still be an improvement over r10's, and hasn't been removed from the NDK as of r15 (our roadmap has the removal slated for r18 atm).

+enh: Was openssl one of the things you tried building the other week? I'm curious what needs to be done to make openssl build with Clang.

To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+unsubscribe@googlegroups.com.

To post to this group, send email to andro...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.

enh

unread,
Jul 11, 2017, 1:33:16 AM7/11/17
to Dan Albert, android-ndk, Kenneth Geisshirt
On Mon, Jul 10, 2017 at 7:59 PM, Dan Albert <dana...@google.com> wrote:
> Yeah, our GCC actually did get some updates/cleanups post r10, it just
> didn't go beyond 4.9. It should still be an improvement over r10's, and
> hasn't been removed from the NDK as of r15 (our roadmap has the removal
> slated for r18 atm).
>
> +enh: Was openssl one of the things you tried building the other week? I'm
> curious what needs to be done to make openssl build with Clang.

no, but i've just looked at https://wiki.openssl.org/index.php/Android
and their "Configure" perl script and i'm horrified. these people
really didn't believe in standalone toolchains!

i think the answer to "how do you build openssl with clang?" is "by
not using any part of the openssl build system". (even their "new"
build system in 1.1 versions of openssl seems to require you to use
sed on its generated files if you want clang:
https://wiki.openssl.org/index.php/Compilation_and_Installation)

boringssl seems a bit less mad
(https://boringssl.googlesource.com/boringssl/+/master/BUILDING.md)
but the bit about "Go is required" sounds fun. plus they don't have
actual releases.

but if you're happy to use gcc instead of clang, as Alex Cohn said,
that works out of the box. i used this:

PACKAGE_VERSION=1.0.2l
PACKAGE_URL=https://www.openssl.org/source/openssl-$PACKAGE_VERSION.tar.gz

function ndkports_configure() {
# TODO
export MACHINE=arm64
export ARCH=arm64

export CC=$target_host-gcc

export SYSTEM=android
./config shared
--
Elliott Hughes - http://who/enh - http://jessies.org/~enh/
Android native code/tools questions? Mail me/drop by/add me as a reviewer.

AppCoder

unread,
Jul 11, 2017, 2:01:05 PM7/11/17
to android-ndk, dana...@google.com, ken...@geisshirt.dk
> curious what needs to be done to make openssl build with Clang.

no, but i've just looked at https://wiki.openssl.org/index.php/Android
and their "Configure" perl script and i'm horrified. these people
really didn't believe in standalone toolchains!


Might look at the aws-sdk-cpp

https://github.com/aws/aws-sdk-cpp

It pushes cmake to build openSSL with clang 

Tom Micheline

unread,
Jul 11, 2017, 7:29:35 PM7/11/17
to android-ndk
As others have pointed out, pre-r11 is ancient and should be avoided.  However, if you must here is a snippet from a shell script I used a long time ago when I needed to determine the ndk release number.  Didn't include the implementation of minor_version_number_to_letter but you should get the idea.

source_properties="$ndk_path/source.properties"
release_file
="$ndk_path/RELEASE.TXT"

# NDK version r11 and later encode NDK version in source.properties.
if [ -s "$source_properties" ]; then
  major_version
=$(sed -En -e 's/^Pkg.Revision[ \t]*=[ \t]*([0-9a-f]+).*/\1/p' $source_properties)
  numerical_minor_version
=$(sed -En -e 's/^Pkg.Revision[ \t]*=[ \t]*[0-9a-f]+\.([0-9]+).*/\1/p' $source_properties)
  minor_version
=$(minor_version_number_to_letter $numerical_minor_version)
elif [ -s "$release_file" ]; then
  major_version
=$(sed -E 's/r([0-9]{1,2})([a-z]{0,1}).*/\1/' $release_file)
  minor_version
=$(sed -E 's/r([0-9]{1,2})([a-z]{0,1}).*/\2/' $release_file)
else
  echo
"NDK unsupported: No RELEASE.TXT or source.properties file" >&2
  echo
"Unknown"
 
exit -1
fi
Reply all
Reply to author
Forward
0 new messages