Skip to content

Commit 554acba

Browse files
committed
fix: keep list values on one line in the toolchain dump
1 parent 3b6fab1 commit 554acba

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎.github/tests/harness/fixtures/host-nested-reconfigure/run.cmake‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ file(GLOB _links "${_bld}/buildmaster/links/*.cmake")
8484
file(TOUCH ${_links})
8585
_hn_run("build 3" _out "${CMAKE_COMMAND}" --build "${_bld}")
8686
_hn_no_self_skip("build 3" "${_out}")
87+
file(STRINGS "${_nested}/CMakeCache.txt" _nl REGEX "contained a newline")
88+
if(_nl)
89+
message(FATAL_ERROR
90+
"host-nested-reconfigure: build 3: toolchain dump split a list value\n${_nl}")
91+
endif()
8792
_hn_nested_edges("build 3")
8893
if(NOT EXISTS "${_nested}/CMakeFiles/hn-buffer.dir/src/extra.c.o"
8994
AND NOT EXISTS "${_nested}/CMakeFiles/hn-buffer.dir/src/extra.c.obj")

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ If you landed here from a release link and have not read the tree:
4949
### Fixed
5050
- **A reconfigure no longer skips the ids its own build dir published.** When ninja re-ran CMake inside a nested project (a `CONFIGURE_DEPENDS` glob mismatch, or a `links/*.cmake` rewritten by the parent), `buildmaster_component` treated the leftover `links/<id>.cmake` of every dependency that same project had configured as "already built by" another process. Their `<id>_build` / `<id>_install` stages vanished from the nested graph and a `BACKEND=host` library compiled before its dependencies were installed (missing headers). A top-level `cmake <builddir>` hit the same skip. Each build dir now records the ids it published in `bm-owned-links.txt`, and a reconfigure configures those again. Fixture `host-nested-reconfigure` drives configure → build → build → forced nested reconfigure → top-level reconfigure.
5151
- **A parent no longer rewrites the links file its nested project wrote for the same id.** When a `cmake` component's nested BuildMaster project declares that same id (for example with `BACKEND=host`), both processes wrote `links/<id>.cmake` with different content. The parent rewrite made the nested `build.ninja` stale, and the next build re-ran CMake in the nested project and then in the parent. Links files now record their writer's binary dir (`_BM_LINKS_WRITER`); the parent keeps a file written from the component's own build dir unless it adds dests.
52+
- **List values in the toolchain dump stay on one line.** `_bm_tc_export` / `_bm_tc_export_raw` stored each line in a CMake list property, so a value containing `;` (for example `BUILDMASTER_KNOWN_TOOLCHAINS`) was split into one line per item. Nested configures then cached a multi-line value and warned `Value of BUILDMASTER_KNOWN_TOOLCHAINS contained a newline; truncating`. Semicolons are now escaped in the property and the dump writes `set(X "a;b")`.
5253

5354
[2.0.2]: https://github.com/StormBytePP/StormByte-BuildMaster/compare/2.0.1...2.0.2
5455

‎toolchain/export.cmake‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@ endfunction()
1616
## @param[in] value Raw value; backslashes become `/`, quotes are escaped.
1717
## @note Used for the host dump (`BUILDMASTER_TOOLCHAIN_FILE`). Component
1818
## overlays are written later by `_bm_tc_write_component`.
19+
## @note `;` is escaped in the line list, so a list value stays one
20+
## `set()` line. Unescaped, `_bm_tc_write` split it into one line per
21+
## item and the nested cache warned "contained a newline".
1922
function(_bm_tc_export name value)
2023
_bm_log_message(TOOLCHAIN LOWLEVEL "Entering _bm_tc_export")
2124
if("${name}" STREQUAL "")
2225
_bm_log_message(TOOLCHAIN FATAL "_bm_tc_export: empty name")
2326
endif()
2427
string(REPLACE "\\" "/" _bm_tc_val "${value}")
2528
string(REPLACE "\"" "\\\"" _bm_tc_val "${_bm_tc_val}")
29+
string(REPLACE ";" "\\;" _bm_tc_val "${_bm_tc_val}")
2630
set_property(GLOBAL APPEND PROPERTY BUILDMASTER_TOOLCHAIN_LINES
2731
"set(${name} \"${_bm_tc_val}\")")
2832
_bm_log_message(TOOLCHAIN LOWLEVEL "Exiting _bm_tc_export")
@@ -37,7 +41,8 @@ function(_bm_tc_export_raw line)
3741
_bm_log_message(TOOLCHAIN LOWLEVEL "Exiting _bm_tc_export_raw")
3842
return()
3943
endif()
40-
set_property(GLOBAL APPEND PROPERTY BUILDMASTER_TOOLCHAIN_LINES "${line}")
44+
string(REPLACE ";" "\\;" _bm_tc_line "${line}")
45+
set_property(GLOBAL APPEND PROPERTY BUILDMASTER_TOOLCHAIN_LINES "${_bm_tc_line}")
4146
_bm_log_message(TOOLCHAIN LOWLEVEL "Exiting _bm_tc_export_raw")
4247
endfunction()
4348

0 commit comments

Comments
 (0)