Avoid dereferencing null if no C/C++ compiler is present

Fixes #328, which requested better diagnostic messages in the case of
a missing C/C++ compiler toolchain.  Gradle actually has perfectly
good, informative messages in that case.  Unfortunately, we were
killing the build by dereferencing null before Gradle had a chance to
explain.  Now we bail out of some setup work early to avoid the null
dereference, thereby letting Gradle explain things properly.
This commit is contained in:
Ben Liblit 2018-07-19 22:21:02 -05:00 committed by Manu Sridharan
parent 10d3adf324
commit 2b2483abd6
1 changed files with 6 additions and 4 deletions

View File

@ -36,11 +36,13 @@ def addCastRpath(currentJvm, targetPlatform, linker) {
}
}
def addCastEnvironment(task, xlatorLibrary) {
def castLibrary = xlatorLibrary.libs[2].linkFiles.singleFile
def castLibraryDirectory = castLibrary.parent
static final def addCastEnvironment(task, xlatorLibrary) {
final def castLibrary = xlatorLibrary.libs[2]
if (castLibrary == null) return
final def castLibraryFile = castLibrary.linkFiles.singleFile
final def castLibraryDirectory = castLibraryFile.parent
assert castLibraryDirectory.endsWith('/com.ibm.wala.cast/build/libs/cast/shared')
task.environment 'DYLD_LIBRARY_PATH', castLibrary.parent
task.environment 'DYLD_LIBRARY_PATH', castLibraryDirectory
}
model {