From f407c8d94f55803667ca46739ae838b4b0cede44 Mon Sep 17 00:00:00 2001 From: Ryan Blue Date: Wed, 30 Aug 2023 16:16:06 -0400 Subject: [PATCH] Add download error message --- cmake/modules/DownloadAndCheck.cmake | 11 +++++++++++ wpimath/CMakeLists.txt | 15 ++++++++------- wpiutil/CMakeLists.txt | 7 ++++--- 3 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 cmake/modules/DownloadAndCheck.cmake diff --git a/cmake/modules/DownloadAndCheck.cmake b/cmake/modules/DownloadAndCheck.cmake new file mode 100644 index 00000000000..b6e09533209 --- /dev/null +++ b/cmake/modules/DownloadAndCheck.cmake @@ -0,0 +1,11 @@ +MACRO(DOWNLOAD_AND_CHECK source destination) + file(DOWNLOAD ${source} ${destination} STATUS download_status) + list(GET download_status 0 status_code) + list(GET download_status 1 status_message) + + if(${status_code} EQUAL 0) + message(VERBOSE "Download of \"${source}\" successful.") + else() + message(FATAL_ERROR "Download of \"${source}\" failed: ${status_message}") + endif() +ENDMACRO() \ No newline at end of file diff --git a/wpimath/CMakeLists.txt b/wpimath/CMakeLists.txt index 7c7458d2486..e7fbc1ae3e1 100644 --- a/wpimath/CMakeLists.txt +++ b/wpimath/CMakeLists.txt @@ -3,6 +3,7 @@ project(wpimath) include(SubDirList) include(CompileWarnings) include(AddTest) +include(DownloadAndCheck) file(GLOB wpimath_jni_src src/main/native/cpp/jni/WPIMathJNI_DARE.cpp src/main/native/cpp/jni/WPIMathJNI_Eigen.cpp @@ -24,19 +25,19 @@ if (WITH_JAVA) message(STATUS "Downloading EJML jarfiles...") - file(DOWNLOAD "${BASE_URL}org/ejml/ejml-cdense/0.42/ejml-cdense-0.42.jar" + DOWNLOAD_AND_CHECK("${BASE_URL}org/ejml/ejml-cdense/0.42/ejml-cdense-0.42.jar" "${JAR_ROOT}/ejml-cdense-0.42.jar") - file(DOWNLOAD "${BASE_URL}org/ejml/ejml-core/0.42/ejml-core-0.42.jar" + DOWNLOAD_AND_CHECK("${BASE_URL}org/ejml/ejml-core/0.42/ejml-core-0.42.jar" "${JAR_ROOT}/ejml-core-0.42.jar") - file(DOWNLOAD "${BASE_URL}org/ejml/ejml-ddense/0.42/ejml-ddense-0.42.jar" + DOWNLOAD_AND_CHECK("${BASE_URL}org/ejml/ejml-ddense/0.42/ejml-ddense-0.42.jar" "${JAR_ROOT}/ejml-ddense-0.42.jar") - file(DOWNLOAD "${BASE_URL}org/ejml/ejml-dsparse/0.42/ejml-dsparse-0.42.jar" + DOWNLOAD_AND_CHECK("${BASE_URL}org/ejml/ejml-dsparse/0.42/ejml-dsparse-0.42.jar" "${JAR_ROOT}/ejml-dsparse-0.42.jar") - file(DOWNLOAD "${BASE_URL}org/ejml/ejml-fdense/0.42/ejml-fdense-0.42.jar" + DOWNLOAD_AND_CHECK("${BASE_URL}org/ejml/ejml-fdense/0.42/ejml-fdense-0.42.jar" "${JAR_ROOT}/ejml-fdense-0.42.jar") - file(DOWNLOAD "${BASE_URL}org/ejml/ejml-simple/0.42/ejml-simple-0.42.jar" + DOWNLOAD_AND_CHECK("${BASE_URL}org/ejml/ejml-simple/0.42/ejml-simple-0.42.jar" "${JAR_ROOT}/ejml-simple-0.42.jar") - file(DOWNLOAD "${BASE_URL}org/ejml/ejml-zdense/0.42/ejml-zdense-0.42.jar" + DOWNLOAD_AND_CHECK("${BASE_URL}org/ejml/ejml-zdense/0.42/ejml-zdense-0.42.jar" "${JAR_ROOT}/ejml-zdense-0.42.jar") message(STATUS "All files downloaded.") diff --git a/wpiutil/CMakeLists.txt b/wpiutil/CMakeLists.txt index 5db2b4c6589..595e86b82e7 100644 --- a/wpiutil/CMakeLists.txt +++ b/wpiutil/CMakeLists.txt @@ -4,6 +4,7 @@ include(SubDirList) include(GenResources) include(CompileWarnings) include(AddTest) +include(DownloadAndCheck) file(GLOB wpiutil_jni_src src/main/native/cpp/jni/WPIUtilJNI.cpp src/main/native/cpp/jni/DataLogJNI.cpp) @@ -20,11 +21,11 @@ if (WITH_JAVA) message(STATUS "Downloading Jackson jarfiles...") - file(DOWNLOAD "${BASE_URL}com/fasterxml/jackson/core/jackson-core/2.15.2/jackson-core-2.15.2.jar" + DOWNLOAD_AND_CHECK("${BASE_URL}com/fasterxml/jackson/core/jackson-core/2.15.2/jackson-core-2.15.2.jar" "${JAR_ROOT}/jackson-core-2.15.2.jar") - file(DOWNLOAD "${BASE_URL}com/fasterxml/jackson/core/jackson-databind/2.15.2/jackson-databind-2.15.2.jar" + DOWNLOAD_AND_CHECK("${BASE_URL}com/fasterxml/jackson/core/jackson-databind/2.15.2/jackson-databind-2.15.2.jar" "${JAR_ROOT}/jackson-databind-2.15.2.jar") - file(DOWNLOAD "${BASE_URL}com/fasterxml/jackson/core/jackson-annotations/2.15.2/jackson-annotations-2.15.2.jar" + DOWNLOAD_AND_CHECK("${BASE_URL}com/fasterxml/jackson/core/jackson-annotations/2.15.2/jackson-annotations-2.15.2.jar" "${JAR_ROOT}/jackson-annotations-2.15.2.jar") message(STATUS "All files downloaded.")