From 2b2483abd6d9282e2db4c447e8f2d5a157735d5c Mon Sep 17 00:00:00 2001 From: Ben Liblit Date: Thu, 19 Jul 2018 22:21:02 -0500 Subject: [PATCH] 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. --- com.ibm.wala.cast.test/build.gradle | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/com.ibm.wala.cast.test/build.gradle b/com.ibm.wala.cast.test/build.gradle index 0ce96cbc5..6ea28fc21 100644 --- a/com.ibm.wala.cast.test/build.gradle +++ b/com.ibm.wala.cast.test/build.gradle @@ -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 {