Adds JNI symbol check to ensure we don't miss any definitions (#160)

This commit is contained in:
Thad House
2016-11-25 18:07:58 -07:00
committed by Peter Johnson
parent b8e9439d32
commit bc06c843c7
6 changed files with 104 additions and 0 deletions

View File

@@ -59,3 +59,29 @@ ext.debugStripSetup = {
}
}
}
ext.checkNativeSymbols = { getSymbolFunc ->
project.tasks.whenObjectAdded { task ->
if (task.name.contains('link') && task.name.contains('SharedLibrary')) {
def library = task.outputFile.absolutePath
task.doLast {
def nmOutput = new ByteArrayOutputStream()
exec {
commandLine "nm", library
standardOutput nmOutput
}
// Remove '\r' so we can check for full string contents
String nmSymbols = nmOutput.toString().replace('\r', '')
def symbolList = getSymbolFunc()
symbolList.each {
//Add \n so we can check for the exact symbol
def found = nmSymbols.contains(it + '\n')
if (!found) {
throw new GradleException("Found a definition that does not have a matching symbol ${it}")
}
}
}
}
}
}