Skip to content

Commit

Permalink
cmake_xxd: fixed splitting into lines
Browse files Browse the repository at this point in the history
  • Loading branch information
a.borisov committed Dec 29, 2021
1 parent 0ccd97d commit 16b1418
Show file tree
Hide file tree
Showing 9 changed files with 8,159 additions and 8,991 deletions.
6 changes: 3 additions & 3 deletions CMakeXxdImpl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ set(FORMATTED_HEX "0x${FORMATTED_HEX}")
if(${FILE_TYPE} MATCHES "TEXT")
string(REPLACE "0x0D," "" FORMATTED_HEX ${FORMATTED_HEX})
string(REPLACE "0x0d," "" FORMATTED_HEX ${FORMATTED_HEX})
string(REPLACE "0x0A," "0x0A,\n" FORMATTED_HEX ${FORMATTED_HEX})
string(REPLACE "0x0a," "0x0a,\n" FORMATTED_HEX ${FORMATTED_HEX})
string(REPLACE "0x0A," "0x0A,," FORMATTED_HEX ${FORMATTED_HEX})
string(REPLACE "0x0a," "0x0a,," FORMATTED_HEX ${FORMATTED_HEX})
elseif(${FILE_TYPE} MATCHES "BIN")
else()
message(FATAL_ERROR "CMAKE_XXD: expected \"TEXT\" or \"BIN\" in FILE_TYPE")
endif()
string(REGEX MATCHALL "([^,;]*,)([^,;]*,)?([^,;]*,)?([^,;]*,)?([^,;]*,)?([^,;]*,)?([^,;]*,)?([^,;]*,)?"
string(REGEX MATCHALL "([^,]+,)([^,]+,)?([^,]+,)?([^,]+,)?([^,]+,)?([^,]+,)?([^,]+,)?([^,]+,)?"
SEPARATED_LINES "${FORMATTED_HEX}, ")
list(JOIN SEPARATED_LINES "\n" FORMATTED_HEX)
file(WRITE ${XXD_TMP_DIR}/${INPUT_NAME}.inc.temp "static unsigned char ${CPP_STR_CONST_NAME}[] = {\n${FORMATTED_HEX}\n};\n")
Expand Down
9 changes: 4 additions & 5 deletions examples/test/unit_test.das.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ static unsigned char unit_test_das[] = {
0x6d,0x62,0x6f,0x6c,0x73,0x3d,0x66,0x61,
0x6c,0x73,0x65,0x0a,
0x0a,
0x64,0x65,0x66,
0x20,0x73,0x74,0x61,0x72,0x74,0x5f,0x65,
0x66,0x66,0x65,0x63,0x74,0x28,0x6e,0x61,
0x6d,0x65,0x3b,0x20,0x74,0x6d,0x29,0x0a,

0x64,0x65,0x66,0x20,0x73,0x74,0x61,0x72,
0x74,0x5f,0x65,0x66,0x66,0x65,0x63,0x74,
0x28,0x6e,0x61,0x6d,0x65,0x3b,0x20,0x74,
0x6d,0x29,0x0a,
0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,
0x72,0x6e,0x20,0x73,0x74,0x61,0x72,0x74,
0x5f,0x65,0x66,0x66,0x65,0x63,0x74,0x28,
Expand Down
31 changes: 14 additions & 17 deletions examples/tutorial/tutorial04module.das.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,19 @@ static unsigned char tutorial04module_das[] = {
0x6d,0x62,0x6f,0x6c,0x73,0x20,0x3d,0x20,
0x66,0x61,0x6c,0x73,0x65,0x0a,
0x0a,
0x63,
0x6c,0x61,0x73,0x73,0x20,0x54,0x75,0x74,
0x6f,0x72,0x69,0x61,0x6c,0x42,0x61,0x73,
0x65,0x43,0x6c,0x61,0x73,0x73,0x0a,
0x20,
0x20,0x20,0x20,0x64,0x65,0x66,0x20,0x61,
0x62,0x73,0x74,0x72,0x61,0x63,0x74,0x20,
0x75,0x70,0x64,0x61,0x74,0x65,0x20,0x28,
0x20,0x64,0x74,0x20,0x3a,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x20,0x29,0x20,0x3a,0x20,
0x76,0x6f,0x69,0x64,0x0a,
0x20,0x20,0x20,
0x20,0x64,0x65,0x66,0x20,0x61,0x62,0x73,
0x74,0x72,0x61,0x63,0x74,0x20,0x67,0x65,
0x74,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,
0x6f,0x6e,0x20,0x3a,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x33,0x0a,
0x63,0x6c,0x61,0x73,0x73,0x20,0x54,0x75,
0x74,0x6f,0x72,0x69,0x61,0x6c,0x42,0x61,
0x73,0x65,0x43,0x6c,0x61,0x73,0x73,0x0a,
0x20,0x20,0x20,0x20,0x64,0x65,0x66,0x20,
0x61,0x62,0x73,0x74,0x72,0x61,0x63,0x74,
0x20,0x75,0x70,0x64,0x61,0x74,0x65,0x20,
0x28,0x20,0x64,0x74,0x20,0x3a,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x20,0x29,0x20,0x3a,
0x20,0x76,0x6f,0x69,0x64,0x0a,
0x20,0x20,0x20,0x20,0x64,0x65,0x66,0x20,
0x61,0x62,0x73,0x74,0x72,0x61,0x63,0x74,
0x20,0x67,0x65,0x74,0x5f,0x70,0x6f,0x73,
0x69,0x74,0x69,0x6f,0x6e,0x20,0x3a,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x33,0x0a,
0x0a,
};
Loading

0 comments on commit 16b1418

Please sign in to comment.