Skip to content

Commit f531e85

Browse files
casaroliPatrickRobbIOL
authored andcommitted
const sample container (#101)
* feat(sample_container): use const specifier This will put the sample container in the flash, saving RAM. * feat(generate_ocre_file): use const specifier This will put the generated sample container in the flash, saving RAM. --------- Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
1 parent 130768c commit f531e85

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ if(NOT "${OCRE_INPUT_FILE}" STREQUAL "")
6565

6666
add_custom_command(
6767
OUTPUT ${CMAKE_CURRENT_LIST_DIR}/src/ocre/ocre_input_file.g
68-
COMMAND xxd -i ${OCRE_INPUT_FILE} | sed 's/unsigned char .*\\[/static const unsigned char wasm_binary[/' | sed 's/unsigned int .*_len/static const unsigned int wasm_binary_len/' > ${CMAKE_CURRENT_LIST_DIR}/src/ocre/ocre_input_file.g
68+
COMMAND xxd -n wasm_binary -i ${OCRE_INPUT_FILE} | sed 's/^unsigned/static const unsigned/' > ${OCRE_ROOT_DIR}/src/ocre/ocre_input_file.g
6969
DEPENDS ${OCRE_INPUT_FILE}
7070
COMMENT "Generating C header from ${OCRE_INPUT_FILE}"
7171
)

src/ocre/ocre_input_file.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#ifndef OCRE_INPUT_FILE_H
99
#define OCRE_INPUT_FILE_H
1010
// Sample WASM binary data
11-
static unsigned char wasm_binary[] = {
11+
static const unsigned char wasm_binary[] = {
1212
0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x35, 0x09, 0x60,
1313
0x03, 0x7f, 0x7f, 0x7f, 0x01, 0x7f, 0x60, 0x03, 0x7f, 0x7e, 0x7f, 0x01,
1414
0x7e, 0x60, 0x01, 0x7f, 0x01, 0x7f, 0x60, 0x02, 0x7f, 0x7f, 0x01, 0x7f,
@@ -332,6 +332,6 @@ static unsigned char wasm_binary[] = {
332332
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x04, 0x00, 0x00
333333
};
334334

335-
static unsigned int wasm_binary_len = 3850;
335+
static const unsigned int wasm_binary_len = 3850;
336336

337337
#endif // OCRE_INPUT_FILE_H

0 commit comments

Comments
 (0)