|
6 | 6 | from pythonforandroid.util import BuildInterruptingException
|
7 | 7 |
|
8 | 8 | # We only check the NDK major version
|
9 |
| -MIN_NDK_VERSION = 17 |
10 |
| -MAX_NDK_VERSION = 17 |
| 9 | +MIN_NDK_VERSION = 19 |
| 10 | +MAX_NDK_VERSION = 19 |
11 | 11 |
|
12 |
| -RECOMMENDED_NDK_VERSION = '17c' |
13 |
| -OLD_NDK_MESSAGE = 'Older NDKs may not be compatible with all p4a features.' |
| 12 | +RECOMMENDED_NDK_VERSION = '19b' |
14 | 13 | NEW_NDK_MESSAGE = 'Newer NDKs may not be fully supported by p4a.'
|
| 14 | +NDK_DOWNLOAD_URL = 'https://developer.android.com/ndk/downloads/' |
15 | 15 |
|
16 | 16 |
|
17 | 17 | def check_ndk_version(ndk_dir):
|
18 |
| - # Check the NDK version against what is currently recommended |
| 18 | + """ |
| 19 | + Check the NDK version against what is currently recommended and raise an |
| 20 | + exception of :class:`~pythonforandroid.util.BuildInterruptingException` in |
| 21 | + case that the user tries to use an NDK lower than minimum supported, |
| 22 | + specified via attribute `MIN_NDK_VERSION`. |
| 23 | +
|
| 24 | + .. versionchanged:: 2019.06.06.1.dev0 |
| 25 | + Added the ability to get android's ndk `letter version` and also |
| 26 | + rewrote to raise an exception in case that an NDK version lower than |
| 27 | + the minimum supported is detected. |
| 28 | + """ |
19 | 29 | version = read_ndk_version(ndk_dir)
|
20 | 30 |
|
21 | 31 | if version is None:
|
22 |
| - return # if we failed to read the version, just don't worry about it |
| 32 | + warning( |
| 33 | + 'Unable to read the ndk version, assuming that you are using an' |
| 34 | + ' NDK greater than {min_supported} (the minimum ndk required to' |
| 35 | + ' use p4a successfully).\n' |
| 36 | + 'Note: If you got build errors, consider to download the' |
| 37 | + ' recommended ndk version which is {rec_version} and try' |
| 38 | + ' it again (after removing all the files generated with this' |
| 39 | + ' build). To download the android NDK visit the following page: ' |
| 40 | + '{ndk_url}'.format( |
| 41 | + min_supported=MIN_NDK_VERSION, |
| 42 | + rec_version=RECOMMENDED_NDK_VERSION, |
| 43 | + ndk_url=NDK_DOWNLOAD_URL, |
| 44 | + ) |
| 45 | + ) |
| 46 | + return |
| 47 | + |
| 48 | + # create a dictionary which will describe the relationship of the android's |
| 49 | + # ndk minor version with the `human readable` letter version, egs: |
| 50 | + # Pkg.Revision = 17.1.4828580 => ndk-17b |
| 51 | + # Pkg.Revision = 17.2.4988734 => ndk-17c |
| 52 | + # Pkg.Revision = 19.0.5232133 => ndk-19 (No letter) |
| 53 | + minor_to_letter = {0: ''} |
| 54 | + minor_to_letter.update( |
| 55 | + {n + 1: chr(i) for n, i in enumerate(range(ord('b'), ord('b') + 25))} |
| 56 | + ) |
23 | 57 |
|
24 | 58 | major_version = version.version[0]
|
| 59 | + letter_version = minor_to_letter[version.version[1]] |
| 60 | + string_version = '{major_version}{letter_version}'.format( |
| 61 | + major_version=major_version, letter_version=letter_version |
| 62 | + ) |
25 | 63 |
|
26 |
| - info('Found NDK revision {}'.format(version)) |
| 64 | + info('Found NDK version {}'.format(string_version)) |
27 | 65 |
|
28 | 66 | if major_version < MIN_NDK_VERSION:
|
29 |
| - warning('Minimum recommended NDK version is {}'.format( |
30 |
| - RECOMMENDED_NDK_VERSION)) |
31 |
| - warning(OLD_NDK_MESSAGE) |
| 67 | + raise BuildInterruptingException( |
| 68 | + 'Unsupported NDK version detected {user_version}\n' |
| 69 | + '* Note: Minimum supported NDK version is {min_supported}'.format( |
| 70 | + user_version=string_version, min_supported=MIN_NDK_VERSION |
| 71 | + ), |
| 72 | + instructions=( |
| 73 | + 'Please, go to the android ndk page ({ndk_url}) and download a' |
| 74 | + ' supported version.\n*** The currently recommended NDK' |
| 75 | + ' version is {rec_version} ***'.format( |
| 76 | + ndk_url=NDK_DOWNLOAD_URL, |
| 77 | + rec_version=RECOMMENDED_NDK_VERSION, |
| 78 | + ) |
| 79 | + ), |
| 80 | + ) |
32 | 81 | elif major_version > MAX_NDK_VERSION:
|
33 |
| - warning('Maximum recommended NDK version is {}'.format( |
34 |
| - RECOMMENDED_NDK_VERSION)) |
| 82 | + warning( |
| 83 | + 'Maximum recommended NDK version is {}'.format( |
| 84 | + RECOMMENDED_NDK_VERSION |
| 85 | + ) |
| 86 | + ) |
35 | 87 | warning(NEW_NDK_MESSAGE)
|
36 | 88 |
|
37 | 89 |
|
|
0 commit comments