mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Files are named only with major.minor versions. Full versions are: * bootstrap 4.1.3 * coreui 2.1.8 * feather 4.8.0 * jquery 3.3.1 * popper 1.14.4
24 lines
1.0 KiB
CMake
24 lines
1.0 KiB
CMake
# Parameters: input output prefix namespace
|
|
FILE(READ ${input} fileHex HEX)
|
|
STRING(LENGTH "${fileHex}" fileHexSize)
|
|
MATH(EXPR fileSize "${fileHexSize} / 2")
|
|
|
|
GET_FILENAME_COMPONENT(inputBase ${input} NAME)
|
|
STRING(REGEX REPLACE "[^a-zA-Z0-9]" "_" funcName "${inputBase}")
|
|
SET(funcName "GetResource_${funcName}")
|
|
|
|
FILE(WRITE "${output}" "#include <stddef.h>\n#include <wpi/StringRef.h>\nextern \"C\" {\nstatic const unsigned char contents[] = {")
|
|
|
|
STRING(REGEX MATCHALL ".." outputData "${fileHex}")
|
|
STRING(REGEX REPLACE ";" ", 0x" outputData "${outputData}")
|
|
FILE(APPEND "${output}" " 0x${outputData} };\n")
|
|
FILE(APPEND "${output}" "const unsigned char* ${prefix}${funcName}(size_t* len) {\n *len = ${fileSize};\n return contents;\n}\n}\n")
|
|
|
|
IF(NOT namespace STREQUAL "")
|
|
FILE(APPEND "${output}" "namespace ${namespace} {\n")
|
|
ENDIF()
|
|
FILE(APPEND "${output}" "wpi::StringRef ${funcName}() {\n return wpi::StringRef(reinterpret_cast<const char*>(contents), ${fileSize});\n}\n")
|
|
IF(NOT namespace STREQUAL "")
|
|
FILE(APPEND "${output}" "}\n")
|
|
ENDIF()
|