mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-01 02:41:48 +00:00
Adds JNI symbol check to ensure we don't miss any definitions (#160)
This commit is contained in:
committed by
Peter Johnson
parent
b8e9439d32
commit
bc06c843c7
@@ -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}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user