CMakeLists: when gzip is available spiOverJtag .bit and .rbf are compressed before installing

This commit is contained in:
Gwenhael Goavec-Merou 2023-02-02 07:38:35 +01:00
parent fab4d02128
commit cf61e715cb
5 changed files with 53 additions and 6 deletions

View File

@ -52,6 +52,7 @@ jobs:
sudo apt update -qq
sudo apt install -y \
cmake \
gzip \
libftdi1-2 \
libftdi1-dev \
libhidapi-hidraw0 \

View File

@ -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)
install(FILES
# 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
${GZ_FILES}
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/openFPGALoader
)

View File

@ -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)

View File

@ -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

View File

@ -14,6 +14,7 @@ depends=(
makedepends=(
"${MINGW_PACKAGE_PREFIX}-cc"
"${MINGW_PACKAGE_PREFIX}-cmake"
"${MINGW_PACKAGE_PREFIX}-gzip"
)
source=()