diff --git a/.github/workflows/Test.yml b/.github/workflows/Test.yml index 80e437f..f53dce0 100644 --- a/.github/workflows/Test.yml +++ b/.github/workflows/Test.yml @@ -52,6 +52,7 @@ jobs: sudo apt update -qq sudo apt install -y \ cmake \ + gzip \ libftdi1-2 \ libftdi1-dev \ libhidapi-hidraw0 \ diff --git a/CMakeLists.txt b/CMakeLists.txt index c3c4518..93f1a0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -284,12 +284,43 @@ math(EXPR FTDI_VAL "${LIBFTDI_VERSION_MAJOR} * 100 + ${LIBFTDI_VERSION_MINOR}") add_definitions(-DFTDI_VERSION=${FTDI_VAL}) install(TARGETS openFPGALoader DESTINATION bin) -file(GLOB BITS_FILES spiOverJtag/spiOverJtag_*.bit) -file(GLOB RBF_FILES spiOverJtag/spiOverJtag_*.rbf) + file(GLOB GZ_FILES spiOverJtag/spiOverJtag_*.*.gz) + +# Compress rbf and bit files present into repository +# TODO: test compat with Windows and MacOS +list(INSERT CMAKE_MODULE_PATH 0 ${PROJECT_SOURCE_DIR}/cmake/Modules) +include(FindGZIP) + +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux" AND GZIP_PRG) + set(SPIOVERJTAG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/spiOverJtag") + file(GLOB BITS_FILES RELATIVE ${SPIOVERJTAG_DIR} spiOverJtag/spiOverJtag_*.bit) + file(GLOB RBF_FILES RELATIVE ${SPIOVERJTAG_DIR} spiOverJtag/spiOverJtag_*.rbf) + + STRING(REGEX REPLACE ".bit" ".bit.gz" BIT_GZ_FILES "${BITS_FILES}") + STRING(REGEX REPLACE ".rbf" ".rbf.gz" RBF_GZ_FILES "${RBF_FILES}") + + FOREACH(bit ${BITS_FILES} ${RBF_FILES}) + ADD_CUSTOM_COMMAND(OUTPUT ${bit}.gz + COMMAND ${GZIP_PRG} -9 -c ${bit} > ${CMAKE_CURRENT_BINARY_DIR}/${bit}.gz + DEPENDS ${SPIOVERJTAG_DIR}/${bit} + WORKING_DIRECTORY ${SPIOVERJTAG_DIR} + COMMENT "Building ${bit}.gz") + list(APPEND GZ_FILES ${CMAKE_CURRENT_BINARY_DIR}/${bit}.gz) + ENDFOREACH(bit) + + ADD_CUSTOM_TARGET(bit ALL DEPENDS ${BIT_GZ_FILES} ${RBF_GZ_FILES}) +else() + file(GLOB BITS_FILES spiOverJtag/spiOverJtag_*.bit) + file(GLOB RBF_FILES spiOverJtag/spiOverJtag_*.rbf) + install(FILES + ${BITS_FILES} + ${RBF_FILES} + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/openFPGALoader + ) +endif() + install(FILES - ${BITS_FILES} - ${RBF_FILES} ${GZ_FILES} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/openFPGALoader ) diff --git a/cmake/Modules/FindGZIP.cmake b/cmake/Modules/FindGZIP.cmake new file mode 100644 index 0000000..e6f8b3b --- /dev/null +++ b/cmake/Modules/FindGZIP.cmake @@ -0,0 +1,13 @@ +FIND_PROGRAM(GZIP_PRG + NAMES gzip + PATHS /bin + /usr/bin + /usr/local/bin + ${CYGWIN_INSTALL_PATH}/bin + ${MSYS_INSTALL_PATH}/usr/bin +) + +IF(NOT GZIP_PRG) + message("Unable to find 'gzip' program") +ENDIF(NOT GZIP_PRG) + diff --git a/doc/guide/install.rst b/doc/guide/install.rst index 262c3b6..4d20446 100644 --- a/doc/guide/install.rst +++ b/doc/guide/install.rst @@ -19,7 +19,7 @@ Alternatively, you could build from source. First: install required libraries: .. code-block:: bash - sudo pacman -S git cmake make gcc pkgconf libftdi libusb zlib hidapi + sudo pacman -S git cmake make gcc pkgconf libftdi libusb zlib hidapi gzip Build step is similar as Debian @@ -42,6 +42,7 @@ This application uses ``libftdi1``, so this library must be installed (and, depe sudo apt install \ git \ + gzip \ libftdi1-2 \ libftdi1-dev \ libhidapi-hidraw0 \ @@ -156,7 +157,7 @@ Alternatively, if you want to build it by hand: .. code-block:: bash brew install --only-dependencies openfpgaloader - brew install cmake pkg-config zlib + brew install cmake pkg-config zlib gzip git clone https://github.com/trabucayre/openFPGALoader cd openFPGALoader mkdir build diff --git a/scripts/msys2/PKGBUILD b/scripts/msys2/PKGBUILD index 51376e9..dcf3a23 100644 --- a/scripts/msys2/PKGBUILD +++ b/scripts/msys2/PKGBUILD @@ -14,6 +14,7 @@ depends=( makedepends=( "${MINGW_PACKAGE_PREFIX}-cc" "${MINGW_PACKAGE_PREFIX}-cmake" + "${MINGW_PACKAGE_PREFIX}-gzip" ) source=()