Merge pull request #1245 from realm/ap/ndk_version_check
Check that Android NDK version 10e is being used for the build
This commit is contained in:
commit
bc907dadbe
|
@ -137,6 +137,41 @@ def findNdkBuildFullPath() {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def checkNdkVersion(ndkBuildFullPath) {
|
||||||
|
def ndkPath = new File(ndkBuildFullPath).getParent()
|
||||||
|
def detectedNdkVersion
|
||||||
|
def releaseFile = new File(ndkPath, 'RELEASE.TXT')
|
||||||
|
def propertyFile = new File(ndkPath, 'source.properties')
|
||||||
|
if (releaseFile.isFile()) {
|
||||||
|
detectedNdkVersion = releaseFile.text.trim().split()[0].split('-')[0]
|
||||||
|
} else if (propertyFile.isFile()) {
|
||||||
|
detectedNdkVersion = getValueFromPropertiesFile(propertyFile, 'Pkg.Revision')
|
||||||
|
if (detectedNdkVersion == null) {
|
||||||
|
throw new GradleException("Failed to obtain the NDK version information from ${ndkPath}/source.properties")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new GradleException("Neither ${releaseFile.getAbsolutePath()} nor ${propertyFile.getAbsolutePath()} is a file.")
|
||||||
|
}
|
||||||
|
if (detectedNdkVersion != project.ndkVersion) {
|
||||||
|
throw new GradleException("Your NDK version: ${detectedNdkVersion}."
|
||||||
|
+ " Realm JNI must be compiled with the version ${project.ndkVersion} of NDK.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static def getValueFromPropertiesFile(File propFile, String key) {
|
||||||
|
if (!propFile.isFile() || !propFile.canRead()) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
def prop = new Properties()
|
||||||
|
def reader = propFile.newReader()
|
||||||
|
try {
|
||||||
|
prop.load(reader)
|
||||||
|
} finally {
|
||||||
|
reader.close()
|
||||||
|
}
|
||||||
|
return prop.get(key)
|
||||||
|
}
|
||||||
|
|
||||||
def getNdkBuildFullPath() {
|
def getNdkBuildFullPath() {
|
||||||
def ndkBuildFullPath = findNdkBuildFullPath()
|
def ndkBuildFullPath = findNdkBuildFullPath()
|
||||||
if (ndkBuildFullPath == null) {
|
if (ndkBuildFullPath == null) {
|
||||||
|
@ -153,6 +188,9 @@ def getNdkBuildFullPath() {
|
||||||
"(On Windows, make sure you escape backslashes in local.properties or use forward slashes, e.g. C:\\\\ndk or C:/ndk rather than C:\\ndk)",
|
"(On Windows, make sure you escape backslashes in local.properties or use forward slashes, e.g. C:\\\\ndk or C:/ndk rather than C:\\ndk)",
|
||||||
null)
|
null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkNdkVersion(ndkBuildFullPath);
|
||||||
|
|
||||||
return ndkBuildFullPath
|
return ndkBuildFullPath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,3 +6,4 @@ POM_PACKAGING=aar
|
||||||
POM_DESCRIPTION=Android Realm React Native module. Realm is a mobile database: a replacement for SQLite & ORMs
|
POM_DESCRIPTION=Android Realm React Native module. Realm is a mobile database: a replacement for SQLite & ORMs
|
||||||
DEBUG_BUILD=true
|
DEBUG_BUILD=true
|
||||||
android.useDeprecatedNdk=true
|
android.useDeprecatedNdk=true
|
||||||
|
ndkVersion=r10e
|
||||||
|
|
Loading…
Reference in New Issue