2019-09-29 15:36:46 +00:00
|
|
|
# CMake script file to process a text file by wrapping every line in double quotes.
|
|
|
|
# Input file must not abuse quotes, staying with single quotes is probably best.
|
|
|
|
# note also empty lines cannot be stripped: they have a meaning (separator) in markdown
|
|
|
|
# so we use file( READ ... ) to read the full file content, including empty lines
|
|
|
|
|
|
|
|
file( READ ${inputFile} buffer )
|
|
|
|
|
2020-01-29 17:47:06 +00:00
|
|
|
file( WRITE ${outputFile} "// Do not edit this file, it is autogenerated by CMake from the .md file\n" )
|
2019-09-29 15:36:46 +00:00
|
|
|
|
2019-10-01 15:03:00 +00:00
|
|
|
#Remark: strings can contain semicolon. a semicolon is a separation in cmake.
|
|
|
|
#so, to avoid stripping semicolon in variables we have to quote them
|
|
|
|
|
2019-10-01 07:56:35 +00:00
|
|
|
# Replace each "\" char by "\\". the \ is found in .md files
|
2019-10-01 15:03:00 +00:00
|
|
|
# to prepend some chars that are usually control chars
|
|
|
|
STRING( REPLACE "\\" "\\\\" linea "${buffer}" )
|
|
|
|
|
|
|
|
# Replace each " char by \"
|
|
|
|
STRING( REPLACE "\"" "\\\"" linem "${linea}" )
|
2019-10-01 07:56:35 +00:00
|
|
|
|
2019-09-29 15:36:46 +00:00
|
|
|
# Replace each EOL char by "\n" + " + EOL
|
2019-10-01 15:03:00 +00:00
|
|
|
STRING( REPLACE "\n" "\\n\"\n\"" buff_m "${linem}" )
|
2019-10-01 07:56:35 +00:00
|
|
|
|
|
|
|
# create the full string compatible "C":
|
|
|
|
# _HKI( "<md string>"\n
|
|
|
|
# to make it translatable. We use here the marker _HKI because
|
|
|
|
# the translation will be explicitely called in Kicad code
|
2019-09-29 15:36:46 +00:00
|
|
|
# Write the buffer between quotes
|
2019-10-01 15:03:00 +00:00
|
|
|
file( APPEND ${outputFile} "_HKI( \"" "${buff_m}" "\" );\n" )
|