Skip to content

Commit

Permalink
Add download error message
Browse files Browse the repository at this point in the history
  • Loading branch information
rzblue committed Aug 30, 2023
1 parent 4e0d785 commit f407c8d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
11 changes: 11 additions & 0 deletions cmake/modules/DownloadAndCheck.cmake
Original file line number Diff line number Diff line change
@@ -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()
15 changes: 8 additions & 7 deletions wpimath/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.")
Expand Down
7 changes: 4 additions & 3 deletions wpiutil/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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.")
Expand Down

0 comments on commit f407c8d

Please sign in to comment.