mirror of
https://github.com/espressif/esp-idf.git
synced 2026-09-22 13:01:16 +03:00
Merge branch 'fix/ble_log_compression_issue_on_windows_v5.3' into 'release/v5.3'
fix(bt): fix BLE log compression build on Windows (5.3) See merge request espressif/esp-idf!51243
This commit is contained in:
@@ -572,6 +572,16 @@ class LogCompressor:
|
||||
with open(file_path, 'rb') as f:
|
||||
content = f.read()
|
||||
|
||||
# Normalize CRLF/CR to LF. On Windows the IDF sources are checked out
|
||||
# with CRLF line endings (core.autocrlf=true). Without normalization the
|
||||
# '\r' survives into generated log macros as '\' + '\r' + '\n' inside
|
||||
# multi-line argument expressions, breaking the backslash
|
||||
# line-continuation and producing syntax errors when the header is
|
||||
# compiled. Normalizing once, right after the read, keeps every
|
||||
# downstream step (tree-sitter parse, byte-offset tag replacement,
|
||||
# generated macros) on consistent LF offsets.
|
||||
content = content.replace(b'\r\n', b'\n').replace(b'\r', b'\n')
|
||||
|
||||
# NimBLE host macros are emitted to nimble_log_index.h (module BLE_HOST when NimBLE is enabled).
|
||||
# Ensure each compressed NimBLE source includes that header.
|
||||
if (
|
||||
@@ -774,7 +784,13 @@ class LogCompressor:
|
||||
|
||||
header_content += f'#endif // __{module.upper()}_INTERNAL_LOG_INDEX_H\n'
|
||||
|
||||
with open(header_path, 'w') as f:
|
||||
# newline='' disables newline translation so the generated header is
|
||||
# written with LF on every platform. On Windows the default text-mode
|
||||
# write turns '\n' into '\r\n', which breaks the macro line-continuations
|
||||
# below: a backslash must be followed immediately by '\n', but with CRLF
|
||||
# it is followed by '\r' and the continuation (and hence the macro) is
|
||||
# split, producing a flood of syntax errors when the header is compiled.
|
||||
with open(header_path, 'w', newline='', encoding='utf-8') as f:
|
||||
f.write(header_content)
|
||||
else:
|
||||
append_content = ''
|
||||
@@ -800,7 +816,7 @@ class LogCompressor:
|
||||
else:
|
||||
raise RuntimeError('#endif not found')
|
||||
lines.insert(idx, append_content)
|
||||
with open(header_path, 'w', encoding='utf-8') as f:
|
||||
with open(header_path, 'w', encoding='utf-8', newline='') as f:
|
||||
f.writelines(lines)
|
||||
LOGGER.info(f'Generated log index header: {header_path}')
|
||||
|
||||
@@ -874,7 +890,15 @@ class LogCompressor:
|
||||
)
|
||||
|
||||
# Load configuration
|
||||
modules = args.module.split(';')
|
||||
# Strip surrounding quote chars before splitting. CMakeLists.txt wraps the
|
||||
# semicolon-separated list in single quotes ("'${MODULES}'") to protect the
|
||||
# ';' from POSIX shells, which strip them. cmd.exe on Windows does NOT treat
|
||||
# single quotes as quoting characters, so args.module arrives literally as
|
||||
# 'BLE_MESH;BLE_HOST' and the bare split(';') would yield "'BLE_MESH" /
|
||||
# "BLE_HOST'" — which never match the YAML keys and every module gets
|
||||
# skipped. Stripping is a no-op on Linux/macOS where the shell already
|
||||
# removed the quotes.
|
||||
modules = args.module.strip("'\"").split(';')
|
||||
config_path = self.build_dir / 'ble_log/module_info.yml'
|
||||
self.load_config(str(config_path), modules)
|
||||
|
||||
@@ -889,7 +913,9 @@ class LogCompressor:
|
||||
self.db_manager = db_manager
|
||||
|
||||
# Prepare source files
|
||||
src_list = args.srcs.split(';')
|
||||
# Same quote-stripping rationale as args.module above (cmd.exe passes the
|
||||
# CMakeLists single quotes through literally on Windows).
|
||||
src_list = args.srcs.strip("'\"").split(';')
|
||||
self.prepare_source_files(src_list)
|
||||
|
||||
# Collect files to process
|
||||
|
||||
Reference in New Issue
Block a user