Skip to content

Commit 197ebca

Browse files
authored
[NXP] Ensuring that Python always uses UTF-8 encoding when invoked from CMakeLists.txt (project-chip#41445)
This change addresses potential parsing issues that can occur in environments where the system's default encoding differs from UTF-8. Signed-off-by: Gatien Chapon <[email protected]>
1 parent 73fe2a8 commit 197ebca

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

build/chip/chip_codegen.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function(chip_codegen TARGET_NAME)
4141
#
4242
# This translates them to the actually fully expanded path.
4343
execute_process(
44-
COMMAND "${Python3_EXECUTABLE}" "${CHIP_ROOT}/scripts/codegen_paths.py" "--idl" "${ARG_INPUT}" ${ARG_OUTPUTS}
44+
COMMAND "${Python3_EXECUTABLE}" -X utf8 "${CHIP_ROOT}/scripts/codegen_paths.py" "--idl" "${ARG_INPUT}" ${ARG_OUTPUTS}
4545
OUTPUT_VARIABLE GENERATED_PATHS_OUT
4646
)
4747
string(REPLACE "\n" ";" GENERATED_PATHS "${GENERATED_PATHS_OUT}")
@@ -65,7 +65,7 @@ function(chip_codegen TARGET_NAME)
6565

6666
add_custom_command(
6767
OUTPUT ${OUT_NAMES}
68-
COMMAND "${Python3_EXECUTABLE}" "${CHIP_ROOT}/scripts/codegen.py"
68+
COMMAND "${Python3_EXECUTABLE}" -X utf8 "${CHIP_ROOT}/scripts/codegen.py"
6969
ARGS "--generator" "${ARG_GENERATOR}"
7070
"--output-dir" "${GEN_FOLDER}"
7171
"--expected-outputs" "${GEN_FOLDER}/expected.outputs"
@@ -219,7 +219,7 @@ function(chip_zapgen TARGET_NAME)
219219
# Error: EEXIST: file already exists, mkdir '/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/pkg/465fcc8a6282e28dc7a166859d5814d34e2fb94249a72fa9229033b5b32dff1a'
220220
add_custom_command(
221221
OUTPUT ${OUT_NAMES}
222-
COMMAND "${Python3_EXECUTABLE}" "${CHIP_ROOT}/scripts/tools/zap/generate.py"
222+
COMMAND "${Python3_EXECUTABLE}" -X utf8 "${CHIP_ROOT}/scripts/tools/zap/generate.py"
223223
ARGS ${ZAPGEN_ARGS}
224224
DEPENDS
225225
"${ARG_INPUT}"

0 commit comments

Comments
 (0)